11808 lines
2.3 MiB
11808 lines
2.3 MiB
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.bim-engine-wrapper{position:relative;width:100%;height:100%;font-family:sans-serif;box-sizing:border-box;overflow:hidden;background:linear-gradient(to bottom,#d6e0eb,#f6faff)}.bim-engine-opt-btn-container{z-index:100}.bim-construct-tree-btn{position:absolute;top:20px;left:20px!important;z-index:100}.bim-engine-version{position:absolute;bottom:6px;left:10px;font-size:11px;color:#00000040;pointer-events:none;-webkit-user-select:none;user-select:none;z-index:1;font-family:system-ui,-apple-system,sans-serif;letter-spacing:.3px}.bim-engine-size{position:absolute;bottom:6px;left:56px;font-size:11px;color:#00000059;pointer-events:none;-webkit-user-select:none;user-select:none;z-index:1;font-family:system-ui,-apple-system,sans-serif;letter-spacing:.3px}.bim-dialog{position:absolute;background-color:var(--bim-bg-elevated);border:1px solid var(--bim-border-default);border-radius:var(--bim-panel-radius, 12px);box-shadow:var(--bim-shadow-lg);display:flex;flex-direction:column;z-index:10001;color:var(--bim-dialog-title-color, var(--bim-text-primary));overflow:hidden;min-width:200px;min-height:100px;pointer-events:auto}.bim-dialog-header{height:40px;background-color:var(--bim-bg-inset);display:flex;align-items:center;justify-content:space-between;padding:0 12px;cursor:default;-webkit-user-select:none;user-select:none;border-bottom:1px solid var(--bim-border-default);flex-shrink:0}.bim-dialog-header.draggable{cursor:move}.bim-dialog-title{font-size:14px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--bim-dialog-title-color)}.bim-dialog-close{cursor:pointer;font-size:18px;color:var(--bim-text-tertiary);line-height:1;margin-left:8px}.bim-dialog-close:hover{color:var(--bim-text-primary)}.bim-dialog-content{flex:1;overflow:auto;font-size:14px;color:var(--bim-dialog-text-color, var(--bim-text-secondary))}.bim-dialog-resize-handle{position:absolute;width:10px;height:10px;bottom:0;right:0;cursor:se-resize;z-index:10}.bim-dialog-resize-handle:after{content:"";position:absolute;bottom:3px;right:3px;width:6px;height:6px;border-right:2px solid var(--bim-text-tertiary);border-bottom:2px solid var(--bim-text-tertiary)}.bim-dialog-resize-handle:hover:after{border-color:var(--bim-text-primary)}.originRotate{width:10px;height:10px;background-color:red}.versionText{position:absolute;right:10px;color:#86d9ff;z-index:1000;bottom:0;font-size:10px;background:transparent;pointer-events:none}.originDiv{position:absolute;top:100px;left:100px;width:30px;height:30px;border-radius:50%;z-index:1000;pointer-events:none}.tagDiv{color:gray;background:#fffc;padding:5px;font-size:12px}.catchPoint{pointer-events:none;stroke:#08dfd7;fill:transparent;stroke-width:2}.catchLine{position:absolute;width:10px;height:10px;pointer-events:none;background-color:green}.catchPlane{position:absolute;width:10px;height:10px;pointer-events:none;background-color:#ff0}.ViewCube{position:absolute;width:120px;height:120px;top:0;right:0;z-index:999}.homeViewWrapper{position:absolute;cursor:pointer;pointer-events:auto;background-image:url(/assets/viewcube/home.png);background-size:100% 100%;background-repeat:no-repeat;background-color:#fff0;color:#fff;top:10px;right:100;width:20px;height:20px;z-index:999;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.viewSettingWrapper{position:absolute;cursor:pointer;pointer-events:auto;background-size:100% 100%;background-repeat:no-repeat;font-weight:800;background-color:#fff0;color:#fff;top:30px;right:100;width:20px;height:20px;z-index:999;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.cameraToggleWrapper{position:absolute;cursor:pointer;pointer-events:auto;background-color:#ffffffe6;color:#333;font-size:26px;font-weight:700;display:none;align-items:center;justify-content:center;border-radius:4px;box-shadow:0 2px 4px #0003;transition:all .3s ease;top:70px;right:90px;width:44px;height:44px;z-index:999;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.cameraToggleWrapper.show{display:flex}.cameraToggleWrapper:hover{background-color:#fff;box-shadow:0 3px 6px #0000004d;transform:scale(1.1)}.screenshotWrapper{position:absolute;cursor:pointer;pointer-events:auto;background-color:#ffffffe6;color:#333;font-size:20px;display:none;align-items:center;justify-content:center;border-radius:4px;box-shadow:0 2px 4px #0003;transition:all .3s ease;top:120px;right:90px;width:44px;height:44px;z-index:999;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.screenshotWrapper.show{display:flex}.screenshotWrapper:hover{background-color:#fff;box-shadow:0 3px 6px #0000004d;transform:scale(1.1)}.fullscreenWrapper{position:absolute;cursor:pointer;pointer-events:auto;background-color:#ffffffe6;color:#333;font-size:26px;font-weight:700;display:none;align-items:center;justify-content:center;border-radius:4px;box-shadow:0 2px 4px #0003;transition:all .3s ease;top:170px;right:90px;width:44px;height:44px;z-index:999;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.fullscreenWrapper.show{display:flex}.fullscreenWrapper:hover{background-color:#fff;box-shadow:0 3px 6px #0000004d;transform:scale(1.1)}.measure-elevation{position:absolute;pointer-events:none}.measureSvg{position:absolute;width:1920px;height:1080px}.catch-point{position:absolute;width:10px;height:10px;background-color:red;border-radius:50%;pointer-events:none}.annotation-container{position:absolute;pointer-events:none;top:0;left:0}.measureLine{position:absolute;pointer-events:none;stroke:#009bea;fill:#009bea;filter:drop-shadow(1px 1px 2px rgba(0,0,0,.3))}.measureBack{cursor:pointer;pointer-events:auto;fill:#fff;padding:5px;top:-50px;rx:5;ry:5;filter:drop-shadow(1px 1px 2px rgba(0,0,0,.3))}.measureLabel{position:absolute;fill:#fff;font-size:14px;stroke:#009bea;font-weight:100;pointer-events:none}.measurePointer{fill:#009bea}.Hight{stroke:#fff;font-weight:500;filter:drop-shadow(2px 1px 2px rgba(255,255,255,1))}.allow-select{pointer-events:auto}.disallow-select{pointer-events:none}.angle-annotation{position:absolute;pointer-events:auto}.MapController{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.engine-2d-container{position:relative;width:100%;height:100%;overflow:hidden}.engine-2d-canvas{display:block;width:100%;height:100%;outline:none}.engine-2d-cad-cursor{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;overflow:hidden}.engine-2d-cad-cursor__h{position:absolute;left:0;width:100%;height:1px;background:var(--e2d-cursor, rgba(255, 255, 255, .85));transform:translateY(-50%)}.engine-2d-cad-cursor__v{position:absolute;top:0;width:1px;height:100%;background:var(--e2d-cursor, rgba(255, 255, 255, .85));transform:translate(-50%)}.engine-2d-cad-cursor__box{position:absolute;width:8px;height:8px;border:1px solid var(--e2d-cursor, rgba(255, 255, 255, .85));transform:translate(-50%,-50%)}.engine-2d-context-menu{position:absolute;z-index:9999;min-width:140px;background:var(--e2d-bg2, #252526);border:1px solid var(--e2d-border, rgba(255, 255, 255, .12));border-radius:4px;box-shadow:0 4px 16px var(--e2d-shadow, rgba(0, 0, 0, .5));padding:4px 0;display:none;-webkit-user-select:none;user-select:none}.engine-2d-context-menu--visible{display:block}.engine-2d-context-menu__item{padding:7px 16px;font-size:13px;color:var(--e2d-text2, #cccccc);cursor:pointer;white-space:nowrap;transition:background .1s,color .1s}.engine-2d-context-menu__item:hover{background:var(--e2d-bg-accent, #094771);color:var(--e2d-text-accent, #ffffff)}.engine-2d-context-menu__divider{height:1px;background:var(--e2d-border, rgba(255, 255, 255, .1));margin:4px 0}.engine-2d-stats{position:absolute;top:10px;left:10px;background:var(--e2d-float-bg, rgba(0, 0, 0, .7));color:var(--e2d-text, #e0e0e0);padding:8px 12px;border-radius:4px;font-family:monospace;font-size:12px;pointer-events:none;-webkit-user-select:none;user-select:none}.engine-2d-stats div{margin:2px 0}.engine-2d-loading{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);background:var(--e2d-float-bg, rgba(0, 0, 0, .8));color:var(--e2d-text, #e0e0e0);padding:20px 40px;border-radius:8px;font-size:16px;text-align:center}.engine-2d-loading-spinner{border:3px solid var(--e2d-border, rgba(255, 255, 255, .3));border-top:3px solid var(--e2d-accent, #4fc3f7);border-radius:50%;width:40px;height:40px;animation:engine-2d-spin 1s linear infinite;margin:0 auto 10px}@keyframes engine-2d-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.engine-2d-error{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);background:#d32f2feb;color:#fff;padding:20px 40px;border-radius:8px;font-size:14px;max-width:80%;text-align:center}.engine-2d-controls-hint{position:absolute;bottom:10px;left:10px;background:var(--e2d-float-bg, rgba(0, 0, 0, .6));color:var(--e2d-text, #e0e0e0);border:1px solid var(--e2d-float-border, rgba(255, 255, 255, .08));padding:8px 12px;border-radius:4px;font-size:12px;pointer-events:none;-webkit-user-select:none;user-select:none}.engine-2d-controls-hint kbd{background:var(--e2d-icon-bg, rgba(255, 255, 255, .2));color:var(--e2d-text, #e0e0e0);padding:2px 6px;border-radius:3px;font-family:monospace}.engine-2d-search{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:9998;display:none}.engine-2d-search--visible{display:block}.engine-2d-search__box{position:absolute;top:14%;left:50%;transform:translate(-50%);width:480px;max-width:calc(100% - 40px);background:var(--e2d-bg, #1e1f22);border:1px solid var(--e2d-border, rgba(255, 255, 255, .14));border-radius:10px;box-shadow:0 8px 40px var(--e2d-shadow-lg, rgba(0, 0, 0, .65)),0 2px 8px var(--e2d-shadow, rgba(0, 0, 0, .4));overflow:hidden;pointer-events:auto;animation:engine-2d-search-in .18s cubic-bezier(.34,1.2,.64,1)}@keyframes engine-2d-search-in{0%{opacity:0;transform:translate(-50%) translateY(-8px) scale(.97)}to{opacity:1;transform:translate(-50%) translateY(0) scale(1)}}.engine-2d-search__input-row{display:flex;align-items:center;padding:0 12px;gap:8px;height:48px}.engine-2d-search__icon{flex-shrink:0;color:var(--e2d-icon, rgba(255, 255, 255, .4));display:flex;align-items:center}.engine-2d-search__input{flex:1;background:transparent;border:none;outline:none;color:var(--e2d-text, #e0e0e0);font-size:14px;line-height:1.4;caret-color:var(--e2d-accent, #4fc3f7)}.engine-2d-search__input::placeholder{color:var(--e2d-text3, rgba(255, 255, 255, .25))}.engine-2d-search__clear{flex-shrink:0;background:var(--e2d-icon-bg, rgba(255, 255, 255, .08));border:none;border-radius:4px;color:var(--e2d-icon, rgba(255, 255, 255, .5));cursor:pointer;display:flex;align-items:center;justify-content:center;width:22px;height:22px;padding:0;opacity:0;pointer-events:none;transition:opacity .15s,background .15s,color .15s}.engine-2d-search__clear:hover{background:var(--e2d-icon-bg-hover, rgba(255, 255, 255, .16));color:var(--e2d-close-hover, #ffffff)}.engine-2d-search__divider{height:1px;background:var(--e2d-border2, rgba(255, 255, 255, .08));display:none}.engine-2d-search__status{padding:6px 16px;font-size:11px;color:var(--e2d-text3, rgba(255, 255, 255, .35));display:none;-webkit-user-select:none;user-select:none}.engine-2d-search__list{list-style:none;margin:0;padding:4px 0;max-height:320px;overflow-y:auto;display:none;scrollbar-width:thin;scrollbar-color:var(--e2d-scrollbar, rgba(255, 255, 255, .15)) transparent}.engine-2d-search__list::-webkit-scrollbar{width:4px}.engine-2d-search__list::-webkit-scrollbar-track{background:transparent}.engine-2d-search__list::-webkit-scrollbar-thumb{background:var(--e2d-scrollbar, rgba(255, 255, 255, .15));border-radius:2px}.engine-2d-search__item{display:flex;align-items:center;gap:8px;padding:8px 14px;cursor:pointer;transition:background .1s;min-height:38px;flex-wrap:nowrap}.engine-2d-search__item:hover,.engine-2d-search__item--active{background:var(--e2d-bg-hover, rgba(79, 195, 247, .08))}.engine-2d-search__item-badge{flex-shrink:0;font-size:10px;font-weight:500;padding:2px 6px;border-radius:3px;letter-spacing:.03em;white-space:nowrap}.engine-2d-search__item-name{flex:1;font-size:13px;color:var(--e2d-text, #e0e0e0);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.engine-2d-search__item-layer{flex-shrink:0;font-size:11px;color:var(--e2d-text3, rgba(255, 255, 255, .3));white-space:nowrap;max-width:100px;overflow:hidden;text-overflow:ellipsis}.engine-2d-search__item-desc{flex-shrink:0;font-size:11px;color:var(--e2d-text4, rgba(255, 255, 255, .25));white-space:nowrap;max-width:120px;overflow:hidden;text-overflow:ellipsis}.engine-2d-search__mark{background:transparent;color:var(--e2d-accent, #4fc3f7);font-weight:600}.engine-2d-mouse-coord{position:absolute;bottom:10px;left:50%;transform:translate(-50%);display:flex;align-items:center;gap:12px;background:var(--e2d-float-bg, rgba(0, 0, 0, .65));color:var(--e2d-text, #e0e0e0);padding:5px 14px;border-radius:4px;font-family:monospace;font-size:12px;pointer-events:none;-webkit-user-select:none;user-select:none;border:1px solid var(--e2d-float-border, rgba(255, 255, 255, .08))}.engine-2d-mouse-coord__label{color:var(--e2d-coord-label, rgba(255, 255, 255, .45));font-size:11px;letter-spacing:.05em}.engine-2d-mouse-coord__value{min-width:90px;color:var(--e2d-coord-value, #76c8ff)}.panorama-annotation-container{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:1000;overflow:hidden}.panorama-annotation{position:absolute;pointer-events:auto;cursor:pointer;transform:translate(-50%,-50%);transition:opacity .2s ease,transform .2s ease;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.panorama-annotation:hover{z-index:1001;transform:translate(-50%,-50%) scale(1.1)}.panorama-annotation-icon{width:40px;height:40px}.panorama-annotation-icon img{width:100%;height:100%;object-fit:contain;display:block;filter:drop-shadow(0 2px 4px rgba(0,0,0,.3))}.panorama-annotation-text{max-width:200px;text-align:center;line-height:1.4}.panorama-annotation-link{transition:background-color .2s ease,transform .2s ease}.panorama-annotation-link:hover{z-index:1002}.panorama-annotation-link img{display:block;flex-shrink:0}.panorama-annotation.hidden{display:none!important}@keyframes pulse{0%,to{opacity:1}50%{opacity:.5}}.panorama-annotation.loading{animation:pulse 1.5s ease-in-out infinite}@media(max-width:768px){.panorama-annotation-icon{width:32px;height:32px}.panorama-annotation-text,.panorama-annotation-link{font-size:12px!important;padding:6px 10px!important}}.bim-right-key{position:fixed;z-index:10000;display:none;background:transparent}.bim-right-key.visible{display:block}.bim-menu{display:flex;flex-direction:column;background:var(--bim-bg-elevated);border:1px solid var(--bim-border-default);border-radius:8px;padding:6px;margin:0;list-style:none;box-shadow:var(--bim-shadow-lg);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;-webkit-user-select:none;user-select:none;color:var(--bim-text-primary)}.bim-menu-group{display:flex;flex-direction:column}.bim-menu-divider{height:1px;background-color:var(--bim-divider);margin:4px 0}.bim-menu-item{display:flex;align-items:center;padding:8px 12px;cursor:pointer;transition:all .2s ease;font-size:13px;position:relative;color:var(--bim-text-primary);border-radius:6px}.bim-menu-item:hover{background-color:var(--bim-component-bg-hover)}.bim-menu-item.disabled{opacity:.5;cursor:not-allowed;pointer-events:none}.bim-menu-item-icon{display:none}.bim-menu.has-icons .bim-menu-item-icon{width:16px;height:16px;margin-right:8px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.bim-menu-item-icon svg{width:100%;height:100%;fill:currentColor}.bim-menu-item-label{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.bim-menu-item-arrow{width:12px;height:12px;margin-left:8px;display:flex;align-items:center;justify-content:center;opacity:.7}.bim-menu-item-arrow svg{width:100%;height:100%;fill:currentColor}.radial-toolbar-wrapper{position:absolute;right:20px;bottom:20px;z-index:1000;pointer-events:none}.radial-main-btn,.radial-sub-btn{border:1px solid transparent;border-radius:9999px;display:flex;align-items:center;justify-content:center;cursor:pointer;pointer-events:auto;outline:none;transition:transform .22s ease,opacity .22s ease,box-shadow .22s ease,background-color .22s ease,color .22s ease}.radial-main-btn{position:absolute;right:0;bottom:0;width:var(--rt-main-size, 70px);height:var(--rt-main-size, 70px);background:var(--rt-main-bg, rgba(255, 255, 255, .92));border-color:var(--rt-main-border, rgba(203, 213, 225, .65));box-shadow:var(--rt-main-shadow, 0 4px 12px rgba(0, 0, 0, .12));color:var(--rt-main-icon, #334155)}.radial-main-btn:hover{transform:translateZ(0) scale(1.04);background:var(--rt-main-bg-hover, #ffffff);box-shadow:var(--rt-main-shadow-hover, 0 6px 20px rgba(0, 0, 0, .14));color:var(--rt-main-icon-hover, #1e293b)}.radial-main-btn:active{transform:translateZ(0) scale(.97)}.radial-main-btn svg{width:34px;height:34px}.radial-sub-btn{position:absolute;right:var(--rt-main-offset, 10px);bottom:var(--rt-main-offset, 10px);width:var(--rt-sub-size, 50px);height:var(--rt-sub-size, 50px);background:var(--rt-sub-bg, rgba(255, 255, 255, .9));border-color:var(--rt-sub-border, rgba(203, 213, 225, .65));box-shadow:var(--rt-sub-shadow, 0 2px 8px rgba(0, 0, 0, .1));color:var(--rt-sub-icon, #334155);opacity:0;transform:translate(0) scale(.76);transform-origin:center;--rt-delay-current: var(--rt-close-delay, 0s);transition-delay:var(--rt-delay-current)}.radial-toolbar-wrapper.is-active .radial-sub-btn{--rt-delay-current: var(--rt-open-delay, 0s);opacity:1;transform:translate(var(--rt-x),var(--rt-y)) scale(1)}.radial-sub-btn:hover{background:var(--rt-sub-bg-hover, var(--bim-primary, #2563eb));box-shadow:var(--rt-sub-shadow-hover, 0 4px 14px rgba(0, 0, 0, .16));color:var(--rt-sub-icon-hover, var(--bim-text-inverse, #ffffff))}.radial-sub-btn.is-active,.radial-sub-btn[data-active=true]{background:var(--bim-primary, #2563eb);border:1px solid var(--bim-primary-active, #1d4ed8);box-shadow:var(--bim-shadow-glow, 0 0 0 2px rgba(37, 99, 235, .28));color:var(--bim-text-inverse, #ffffff)}.radial-sub-btn.is-active:hover,.radial-sub-btn[data-active=true]:hover{background:var(--bim-primary-hover, #3b82f6)}.radial-sub-btn.is-active .radial-sub-btn-icon,.radial-sub-btn[data-active=true] .radial-sub-btn-icon{color:var(--bim-icon-inverse, #ffffff)}.radial-sub-btn:active{transform:translate(var(--rt-x),var(--rt-y)) scale(.94)}.radial-sub-btn-icon{width:22px;height:22px;display:flex;align-items:center;justify-content:center}.radial-sub-btn-icon svg{width:100%;height:100%}.bottom-dock-stack{position:absolute;left:50%;bottom:20px;transform:translate(-50%);width:0;height:0;z-index:1000;pointer-events:none}.bottom-dock-panel{position:absolute;left:50%;bottom:0;transform:translate(-50%);width:fit-content;max-width:calc(100vw - 40px);pointer-events:auto;border-radius:12px;border:1px solid var(--bd-border, rgba(148, 163, 184, .35));background:var(--bd-bg, rgba(255, 255, 255, .94));box-shadow:var(--bd-shadow, 0 2px 8px rgba(15, 23, 42, .1));transition:transform .22s ease,opacity .2s ease;overflow:visible;z-index:1}.bottom-dock-panel:hover,.bottom-dock-panel:focus-within{z-index:10}.bottom-dock-panel.is-entering{opacity:0}.bottom-dock-panel.is-leaving{opacity:0;pointer-events:none}.bottom-dock-panel-close{position:absolute;top:5px;right:5px;transform:translate(35%,-35%);z-index:2;width:16px;height:16px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--bd-close-color, #475569);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:background-color .16s ease,color .16s ease,border-color .16s ease}.bottom-dock-panel-close:hover{background:var(--bd-close-bg-hover, rgba(15, 23, 42, .08));color:var(--bd-close-color-hover, #0f172a);border-color:var(--bd-close-border-hover, rgba(148, 163, 184, .3))}.bottom-dock-panel-close:active{transform:translate(35%,-35%) scale(.96)}.bottom-dock-panel-body{min-height:50px;padding:10px;background:var(--bd-body-bg, transparent);width:fit-content;max-width:calc(100vw - 40px);box-sizing:border-box;border-radius:inherit}.bottom-dock-placeholder{border-radius:8px;border:1px dashed var(--bd-placeholder-border, rgba(148, 163, 184, .55));padding:10px;color:var(--bd-placeholder-text, #64748b);font-size:12px;line-height:1.5;text-align:center}.measure-dock-panel{width:fit-content;max-width:100%;padding:0;border-radius:8px;border:none;box-sizing:border-box;color:var(--bim-text-secondary, #475569);font-size:13px;line-height:1.5}.measure-dock-panel-main{display:block}.measure-dock-panel-settings{display:none;flex-direction:column;gap:6px;min-height:74px;box-sizing:border-box}.measure-dock-settings-row{display:flex;align-items:center;justify-content:space-between;gap:8px}.measure-dock-settings-label{color:var(--bim-text-secondary, #64748b);font-size:12px}.measure-dock-settings-select{width:88px;height:24px;border-radius:6px;border:1px solid rgba(148,163,184,.36);background:color-mix(in srgb,var(--bim-bg-inset, #edf1f6) 90%,#ffffff 10%);color:var(--bim-text-primary, #0f172a);font-size:12px;padding:0 6px;box-sizing:border-box}.measure-dock-settings-actions{display:flex;justify-content:flex-end;gap:8px}.measure-dock-settings-btn{height:24px;min-width:52px;border-radius:6px;border:1px solid rgba(148,163,184,.36);background:color-mix(in srgb,var(--bim-bg-inset, #edf1f6) 90%,#ffffff 10%);color:var(--bim-text-secondary, #64748b);font-size:12px;line-height:1;cursor:pointer}.measure-dock-settings-btn.is-save{border-color:color-mix(in srgb,var(--bim-primary, #4f88ff) 46%,transparent 54%);color:color-mix(in srgb,var(--bim-primary, #4f88ff) 78%,#6f9dff 22%)}.measure-dock-panel-top{display:flex;align-items:center;justify-content:space-between;gap:10px}.measure-dock-clearheight-options{display:none;flex-direction:column;gap:8px;margin-bottom:10px;padding:8px;border-radius:8px;border:1px solid rgba(148,163,184,.28);background:color-mix(in srgb,var(--bim-bg-inset, #edf1f6) 90%,#ffffff 10%)}.measure-dock-clearheight-options.is-visible{display:flex}.measure-dock-clearheight-group{display:flex;align-items:center;gap:8px}.measure-dock-clearheight-label{min-width:60px;color:var(--bim-text-secondary, #64748b);font-size:12px}.measure-dock-clearheight-buttons{display:flex;gap:8px}.measure-dock-clearheight-btn{height:28px;padding:0 10px;border-radius:6px;border:1px solid rgba(148,163,184,.36);background:color-mix(in srgb,var(--bim-bg-elevated, #f8fafc) 88%,#ffffff 12%);color:var(--bim-text-secondary, #64748b);font-size:12px;line-height:1;cursor:pointer;transition:all .15s ease}.measure-dock-clearheight-btn:hover{border-color:#94a3b88f}.measure-dock-clearheight-btn.is-active{border-color:color-mix(in srgb,var(--bim-primary, #4f88ff) 70%,#9db9ff 30%);background:color-mix(in srgb,var(--bim-primary-subtle, rgba(96, 140, 255, .18)) 72%,#ffffff 28%);color:color-mix(in srgb,var(--bim-primary, #4f88ff) 78%,#6f9dff 22%)}.measure-dock-panel-mode-zone{flex:1;min-width:0;display:flex;flex-direction:column;gap:10px}.measure-dock-panel-mode-row{display:grid;grid-template-columns:repeat(5,32px);gap:10px}.measure-dock-panel-mode-row-secondary{display:none}.measure-dock-panel-mode-btn{width:32px;height:32px;border-radius:8px;border:1px solid rgba(148,163,184,.28);background:color-mix(in srgb,var(--bim-bg-inset, #edf1f6) 92%,#ffffff 8%);color:color-mix(in srgb,var(--bim-text-secondary, #64748b) 94%,#475569 6%);display:inline-flex;align-items:center;justify-content:center;padding:0;box-sizing:border-box;cursor:pointer;transition:all .15s ease}.measure-dock-panel-mode-icon{width:20px;height:20px;display:inline-flex;align-items:center;justify-content:center}.measure-dock-panel-mode-icon svg{width:100%;height:100%;fill:currentColor}.measure-dock-panel-mode-btn:hover{border-color:#94a3b880;background:color-mix(in srgb,var(--bim-component-bg-hover, #dce5f2) 64%,#ffffff 36%)}.measure-dock-panel-mode-btn.is-active{border-color:color-mix(in srgb,var(--bim-primary, #4f88ff) 70%,#9db9ff 30%);color:color-mix(in srgb,var(--bim-primary, #4f88ff) 78%,#6f9dff 22%);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--bim-primary, #4f88ff) 35%,transparent 65%)}.measure-dock-panel-actions{flex:0 0 auto;display:flex;flex-direction:row;gap:10px;align-items:center}.measure-dock-panel-action-btn{width:32px;height:32px;border-radius:6px;border:1px solid rgba(148,163,184,.22);background:color-mix(in srgb,var(--bim-bg-inset, #edf1f6) 92%,#ffffff 8%);color:var(--bim-text-secondary, #475569);padding:0;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:all .15s ease}.measure-dock-panel-action-btn:hover{border-color:#94a3b880;color:var(--bim-text-primary, #0f172a)}.measure-dock-panel-action-btn svg{width:18px;height:18px;fill:currentColor}.measure-dock-panel-action-expand{width:16px;height:32px}.measure-dock-panel-action-expand.is-expanded{height:74px}.measure-dock-panel-action-expand.is-collapsed{height:32px}.measure-dock-panel-action-clear{background:color-mix(in srgb,var(--bim-danger, #ef4444) 16%,#ffffff 84%);border-color:color-mix(in srgb,var(--bim-danger, #ef4444) 26%,transparent 74%);color:var(--bim-danger, #ef4444)}.measure-dock-panel-action-clear:hover{border-color:color-mix(in srgb,var(--bim-danger, #ef4444) 40%,transparent 60%);color:var(--bim-danger, #ef4444)}.measure-dock-panel-action-settings{color:color-mix(in srgb,var(--bim-text-primary, #0f172a) 86%,#000 14%)}.measure-dock-panel-mode-row .measure-dock-panel-action-btn{border-radius:8px}.measure-dock-panel-action-expand svg{transition:transform .15s ease}.measure-dock-panel-action-expand.is-expanded svg{transform:rotate(180deg)}.measure-dock-panel [data-tooltip]{position:relative}.measure-dock-panel [data-tooltip]:after{content:attr(data-tooltip);position:absolute;left:50%;bottom:calc(100% + 6px);transform:translate(-50%);padding:4px 8px;border-radius:6px;background:#0f172aeb;color:#f8fafc;font-size:12px;line-height:1.2;white-space:nowrap;pointer-events:none;opacity:0;visibility:hidden;z-index:8;transition:opacity 60ms ease}.measure-dock-panel [data-tooltip]:hover:after,.measure-dock-panel [data-tooltip]:focus-visible:after{opacity:1;visibility:visible}@media(max-width:720px){.measure-dock-panel-top{flex-direction:column}.measure-dock-clearheight-group{flex-direction:column;align-items:flex-start;gap:6px}.measure-dock-panel-actions{width:100%;flex-direction:row;justify-content:flex-end}.measure-dock-panel-action-btn,.measure-dock-panel-mode-btn{width:32px;height:32px}.measure-dock-panel-action-expand{width:16px;height:32px}.measure-dock-panel-action-expand.is-expanded{height:74px}}.section-dock-panel{width:fit-content;max-width:100%;display:flex;flex-direction:column;gap:10px;color:var(--bim-text-secondary, #475569)}.section-dock-axis-panel{display:none;width:fit-content;border-radius:8px;padding:0;gap:10px}.section-dock-axis-panel.is-visible{display:flex}.section-dock-axis-btn{width:32px;height:32px;border-radius:8px;border:1px solid rgba(148,163,184,.28);background:color-mix(in srgb,var(--bim-bg-inset, #edf1f6) 92%,#ffffff 8%);color:color-mix(in srgb,var(--bim-text-secondary, #64748b) 94%,#475569 6%);font-size:16px;line-height:1;box-sizing:border-box;padding:0;cursor:pointer;transition:all .15s ease}.section-dock-axis-btn:hover{border-color:#94a3b880;background:color-mix(in srgb,var(--bim-component-bg-hover, #dce5f2) 64%,#ffffff 36%)}.section-dock-axis-btn.is-active{border-color:color-mix(in srgb,var(--bim-primary, #4f88ff) 70%,#9db9ff 30%);background:color-mix(in srgb,var(--bim-primary-subtle, rgba(96, 140, 255, .18)) 72%,#ffffff 28%);color:color-mix(in srgb,var(--bim-primary, #4f88ff) 78%,#6f9dff 22%)}.section-dock-main{display:flex;align-items:center;gap:10px;padding:0;border-radius:8px}.section-dock-types,.section-dock-tools{display:flex;align-items:center;gap:10px}.section-dock-divider{width:1px;height:32px;background:color-mix(in srgb,var(--bim-border-default, #cbd5e1) 84%,transparent 16%)}.section-dock-divider.is-hidden{display:none}.section-dock-type-btn,.section-dock-tool-btn{width:32px;height:32px;border:1px solid rgba(148,163,184,.28);border-radius:8px;background:color-mix(in srgb,var(--bim-bg-inset, #edf1f6) 92%,#ffffff 8%);color:color-mix(in srgb,var(--bim-text-secondary, #64748b) 94%,#475569 6%);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;box-sizing:border-box;padding:0;transition:all .15s ease}.section-dock-type-btn:hover,.section-dock-tool-btn:hover{border-color:var(--bim-border-strong, rgba(100, 116, 139, .6));background:color-mix(in srgb,var(--bim-component-bg-hover, #dce5f2) 64%,#ffffff 36%)}.section-dock-type-btn.is-active,.section-dock-tool-btn.is-active{border-color:color-mix(in srgb,var(--bim-primary, #4f88ff) 70%,#9db9ff 30%);color:color-mix(in srgb,var(--bim-primary, #4f88ff) 78%,#6f9dff 22%)}.section-dock-type-icon,.section-dock-tool-icon{width:20px;height:20px;display:inline-flex;align-items:center;justify-content:center}.section-dock-type-icon svg,.section-dock-tool-icon svg{width:100%;height:100%;fill:currentColor}.section-dock-panel [data-tooltip]{position:relative}.section-dock-panel [data-tooltip]:after{content:attr(data-tooltip);position:absolute;left:50%;bottom:calc(100% + 6px);transform:translate(-50%);padding:4px 8px;border-radius:6px;background:#0f172aeb;color:#f8fafc;font-size:12px;line-height:1.2;white-space:nowrap;pointer-events:none;opacity:0;visibility:hidden;z-index:8;transition:opacity 60ms ease}.section-dock-panel [data-tooltip]:hover:after,.section-dock-panel [data-tooltip]:focus-visible:after{opacity:1;visibility:visible}.walk-control-panel.walk-dock-panel{gap:10px;padding:0;background:transparent;border:none;border-radius:8px;box-shadow:none;color:var(--bim-text-secondary, #64748b)}.walk-control-panel.walk-dock-panel .walk-divider{height:32px}.walk-control-panel.walk-dock-panel .walk-control-left,.walk-control-panel.walk-dock-panel .walk-control-settings{gap:10px}.walk-control-panel.walk-dock-panel .walk-icon-btn{width:32px;height:32px;padding:0;border-radius:8px;border:1px solid rgba(148,163,184,.28);background:color-mix(in srgb,var(--bim-bg-inset, #edf1f6) 92%,#ffffff 8%);color:color-mix(in srgb,var(--bim-text-secondary, #64748b) 94%,#475569 6%)}.walk-control-panel.walk-dock-panel .walk-icon-btn:hover{border-color:#94a3b880;background:color-mix(in srgb,var(--bim-component-bg-hover, #dce5f2) 64%,#ffffff 36%)}.walk-control-panel.walk-dock-panel .walk-icon-btn.active{border-color:color-mix(in srgb,var(--bim-primary, #4f88ff) 70%,#9db9ff 30%);background:color-mix(in srgb,var(--bim-primary-subtle, rgba(96, 140, 255, .18)) 72%,#ffffff 28%);color:color-mix(in srgb,var(--bim-primary, #4f88ff) 78%,#6f9dff 22%)}.walk-control-panel.walk-dock-panel .walk-icon-btn svg{width:20px;height:20px}.walk-control-panel.walk-dock-panel .walk-icon-btn.active svg{fill:currentColor}.walk-control-panel.walk-dock-panel .walk-speed-control{gap:8px}.walk-control-panel.walk-dock-panel .walk-speed-label,.walk-control-panel.walk-dock-panel .walk-checkbox-label,.walk-control-panel.walk-dock-panel .walk-select-label{font-size:12px}.walk-control-panel.walk-dock-panel .walk-speed-group{padding:2px;border:1px solid rgba(148,163,184,.28);background:color-mix(in srgb,var(--bim-bg-inset, #edf1f6) 92%,#ffffff 8%)}.walk-control-panel.walk-dock-panel .walk-speed-btn{width:24px;height:24px;font-size:14px;line-height:1;padding:0;display:inline-flex;align-items:center;justify-content:center;border:1px solid rgba(148,163,184,.28);background:color-mix(in srgb,var(--bim-bg-elevated, #f8fafc) 88%,#ffffff 12%);color:var(--bim-text-primary, #0f172a)}.walk-control-panel.walk-dock-panel .walk-speed-display{min-width:30px;font-size:12px;color:var(--bim-text-primary, #0f172a)}.walk-control-panel.walk-dock-panel .walk-checkbox{width:14px;height:14px;accent-color:var(--bim-primary, #3b82f6)}.walk-control-panel.walk-dock-panel .walk-select{min-width:90px;height:24px;padding:2px 8px;font-size:12px;border:1px solid rgba(148,163,184,.28);background:color-mix(in srgb,var(--bim-bg-inset, #edf1f6) 92%,#ffffff 8%);color:var(--bim-text-primary, #0f172a)}.walk-control-panel.walk-dock-panel .walk-exit-btn{height:32px;padding:0 12px;border-radius:8px;font-size:12px}.walk-control-panel{display:flex;align-items:center;gap:20px;padding:12px 20px;background-color:var(--bim-bg-base, #152232);border:1px solid var(--bim-border-strong, #475569);border-radius:12px;box-shadow:var(--bim-shadow-xl, 0 20px 40px rgba(0, 0, 0, .3));-webkit-user-select:none;user-select:none}.walk-divider{width:1px;height:40px;background:var(--bim-divider);flex-shrink:0}.walk-control-left{display:flex;gap:8px}.walk-icon-btn{width:48px;height:48px;display:flex;align-items:center;justify-content:center;background:var(--bim-bg-inset);border:1px solid var(--bim-border-default);border-radius:8px;cursor:pointer;transition:all .2s ease;color:var(--bim-icon-default);padding:8px}.walk-icon-btn:hover{background:var(--bim-component-bg-hover);border-color:var(--bim-border-strong)}.walk-icon-btn.active{background:var(--bim-primary-subtle);border-color:var(--bim-primary);color:var(--bim-primary)}.walk-icon-btn.active svg{fill:var(--bim-primary)}.walk-icon-btn svg{width:32px;height:32px}.walk-control-settings{display:flex;align-items:center;gap:16px;flex:1}.walk-speed-control{display:flex;align-items:center;gap:12px}.walk-speed-label{color:var(--bim-text-primary);font-size:14px;white-space:nowrap}.walk-speed-group{display:flex;align-items:center;gap:8px;background:var(--bim-bg-inset);border:1px solid var(--bim-border-subtle);border-radius:6px;padding:4px}.walk-speed-btn{width:32px;height:32px;background:var(--bim-bg-elevated);border:1px solid var(--bim-border-subtle);border-radius:4px;color:var(--bim-text-primary);font-size:18px;cursor:pointer;transition:all .2s ease}.walk-speed-btn:hover{background:var(--bim-component-bg-hover);border-color:var(--bim-border-strong)}.walk-speed-btn:disabled{opacity:.5;cursor:not-allowed}.walk-speed-display{min-width:40px;text-align:center;color:var(--bim-text-primary);font-size:14px;font-weight:700}.walk-checkbox-wrapper{display:flex;align-items:center;gap:8px;cursor:pointer}.walk-checkbox{width:18px;height:18px;cursor:pointer}.walk-checkbox:disabled{opacity:.5;cursor:not-allowed}.walk-checkbox-label{color:var(--bim-text-primary);font-size:14px;white-space:nowrap}.walk-checkbox-wrapper input:disabled+.walk-checkbox-label{opacity:.5}.walk-select-wrapper{display:flex;align-items:center;gap:8px}.walk-select-label{color:var(--bim-text-primary);font-size:14px;white-space:nowrap}.walk-select{padding:6px 12px;background:var(--bim-bg-inset);border:1px solid var(--bim-border-default);border-radius:6px;color:var(--bim-text-primary);font-size:14px;cursor:pointer;min-width:120px}.walk-select option{background:var(--bim-bg-elevated);color:var(--bim-text-primary)}.walk-exit-btn{padding:10px 24px;background:var(--bim-primary);border:none;border-radius:8px;color:var(--bim-text-inverse);font-size:14px;font-weight:600;cursor:pointer;transition:all .2s ease;white-space:nowrap}.walk-exit-btn:hover{background:var(--bim-primary-hover);transform:scale(1.02)}.walk-path-panel{padding:16px;box-sizing:border-box}.walk-path-btn{border:none;border-radius:6px;cursor:pointer;font-size:14px;transition:all .2s;box-sizing:border-box}.walk-path-btn-group{display:flex;gap:8px;margin-top:16px}.walk-path-btn-play{flex:1;height:32px;padding:0 16px;background:var(--bim-primary, #3b82f6);color:#fff}.walk-path-btn-play:hover:not(:disabled){opacity:.9}.walk-path-btn-play:disabled{opacity:.5;cursor:not-allowed}.walk-path-btn-stop{flex:1;height:32px;padding:0 16px;background:#ef4444;color:#fff}.walk-path-btn-stop:hover:not(:disabled){opacity:.9}.walk-path-btn-stop:disabled{opacity:.5;cursor:not-allowed}.walk-path-btn-small{height:28px;padding:0 12px;font-size:12px;background:var(--bim-bg-elevated, #1f2d3e);color:var(--bim-text-primary, #fff);border:1px solid var(--bim-border-default, #334155)}.walk-path-btn-small:hover{background:var(--bim-border-default, #334155)}.walk-path-btn-danger{color:#ef4444}.walk-path-settings{display:flex;flex-direction:column;gap:12px;margin-bottom:16px}.walk-path-form-group{display:flex;flex-direction:column;gap:6px}.walk-path-form-group label{font-size:12px;color:var(--bim-text-secondary, #94a3b8)}.walk-path-form-group-inline{flex-direction:row;align-items:center}.walk-path-input{padding:8px 12px;border:1px solid var(--bim-border-default, #334155);border-radius:4px;background:var(--bim-bg-elevated, #1f2d3e);color:var(--bim-text-primary, #fff);font-size:14px;width:100%;box-sizing:border-box}.walk-path-input:focus{outline:none;border-color:var(--bim-primary, #3b82f6)}.walk-path-input-wrapper{display:flex;align-items:center;gap:8px}.walk-path-input-wrapper .walk-path-input{flex:1}.walk-path-unit{color:var(--bim-text-secondary, #94a3b8);font-size:14px}.walk-path-checkbox{width:16px;height:16px;margin-right:8px}.walk-path-points-section{margin-bottom:16px}.walk-path-points-toolbar{display:flex;gap:8px;margin-bottom:12px}.walk-path-points-list{height:200px;overflow-y:auto;display:flex;flex-direction:column;gap:8px}.walk-path-empty{text-align:center;padding:32px 16px;color:var(--bim-text-secondary, #94a3b8);font-size:14px}.walk-path-point-item{display:flex;justify-content:space-between;align-items:center;padding:6px 12px;background:var(--bim-bg-elevated, #1f2d3e);border-radius:4px;transition:all .2s}.walk-path-point-item:hover{background:var(--bim-border-default, #334155)}.walk-path-point-item:hover .walk-path-point-actions{opacity:1}.walk-path-point-item-active{background:var(--bim-primary, #3b82f6)}.walk-path-point-item-active .walk-path-point-name{color:#fff}.walk-path-point-item-active .walk-path-point-actions{opacity:1}.walk-path-point-name{font-size:14px;color:var(--bim-text-primary, #fff)}.walk-path-point-actions{display:flex;gap:8px;opacity:0;transition:opacity .2s}.walk-path-btn-icon{width:28px;height:28px;border:none;border-radius:4px;background:transparent;color:var(--bim-text-primary, #fff);cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:14px}.walk-path-btn-icon:hover{background:#ffffff1a}.walk-path-btn-icon-danger:hover{background:#ef444433;color:#ef4444}.bim-measure-panel{width:100%;display:flex;flex-direction:column;box-sizing:border-box;color:var(--bim-text-secondary)}.bim-measure-settings{display:none;box-sizing:border-box;color:var(--bim-text-secondary)}.bim-measure-settings-title{font-size:14px;font-weight:600;margin-bottom:10px}.bim-measure-settings-row{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px}.bim-measure-settings-row .label{color:var(--bim-text-secondary);font-size:13px;flex:0 0 auto}.bim-measure-settings-select{flex:0 0 auto;width:120px;height:28px;border-radius:6px;border:1px solid var(--bim-border-default);background:var(--bim-bg-inset);color:var(--bim-text-primary);padding:0 8px;box-sizing:border-box;outline:none}.bim-measure-settings-hint{font-size:12px;line-height:1.4;color:var(--bim-text-tertiary);margin-top:-4px;margin-bottom:8px}.bim-measure-settings-actions{margin-top:14px;display:flex;justify-content:flex-start;gap:10px}.bim-measure-settings-save,.bim-measure-settings-cancel{flex:0 0 auto!important;width:auto;min-width:0;height:30px;padding:0 12px;border-radius:4px;cursor:pointer;box-sizing:border-box}.bim-measure-settings-save{border:none;background:var(--bim-primary);color:var(--bim-text-inverse)}.bim-measure-settings-cancel{border:1px solid var(--bim-border-default);background:transparent;color:var(--bim-text-secondary)}.bim-measure-settings-save:hover,.bim-measure-settings-save:active,.bim-measure-settings-save:focus,.bim-measure-settings-cancel:hover,.bim-measure-settings-cancel:active,.bim-measure-settings-cancel:focus{background:inherit;outline:none}.bim-measure-settings-save:hover{background:var(--bim-primary-hover)}.bim-measure-tools{display:flex;flex-direction:column;gap:8px}.bim-measure-tool-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}.bim-measure-tool-btn{width:100%;height:42px;border-radius:6px;border:1px solid var(--bim-border-default);background:var(--bim-bg-inset);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .2s ease;padding:0;box-sizing:border-box}.bim-measure-tool-btn:hover{background:var(--bim-component-bg-hover);border-color:var(--bim-border-strong)}.bim-measure-tool-btn.is-active{border-color:var(--bim-primary);background:var(--bim-primary-subtle)}.bim-measure-tool-btn.is-active .bim-measure-tool-icon{color:var(--bim-primary)}.bim-measure-tool-icon{width:28px;height:28px;display:inline-flex;align-items:center;justify-content:center;color:var(--bim-icon-default)}.bim-measure-tool-icon svg{width:100%;height:100%;fill:currentColor}.bim-measure-toggle{display:flex;justify-content:flex-end}.bim-measure-toggle-btn{height:22px;border-radius:4px;border:1px solid var(--bim-border-default);background:var(--bim-bg-inset);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;transition:all .2s ease;padding:0 6px;gap:4px;font-size:12px;line-height:1}.bim-measure-toggle-btn:hover{background:var(--bim-component-bg-hover);border-color:var(--bim-border-strong)}.bim-measure-toggle-text{color:var(--bim-text-secondary)}.bim-measure-toggle-icon svg{width:14px;height:14px;fill:currentColor;color:var(--bim-icon-default);transition:transform .15s ease}.bim-measure-toggle-btn.is-expanded .bim-measure-toggle-icon svg{transform:rotate(180deg)}.bim-measure-mode-options{display:none;flex-direction:column;gap:8px;margin-top:12px;padding-top:12px;border-top:1px solid var(--bim-divider)}.bim-measure-mode-options.is-visible{display:flex}.bim-measure-radio-group{display:flex;align-items:center;gap:8px;font-size:13px;line-height:1.4}.bim-measure-radio-group .bim-measure-radio-label{color:var(--bim-text-secondary);min-width:58px;flex:0 0 auto}.bim-measure-radio-group .bim-measure-radio-items{display:flex;gap:4px}.bim-measure-radio-item{display:inline-flex;align-items:center;justify-content:center;height:26px;padding:0 10px;border-radius:4px;border:1px solid var(--bim-border-default);background:var(--bim-bg-inset);color:var(--bim-text-secondary);font-size:12px;cursor:pointer;transition:all .15s ease;-webkit-user-select:none;user-select:none}.bim-measure-radio-item:hover{border-color:var(--bim-border-strong);color:var(--bim-text-primary)}.bim-measure-radio-item.is-active{background:var(--bim-primary-subtle);border-color:var(--bim-primary);color:var(--bim-primary)}.bim-measure-result{margin-top:12px;padding-top:12px;border-top:1px solid var(--bim-divider);display:flex;flex-direction:column;gap:10px}.bim-measure-row{display:flex;align-items:baseline;gap:8px;font-size:13px;line-height:1.4}.bim-measure-row .label{color:var(--bim-text-secondary);min-width:84px}.bim-measure-row .value{color:var(--bim-text-primary);flex:1;word-break:break-word}.bim-measure-main-number{color:#ffd24a}.bim-measure-main-number.is-laser-text,.bim-measure-main-unit{color:var(--bim-text-primary)}.bim-measure-xyz{display:flex;flex-direction:column;gap:6px}.bim-measure-xyz .value{font-variant-numeric:tabular-nums}.bim-measure-xyz-x{color:#ff4d4f!important}.bim-measure-xyz-y{color:#52c41a!important}.bim-measure-xyz-z{color:#1677ff!important}.bim-measure-footer{margin-top:12px;padding-top:10px;border-top:1px solid var(--bim-divider);display:flex;align-items:center;justify-content:flex-start;gap:10px}.bim-measure-clear-btn{background:transparent;border:none;color:var(--bim-danger);cursor:pointer;padding:0;font-size:13px;flex:0 0 auto!important;width:auto;min-width:0}.bim-measure-clear-btn:hover,.bim-measure-clear-btn:active,.bim-measure-clear-btn:focus{background:transparent;border:none;outline:none;text-decoration:none}.bim-measure-settings-btn{width:24px;height:24px;border-radius:4px;border:none;background:transparent;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;padding:0;margin-left:auto;flex:0 0 auto!important}.bim-measure-settings-btn:hover,.bim-measure-settings-btn:active,.bim-measure-settings-btn:focus{background:transparent;border:none;outline:none}.bim-measure-settings-btn svg{width:18px;height:18px;fill:currentColor;color:var(--bim-icon-default)}.section-plane-panel{display:flex;gap:8px;padding:12px 12px 16px;box-sizing:border-box}.section-plane-btn{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;padding:10px;border:1px solid var(--bim-border-default);background:var(--bim-bg-inset);border-radius:8px;cursor:pointer;transition:all .2s ease;min-width:60px;outline:none;color:var(--bim-text-primary)}.section-plane-btn:hover{background:var(--bim-component-bg-hover);border-color:var(--bim-border-strong)}.section-plane-btn:active{background:var(--bim-primary-subtle);border-color:var(--bim-primary)}.section-plane-btn.is-active{background:var(--bim-primary-subtle);border-color:var(--bim-primary);color:var(--bim-primary)}.section-plane-btn.is-active .section-plane-btn-icon{color:var(--bim-primary)}.section-plane-btn-icon{width:24px;height:24px;display:flex;align-items:center;justify-content:center;color:var(--bim-icon-default)}.section-plane-btn-icon svg{width:100%;height:100%;fill:currentColor}.section-plane-btn-label{font-size:12px;color:inherit;text-align:center;line-height:1.2}.section-axis-panel{display:flex;flex-direction:column;gap:8px;padding:12px 12px 16px;box-sizing:border-box}.section-axis-row-1{display:flex;gap:8px;padding-bottom:8px;border-bottom:1px solid var(--bim-divider)}.section-axis-row-2{display:flex;gap:8px;padding-top:8px}.section-axis-btn{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;padding:8px;background:var(--bim-bg-inset);border:1px solid var(--bim-border-default);border-radius:8px;cursor:pointer;transition:all .2s ease;outline:none;color:var(--bim-text-primary);min-height:48px}.section-axis-btn:hover{background:var(--bim-component-bg-hover);border-color:var(--bim-border-strong)}.section-axis-btn.active{background:var(--bim-primary-subtle);border-color:var(--bim-primary);color:var(--bim-primary)}.section-axis-btn.active .section-axis-btn-icon{color:var(--bim-primary)}.section-axis-btn-icon{width:24px;height:24px;display:inline-flex;align-items:center;justify-content:center;color:var(--bim-icon-default)}.section-axis-btn-icon svg{width:100%;height:100%}.section-axis-btn-label{font-size:12px;color:inherit;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}.section-axis-btn-text{min-height:40px}.section-axis-btn-text .section-axis-btn-label{font-size:18px;font-weight:600}.section-box-panel{display:flex;flex-direction:column;padding:12px;box-sizing:border-box;-webkit-user-select:none;user-select:none}.section-box-row-buttons{display:flex;gap:6px;padding-bottom:12px;border-bottom:1px solid var(--bim-divider)}.section-box-btn{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;padding:6px;background:var(--bim-bg-inset);border:1px solid var(--bim-border-default);border-radius:8px;cursor:pointer;color:var(--bim-text-primary);min-height:44px;transition:all .2s ease}.section-box-btn:hover{background:var(--bim-component-bg-hover);border-color:var(--bim-border-strong)}.section-box-btn.active{background:var(--bim-primary-subtle);border-color:var(--bim-primary);color:var(--bim-primary)}.section-box-btn.active .section-box-btn-icon{color:var(--bim-primary)}.section-box-btn-icon{width:24px;height:24px;color:var(--bim-icon-default)}.section-box-btn-icon svg{width:100%;height:100%}.section-box-btn-label{font-size:11px;white-space:nowrap}.section-box-sliders{display:flex;flex-direction:column;gap:16px;padding-top:16px}.section-box-slider{display:flex;align-items:center;gap:12px;position:relative;z-index:1}.section-box-slider:hover{z-index:10}.section-box-slider-label{font-size:13px;font-weight:700;color:var(--bim-text-primary);min-width:14px}.section-box-slider-track{position:relative;flex:1;height:4px;background:var(--bim-border-default);border-radius:2px}.section-box-slider-range{position:absolute;top:0;height:100%;background:var(--bim-primary);border-radius:2px;pointer-events:none}.section-box-slider-handle{position:absolute;top:50%;width:14px;height:14px;background:var(--bim-bg-elevated);border:2px solid var(--bim-primary);border-radius:50%;transform:translate(-50%,-50%);cursor:grab;z-index:5;touch-action:none;transition:transform .2s,box-shadow .2s}.section-box-slider-handle:hover{transform:translate(-50%,-50%) scale(1.2);box-shadow:0 0 0 4px var(--bim-primary-subtle)}.section-box-slider-handle.dragging{cursor:grabbing;transform:translate(-50%,-50%) scale(1.2);background:var(--bim-primary)}.bim-collapse{background-color:var(--bim-bg-elevated);border:1px solid var(--bim-border-default);border-radius:8px;font-size:14px;color:var(--bim-text-primary)}.bim-collapse.is-ghost{background-color:transparent;border:none}.bim-collapse.is-ghost .bim-collapse-item{border-bottom:none}.bim-collapse.is-ghost .bim-collapse-header{background-color:var(--bim-component-bg);padding-left:12px;padding-right:0;border-bottom:1px solid var(--bim-border-default)}.bim-collapse.is-ghost .bim-collapse-header:hover{background-color:var(--bim-component-bg-hover)}.bim-collapse.is-ghost .bim-collapse-content{background-color:transparent;border-top:none}.bim-collapse-item{border-bottom:1px solid var(--bim-border-subtle)}.bim-collapse-item:last-child{border-bottom:none}.bim-collapse-item.is-disabled .bim-collapse-header{color:var(--bim-text-disabled);cursor:not-allowed}.bim-collapse-header{display:flex;align-items:center;padding:12px 16px;background-color:var(--bim-component-bg);cursor:pointer;transition:all .2s ease;position:relative}.bim-collapse-header:hover{background-color:var(--bim-component-bg-hover)}.bim-collapse-arrow{margin-right:12px;font-size:12px;width:12px;height:12px;transition:transform .24s;display:inline-flex;align-items:center;justify-content:center}.bim-collapse-arrow svg{width:100%;height:100%;fill:currentColor}.bim-collapse-item.is-active .bim-collapse-arrow{transform:rotate(90deg)}.bim-collapse-icon{margin-right:8px;display:inline-flex;align-items:center}.bim-collapse-icon svg{width:16px;height:16px;fill:currentColor}.bim-collapse-title{flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.bim-collapse-extra{margin-left:auto}.bim-collapse-content{overflow:hidden;background-color:var(--bim-bg-elevated);border-top:1px solid var(--bim-border-subtle);transition:height .2s ease-in-out,opacity .2s ease-in-out}.bim-collapse-content.is-hidden{display:none}.bim-ai-chat{position:absolute;width:440px;height:600px;display:flex;flex-direction:column;background:var(--bim-ai-panel, rgba(11, 18, 32, .95));border:1px solid var(--bim-ai-border, rgba(255, 255, 255, .1));border-radius:16px;backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px);box-shadow:0 12px 32px var(--bim-ai-shadow, rgba(0, 0, 0, .4));z-index:1000;font-family:Public Sans,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;overflow:hidden;resize:both;min-width:360px;min-height:400px;max-width:90vw;max-height:90vh}.bim-ai-chat-header{display:flex;align-items:center;justify-content:space-between;height:56px;padding:12px 16px;border-bottom:1px solid var(--bim-ai-border, rgba(255, 255, 255, .1));flex-shrink:0;cursor:move;-webkit-user-select:none;user-select:none;border-radius:16px 16px 0 0}.bim-ai-chat-title{font-size:18px;font-weight:600;color:var(--bim-ai-text, #E5E7EB)}.bim-ai-chat-actions{display:flex;gap:8px}.bim-ai-chat-action-btn{width:32px;height:32px;border-radius:999px;border:1px solid var(--bim-ai-border, rgba(255, 255, 255, .1));background:transparent;color:var(--bim-ai-text, #E5E7EB);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .2s ease}.bim-ai-chat-action-btn:hover{background:var(--bim-ai-subtle-fill, rgba(255, 255, 255, .05))}.bim-ai-chat-action-btn svg{width:18px;height:18px}.bim-ai-chat-messages{flex:1;overflow-y:auto;padding:12px;display:flex;flex-direction:column;gap:10px}.bim-ai-msg-ai{max-width:320px}.bim-ai-msg-ai .bim-ai-bubble{background:var(--bim-ai-panel2, rgba(15, 23, 42, .95));border:1px solid var(--bim-ai-border, rgba(255, 255, 255, .1));border-radius:16px;padding:10px}.bim-ai-msg-ai .bim-ai-bubble-content{font-size:13px;line-height:1.4;color:var(--bim-ai-text, #E5E7EB)}.bim-ai-msg-user{display:flex;justify-content:flex-end}.bim-ai-msg-user .bim-ai-bubble{max-width:300px;background:var(--bim-ai-user-bubble, rgba(29, 78, 216, .8));border-radius:16px;padding:10px;box-shadow:0 10px 26px #0003}.bim-ai-msg-user .bim-ai-bubble-content{font-size:13px;line-height:1.4;color:var(--bim-ai-user-text, #EEF2FF)}.bim-ai-step{display:flex;align-items:center;gap:10px;padding:10px;border-radius:14px;max-width:380px}.bim-ai-step-running{background:var(--bim-ai-info-soft, rgba(56, 189, 248, .1));border:1px solid rgba(56,189,248,.33)}.bim-ai-step-done{background:var(--bim-ai-success-soft, rgba(52, 211, 153, .1));border:1px solid rgba(52,211,153,.33)}.bim-ai-step-error{background:var(--bim-ai-danger-soft, rgba(239, 68, 68, .1));border:1px solid var(--bim-ai-danger-stroke, rgba(239, 68, 68, .33))}.bim-ai-step-icon{width:16px;height:16px;flex-shrink:0}.bim-ai-step-running .bim-ai-step-icon{color:var(--bim-ai-info, #38BDF8)}.bim-ai-step-done .bim-ai-step-icon{color:var(--bim-ai-success, #34D399)}.bim-ai-step-error .bim-ai-step-icon{color:var(--bim-ai-danger, #EF4444)}.bim-ai-step-text{font-size:12px;line-height:1.4;color:var(--bim-ai-text, #E5E7EB)}.bim-ai-thinking{display:flex;align-items:center;gap:10px;padding:10px;border-radius:14px;background:var(--bim-ai-panel2, rgba(15, 23, 42, .95));border:1px solid var(--bim-ai-border, rgba(255, 255, 255, .1));max-width:380px}.bim-ai-thinking-icon{width:16px;height:16px;color:var(--bim-ai-muted, #94A3B8);animation:bim-ai-spin 1s linear infinite}.bim-ai-thinking-text{font-size:12px;font-weight:600;color:var(--bim-ai-muted, #94A3B8)}@keyframes bim-ai-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.bim-ai-question-active{width:360px;border-radius:14px;background:var(--bim-ai-panel2, rgba(15, 23, 42, .95));border:1px solid var(--bim-ai-accent-stroke, rgba(59, 130, 246, .33));box-shadow:0 4px 16px var(--bim-ai-shadow, rgba(0, 0, 0, .4));overflow:hidden}.bim-ai-question-header{display:flex;align-items:center;gap:8px;padding:12px;border-bottom:1px solid var(--bim-ai-border, rgba(255, 255, 255, .1))}.bim-ai-question-icon{width:24px;height:24px;border-radius:6px;background:var(--bim-ai-accent-soft, rgba(59, 130, 246, .1));display:flex;align-items:center;justify-content:center;color:var(--bim-ai-accent, #3B82F6)}.bim-ai-question-icon svg{width:14px;height:14px}.bim-ai-question-title{font-size:13px;font-weight:600;color:var(--bim-ai-text, #E5E7EB)}.bim-ai-question-content{padding:12px;display:flex;flex-direction:column;gap:10px}.bim-ai-question-text{font-size:13px;line-height:1.4;color:var(--bim-ai-text, #E5E7EB)}.bim-ai-question-options{display:flex;flex-direction:column;gap:6px}.bim-ai-option{display:flex;align-items:center;gap:8px;padding:8px 10px;border-radius:8px;background:var(--bim-ai-subtle-fill, rgba(255, 255, 255, .05));border:1px solid var(--bim-ai-border, rgba(255, 255, 255, .1));cursor:pointer;transition:all .2s ease}.bim-ai-option:hover{background:var(--bim-ai-subtle-fill-hover, rgba(255, 255, 255, .08))}.bim-ai-option.selected{background:var(--bim-ai-accent-soft, rgba(59, 130, 246, .1));border-color:var(--bim-ai-accent-stroke, rgba(59, 130, 246, .33))}.bim-ai-option-radio{width:16px;height:16px;border-radius:50%;border:1.5px solid var(--bim-ai-muted, #94A3B8);flex-shrink:0;display:flex;align-items:center;justify-content:center}.bim-ai-option.selected .bim-ai-option-radio{background:var(--bim-ai-accent, #3B82F6);border-color:var(--bim-ai-accent, #3B82F6)}.bim-ai-option-radio-dot{width:6px;height:6px;border-radius:50%;background:var(--bim-ai-accent-ink, #FFFFFF);display:none}.bim-ai-option.selected .bim-ai-option-radio-dot{display:block}.bim-ai-option-text{font-size:12px;color:var(--bim-ai-text, #E5E7EB)}.bim-ai-option-input{flex:1;background:var(--bim-ai-textbox-fill, rgba(15, 23, 42, .6));border:1px solid var(--bim-ai-border, rgba(255, 255, 255, .1));border-radius:6px;padding:6px 8px;font-size:12px;color:var(--bim-ai-text, #E5E7EB);outline:none;margin-top:8px;width:100%}.bim-ai-option-input:focus{border-color:var(--bim-ai-accent-stroke, rgba(59, 130, 246, .33))}.bim-ai-question-footer{display:flex;justify-content:flex-end;padding:12px;border-top:1px solid var(--bim-ai-border, rgba(255, 255, 255, .1))}.bim-ai-question-submit{display:flex;align-items:center;gap:4px;padding:8px 12px;border-radius:8px;background:var(--bim-ai-accent, #3B82F6);color:var(--bim-ai-accent-ink, #FFFFFF);border:none;cursor:pointer;font-size:12px;font-weight:600;transition:all .2s ease}.bim-ai-question-submit:hover{filter:brightness(1.1)}.bim-ai-question-submit svg{width:12px;height:12px}.bim-ai-question-answered{max-width:340px;padding:10px;border-radius:12px;background:var(--bim-ai-panel2, rgba(15, 23, 42, .95));border:1px solid var(--bim-ai-border, rgba(255, 255, 255, .1));display:flex;flex-direction:column;gap:8px}.bim-ai-qa-row{display:flex;gap:8px;align-items:flex-start}.bim-ai-qa-badge{width:18px;height:18px;border-radius:5px;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:700;flex-shrink:0}.bim-ai-qa-badge-q{background:var(--bim-ai-accent-soft, rgba(59, 130, 246, .1));color:var(--bim-ai-accent, #3B82F6)}.bim-ai-qa-badge-a{background:var(--bim-ai-success-soft, rgba(52, 211, 153, .1));color:var(--bim-ai-success, #34D399)}.bim-ai-qa-question{font-size:12px;line-height:1.4;color:var(--bim-ai-muted, #94A3B8)}.bim-ai-qa-answer{font-size:12px;line-height:1.4;color:var(--bim-ai-text, #E5E7EB)}.bim-ai-chat-composer{padding:12px;border-top:1px solid var(--bim-ai-border, rgba(255, 255, 255, .1));display:flex;flex-direction:column;gap:8px;flex-shrink:0}.bim-ai-quick-prompts{display:flex;gap:8px;flex-wrap:wrap}.bim-ai-quick-prompt{padding:5px 8px;border-radius:999px;background:var(--bim-ai-subtle-fill, rgba(255, 255, 255, .05));border:1px solid var(--bim-ai-border, rgba(255, 255, 255, .1));color:var(--bim-ai-text, #E5E7EB);font-size:12px;font-weight:600;cursor:pointer;transition:all .2s ease}.bim-ai-quick-prompt:hover{background:var(--bim-ai-subtle-fill-hover, rgba(255, 255, 255, .08))}.bim-ai-input-row{display:flex;gap:8px;align-items:flex-end}.bim-ai-textbox{flex:1;display:flex;flex-direction:column;gap:6px;padding:10px;border-radius:16px;background:var(--bim-ai-textbox-fill, rgba(15, 23, 42, .6));border:1px solid var(--bim-ai-border, rgba(255, 255, 255, .1))}.bim-ai-textbox:focus-within{border-color:var(--bim-ai-accent-stroke, rgba(59, 130, 246, .33))}.bim-ai-textarea{background:transparent;border:none;outline:none;resize:none;font-size:13px;line-height:1.4;color:var(--bim-ai-text, #E5E7EB);min-height:20px;max-height:100px}.bim-ai-textarea::placeholder{color:var(--bim-ai-muted, #94A3B8)}.bim-ai-helper{display:flex;justify-content:space-between;font-size:11px;color:var(--bim-ai-muted, #94A3B8)}.bim-ai-send-btn{width:40px;height:40px;border-radius:14px;background:var(--bim-ai-accent, #3B82F6);border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;color:var(--bim-ai-accent-ink, #FFFFFF);transition:background .2s ease;flex-shrink:0}.bim-ai-send-btn:hover{background:var(--bim-ai-accent-hover, #2563EB)}.bim-ai-send-btn svg{width:18px;height:18px}.bim-ai-chat.light{--bim-ai-panel: rgba(255, 255, 255, .95);--bim-ai-panel2: #FFFFFF;--bim-ai-border: rgba(15, 23, 42, .1);--bim-ai-text: #0F172A;--bim-ai-muted: #475569;--bim-ai-shadow: rgba(11, 18, 32, .1);--bim-ai-subtle-fill: rgba(15, 23, 42, .05);--bim-ai-subtle-fill-hover: rgba(15, 23, 42, .08);--bim-ai-textbox-fill: #F1F5F9;--bim-ai-user-bubble: #2563EB;--bim-ai-user-text: #FFFFFF;--bim-ai-accent: #2563EB;--bim-ai-accent-soft: rgba(37, 99, 235, .08);--bim-ai-accent-stroke: rgba(37, 99, 235, .2);--bim-ai-success: #059669;--bim-ai-success-soft: rgba(5, 150, 105, .08);--bim-ai-danger: #DC2626;--bim-ai-danger-soft: rgba(220, 38, 38, .08);--bim-ai-danger-stroke: rgba(220, 38, 38, .2);--bim-ai-info: #0284C7;--bim-ai-info-soft: rgba(2, 132, 199, .08)}.bim-btn-group-root{display:flex;gap:8px;z-index:1000;position:absolute;pointer-events:auto;background:transparent}.bim-btn-group-root.static{position:relative;inset:auto;transform:none}.bim-btn-group-root.dir-row{flex-direction:row;align-items:center}.bim-btn-group-root.dir-column{flex-direction:column;align-items:stretch}.bim-btn-group-section{display:flex;gap:4px;background-color:var(--bim-btn-group-section-bg, rgba(17, 17, 17, .88));border-radius:6px;padding:4px;box-shadow:0 2px 8px #0000004d,0 1px 3px #0003}.bim-btn-group-root.dir-row .bim-btn-group-section{flex-direction:row;align-items:center}.bim-btn-group-root.dir-column .bim-btn-group-section{flex-direction:column}.opt-btn-wrapper{position:relative}.opt-btn{display:flex;cursor:pointer;border-radius:4px;transition:background-color .2s,color .2s,border-color .2s;color:var(--bim-btn-text-color, #ccc);background-color:var(--bim-btn-bg, transparent);padding:6px;align-items:center;position:relative;justify-content:center;border:1px solid transparent;outline:none}.opt-btn:hover{background-color:var(--bim-btn-hover-bg, #444)}.opt-btn.active{background-color:var(--bim-btn-active-bg, rgba(255, 255, 255, .15));color:var(--bim-btn-text-active-color, #fff)}.opt-btn.disabled{opacity:.5;cursor:not-allowed}.opt-btn-icon{width:var(--bim-icon-size, 24px);height:var(--bim-icon-size, 24px);display:flex;align-items:center;justify-content:center;color:var(--bim-icon-color, #ccc);flex-shrink:0}.opt-btn-icon svg{width:100%;height:100%;fill:currentColor}.opt-btn-arrow{font-size:10px;opacity:.6;transition:transform .2s;display:inline-block;margin-left:4px}.opt-btn-arrow.rotated{transform:rotate(180deg)}.opt-btn-text-wrapper{display:flex;align-items:center;justify-content:center;pointer-events:none}.opt-btn-label{display:inline}.opt-btn.no-label .opt-btn-label{display:none}.opt-btn.align-vertical:not(.no-label){flex-direction:column;text-align:center}.opt-btn.align-vertical:not(.no-label) .opt-btn-text-wrapper{margin-top:4px}.opt-btn.align-vertical:not(.no-label) .opt-btn-label{font-size:12px;line-height:1.2}.opt-btn.align-horizontal:not(.no-label){flex-direction:row}.opt-btn.align-horizontal:not(.no-label) .opt-btn-text-wrapper{margin-left:8px}.opt-btn.align-horizontal:not(.no-label) .opt-btn-label{font-size:14px}.opt-btn.no-label .opt-btn-text-wrapper{width:0;height:0;margin:0;padding:0;overflow:visible;position:absolute;top:0;right:0}.opt-btn.no-label .opt-btn-arrow{position:absolute;top:2px;right:2px;margin:0;font-size:8px}.opt-btn-dropdown{position:absolute;background-color:var(--bim-toolbar-bg, rgba(17, 17, 17, .95));border-radius:4px;padding:4px;box-shadow:0 4px 12px #0003;z-index:1001;display:flex;flex-direction:column;border:1px solid rgba(255,255,255,.1);opacity:0;visibility:hidden;transform:translateY(-10px);transition:opacity .2s ease,transform .2s cubic-bezier(.2,0,.2,1),visibility .2s}@keyframes dropdown-fade-in{0%{opacity:0;transform:translateY(-8px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}.opt-btn-dropdown{animation:dropdown-fade-in .2s cubic-bezier(.2,0,.2,1) forwards;opacity:1;visibility:visible;transform:none}.opt-btn-dropdown-item{display:flex;align-items:center;padding:8px 12px;cursor:pointer;border-radius:4px;color:var(--bim-btn-text-color, #ccc);transition:background .2s,border-color .2s,color .2s;box-sizing:border-box;border:1px solid transparent;outline:none}.opt-btn-dropdown-item .opt-btn-icon{color:var(--bim-icon-color, #ccc)}.opt-btn-dropdown-item:hover{background-color:var(--bim-btn-hover-bg, #444)}.opt-btn-dropdown-item.active{background-color:var(--bim-btn-active-bg, rgba(255, 255, 255, .15));color:var(--bim-btn-text-active-color, #fff)}.opt-btn-dropdown-item.align-horizontal{flex-direction:row}.opt-btn-dropdown-item.align-horizontal .opt-btn-icon{width:18px;height:18px;margin-right:8px}.opt-btn-dropdown-item.align-vertical{flex-direction:column;text-align:center}.opt-btn-dropdown-item.align-vertical .opt-btn-icon{width:24px;height:24px;margin-bottom:4px}.opt-btn-dropdown-item.align-vertical .opt-btn-dropdown-label{font-size:12px}.bim-btn-group-root.is-bottom-toolbar .opt-btn-icon{width:32px;height:32px}.bim-btn-group-root.is-bottom-toolbar .opt-btn{padding:8px}.bim-btn-group-root.is-bottom-toolbar.dir-row{max-width:calc(100% - 40px);overflow-x:auto;overflow-y:visible;scrollbar-width:thin;scrollbar-color:rgba(255,255,255,.2) transparent}.bim-btn-group-root.is-bottom-toolbar.dir-row .bim-btn-group-section{flex-shrink:0}.bim-btn-group-root.is-bottom-toolbar.dir-row::-webkit-scrollbar{height:4px}.bim-btn-group-root.is-bottom-toolbar.dir-row::-webkit-scrollbar-track{background:transparent}.bim-btn-group-root.is-bottom-toolbar.dir-row::-webkit-scrollbar-thumb{background:#fff3;border-radius:2px}.bim-btn-group-root.is-bottom-toolbar.dir-row::-webkit-scrollbar-thumb:hover{background:#fff6}.bim-btn-group-root.type-glass-pill .bim-btn-group-section{background:var(--bim-floating-bg);backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px);border:1px solid var(--bim-floating-border);border-radius:9999px;box-shadow:none;padding:8px;gap:10px}.bim-btn-group-root.type-glass-pill .opt-btn{width:48px;height:48px;min-width:48px;border-radius:9999px;background:var(--bim-floating-btn-bg);border:1px solid var(--bim-floating-btn-border);box-shadow:var(--bim-floating-btn-shadow);color:var(--bim-text-primary);padding:0;transition:all .2s ease-out}.bim-btn-group-root.type-glass-pill .opt-btn:hover{background:var(--bim-floating-btn-bg-hover);transform:scale(1.05);box-shadow:var(--bim-floating-btn-shadow-hover)}.bim-btn-group-root.type-glass-pill .opt-btn:active{transform:scale(.98)}.bim-btn-group-root.type-glass-pill .opt-btn.active{background:var(--bim-primary);border:1px solid var(--bim-primary-active);color:var(--bim-text-inverse);box-shadow:var(--bim-shadow-glow)}.bim-btn-group-root.type-glass-pill .opt-btn.active:hover{background:var(--bim-primary-hover);transform:scale(1.05)}.bim-btn-group-root.type-glass-pill .opt-btn.active:active{transform:scale(.98)}.bim-btn-group-root.type-glass-pill .opt-btn.active .opt-btn-icon{color:var(--bim-icon-inverse)}.bim-btn-group-root.type-glass-pill .opt-btn.disabled{opacity:.3;cursor:not-allowed;transform:none;box-shadow:none}.bim-btn-group-root.type-glass-pill .opt-btn-icon{width:18px;height:18px;color:var(--bim-floating-icon-color);transition:color .2s ease-out}.bim-btn-group-root.type-glass-pill .opt-btn-icon svg{width:18px;height:18px}.bim-btn-group-root.type-glass-pill .opt-btn:hover .opt-btn-icon{color:var(--bim-floating-icon-color-hover)}.bim-btn-group-root.type-glass-pill .opt-btn-label{display:none!important}.bim-btn-group-root.type-glass-pill .opt-btn-text-wrapper{position:absolute;top:2px;right:2px;width:0;height:0;margin:0;padding:0}.bim-btn-group-root.type-glass-pill .opt-btn-arrow{font-size:8px;position:absolute;top:0;right:0;color:var(--bim-text-tertiary)}.opt-btn-dropdown.type-glass-pill{background:#fffffff2;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border:1px solid rgba(226,232,240,.6);border-radius:12px;box-shadow:0 8px 24px #0000001f;padding:6px}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item{display:flex;flex-direction:row;align-items:center;gap:10px;border-radius:8px;color:#334155;padding:8px 12px;font-size:13px;font-weight:400;transition:all .1s ease-out}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item:hover{background:#f1f5f9}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item:active{background:#e2e8f0}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item.active{background:#3b82f6;color:#fff}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item.active .opt-btn-icon,.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item.active .opt-btn-dropdown-label{color:#fff}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item .opt-btn-icon{width:18px;height:18px;color:#334155;flex-shrink:0}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item .opt-btn-icon svg{width:18px;height:18px}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item .opt-btn-dropdown-label{white-space:nowrap;color:#334155}.opt-btn-dropdown.type-glass-pill.theme-dark{background:var(--bim-bg-overlay);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border:1px solid var(--bim-border-default);box-shadow:var(--bim-shadow-lg)}.opt-btn-dropdown.type-glass-pill.theme-dark .opt-btn-dropdown-item{color:var(--bim-text-primary)}.opt-btn-dropdown.type-glass-pill.theme-dark .opt-btn-dropdown-item:hover{background:var(--bim-floating-btn-bg)}.opt-btn-dropdown.type-glass-pill.theme-dark .opt-btn-dropdown-item:active{background:var(--bim-floating-btn-bg-hover)}.opt-btn-dropdown.type-glass-pill.theme-dark .opt-btn-dropdown-item.active{background:var(--bim-primary);color:var(--bim-text-inverse)}.opt-btn-dropdown.type-glass-pill.theme-dark .opt-btn-dropdown-item .opt-btn-icon{color:var(--bim-floating-icon-color)}.opt-btn-dropdown.type-glass-pill.theme-dark .opt-btn-dropdown-item .opt-btn-dropdown-label{color:var(--bim-text-primary)}.bim-tree{width:100%;height:100%;display:flex;flex-direction:column;overflow:hidden;font-size:14px;color:var(--bim-text-primary);-webkit-user-select:none;user-select:none;position:relative;background:transparent}.bim-tree-search{padding:6px;background-color:transparent;flex-shrink:0;position:relative}.bim-tree-search-wrapper{position:relative;width:100%;display:flex;align-items:center}.bim-tree-search-icon{position:absolute;left:8px;width:16px;height:16px;color:var(--bim-text-secondary);pointer-events:none;display:flex;align-items:center;justify-content:center}.bim-tree-search-icon svg{width:100%;height:100%}.bim-tree-search-input{width:100%;height:30px;padding:4px 8px 4px 30px;border:1px solid var(--bim-border-default);border-radius:4px;outline:none;font-size:13px;color:inherit;background-color:var(--bim-bg-elevated);transition:all .2s;box-sizing:border-box}.bim-tree-search-input:focus{border-color:var(--bim-primary);box-shadow:var(--bim-focus-ring)}.bim-tree-search-results{position:absolute;top:100%;left:8px;right:8px;background-color:var(--bim-bg-elevated);border:1px solid var(--bim-border-default);box-shadow:var(--bim-shadow-md);border-radius:4px;max-height:200px;overflow-y:auto;z-index:10;display:none}.bim-tree-search-results.is-visible{display:block}.bim-tree-search-item{padding:8px 12px;cursor:pointer;border-bottom:1px solid rgba(0,0,0,.03)}.bim-tree-search-item:last-child{border-bottom:none}.bim-tree-search-item:hover{background-color:var(--bim-component-bg-hover)}.bim-tree-search-item-title{font-weight:500;display:block}.bim-tree-search-item-path{font-size:12px;color:var(--bim-text-secondary);margin-top:2px;display:block}.bim-tree-node-content:hover{background-color:var(--bim-component-bg-hover)}.bim-tree-switcher{width:24px;height:32px;display:flex;align-items:center;justify-content:center;cursor:pointer;color:var(--bim-text-secondary);transition:transform .2s;flex-shrink:0}.bim-tree-switcher svg{width:12px;height:12px;fill:currentColor;transition:transform .2s}.bim-tree-switcher.is-expanded svg{transform:rotate(90deg)}.bim-tree-switcher.is-hidden{visibility:hidden}.bim-tree-checkbox{width:16px;height:16px;border:1px solid var(--bim-border-default);border-radius:2px;margin-right:8px;background-color:var(--bim-bg-elevated);position:relative;cursor:pointer;flex-shrink:0;transition:all .2s}.bim-tree-checkbox:hover{border-color:var(--bim-primary)}.bim-tree-checkbox.is-checked{background-color:var(--bim-primary);border-color:var(--bim-primary)}.bim-tree-checkbox.is-checked:after{content:"";position:absolute;top:1px;left:4px;width:5px;height:9px;border:2px solid var(--bim-text-inverse);border-top:0;border-left:0;transform:rotate(45deg)}.bim-tree-checkbox.is-indeterminate{background-color:var(--bim-bg-elevated);border-color:var(--bim-primary)}.bim-tree-checkbox.is-indeterminate:after{content:"";position:absolute;top:6px;left:3px;width:8px;height:2px;background-color:var(--bim-primary)}.bim-tree-node.is-disabled .bim-tree-checkbox{background-color:var(--bim-component-bg-disabled);border-color:var(--bim-border-disabled);cursor:not-allowed}.bim-tree-node.is-disabled .bim-tree-checkbox.is-checked{background-color:var(--bim-text-disabled)}.bim-tree-node.is-disabled .bim-tree-node-content{color:var(--bim-text-disabled);cursor:not-allowed}.bim-tree-icon{width:16px;height:16px;margin-right:6px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.bim-tree-icon img,.bim-tree-icon svg{width:100%;height:100%}.bim-tree-title{flex:1;white-space:nowrap}.bim-tree-children{display:none;overflow:visible}.bim-tree-children.is-visible{display:block}.bim-tree-node-content.is-selected{background-color:var(--bim-component-bg-selected);color:var(--bim-primary)}.bim-tree-node-actions{display:none;align-items:center;margin-left:8px;flex-shrink:0}.bim-tree-node-content.is-selected .bim-tree-node-actions{display:flex}.bim-tree-content{flex:1;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;scroll-behavior:auto;padding:2px 0;min-height:0}.bim-tree-node{display:flex;flex-direction:column;width:100%}.bim-tree-node-content{display:flex;align-items:center;height:32px;cursor:pointer;transition:background-color .2s;border-radius:4px;padding-right:8px;width:100%;box-sizing:border-box}.bim-tab{display:flex;flex-direction:column;width:100%;height:100%;background:transparent;color:var(--bim-text-secondary)}.bim-tab__nav{display:flex;align-items:center;gap:4px;padding:4px;margin:8px 12px;background:var(--bim-bg-inset);border-radius:8px;border:1px solid var(--bim-border-subtle)}.bim-tab__item{flex:1;display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:8px 12px;border:none;border-radius:6px;background:transparent;color:var(--bim-text-secondary);cursor:pointer;transition:all .2s ease;font-size:13px;font-weight:500}.bim-tab__item:hover{color:var(--bim-text-primary);background-color:var(--bim-component-bg-hover)}.bim-tab__item.is-active{color:var(--bim-primary);background-color:var(--bim-bg-elevated);box-shadow:0 1px 3px #0000001a}.bim-tab__item.is-disabled{opacity:.5;cursor:not-allowed}.bim-tab__icon{width:16px;height:16px;display:inline-flex;align-items:center;justify-content:center;color:var(--bim-tab-icon, currentColor)}.bim-tab__icon svg{width:100%;height:100%;fill:currentColor}.bim-tab__title{white-space:nowrap}.bim-tab__content{flex:1;display:flex;position:relative;min-height:0;overflow:hidden}.bim-tab__panel{display:none;width:100%;height:100%;flex:1}.bim-tab__panel.is-active{display:flex;flex-direction:column;height:100%}.construct-tab__container{height:100%;display:flex;flex-direction:column}.construct-tab__panel-content{flex:1;display:flex;flex-direction:column;min-height:0;overflow:hidden}.construct-tab__panel-content .bim-tree{flex:1}')),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
|
||
(function(bs,jl){typeof exports=="object"&&typeof module<"u"?jl(exports,require("opentype.js")):typeof define=="function"&&define.amd?define(["exports","opentype.js"],jl):(bs=typeof globalThis<"u"?globalThis:bs||self,jl(bs.IflowEngine={},bs["{}"]))})(this,(function(bs,jl){"use strict";function yM(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const xM=yM(jl),TA={name:"light",primary:"#2563eb",primaryHover:"#1d4ed8",primaryActive:"#1e40af",primarySubtle:"rgba(37, 99, 235, 0.1)",success:"#16a34a",successHover:"#15803d",successSubtle:"rgba(22, 163, 74, 0.1)",warning:"#d97706",warningHover:"#b45309",warningSubtle:"rgba(217, 119, 6, 0.1)",danger:"#dc2626",dangerHover:"#b91c1c",dangerSubtle:"rgba(220, 38, 38, 0.1)",info:"#0891b2",infoHover:"#0e7490",infoSubtle:"rgba(8, 145, 178, 0.1)",bgBase:"#f8fafc",bgElevated:"#ffffff",bgOverlay:"rgba(255, 255, 255, 0.98)",bgInset:"#f1f5f9",bgGlass:"rgba(255, 255, 255, 0.8)",bgGlassBlur:"24px",textPrimary:"#0f172a",textSecondary:"#475569",textTertiary:"#94a3b8",textDisabled:"#cbd5e1",textInverse:"#ffffff",textLink:"#2563eb",textLinkHover:"#1d4ed8",iconDefault:"#64748b",iconHover:"#334155",iconActive:"#2563eb",iconDisabled:"#cbd5e1",iconInverse:"#ffffff",borderDefault:"#e2e8f0",borderSubtle:"#f1f5f9",borderStrong:"#cbd5e1",borderDisabled:"#f1f5f9",divider:"#e2e8f0",componentBg:"transparent",componentBgHover:"rgba(15, 23, 42, 0.04)",componentBgActive:"rgba(15, 23, 42, 0.08)",componentBgSelected:"rgba(37, 99, 235, 0.08)",componentBgDisabled:"#f8fafc",focusRing:"rgba(37, 99, 235, 0.5)",focusRingOffset:"#ffffff",selectionBg:"rgba(37, 99, 235, 0.15)",selectionText:"#0f172a",shadowSm:"0 2px 8px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.08)",shadowMd:"0 4px 12px rgba(0, 0, 0, 0.12), 0 6px 20px rgba(0, 0, 0, 0.1)",shadowLg:"0 10px 25px rgba(0, 0, 0, 0.15), 0 6px 10px rgba(0, 0, 0, 0.1)",shadowXl:"0 20px 40px rgba(0, 0, 0, 0.2), 0 10px 15px rgba(0, 0, 0, 0.1)",shadowGlow:"0 2px 8px rgba(59, 130, 246, 0.3), 0 4px 16px rgba(59, 130, 246, 0.2)",scrollbarTrack:"#f1f5f9",scrollbarThumb:"#cbd5e1",scrollbarThumbHover:"#94a3b8",floatingBg:"rgba(255, 255, 255, 0.8)",floatingBorder:"rgba(226, 232, 240, 0.5)",floatingShadow:"0 4px 24px rgba(0, 0, 0, 0.06)",floatingBtnBg:"rgba(255, 255, 255, 0.9)",floatingBtnBorder:"rgba(203, 213, 225, 0.6)",floatingBtnShadow:"0 2px 8px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.08)",floatingBtnBgHover:"#ffffff",floatingBtnShadowHover:"0 4px 12px rgba(0, 0, 0, 0.12), 0 6px 20px rgba(0, 0, 0, 0.1)",floatingIconColor:"#334155",floatingIconColorHover:"#1e293b",panelBg:"rgba(255, 255, 255, 0.95)",panelBorder:"rgba(226, 232, 240, 0.6)",panelHeaderBg:"rgba(248, 250, 252, 0.9)",panelRadius:"12px",tabBg:"#f1f5f9",tabItemBg:"transparent",tabItemBgHover:"rgba(255, 255, 255, 0.6)",tabItemBgActive:"#ffffff",tabItemTextActive:"#2563eb",overrides:{dialog:{headerBg:"#f8fafc"},toolbar:{bg:"rgba(255, 255, 255, 0.9)",buttonBg:"rgba(255, 255, 255, 0.95)",buttonBgHover:"#ffffff",buttonBgActive:"#2563eb"},input:{bg:"#ffffff",bgFocus:"#ffffff",placeholder:"#94a3b8"}}},_M={name:"dark",primary:"#3b82f6",primaryHover:"#60a5fa",primaryActive:"#2563eb",primarySubtle:"rgba(59, 130, 246, 0.15)",success:"#22c55e",successHover:"#4ade80",successSubtle:"rgba(34, 197, 94, 0.15)",warning:"#f59e0b",warningHover:"#fbbf24",warningSubtle:"rgba(245, 158, 11, 0.15)",danger:"#ef4444",dangerHover:"#f87171",dangerSubtle:"rgba(239, 68, 68, 0.15)",info:"#06b6d4",infoHover:"#22d3ee",infoSubtle:"rgba(6, 182, 212, 0.15)",bgBase:"#152232",bgElevated:"#1f2d3e",bgOverlay:"rgba(21, 34, 50, 0.98)",bgInset:"#152232",bgGlass:"rgba(21, 34, 50, 0.85)",bgGlassBlur:"24px",textPrimary:"#ffffff",textSecondary:"#94a3b8",textTertiary:"#64748b",textDisabled:"#475569",textInverse:"#152232",textLink:"#60a5fa",textLinkHover:"#93c5fd",iconDefault:"#ffffff",iconHover:"#ffffff",iconActive:"#3b82f6",iconDisabled:"#475569",iconInverse:"#152232",borderDefault:"rgba(51, 65, 85, 0.5)",borderSubtle:"rgba(51, 65, 85, 0.5)",borderStrong:"#475569",borderDisabled:"#1e293b",divider:"#334155",componentBg:"transparent",componentBgHover:"rgba(248, 250, 252, 0.06)",componentBgActive:"rgba(248, 250, 252, 0.1)",componentBgSelected:"rgba(59, 130, 246, 0.2)",componentBgDisabled:"#1e293b",focusRing:"rgba(59, 130, 246, 0.5)",focusRingOffset:"#1e293b",selectionBg:"rgba(59, 130, 246, 0.3)",selectionText:"#f8fafc",shadowSm:"0 2px 8px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3)",shadowMd:"0 4px 12px rgba(0, 0, 0, 0.5), 0 6px 20px rgba(0, 0, 0, 0.4)",shadowLg:"0 10px 25px rgba(0, 0, 0, 0.6), 0 6px 10px rgba(0, 0, 0, 0.4)",shadowXl:"0 20px 40px rgba(0, 0, 0, 0.7), 0 10px 15px rgba(0, 0, 0, 0.5)",shadowGlow:"0 2px 8px rgba(59, 130, 246, 0.4), 0 4px 16px rgba(59, 130, 246, 0.25)",scrollbarTrack:"#1e293b",scrollbarThumb:"#475569",scrollbarThumbHover:"#64748b",floatingBg:"rgba(15, 23, 42, 0.85)",floatingBorder:"rgba(51, 65, 85, 0.4)",floatingShadow:"0 4px 24px rgba(0, 0, 0, 0.25)",floatingBtnBg:"rgba(51, 65, 85, 0.6)",floatingBtnBorder:"rgba(100, 116, 139, 0.5)",floatingBtnShadow:"0 2px 8px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.25)",floatingBtnBgHover:"rgba(71, 85, 105, 0.7)",floatingBtnShadowHover:"0 4px 12px rgba(0, 0, 0, 0.35), 0 6px 20px rgba(0, 0, 0, 0.3)",floatingIconColor:"#e2e8f0",floatingIconColorHover:"#f8fafc",panelBg:"rgba(15, 23, 42, 0.95)",panelBorder:"rgba(51, 65, 85, 0.5)",panelHeaderBg:"rgba(15, 23, 42, 0.9)",panelRadius:"12px",tabBg:"rgba(30, 41, 59, 0.6)",tabItemBg:"transparent",tabItemBgHover:"rgba(51, 65, 85, 0.5)",tabItemBgActive:"rgba(51, 65, 85, 0.8)",tabItemTextActive:"#60a5fa",overrides:{dialog:{headerBg:"#0f172a"},toolbar:{bg:"rgba(30, 41, 59, 0.9)",buttonBg:"rgba(51, 65, 85, 0.6)",buttonBgHover:"rgba(71, 85, 105, 0.7)",buttonBgActive:"#3b82f6"},input:{bg:"#0f172a",bgFocus:"#1e293b",placeholder:"#64748b"}}};class EM{currentTheme=TA;listeners=[];constructor(){}getTheme(){return this.currentTheme}setTheme(e){e==="light"?this.applyTheme(TA):this.applyTheme(_M)}setCustomTheme(e){this.applyTheme(e)}applyTheme(e){this.currentTheme=e,this.notifyListeners()}subscribe(e){return this.listeners.push(e),e(this.currentTheme),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}notifyListeners(){this.listeners.forEach(e=>e(this.currentTheme))}}const ht=new EM,MM={common:{title:"BimEngine",description:"这是一个使用 BIM-ENGINE。",openTestDialog:"打开测试弹窗",openInfoDialog:"打开信息弹窗 (封装版)"},toolbar:{home:"首页",measure:"测量",zoomBox:"选框放大",info:"信息",location:"定位",setting:"设置",walk:"漫游",map:"地图",property:"构件详情",fullscreen:"全屏",walkMenu:"漫游菜单",walkPerson:"第一人称",walkBird:"第三人称",tree:"模型树",section:"剖切",sectionPlane:"拾取面剖切",sectionAxis:"轴向剖切",sectionBox:"剖切盒",cameraSwitch:"相机切换"},dialog:{testTitle:"测试弹窗",testContent:'<div style="padding: 10px;">这是一个 <b>可拖拽</b> 且 <b>可缩放</b> 的弹窗。<br><br>你可以尝试拖动标题栏,或者拖动右下角改变大小。</div>'},menu:{info:"信息",home:"首页",componentDetail:"构件详情",hideSelected:"隐藏选中构件",transparentSelected:"半透明选中构件",cancelTranslucent:"取消半透明",isolateSelected:"隔离选中构件",hideOthers:"其他构件隐藏",transparentOthers:"其他构件半透明",fitSectionBox:"剖切盒适应",showAll:"显示全部",quickSelect:"快速选择",selectSameType:"选择同类模型",selectSameLevel:"选择同层模型",selectSameLevelType:"选择同层同类模型"},tree:{searchPlaceholder:"请输入要搜索的内容"},constructTree:{title:"目录树"},tab:{component:"构件",system:"系统",space:"空间",type:"类型",major:"专业"},panel:{property:{title:"构件详情",base:"基本属性",material:"材质信息",advanced:"高级设置",tab:{props:"属性",material:"材质"}},componentDetail:{title:"构件详情",noSelection:"请先选中构件"}},measure:{btnName:"测量",dialogTitle:"测量",modes:{clearHeight:"净高",clearDistance:"净距",distance:"距离",elevation:"标高",point:"坐标",angle:"角度",area:"面积",slope:"坡度"},actions:{expand:"展开",collapse:"收起",clearAll:"删除全部",settings:"设置"},labels:{currentMode:"当前测量方式:",x:"X:",y:"Y:",z:"Z:",value:{clearHeight:"净高:",clearDistance:"净距:",distance:"距离:",elevation:"标高:",point:"坐标:",angle:"角度:",area:"面积:",slope:"坡度:"}},settings:{title:"设置",unit:"单位:",precision:"精度:",hint:"距离、净距、净高和标高默认使用该单位;角度和面积有各自默认单位。",save:"保存设置",cancel:"取消"},clearHeight:{direction:"朝向:",directionDown:"朝下",directionUp:"朝上",selectType:"选择对象:",selectPoint:"选择点",selectElement:"选择构件"}},sectionPlane:{dialogTitle:"拾取面剖切",actions:{hide:"隐藏",reverse:"反向",reset:"重置"}},sectionAxis:{dialogTitle:"轴向剖切",actions:{hide:"隐藏",reverse:"反向",reset:"重置",axisX:"X",axisY:"Y",axisZ:"Z"}},sectionBox:{dialogTitle:"剖切盒",actions:{hide:"隐藏",reverse:"反向",fitToModel:"适应",reset:"重置"},axes:{x:"X",y:"Y",z:"Z"}},walkControl:{speed:"移动速度:",gravity:"重力",collision:"碰撞",characterModel:{label:"建筑工人",constructionWorker:"建筑工人",officeMale:"办公室男性"},walkMode:{label:"行走模式",walk:"行走模式",run:"奔跑模式"},exit:"退出",path:{dialogTitle:"路径漫游",duration:"漫游时间",durationUnit:"秒",loop:"循环播放",addPoint:"添加漫游点",deleteAll:"删除全部",point:"漫游点",play:"播放漫游",stop:"停止漫游",noPoints:"暂无漫游点,请添加"}},info:{dialogTitle:"基本信息",meshCount:"构件数量",totalTriangles:"三角面数量",totalVertices:"顶点数量"},aiChat:{title:"AI 助手",placeholder:"输入你的问题...",quickPrompt:{summarize:"总结这个模型",explain:"解释选中的构件",generate:"生成报告"},action:{new:"新建对话",history:"历史记录",settings:"设置",close:"关闭"},helper:{newline:"Shift + Enter 换行",send:"Enter 发送"},thinking:"正在思考...",other:"其他",otherPlaceholder:"请输入自定义答案",submit:"提交"},setting:{dialogTitle:"设置",presetSelect:"选择预设",presetSelectPlaceholder:"请选择预设",defaultPresetLabel:"默认预设",savePreset:"保存预设",deletePreset:"删除预设",deletePresetForbidden:"默认预设不允许删除",presetDefaultName:"预设",presetNamePrompt:"请输入预设名称",presetNameRequired:"预设名称不能为空",presetNameDuplicate:"预设名称已存在,请使用其他名称",restorePreset:"恢复预设",saveAsNewPreset:"存为新预设",selectPresetFirst:"请先选择预设",presetButton:"预设",undoChanges:"撤销修改",saveAsDialogTitle:"存为新预设",deleteDialogTitle:"删除预设",deleteDialogMessage:"确认删除当前预设吗?删除后不可恢复。",presetNamePlaceholder:"请输入预设名称",confirm:"确定",cancel:"取消",presetPickPrompt:"请输入预设序号",presetPickInvalid:"预设序号无效",renderMode:"渲染模式",modes:{simple:"性能模式",balance:"平衡模式",advanced:"效果模式"},displaySection:"显示设置",edgeLine:"边线",edgeOpacity:"边线透明度",showGrid:"显示轴网",showLevel:"显示标高",contrast:"对比度",saturation:"饱和度",lightIntensity:"光照强度",environment:"环境背景",environmentType:{none:"无",hdr:"HDR背景",sky:"天空盒"},backgroundVisible:"显示背景",ground:"显示地面",groundElevation:"地面高度",groundElevationUnit:"m"}},wM={common:{title:"BimEngine",description:"This is a BIM-ENGINE demo.",openTestDialog:"Open Test Dialog",openInfoDialog:"Open Info Dialog (Wrapped)"},toolbar:{home:"Home",measure:"Measure",zoomBox:"Zoom Box",info:"Info",location:"Location",setting:"Settings",walk:"Walk",map:"Map",property:"Property",fullscreen:"Fullscreen",walkPerson:"Person",walkBird:"Bird Eye",walkMenu:"Menu",tree:"Tree",section:"Section",sectionPlane:"Plane Section",sectionAxis:"Axis Section",sectionBox:"Section Box",cameraSwitch:"Camera"},dialog:{testTitle:"Test Dialog",testContent:'<div style="padding: 10px;">This is a <b>draggable</b> and <b>resizable</b> dialog.<br><br>Try dragging the title bar or resizing from the bottom-right corner.</div>'},menu:{info:"Info",home:"Home",componentDetail:"Component Detail",hideSelected:"Hide Selected",transparentSelected:"Transparent Selected",cancelTranslucent:"Cancel Translucent",isolateSelected:"Isolate Selected",hideOthers:"Hide Others",transparentOthers:"Transparent Others",fitSectionBox:"Fit Section Box",showAll:"Show All",quickSelect:"Quick Select",selectSameType:"Select Same Type",selectSameLevel:"Select Same Level",selectSameLevelType:"Select Same Level & Type"},tree:{searchPlaceholder:"Please enter content to search"},constructTree:{title:"Construct Tree"},tab:{component:"Component",system:"System",space:"Space",type:"Type",major:"Major"},panel:{property:{title:"Component Details",base:"Basic Info",material:"Material",advanced:"Advanced",tab:{props:"Properties",material:"Material"}},componentDetail:{title:"Component Detail",noSelection:"Please select a component first"}},measure:{btnName:"Measure",dialogTitle:"Measure",modes:{clearHeight:"Clear Height",clearDistance:"Clear Distance",distance:"Distance",elevation:"Elevation",point:"Point",angle:"Angle",area:"Area",slope:"Slope"},actions:{expand:"Expand",collapse:"Collapse",clearAll:"Clear All",settings:"Settings"},labels:{currentMode:"Mode:",x:"X:",y:"Y:",z:"Z:",value:{clearHeight:"Clear Height:",clearDistance:"Clear Distance:",distance:"Distance:",elevation:"Elevation:",point:"Point:",angle:"Angle:",area:"Area:",slope:"Slope:"}},settings:{title:"Settings",unit:"Unit:",precision:"Precision:",hint:"Distance, clear distance, clear height and elevation use this unit by default; angle and area use their own units.",save:"Save",cancel:"Cancel"},clearHeight:{direction:"Direction:",directionDown:"Down",directionUp:"Up",selectType:"Select:",selectPoint:"Point",selectElement:"Element"}},sectionPlane:{dialogTitle:"Plane Section",actions:{hide:"Hide",reverse:"Reverse",reset:"Reset"}},sectionAxis:{dialogTitle:"Axis Section",actions:{hide:"Hide",reverse:"Reverse",reset:"Reset",axisX:"X",axisY:"Y",axisZ:"Z"}},sectionBox:{dialogTitle:"Section Box",actions:{hide:"Hide",reverse:"Reverse",fitToModel:"Fit",reset:"Reset"},axes:{x:"X",y:"Y",z:"Z"}},walkControl:{speed:"Speed:",gravity:"Gravity",collision:"Collision",characterModel:{label:"Construction Worker",constructionWorker:"Construction Worker",officeMale:"Office Male"},walkMode:{label:"Walk Mode",walk:"Walk",run:"Run"},exit:"Exit",path:{dialogTitle:"Path Roaming",duration:"Duration",durationUnit:"s",loop:"Loop",addPoint:"Add Point",deleteAll:"Delete All",point:"Point",play:"Play",stop:"Stop",noPoints:"No points yet"}},info:{dialogTitle:"Basic Info",meshCount:"Mesh Count",totalTriangles:"Total Triangles",totalVertices:"Total Vertices"},aiChat:{title:"AI Assistant",placeholder:"Ask a question...",quickPrompt:{summarize:"Summarize this model",explain:"Explain selected component",generate:"Generate report"},action:{new:"New Chat",history:"History",settings:"Settings",close:"Close"},helper:{newline:"Shift + Enter for new line",send:"Enter to send"},thinking:"Thinking...",other:"Other",otherPlaceholder:"Enter custom answer",submit:"Submit"},setting:{dialogTitle:"Settings",presetSelect:"Preset",presetSelectPlaceholder:"Select preset",defaultPresetLabel:"Default Preset",savePreset:"Save Preset",deletePreset:"Delete",deletePresetForbidden:"Default preset cannot be deleted",presetDefaultName:"Preset",presetNamePrompt:"Enter preset name",presetNameRequired:"Preset name is required",presetNameDuplicate:"Preset name already exists",restorePreset:"Restore Preset",saveAsNewPreset:"Save As Preset",selectPresetFirst:"Please select a preset first",presetButton:"Preset",undoChanges:"Undo Changes",saveAsDialogTitle:"Save As Preset",deleteDialogTitle:"Delete Preset",deleteDialogMessage:"Delete current preset? This action cannot be undone.",presetNamePlaceholder:"Enter preset name",confirm:"Confirm",cancel:"Cancel",presetPickPrompt:"Please input preset number",presetPickInvalid:"Invalid preset number",renderMode:"Render Mode",modes:{simple:"Performance",balance:"Balanced",advanced:"Quality"},displaySection:"Display",edgeLine:"Edge Lines",edgeOpacity:"Edge Opacity",showGrid:"Show Grid",showLevel:"Show Level",contrast:"Contrast",saturation:"Saturation",lightIntensity:"Light Intensity",environment:"Environment",environmentType:{none:"None",hdr:"HDR",sky:"Sky"},backgroundVisible:"Show Background",ground:"Ground",groundElevation:"Ground Elevation",groundElevationUnit:"m"}},SM={common:{title:"BimEngine",description:"這是一個使用 BIM-ENGINE。",openTestDialog:"打開測試彈窗",openInfoDialog:"打開資訊彈窗 (封裝版)"},toolbar:{home:"首頁",measure:"測量",zoomBox:"選框放大",info:"資訊",location:"定位",setting:"設定",walk:"漫遊",map:"地圖",property:"構件詳情",fullscreen:"全屏",walkMenu:"漫遊選單",walkPerson:"第一人稱",walkBird:"第三人稱",tree:"模型樹",section:"剖切",sectionPlane:"拾取面剖切",sectionAxis:"軸向剖切",sectionBox:"剖切盒",cameraSwitch:"相機切換"},dialog:{testTitle:"測試彈窗",testContent:'<div style="padding: 10px;">這是一個 <b>可拖曳</b> 且 <b>可縮放</b> 的彈窗。<br><br>你可以嘗試拖動標題欄,或者拖動右下角改變大小。</div>'},menu:{info:"資訊",home:"首頁",componentDetail:"構件詳情",hideSelected:"隱藏選中構件",transparentSelected:"半透明選中構件",cancelTranslucent:"取消半透明",isolateSelected:"隔離選中構件",hideOthers:"其他構件隱藏",transparentOthers:"其他構件半透明",fitSectionBox:"剖切盒適應",showAll:"顯示全部",quickSelect:"快速選擇",selectSameType:"選擇同類模型",selectSameLevel:"選擇同層模型",selectSameLevelType:"選擇同層同類模型"},tree:{searchPlaceholder:"請輸入要搜尋的內容"},constructTree:{title:"目錄樹"},tab:{component:"構件",system:"系統",space:"空間",type:"類型",major:"專業"},panel:{property:{title:"構件詳情",base:"基本屬性",material:"材質資訊",advanced:"進階設定",tab:{props:"屬性",material:"材質"}},componentDetail:{title:"構件詳情",noSelection:"請先選中構件"}},measure:{btnName:"測量",dialogTitle:"測量",modes:{clearHeight:"淨高",clearDistance:"淨距",distance:"距離",elevation:"標高",point:"座標",angle:"角度",area:"面積",slope:"坡度"},actions:{expand:"展開",collapse:"收起",clearAll:"刪除全部",settings:"設定"},labels:{currentMode:"當前測量方式:",x:"X:",y:"Y:",z:"Z:",value:{clearHeight:"淨高:",clearDistance:"淨距:",distance:"距離:",elevation:"標高:",point:"座標:",angle:"角度:",area:"面積:",slope:"坡度:"}},settings:{title:"設定",unit:"單位:",precision:"精度:",hint:"距離、淨距、淨高和標高預設使用該單位;角度和面積有各自預設單位。",save:"儲存設定",cancel:"取消"},clearHeight:{direction:"朝向:",directionDown:"朝下",directionUp:"朝上",selectType:"選擇對象:",selectPoint:"選擇點",selectElement:"選擇構件"}},sectionPlane:{dialogTitle:"拾取面剖切",actions:{hide:"隱藏",reverse:"反向",reset:"重設"}},sectionAxis:{dialogTitle:"軸向剖切",actions:{hide:"隱藏",reverse:"反向",reset:"重設",axisX:"X",axisY:"Y",axisZ:"Z"}},sectionBox:{dialogTitle:"剖切盒",actions:{hide:"隱藏",reverse:"反向",fitToModel:"適應",reset:"重設"},axes:{x:"X",y:"Y",z:"Z"}},walkControl:{speed:"移動速度:",gravity:"重力",collision:"碰撞",characterModel:{label:"建築工人",constructionWorker:"建築工人",officeMale:"辦公室男性"},walkMode:{label:"行走模式",walk:"行走模式",run:"奔跑模式"},exit:"退出",path:{dialogTitle:"路徑漫遊",duration:"漫遊時間",durationUnit:"秒",loop:"循環播放",addPoint:"新增漫遊點",deleteAll:"刪除全部",point:"漫遊點",play:"播放漫遊",stop:"停止漫遊",noPoints:"暫無漫遊點,請新增"}},info:{dialogTitle:"基本資訊",meshCount:"構件數量",totalTriangles:"三角面數量",totalVertices:"頂點數量"},aiChat:{title:"AI 助手",placeholder:"輸入你的問題...",quickPrompt:{summarize:"總結這個模型",explain:"解釋選中的構件",generate:"生成報告"},action:{new:"新建對話",history:"歷史記錄",settings:"設定",close:"關閉"},helper:{newline:"Shift + Enter 換行",send:"Enter 傳送"},thinking:"正在思考...",other:"其他",otherPlaceholder:"請輸入自定義答案",submit:"提交"},setting:{dialogTitle:"設定",presetSelect:"選擇預設",presetSelectPlaceholder:"請選擇預設",defaultPresetLabel:"預設預設",savePreset:"儲存預設",deletePreset:"刪除預設",deletePresetForbidden:"預設預設不允許刪除",presetDefaultName:"預設",presetNamePrompt:"請輸入預設名稱",presetNameRequired:"預設名稱不能為空",presetNameDuplicate:"預設名稱已存在,請使用其他名稱",restorePreset:"還原預設",saveAsNewPreset:"另存為新預設",selectPresetFirst:"請先選擇預設",presetButton:"預設",undoChanges:"撤銷修改",saveAsDialogTitle:"另存為新預設",deleteDialogTitle:"刪除預設",deleteDialogMessage:"確認刪除目前預設嗎?刪除後無法復原。",presetNamePlaceholder:"請輸入預設名稱",confirm:"確定",cancel:"取消",presetPickPrompt:"請輸入預設序號",presetPickInvalid:"預設序號無效",renderMode:"渲染模式",modes:{simple:"效能模式",balance:"平衡模式",advanced:"效果模式"},displaySection:"顯示設定",edgeLine:"邊線",edgeOpacity:"邊線透明度",showGrid:"顯示軸網",showLevel:"顯示標高",contrast:"對比度",saturation:"飽和度",lightIntensity:"光照強度",environment:"環境背景",environmentType:{none:"無",hdr:"HDR背景",sky:"天空盒"},backgroundVisible:"顯示背景",ground:"顯示地面",groundElevation:"地面高度",groundElevationUnit:"m"}};class CM{currentLocale="zh-CN";messages={"zh-CN":MM,"en-US":wM,"zh-TW":SM};listeners=[];constructor(){}getLocale(){return this.currentLocale}setLocale(e){this.messages[e]&&this.currentLocale!==e&&(this.currentLocale=e,this.notifyListeners())}t(e){if(!e)return"";const t=e.split(".");let i=this.messages[this.currentLocale];for(const n of t)if(i&&typeof i=="object"&&n in i)i=i[n];else return e;return i}subscribe(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}notifyListeners(){this.listeners.forEach(e=>e(this.currentLocale))}}const Kt=new CM,Ee=r=>Kt.t(r);class TM{element;options;container;header;contentArea;_isDestroyed=!1;_isInitialized=!1;unsubscribeTheme=null;unsubscribeLocale=null;rafId=null;constructor(e){this.options={title:"Dialog",width:300,height:"auto",position:"center",draggable:!0,resizable:!1,minWidth:200,minHeight:100,...e},this.container=e.container,this.element=this.createDom(),this.header=this.element.querySelector(".bim-dialog-header"),this.contentArea=this.element.querySelector(".bim-dialog-content"),this.init()}setTheme(e){const t=this.element.style;this.options.backgroundColor||t.setProperty("--bim-dialog-bg",e.bgElevated),this.options.headerBackgroundColor||t.setProperty("--bim-dialog-header-bg",e.bgInset),this.options.titleColor||t.setProperty("--bim-dialog-title-color",e.textPrimary),this.options.textColor||t.setProperty("--bim-dialog-text-color",e.textSecondary),this.options.borderColor||t.setProperty("--bim-dialog-border-color",e.borderDefault),t.setProperty("--bim-bg-elevated",e.bgElevated),t.setProperty("--bim-bg-inset",e.bgInset),t.setProperty("--bim-text-primary",e.textPrimary),t.setProperty("--bim-text-secondary",e.textSecondary),t.setProperty("--bim-text-tertiary",e.textTertiary),t.setProperty("--bim-border-default",e.borderDefault),t.setProperty("--bim-shadow-lg",e.shadowLg)}init(){this._isInitialized||(this.container.appendChild(this.element),this.initPosition(),this.options.draggable&&this.initDrag(),this.options.resizable&&this.initResize(),this._isInitialized=!0,this.options.onOpen&&this.options.onOpen(),this.unsubscribeTheme=ht.subscribe(e=>{this.setTheme(e)}),this.unsubscribeLocale=Kt.subscribe(()=>{this.setLocales()}))}setLocales(){if(this.options.title){const e=this.header.querySelector(".bim-dialog-title");e&&(e.textContent=Ee(this.options.title))}}createDom(){const e=document.createElement("div");e.className="bim-dialog",this.options.id&&(e.id=this.options.id);const t=e.style;this.options.backgroundColor&&t.setProperty("--bim-dialog-bg",this.options.backgroundColor),this.options.headerBackgroundColor&&t.setProperty("--bim-dialog-header-bg",this.options.headerBackgroundColor),this.options.titleColor&&t.setProperty("--bim-dialog-title-color",this.options.titleColor),this.options.textColor&&t.setProperty("--bim-dialog-text-color",this.options.textColor),this.options.borderColor&&t.setProperty("--bim-dialog-border-color",this.options.borderColor),this.setSize(e,this.options.width,this.options.height),this.options.minWidth&&(e.style.minWidth=`${this.options.minWidth}px`);const i=document.createElement("div");i.className="bim-dialog-header",this.options.draggable&&i.classList.add("draggable");const n=document.createElement("span");n.className="bim-dialog-title",n.textContent=this.options.title?Ee(this.options.title):"";const s=document.createElement("span");s.className="bim-dialog-close",s.innerHTML="×",s.onclick=()=>{this.close()},i.appendChild(n),i.appendChild(s);const a=document.createElement("div");if(a.className="bim-dialog-content",typeof this.options.content=="string"?a.innerHTML=this.options.content:this.options.content instanceof HTMLElement&&a.appendChild(this.options.content),e.appendChild(i),e.appendChild(a),this.options.resizable){const c=document.createElement("div");c.className="bim-dialog-resize-handle",e.appendChild(c)}const o=c=>{c.stopPropagation()};return["click","dblclick","contextmenu","wheel","mousedown","mouseup","mousemove","touchstart","touchend","touchmove","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointerover","pointerout"].forEach(c=>{e.addEventListener(c,o,{passive:!1})}),e}setSize(e,t,i){t!==void 0&&(t==="auto"||t==="fit-content"?e.style.width=t:e.style.width=typeof t=="number"?`${t}px`:t),i!==void 0&&(i==="auto"||i==="fit-content"?e.style.height=i:e.style.height=typeof i=="number"?`${i}px`:i)}fitWidth(e=!1){this.element.style.width="fit-content",e&&this.initPosition()}fitHeight(e=!1){this.element.style.height="auto";const t=this.element.getBoundingClientRect().height,i=this.options.minHeight??100,n=this.container.clientHeight||0;let s=Math.max(i,t);n>0&&(s=Math.min(s,n)),this.element.style.height=`${s}px`,e?this.initPosition():this.clampToContainer()}clampToContainer(){const e=this.container.clientWidth,t=this.container.clientHeight,i=this.element.offsetWidth,n=this.element.offsetHeight,s=this.options.bottomOffset??70,a=this.element.offsetLeft,o=this.element.offsetTop,l=Math.max(0,e-i),c=Math.max(0,t-n-s),h=Math.max(0,Math.min(a,l)),d=Math.max(0,Math.min(o,c));this.element.style.left=`${h}px`,this.element.style.top=`${d}px`}initPosition(){const e=this.options.position,t=this.element.getBoundingClientRect(),i=this.options.bottomOffset??70;let n=0,s=0;const a=this.container.clientWidth,o=this.container.clientHeight,l=t.width,c=t.height;if(typeof e=="object"&&"x"in e)n=e.x,s=e.y;else switch(e){case"center":n=(a-l)/2,s=(o-c)/2;break;case"top-left":n=0,s=0;break;case"top-center":n=(a-l)/2,s=0;break;case"top-right":n=a-l,s=0;break;case"left-center":n=0,s=(o-c)/2;break;case"right-center":n=a-l,s=(o-c)/2;break;case"bottom-left":n=0,s=o-c-i;break;case"bottom-center":n=(a-l)/2,s=o-c-i;break;case"bottom-right":n=a-l,s=o-c-i;break;default:n=(a-l)/2,s=(o-c)/2}n=Math.max(0,Math.min(n,a-l)),s=Math.max(0,Math.min(s,o-c-i)),this.element.style.left=`${n}px`,this.element.style.top=`${s}px`}initDrag(){let e=0,t=0,i=0,n=0,s=0,a=0,o=0,l=0,c=0;const h=u=>{u.preventDefault(),u.stopPropagation(),e=u.clientX,t=u.clientY,i=this.element.offsetLeft,n=this.element.offsetTop,s=this.container.clientWidth,a=this.container.clientHeight,o=this.element.offsetWidth,l=this.element.offsetHeight,c=this.options.bottomOffset??70,document.addEventListener("mousemove",d,{capture:!0}),document.addEventListener("mouseup",p,{capture:!0})},d=u=>{u.preventDefault(),u.stopPropagation(),!this.rafId&&(this.rafId=requestAnimationFrame(()=>{const A=u.clientX-e,m=u.clientY-t;let g=i+A,f=n+m;const v=s-o,b=a-l-c;g=Math.max(0,Math.min(g,v)),f=Math.max(0,Math.min(f,b)),this.element.style.left=`${g}px`,this.element.style.top=`${f}px`,this.rafId=null}))},p=()=>{this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null),document.removeEventListener("mousemove",d,{capture:!0}),document.removeEventListener("mouseup",p,{capture:!0})};this.header.addEventListener("mousedown",h)}initResize(){const e=this.element.querySelector(".bim-dialog-resize-handle");if(!e)return;let t=0,i=0,n=0,s=0,a=0,o=0,l=0,c=0;const h=u=>{u.preventDefault(),u.stopPropagation(),t=u.clientX,i=u.clientY,n=this.element.offsetWidth,s=this.element.offsetHeight,a=this.container.clientWidth,o=this.container.clientHeight,l=this.element.offsetLeft,c=this.element.offsetTop,document.addEventListener("mousemove",d,{capture:!0}),document.addEventListener("mouseup",p,{capture:!0})},d=u=>{u.preventDefault(),u.stopPropagation(),!this.rafId&&(this.rafId=requestAnimationFrame(()=>{const A=u.clientX-t,m=u.clientY-i,g=a-l,f=o-c,v=Math.min(g,Math.max(this.options.minWidth||100,n+A)),b=Math.min(f,Math.max(this.options.minHeight||50,s+m));this.element.style.width=`${v}px`,this.element.style.height=`${b}px`,this.rafId=null}))},p=()=>{this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null),document.removeEventListener("mousemove",d,{capture:!0}),document.removeEventListener("mouseup",p,{capture:!0})};e.addEventListener("mousedown",h)}setContent(e){this.contentArea.innerHTML="",typeof e=="string"?this.contentArea.innerHTML=e:this.contentArea.appendChild(e)}close(){this._isDestroyed||(this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.element.remove(),this._isDestroyed=!0,this.options.onClose&&this.options.onClose())}destroy(){this.close()}}class Hn{registry;subscriptions=[];constructor(e){this.registry=e}get engineComponent(){return this.registry.engine3d?.getEngineComponent?.()??null}subscribe(e,t){const i=this.registry.on(e,t);this.subscriptions.push(i)}emit(e,t){this.registry.emit(e,t)}destroy(){this.subscriptions.forEach(e=>e()),this.subscriptions=[]}}class IA extends Hn{container;activeDialogs=[];constructor(e,t){super(t),this.container=e}create(e){const t=new TM({container:this.container,...e,onClose:()=>{this.activeDialogs=this.activeDialogs.filter(i=>i!==t),e.onClose&&e.onClose()}});return t.setTheme(ht.getTheme()),this.activeDialogs.push(t),t}updateTheme(e){this.activeDialogs.forEach(t=>{t.setTheme&&t.setTheme(e)})}destroy(){this.activeDialogs.forEach(e=>e.destroy()),this.activeDialogs=[],super.destroy()}}const Gh="183",Tn={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},In={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},PA=0,bf=1,RA=2,IM=3,PM=0,ql=1,DA=2,vo=3,Gn=0,qi=1,Vt=2,ti=0,na=1,Vh=2,yf=3,xf=4,Qh=5,RM=6,gn=100,BA=101,LA=102,kA=103,NA=104,mr=200,UA=201,FA=202,OA=203,Wh=204,jh=205,Xl=206,zA=207,Yl=208,HA=209,GA=210,VA=211,QA=212,WA=213,jA=214,qh=0,Xh=1,Yh=2,sa=3,Kh=4,Zh=5,Jh=6,$h=7,Kl=0,qA=1,XA=2,Xi=0,ed=1,td=2,id=3,ra=4,nd=5,sd=6,rd=7,_f="attached",YA="detached",ad=300,ys=301,gr=302,bo=303,Zl=304,yo=306,Ji=1e3,ln=1001,xo=1002,Ht=1003,Jl=1004,DM=1004,aa=1005,BM=1005,_t=1006,_o=1007,LM=1007,An=1008,kM=1008,ut=1009,Ef=1010,Mf=1011,Eo=1012,od=1013,Vn=1014,oi=1015,Zt=1016,ld=1017,cd=1018,Ar=1020,$l=35902,ec=35899,wf=1021,Mo=1022,hi=1023,xs=1026,_s=1027,Es=1028,tc=1029,Qn=1030,hd=1031,NM=1032,dd=1033,oa=33776,vr=33777,ic=33778,br=33779,nc=35840,ud=35841,la=35842,wo=35843,sc=36196,So=37492,Co=37496,rc=37488,ac=37489,oc=37490,lc=37491,yr=37808,pd=37809,fd=37810,md=37811,ca=37812,gd=37813,Ad=37814,vd=37815,bd=37816,yd=37817,xd=37818,_d=37819,Ed=37820,Md=37821,ha=36492,wd=36494,cc=36495,hc=36283,dc=36284,uc=36285,pc=36286,KA=2200,ZA=2201,JA=2202,To=2300,Io=2301,Sd=2302,Sf=2303,da=2400,ua=2401,fc=2402,Cd=2500,Cf=2501,$A=0,Tf=1,Td=2,ev=3200,UM=3201,FM=3202,OM=3203,xr=0,tv=1,ts="",Jt="srgb",Ri="srgb-linear",mc="linear",Ut="srgb",zM="",HM="rg",GM="ga",VM=0,pa=7680,QM=7681,WM=7682,jM=7683,qM=34055,XM=34056,YM=5386,KM=512,ZM=513,JM=514,$M=515,ew=516,tw=517,iw=518,If=519,iv=512,nv=513,sv=514,Id=515,rv=516,av=517,Pd=518,ov=519,gc=35044,nw=35048,sw=35040,rw=35045,aw=35049,ow=35041,lw=35046,cw=35050,hw=35042,dw="100",Pf="300 es",Pn=2e3,fa=2001,uw={COMPUTE:"compute",RENDER:"render"},pw={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},fw={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},mw={TEXTURE_COMPARE:"depthTextureCompare"};function gw(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}const Aw={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Po(r,e){return new Aw[r](e)}function lv(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Ac(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function cv(){const r=Ac("canvas");return r.style.display="block",r}const hv={};let _r=null;function vw(r){_r=r}function bw(){return _r}function vc(...r){const e="THREE."+r.shift();_r?_r("log",e,...r):console.log(e,...r)}function dv(r){const e=r[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=r[1];t&&t.isStackTrace?r[0]+=" "+t.getLocation():r[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return r}function Ye(...r){r=dv(r);const e="THREE."+r.shift();if(_r)_r("warn",e,...r);else{const t=r[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...r)}}function ct(...r){r=dv(r);const e="THREE."+r.shift();if(_r)_r("error",e,...r);else{const t=r[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...r)}}function bc(...r){const e=r.join(" ");e in hv||(hv[e]=!0,Ye(...r))}function yw(r,e,t){return new Promise(function(i,n){function s(){switch(r.clientWaitSync(e,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:n();break;case r.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:i()}}setTimeout(s,t)})}const xw={[qh]:Xh,[Yh]:Jh,[Kh]:$h,[sa]:Zh,[Xh]:qh,[Jh]:Yh,[$h]:Kh,[Zh]:sa};class is{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const n=i[e];if(n!==void 0){const s=n.indexOf(t);s!==-1&&n.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const n=i.slice(0);for(let s=0,a=n.length;s<a;s++)n[s].call(this,e);e.target=null}}}const $i=["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 uv=1234567;const ma=Math.PI/180,Ro=180/Math.PI;function Rn(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return($i[r&255]+$i[r>>8&255]+$i[r>>16&255]+$i[r>>24&255]+"-"+$i[e&255]+$i[e>>8&255]+"-"+$i[e>>16&15|64]+$i[e>>24&255]+"-"+$i[t&63|128]+$i[t>>8&255]+"-"+$i[t>>16&255]+$i[t>>24&255]+$i[i&255]+$i[i>>8&255]+$i[i>>16&255]+$i[i>>24&255]).toLowerCase()}function dt(r,e,t){return Math.max(e,Math.min(t,r))}function Rf(r,e){return(r%e+e)%e}function _w(r,e,t,i,n){return i+(r-e)*(n-i)/(t-e)}function Ew(r,e,t){return r!==e?(t-r)/(e-r):0}function yc(r,e,t){return(1-t)*r+t*e}function Mw(r,e,t,i){return yc(r,e,1-Math.exp(-t*i))}function ww(r,e=1){return e-Math.abs(Rf(r,e*2)-e)}function Sw(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function Cw(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function Tw(r,e){return r+Math.floor(Math.random()*(e-r+1))}function Iw(r,e){return r+Math.random()*(e-r)}function Pw(r){return r*(.5-Math.random())}function Rw(r){r!==void 0&&(uv=r);let e=uv+=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 Dw(r){return r*ma}function Bw(r){return r*Ro}function Lw(r){return(r&r-1)===0&&r!==0}function kw(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function Nw(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function Uw(r,e,t,i,n){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+i)/2),h=a((e+i)/2),d=s((e-i)/2),p=a((e-i)/2),u=s((i-e)/2),A=a((i-e)/2);switch(n){case"XYX":r.set(o*h,l*d,l*p,o*c);break;case"YZY":r.set(l*p,o*h,l*d,o*c);break;case"ZXZ":r.set(l*d,l*p,o*h,o*c);break;case"XZX":r.set(o*h,l*A,l*u,o*c);break;case"YXY":r.set(l*u,o*h,l*A,o*c);break;case"ZYZ":r.set(l*A,l*u,o*h,o*c);break;default:Ye("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function cn(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function gt(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const Dt={DEG2RAD:ma,RAD2DEG:Ro,generateUUID:Rn,clamp:dt,euclideanModulo:Rf,mapLinear:_w,inverseLerp:Ew,lerp:yc,damp:Mw,pingpong:ww,smoothstep:Sw,smootherstep:Cw,randInt:Tw,randFloat:Iw,randFloatSpread:Pw,seededRandom:Rw,degToRad:Dw,radToDeg:Bw,isPowerOfTwo:Lw,ceilPowerOfTwo:kw,floorPowerOfTwo:Nw,setQuaternionFromProperEuler:Uw,normalize:gt,denormalize:cn};class be{constructor(e=0,t=0){be.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,i=this.y,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6],this.y=n[1]*t+n[4]*i+n[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=dt(this.x,e.x,t.x),this.y=dt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=dt(this.x,e,t),this.y=dt(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(dt(i,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 i=this.dot(e)/t;return Math.acos(dt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,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 i=Math.cos(t),n=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*i-a*n+e.x,this.y=s*n+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Tt{constructor(e=0,t=0,i=0,n=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=n}static slerpFlat(e,t,i,n,s,a,o){let l=i[n+0],c=i[n+1],h=i[n+2],d=i[n+3],p=s[a+0],u=s[a+1],A=s[a+2],m=s[a+3];if(d!==m||l!==p||c!==u||h!==A){let g=l*p+c*u+h*A+d*m;g<0&&(p=-p,u=-u,A=-A,m=-m,g=-g);let f=1-o;if(g<.9995){const v=Math.acos(g),b=Math.sin(v);f=Math.sin(f*v)/b,o=Math.sin(o*v)/b,l=l*f+p*o,c=c*f+u*o,h=h*f+A*o,d=d*f+m*o}else{l=l*f+p*o,c=c*f+u*o,h=h*f+A*o,d=d*f+m*o;const v=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=v,c*=v,h*=v,d*=v}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,n,s,a){const o=i[n],l=i[n+1],c=i[n+2],h=i[n+3],d=s[a],p=s[a+1],u=s[a+2],A=s[a+3];return e[t]=o*A+h*d+l*u-c*p,e[t+1]=l*A+h*p+c*d-o*u,e[t+2]=c*A+h*u+o*p-l*d,e[t+3]=h*A-o*d-l*p-c*u,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,i,n){return this._x=e,this._y=t,this._z=i,this._w=n,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 i=e._x,n=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),h=o(n/2),d=o(s/2),p=l(i/2),u=l(n/2),A=l(s/2);switch(a){case"XYZ":this._x=p*h*d+c*u*A,this._y=c*u*d-p*h*A,this._z=c*h*A+p*u*d,this._w=c*h*d-p*u*A;break;case"YXZ":this._x=p*h*d+c*u*A,this._y=c*u*d-p*h*A,this._z=c*h*A-p*u*d,this._w=c*h*d+p*u*A;break;case"ZXY":this._x=p*h*d-c*u*A,this._y=c*u*d+p*h*A,this._z=c*h*A+p*u*d,this._w=c*h*d-p*u*A;break;case"ZYX":this._x=p*h*d-c*u*A,this._y=c*u*d+p*h*A,this._z=c*h*A-p*u*d,this._w=c*h*d+p*u*A;break;case"YZX":this._x=p*h*d+c*u*A,this._y=c*u*d+p*h*A,this._z=c*h*A-p*u*d,this._w=c*h*d-p*u*A;break;case"XZY":this._x=p*h*d-c*u*A,this._y=c*u*d-p*h*A,this._z=c*h*A+p*u*d,this._w=c*h*d+p*u*A;break;default:Ye("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,n=Math.sin(i);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],n=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],d=t[10],p=i+o+d;if(p>0){const u=.5/Math.sqrt(p+1);this._w=.25/u,this._x=(h-l)*u,this._y=(s-c)*u,this._z=(a-n)*u}else if(i>o&&i>d){const u=2*Math.sqrt(1+i-o-d);this._w=(h-l)/u,this._x=.25*u,this._y=(n+a)/u,this._z=(s+c)/u}else if(o>d){const u=2*Math.sqrt(1+o-i-d);this._w=(s-c)/u,this._x=(n+a)/u,this._y=.25*u,this._z=(l+h)/u}else{const u=2*Math.sqrt(1+d-i-o);this._w=(a-n)/u,this._x=(s+c)/u,this._y=(l+h)/u,this._z=.25*u}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(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=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(dt(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const n=Math.min(1,t/i);return this.slerp(e,n),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 i=e._x,n=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=i*h+a*o+n*c-s*l,this._y=n*h+a*l+s*o-i*c,this._z=s*h+a*c+i*l-n*o,this._w=a*h-i*o-n*l-s*c,this._onChangeCallback(),this}slerp(e,t){let i=e._x,n=e._y,s=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,n=-n,s=-s,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),h=Math.sin(c);l=Math.sin(l*c)/h,t=Math.sin(t*c)/h,this._x=this._x*l+i*t,this._y=this._y*l+n*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+n*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(n*Math.sin(e),n*Math.cos(e),s*Math.sin(t),s*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 T{constructor(e=0,t=0,i=0){T.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,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(pv.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(pv.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,n=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*n,this.y=s[1]*t+s[4]*i+s[7]*n,this.z=s[2]*t+s[5]*i+s[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,s=e.elements,a=1/(s[3]*t+s[7]*i+s[11]*n+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*n+s[12])*a,this.y=(s[1]*t+s[5]*i+s[9]*n+s[13])*a,this.z=(s[2]*t+s[6]*i+s[10]*n+s[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,n=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*n-o*i),h=2*(o*t-s*n),d=2*(s*i-a*t);return this.x=t+l*c+a*d-o*h,this.y=i+l*h+o*c-s*d,this.z=n+l*d+s*h-a*c,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,i=this.y,n=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*n,this.y=s[1]*t+s[5]*i+s[9]*n,this.z=s[2]*t+s[6]*i+s[10]*n,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=dt(this.x,e.x,t.x),this.y=dt(this.y,e.y,t.y),this.z=dt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=dt(this.x,e,t),this.y=dt(this.y,e,t),this.z=dt(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(dt(i,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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,n=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=n*l-s*o,this.y=s*a-i*l,this.z=i*o-n*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Df.copy(this).projectOnVector(e),this.sub(Df)}reflect(e){return this.sub(Df.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 i=this.dot(e)/t;return Math.acos(dt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return t*t+i*i+n*n}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,i){const n=Math.sin(t)*e;return this.x=n*Math.sin(i),this.y=Math.cos(t)*e,this.z=n*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,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(),i=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=n,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,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Df=new T,pv=new Tt;class ft{constructor(e,t,i,n,s,a,o,l,c){ft.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,n,s,a,o,l,c)}set(e,t,i,n,s,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=n,h[2]=o,h[3]=t,h[4]=s,h[5]=l,h[6]=i,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.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 i=e.elements,n=t.elements,s=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],h=i[4],d=i[7],p=i[2],u=i[5],A=i[8],m=n[0],g=n[3],f=n[6],v=n[1],b=n[4],y=n[7],M=n[2],_=n[5],S=n[8];return s[0]=a*m+o*v+l*M,s[3]=a*g+o*b+l*_,s[6]=a*f+o*y+l*S,s[1]=c*m+h*v+d*M,s[4]=c*g+h*b+d*_,s[7]=c*f+h*y+d*S,s[2]=p*m+u*v+A*M,s[5]=p*g+u*b+A*_,s[8]=p*f+u*y+A*S,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],i=e[1],n=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-i*s*h+i*o*l+n*s*c-n*a*l}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=h*a-o*c,p=o*l-h*s,u=c*s-a*l,A=t*d+i*p+n*u;if(A===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/A;return e[0]=d*m,e[1]=(n*c-h*i)*m,e[2]=(o*i-n*a)*m,e[3]=p*m,e[4]=(h*t-n*l)*m,e[5]=(n*s-o*t)*m,e[6]=u*m,e[7]=(i*l-c*t)*m,e[8]=(a*t-i*s)*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,i,n,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-n*c,n*l,-n*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Bf.makeScale(e,t)),this}rotate(e){return this.premultiply(Bf.makeRotation(-e)),this}translate(e,t){return this.premultiply(Bf.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),i=Math.sin(e);return this.set(t,-i,0,i,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,i=e.elements;for(let n=0;n<9;n++)if(t[n]!==i[n])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Bf=new ft,fv=new ft().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),mv=new ft().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Fw(){const r={enabled:!0,workingColorSpace:Ri,spaces:{},convert:function(n,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Ut&&(n.r=Us(n.r),n.g=Us(n.g),n.b=Us(n.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(n.applyMatrix3(this.spaces[s].toXYZ),n.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ut&&(n.r=Do(n.r),n.g=Do(n.g),n.b=Do(n.b))),n},workingToColorSpace:function(n,s){return this.convert(n,this.workingColorSpace,s)},colorSpaceToWorking:function(n,s){return this.convert(n,s,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===ts?mc:this.spaces[n].transfer},getToneMappingMode:function(n){return this.spaces[n].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(n,s=this.workingColorSpace){return n.fromArray(this.spaces[s].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,s,a){return n.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(n,s){return bc("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(n,s)},toWorkingColorSpace:function(n,s){return bc("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(n,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return r.define({[Ri]:{primaries:e,whitePoint:i,transfer:mc,toXYZ:fv,fromXYZ:mv,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Jt},outputColorSpaceConfig:{drawingBufferColorSpace:Jt}},[Jt]:{primaries:e,whitePoint:i,transfer:Ut,toXYZ:fv,fromXYZ:mv,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Jt}}}),r}const Et=Fw();function Us(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Do(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let Bo;class gv{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{Bo===void 0&&(Bo=Ac("canvas")),Bo.width=e.width,Bo.height=e.height;const n=Bo.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),i=Bo}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Ac("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const n=i.getImageData(0,0,e.width,e.height),s=n.data;for(let a=0;a<s.length;a++)s[a]=Us(s[a]/255)*255;return i.putImageData(n,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Us(t[i]/255)*255):t[i]=Us(t[i]);return{data:t,width:e.width,height:e.height}}else return Ye("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Ow=0;class Er{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Ow++}),this.uuid=Rn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&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 i={uuid:this.uuid,url:""},n=this.data;if(n!==null){let s;if(Array.isArray(n)){s=[];for(let a=0,o=n.length;a<o;a++)n[a].isDataTexture?s.push(Lf(n[a].image)):s.push(Lf(n[a]))}else s=Lf(n);i.url=s}return t||(e.images[this.uuid]=i),i}}function Lf(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?gv.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(Ye("Texture: Unable to serialize Texture."),{})}let zw=0;const kf=new T;class ii extends is{constructor(e=ii.DEFAULT_IMAGE,t=ii.DEFAULT_MAPPING,i=ln,n=ln,s=_t,a=An,o=hi,l=ut,c=ii.DEFAULT_ANISOTROPY,h=ts){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:zw++}),this.uuid=Rn(),this.name="",this.source=new Er(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new be(0,0),this.repeat=new be(1,1),this.center=new be(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ft,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,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(kf).x}get height(){return this.source.getSize(kf).y}get depth(){return this.source.getSize(kf).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 i=e[t];if(i===void 0){Ye(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){Ye(`Texture.setValues(): property '${t}' does not exist.`);continue}n&&i&&n.isVector2&&i.isVector2||n&&i&&n.isVector3&&i.isVector3||n&&i&&n.isMatrix3&&i.isMatrix3?n.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={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&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ad)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ji:e.x=e.x-Math.floor(e.x);break;case ln:e.x=e.x<0?0:1;break;case xo: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 Ji:e.y=e.y-Math.floor(e.y);break;case ln:e.y=e.y<0?0:1;break;case xo: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++}}ii.DEFAULT_IMAGE=null,ii.DEFAULT_MAPPING=ad,ii.DEFAULT_ANISOTROPY=1;class Gt{constructor(e=0,t=0,i=0,n=1){Gt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=n}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,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,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,i=this.y,n=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*n+a[12]*s,this.y=a[1]*t+a[5]*i+a[9]*n+a[13]*s,this.z=a[2]*t+a[6]*i+a[10]*n+a[14]*s,this.w=a[3]*t+a[7]*i+a[11]*n+a[15]*s,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,i,n,s;const l=e.elements,c=l[0],h=l[4],d=l[8],p=l[1],u=l[5],A=l[9],m=l[2],g=l[6],f=l[10];if(Math.abs(h-p)<.01&&Math.abs(d-m)<.01&&Math.abs(A-g)<.01){if(Math.abs(h+p)<.1&&Math.abs(d+m)<.1&&Math.abs(A+g)<.1&&Math.abs(c+u+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(c+1)/2,y=(u+1)/2,M=(f+1)/2,_=(h+p)/4,S=(d+m)/4,w=(A+g)/4;return b>y&&b>M?b<.01?(i=0,n=.707106781,s=.707106781):(i=Math.sqrt(b),n=_/i,s=S/i):y>M?y<.01?(i=.707106781,n=0,s=.707106781):(n=Math.sqrt(y),i=_/n,s=w/n):M<.01?(i=.707106781,n=.707106781,s=0):(s=Math.sqrt(M),i=S/s,n=w/s),this.set(i,n,s,t),this}let v=Math.sqrt((g-A)*(g-A)+(d-m)*(d-m)+(p-h)*(p-h));return Math.abs(v)<.001&&(v=1),this.x=(g-A)/v,this.y=(d-m)/v,this.z=(p-h)/v,this.w=Math.acos((c+u+f-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=dt(this.x,e.x,t.x),this.y=dt(this.y,e.y,t.y),this.z=dt(this.z,e.z,t.z),this.w=dt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=dt(this.x,e,t),this.y=dt(this.y,e,t),this.z=dt(this.z,e,t),this.w=dt(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(dt(i,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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,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 Nf extends is{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:_t,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new Gt(0,0,e,t),this.scissorTest=!1,this.viewport=new Gt(0,0,e,t),this.textures=[];const n={width:e,height:t,depth:i.depth},s=new ii(n),a=i.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(e={}){const t={minFilter:_t,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 i=0;i<this.textures.length;i++)this.textures[i].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,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let n=0,s=this.textures.length;n<s;n++)this.textures[n].image.width=e,this.textures[n].image.height=t,this.textures[n].image.depth=i,this.textures[n].isData3DTexture!==!0&&(this.textures[n].isArrayTexture=this.textures[n].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,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const n=Object.assign({},e.textures[t].image);this.textures[t].source=new Er(n)}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 Ei extends Nf{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class Rd extends ii{constructor(e=null,t=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:n},this.magFilter=Ht,this.minFilter=Ht,this.wrapR=ln,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Hw extends Ei{constructor(e=1,t=1,i=1,n={}){super(e,t,n),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new Rd(null,e,t,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}}class xc extends ii{constructor(e=null,t=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:n},this.magFilter=Ht,this.minFilter=Ht,this.wrapR=ln,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Gw extends Ei{constructor(e=1,t=1,i=1,n={}){super(e,t,n),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new xc(null,e,t,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}}class Ke{constructor(e,t,i,n,s,a,o,l,c,h,d,p,u,A,m,g){Ke.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,i,n,s,a,o,l,c,h,d,p,u,A,m,g)}set(e,t,i,n,s,a,o,l,c,h,d,p,u,A,m,g){const f=this.elements;return f[0]=e,f[4]=t,f[8]=i,f[12]=n,f[1]=s,f[5]=a,f[9]=o,f[13]=l,f[2]=c,f[6]=h,f[10]=d,f[14]=p,f[3]=u,f[7]=A,f[11]=m,f[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ke().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[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,i){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const t=this.elements,i=e.elements,n=1/Lo.setFromMatrixColumn(e,0).length(),s=1/Lo.setFromMatrixColumn(e,1).length(),a=1/Lo.setFromMatrixColumn(e,2).length();return t[0]=i[0]*n,t[1]=i[1]*n,t[2]=i[2]*n,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,n=e.y,s=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(n),c=Math.sin(n),h=Math.cos(s),d=Math.sin(s);if(e.order==="XYZ"){const p=a*h,u=a*d,A=o*h,m=o*d;t[0]=l*h,t[4]=-l*d,t[8]=c,t[1]=u+A*c,t[5]=p-m*c,t[9]=-o*l,t[2]=m-p*c,t[6]=A+u*c,t[10]=a*l}else if(e.order==="YXZ"){const p=l*h,u=l*d,A=c*h,m=c*d;t[0]=p+m*o,t[4]=A*o-u,t[8]=a*c,t[1]=a*d,t[5]=a*h,t[9]=-o,t[2]=u*o-A,t[6]=m+p*o,t[10]=a*l}else if(e.order==="ZXY"){const p=l*h,u=l*d,A=c*h,m=c*d;t[0]=p-m*o,t[4]=-a*d,t[8]=A+u*o,t[1]=u+A*o,t[5]=a*h,t[9]=m-p*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const p=a*h,u=a*d,A=o*h,m=o*d;t[0]=l*h,t[4]=A*c-u,t[8]=p*c+m,t[1]=l*d,t[5]=m*c+p,t[9]=u*c-A,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const p=a*l,u=a*c,A=o*l,m=o*c;t[0]=l*h,t[4]=m-p*d,t[8]=A*d+u,t[1]=d,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=u*d+A,t[10]=p-m*d}else if(e.order==="XZY"){const p=a*l,u=a*c,A=o*l,m=o*c;t[0]=l*h,t[4]=-d,t[8]=c*h,t[1]=p*d+m,t[5]=a*h,t[9]=u*d-A,t[2]=A*d-u,t[6]=o*h,t[10]=m*d+p}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(Vw,e,Qw)}lookAt(e,t,i){const n=this.elements;return Dn.subVectors(e,t),Dn.lengthSq()===0&&(Dn.z=1),Dn.normalize(),Mr.crossVectors(i,Dn),Mr.lengthSq()===0&&(Math.abs(i.z)===1?Dn.x+=1e-4:Dn.z+=1e-4,Dn.normalize(),Mr.crossVectors(i,Dn)),Mr.normalize(),Dd.crossVectors(Dn,Mr),n[0]=Mr.x,n[4]=Dd.x,n[8]=Dn.x,n[1]=Mr.y,n[5]=Dd.y,n[9]=Dn.y,n[2]=Mr.z,n[6]=Dd.z,n[10]=Dn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,s=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],h=i[1],d=i[5],p=i[9],u=i[13],A=i[2],m=i[6],g=i[10],f=i[14],v=i[3],b=i[7],y=i[11],M=i[15],_=n[0],S=n[4],w=n[8],E=n[12],I=n[1],B=n[5],R=n[9],U=n[13],C=n[2],F=n[6],O=n[10],H=n[14],j=n[3],G=n[7],re=n[11],q=n[15];return s[0]=a*_+o*I+l*C+c*j,s[4]=a*S+o*B+l*F+c*G,s[8]=a*w+o*R+l*O+c*re,s[12]=a*E+o*U+l*H+c*q,s[1]=h*_+d*I+p*C+u*j,s[5]=h*S+d*B+p*F+u*G,s[9]=h*w+d*R+p*O+u*re,s[13]=h*E+d*U+p*H+u*q,s[2]=A*_+m*I+g*C+f*j,s[6]=A*S+m*B+g*F+f*G,s[10]=A*w+m*R+g*O+f*re,s[14]=A*E+m*U+g*H+f*q,s[3]=v*_+b*I+y*C+M*j,s[7]=v*S+b*B+y*F+M*G,s[11]=v*w+b*R+y*O+M*re,s[15]=v*E+b*U+y*H+M*q,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],i=e[4],n=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],d=e[6],p=e[10],u=e[14],A=e[3],m=e[7],g=e[11],f=e[15],v=l*u-c*p,b=o*u-c*d,y=o*p-l*d,M=a*u-c*h,_=a*p-l*h,S=a*d-o*h;return t*(m*v-g*b+f*y)-i*(A*v-g*M+f*_)+n*(A*b-m*M+f*S)-s*(A*y-m*_+g*S)}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,i){const n=this.elements;return e.isVector3?(n[12]=e.x,n[13]=e.y,n[14]=e.z):(n[12]=e,n[13]=t,n[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=e[9],p=e[10],u=e[11],A=e[12],m=e[13],g=e[14],f=e[15],v=t*o-i*a,b=t*l-n*a,y=t*c-s*a,M=i*l-n*o,_=i*c-s*o,S=n*c-s*l,w=h*m-d*A,E=h*g-p*A,I=h*f-u*A,B=d*g-p*m,R=d*f-u*m,U=p*f-u*g,C=v*U-b*R+y*B+M*I-_*E+S*w;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const F=1/C;return e[0]=(o*U-l*R+c*B)*F,e[1]=(n*R-i*U-s*B)*F,e[2]=(m*S-g*_+f*M)*F,e[3]=(p*_-d*S-u*M)*F,e[4]=(l*I-a*U-c*E)*F,e[5]=(t*U-n*I+s*E)*F,e[6]=(g*y-A*S-f*b)*F,e[7]=(h*S-p*y+u*b)*F,e[8]=(a*R-o*I+c*w)*F,e[9]=(i*I-t*R-s*w)*F,e[10]=(A*_-m*y+f*v)*F,e[11]=(d*y-h*_-u*v)*F,e[12]=(o*E-a*B-l*w)*F,e[13]=(t*B-i*E+n*w)*F,e[14]=(m*b-A*M-g*v)*F,e[15]=(h*M-d*b+p*v)*F,this}scale(e){const t=this.elements,i=e.x,n=e.y,s=e.z;return t[0]*=i,t[4]*=n,t[8]*=s,t[1]*=i,t[5]*=n,t[9]*=s,t[2]*=i,t[6]*=n,t[10]*=s,t[3]*=i,t[7]*=n,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,n))}makeTranslation(e,t,i){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,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),n=Math.sin(t),s=1-i,a=e.x,o=e.y,l=e.z,c=s*a,h=s*o;return this.set(c*a+i,c*o-n*l,c*l+n*o,0,c*o+n*l,h*o+i,h*l-n*a,0,c*l-n*o,h*l+n*a,s*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,n,s,a){return this.set(1,i,s,0,e,1,a,0,t,n,1,0,0,0,0,1),this}compose(e,t,i){const n=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,h=a+a,d=o+o,p=s*c,u=s*h,A=s*d,m=a*h,g=a*d,f=o*d,v=l*c,b=l*h,y=l*d,M=i.x,_=i.y,S=i.z;return n[0]=(1-(m+f))*M,n[1]=(u+y)*M,n[2]=(A-b)*M,n[3]=0,n[4]=(u-y)*_,n[5]=(1-(p+f))*_,n[6]=(g+v)*_,n[7]=0,n[8]=(A+b)*S,n[9]=(g-v)*S,n[10]=(1-(p+m))*S,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,this}decompose(e,t,i){const n=this.elements;e.x=n[12],e.y=n[13],e.z=n[14];const s=this.determinant();if(s===0)return i.set(1,1,1),t.identity(),this;let a=Lo.set(n[0],n[1],n[2]).length();const o=Lo.set(n[4],n[5],n[6]).length(),l=Lo.set(n[8],n[9],n[10]).length();s<0&&(a=-a),ns.copy(this);const c=1/a,h=1/o,d=1/l;return ns.elements[0]*=c,ns.elements[1]*=c,ns.elements[2]*=c,ns.elements[4]*=h,ns.elements[5]*=h,ns.elements[6]*=h,ns.elements[8]*=d,ns.elements[9]*=d,ns.elements[10]*=d,t.setFromRotationMatrix(ns),i.x=a,i.y=o,i.z=l,this}makePerspective(e,t,i,n,s,a,o=Pn,l=!1){const c=this.elements,h=2*s/(t-e),d=2*s/(i-n),p=(t+e)/(t-e),u=(i+n)/(i-n);let A,m;if(l)A=s/(a-s),m=a*s/(a-s);else if(o===Pn)A=-(a+s)/(a-s),m=-2*a*s/(a-s);else if(o===fa)A=-a/(a-s),m=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=p,c[12]=0,c[1]=0,c[5]=d,c[9]=u,c[13]=0,c[2]=0,c[6]=0,c[10]=A,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,n,s,a,o=Pn,l=!1){const c=this.elements,h=2/(t-e),d=2/(i-n),p=-(t+e)/(t-e),u=-(i+n)/(i-n);let A,m;if(l)A=1/(a-s),m=a/(a-s);else if(o===Pn)A=-2/(a-s),m=-(a+s)/(a-s);else if(o===fa)A=-1/(a-s),m=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=p,c[1]=0,c[5]=d,c[9]=0,c[13]=u,c[2]=0,c[6]=0,c[10]=A,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let n=0;n<16;n++)if(t[n]!==i[n])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const Lo=new T,ns=new Ke,Vw=new T(0,0,0),Qw=new T(1,1,1),Mr=new T,Dd=new T,Dn=new T,Av=new Ke,vv=new Tt;class Di{constructor(e=0,t=0,i=0,n=Di.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=n}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,i,n=this._order){return this._x=e,this._y=t,this._z=i,this._order=n,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,i=!0){const n=e.elements,s=n[0],a=n[4],o=n[8],l=n[1],c=n[5],h=n[9],d=n[2],p=n[6],u=n[10];switch(t){case"XYZ":this._y=Math.asin(dt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,u),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(p,c),this._z=0);break;case"YXZ":this._x=Math.asin(-dt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,u),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(dt(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-d,u),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-dt(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(p,u),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(dt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(o,u));break;case"XZY":this._z=Math.asin(-dt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(p,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,u),this._y=0);break;default:Ye("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Av.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Av,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return vv.setFromEuler(this),this.setFromQuaternion(vv,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}}Di.DEFAULT_ORDER="XYZ";class Bd{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 Ww=0;const bv=new T,ko=new Tt,Fs=new Ke,Ld=new T,_c=new T,jw=new T,qw=new Tt,yv=new T(1,0,0),xv=new T(0,1,0),_v=new T(0,0,1),Ev={type:"added"},Xw={type:"removed"},No={type:"childadded",child:null},Uf={type:"childremoved",child:null};class Mt extends is{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Ww++}),this.uuid=Rn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Mt.DEFAULT_UP.clone();const e=new T,t=new Di,i=new Tt,n=new T(1,1,1);function s(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._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:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Ke},normalMatrix:{value:new ft}}),this.matrix=new Ke,this.matrixWorld=new Ke,this.matrixAutoUpdate=Mt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Mt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Bd,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.static=!1,this.userData={},this.pivot=null}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 ko.setFromAxisAngle(e,t),this.quaternion.multiply(ko),this}rotateOnWorldAxis(e,t){return ko.setFromAxisAngle(e,t),this.quaternion.premultiply(ko),this}rotateX(e){return this.rotateOnAxis(yv,e)}rotateY(e){return this.rotateOnAxis(xv,e)}rotateZ(e){return this.rotateOnAxis(_v,e)}translateOnAxis(e,t){return bv.copy(e).applyQuaternion(this.quaternion),this.position.add(bv.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(yv,e)}translateY(e){return this.translateOnAxis(xv,e)}translateZ(e){return this.translateOnAxis(_v,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Fs.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Ld.copy(e):Ld.set(e,t,i);const n=this.parent;this.updateWorldMatrix(!0,!1),_c.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Fs.lookAt(_c,Ld,this.up):Fs.lookAt(Ld,_c,this.up),this.quaternion.setFromRotationMatrix(Fs),n&&(Fs.extractRotation(n.matrixWorld),ko.setFromRotationMatrix(Fs),this.quaternion.premultiply(ko.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(ct("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(Ev),No.child=e,this.dispatchEvent(No),No.child=null):ct("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Xw),Uf.child=e,this.dispatchEvent(Uf),Uf.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),Fs.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Fs.multiply(e.parent.matrixWorld)),e.applyMatrix4(Fs),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Ev),No.child=e,this.dispatchEvent(No),No.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 i=0,n=this.children.length;i<n;i++){const a=this.children[i].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const n=this.children;for(let s=0,a=n.length;s<a;s++)n[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_c,e,jw),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_c,qw,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 i=0,n=t.length;i<n;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].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);const e=this.pivot;if(e!==null){const t=e.x,i=e.y,n=e.z,s=this.matrix.elements;s[12]+=t-s[0]*t-s[4]*i-s[8]*n,s[13]+=i-s[1]*t-s[5]*i-s[9]*n,s[14]+=n-s[2]*t-s[6]*i-s[10]*n}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 i=0,n=t.length;i<n;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.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 n=this.children;for(let s=0,a=n.length;s<a;s++)n[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),this.static!==!1&&(n.static=this.static),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),this.pivot!==null&&(n.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(n.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(n.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),n.instanceInfo=this._instanceInfo.map(o=>({...o})),n.availableInstanceIds=this._availableInstanceIds.slice(),n.availableGeometryIds=this._availableGeometryIds.slice(),n.nextIndexStart=this._nextIndexStart,n.nextVertexStart=this._nextVertexStart,n.geometryCount=this._geometryCount,n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.matricesTexture=this._matricesTexture.toJSON(e),n.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(n.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(n.boundingBox=this.boundingBox.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const d=l[c];s(e.shapes,d)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));n.material=o}else n.material=s(e.materials,this.material);if(this.children.length>0){n.children=[];for(let o=0;o<this.children.length;o++)n.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){n.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];n.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),d=a(e.shapes),p=a(e.skeletons),u=a(e.animations),A=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),h.length>0&&(i.images=h),d.length>0&&(i.shapes=d),p.length>0&&(i.skeletons=p),u.length>0&&(i.animations=u),A.length>0&&(i.nodes=A)}return i.object=n,i;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}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),e.pivot!==null&&(this.pivot=e.pivot.clone()),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.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const n=e.children[i];this.add(n.clone())}return this}}Mt.DEFAULT_UP=new T(0,1,0),Mt.DEFAULT_MATRIX_AUTO_UPDATE=!0,Mt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Mi extends Mt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Yw={type:"move"};class kd{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Mi,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 Mi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new T,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new T),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Mi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new T,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new T),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 i of e.hand.values())this._getHandJoint(t,i)}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,i){let n=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const m of e.hand.values()){const g=t.getJointPose(m,i),f=this._getHandJoint(c,m);g!==null&&(f.matrix.fromArray(g.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=g.radius),f.visible=g!==null}const h=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],p=h.position.distanceTo(d.position),u=.02,A=.005;c.inputState.pinching&&p>u+A?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&p<=u-A&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(n=t.getPose(e.targetRaySpace,i),n===null&&s!==null&&(n=s),n!==null&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,n.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(n.linearVelocity)):o.hasLinearVelocity=!1,n.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(n.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Yw)))}return o!==null&&(o.visible=n!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Mi;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const Mv={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},wr={h:0,s:0,l:0},Nd={h:0,s:0,l:0};function Ff(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}class We{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const n=e;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Jt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Et.colorSpaceToWorking(this,t),this}setRGB(e,t,i,n=Et.workingColorSpace){return this.r=e,this.g=t,this.b=i,Et.colorSpaceToWorking(this,n),this}setHSL(e,t,i,n=Et.workingColorSpace){if(e=Rf(e,1),t=dt(t,0,1),i=dt(i,0,1),t===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+t):i+t-i*t,a=2*i-s;this.r=Ff(a,s,e+1/3),this.g=Ff(a,s,e),this.b=Ff(a,s,e-1/3)}return Et.colorSpaceToWorking(this,n),this}setStyle(e,t=Jt){function i(s){s!==void 0&&parseFloat(s)<1&&Ye("Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=n[1],o=n[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:Ye("Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=n[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);Ye("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Jt){const i=Mv[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Ye("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=Us(e.r),this.g=Us(e.g),this.b=Us(e.b),this}copyLinearToSRGB(e){return this.r=Do(e.r),this.g=Do(e.g),this.b=Do(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Jt){return Et.workingToColorSpace(en.copy(this),e),Math.round(dt(en.r*255,0,255))*65536+Math.round(dt(en.g*255,0,255))*256+Math.round(dt(en.b*255,0,255))}getHexString(e=Jt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Et.workingColorSpace){Et.workingToColorSpace(en.copy(this),t);const i=en.r,n=en.g,s=en.b,a=Math.max(i,n,s),o=Math.min(i,n,s);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=h<=.5?d/(a+o):d/(2-a-o),a){case i:l=(n-s)/d+(n<s?6:0);break;case n:l=(s-i)/d+2;break;case s:l=(i-n)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Et.workingColorSpace){return Et.workingToColorSpace(en.copy(this),t),e.r=en.r,e.g=en.g,e.b=en.b,e}getStyle(e=Jt){Et.workingToColorSpace(en.copy(this),e);const t=en.r,i=en.g,n=en.b;return e!==Jt?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(n*255)})`}offsetHSL(e,t,i){return this.getHSL(wr),this.setHSL(wr.h+e,wr.s+t,wr.l+i)}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,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(wr),e.getHSL(Nd);const i=yc(wr.h,Nd.h,t),n=yc(wr.s,Nd.s,t),s=yc(wr.l,Nd.l,t);return this.setHSL(i,n,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,n=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*n,this.g=s[1]*t+s[4]*i+s[7]*n,this.b=s[2]*t+s[5]*i+s[8]*n,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 en=new We;We.NAMES=Mv;class Ud{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new We(e),this.density=t}clone(){return new Ud(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Fd{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new We(e),this.near=t,this.far=i}clone(){return new Fd(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class ga extends Mt{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 Di,this.environmentIntensity=1,this.environmentRotation=new Di,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__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}}const ss=new T,Os=new T,Of=new T,zs=new T,Uo=new T,Fo=new T,wv=new T,zf=new T,Hf=new T,Gf=new T,Vf=new Gt,Qf=new Gt,Wf=new Gt;class vn{constructor(e=new T,t=new T,i=new T){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,n){n.subVectors(i,t),ss.subVectors(e,t),n.cross(ss);const s=n.lengthSq();return s>0?n.multiplyScalar(1/Math.sqrt(s)):n.set(0,0,0)}static getBarycoord(e,t,i,n,s){ss.subVectors(n,t),Os.subVectors(i,t),Of.subVectors(e,t);const a=ss.dot(ss),o=ss.dot(Os),l=ss.dot(Of),c=Os.dot(Os),h=Os.dot(Of),d=a*c-o*o;if(d===0)return s.set(0,0,0),null;const p=1/d,u=(c*l-o*h)*p,A=(a*h-o*l)*p;return s.set(1-u-A,A,u)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,zs)===null?!1:zs.x>=0&&zs.y>=0&&zs.x+zs.y<=1}static getInterpolation(e,t,i,n,s,a,o,l){return this.getBarycoord(e,t,i,n,zs)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,zs.x),l.addScaledVector(a,zs.y),l.addScaledVector(o,zs.z),l)}static getInterpolatedAttribute(e,t,i,n,s,a){return Vf.setScalar(0),Qf.setScalar(0),Wf.setScalar(0),Vf.fromBufferAttribute(e,t),Qf.fromBufferAttribute(e,i),Wf.fromBufferAttribute(e,n),a.setScalar(0),a.addScaledVector(Vf,s.x),a.addScaledVector(Qf,s.y),a.addScaledVector(Wf,s.z),a}static isFrontFacing(e,t,i,n){return ss.subVectors(i,t),Os.subVectors(e,t),ss.cross(Os).dot(n)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,n){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[n]),this}setFromAttributeAndIndices(e,t,i,n){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,n),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 ss.subVectors(this.c,this.b),Os.subVectors(this.a,this.b),ss.cross(Os).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return vn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return vn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,n,s){return vn.getInterpolation(e,this.a,this.b,this.c,t,i,n,s)}containsPoint(e){return vn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return vn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,n=this.b,s=this.c;let a,o;Uo.subVectors(n,i),Fo.subVectors(s,i),zf.subVectors(e,i);const l=Uo.dot(zf),c=Fo.dot(zf);if(l<=0&&c<=0)return t.copy(i);Hf.subVectors(e,n);const h=Uo.dot(Hf),d=Fo.dot(Hf);if(h>=0&&d<=h)return t.copy(n);const p=l*d-h*c;if(p<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(i).addScaledVector(Uo,a);Gf.subVectors(e,s);const u=Uo.dot(Gf),A=Fo.dot(Gf);if(A>=0&&u<=A)return t.copy(s);const m=u*c-l*A;if(m<=0&&c>=0&&A<=0)return o=c/(c-A),t.copy(i).addScaledVector(Fo,o);const g=h*A-u*d;if(g<=0&&d-h>=0&&u-A>=0)return wv.subVectors(s,n),o=(d-h)/(d-h+(u-A)),t.copy(n).addScaledVector(wv,o);const f=1/(g+m+p);return a=m*f,o=p*f,t.copy(i).addScaledVector(Uo,a).addScaledVector(Fo,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Ft{constructor(e=new T(1/0,1/0,1/0),t=new T(-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,i=e.length;t<i;t+=3)this.expandByPoint(rs.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(rs.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=rs.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),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 i=e.geometry;if(i!==void 0){const s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,rs):rs.fromBufferAttribute(s,a),rs.applyMatrix4(e.matrixWorld),this.expandByPoint(rs);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Od.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Od.copy(i.boundingBox)),Od.applyMatrix4(e.matrixWorld),this.union(Od)}const n=e.children;for(let s=0,a=n.length;s<a;s++)this.expandByObject(n[s],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,rs),rs.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ec),zd.subVectors(this.max,Ec),Oo.subVectors(e.a,Ec),zo.subVectors(e.b,Ec),Ho.subVectors(e.c,Ec),Sr.subVectors(zo,Oo),Cr.subVectors(Ho,zo),Aa.subVectors(Oo,Ho);let t=[0,-Sr.z,Sr.y,0,-Cr.z,Cr.y,0,-Aa.z,Aa.y,Sr.z,0,-Sr.x,Cr.z,0,-Cr.x,Aa.z,0,-Aa.x,-Sr.y,Sr.x,0,-Cr.y,Cr.x,0,-Aa.y,Aa.x,0];return!jf(t,Oo,zo,Ho,zd)||(t=[1,0,0,0,1,0,0,0,1],!jf(t,Oo,zo,Ho,zd))?!1:(Hd.crossVectors(Sr,Cr),t=[Hd.x,Hd.y,Hd.z],jf(t,Oo,zo,Ho,zd))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,rs).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(rs).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:(Hs[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Hs[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Hs[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Hs[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Hs[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Hs[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Hs[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Hs[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Hs),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 Hs=[new T,new T,new T,new T,new T,new T,new T,new T],rs=new T,Od=new Ft,Oo=new T,zo=new T,Ho=new T,Sr=new T,Cr=new T,Aa=new T,Ec=new T,zd=new T,Hd=new T,va=new T;function jf(r,e,t,i,n){for(let s=0,a=r.length-3;s<=a;s+=3){va.fromArray(r,s);const o=n.x*Math.abs(va.x)+n.y*Math.abs(va.y)+n.z*Math.abs(va.z),l=e.dot(va),c=t.dot(va),h=i.dot(va);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const Gs=Kw();function Kw(){const r=new ArrayBuffer(4),e=new Float32Array(r),t=new Uint32Array(r),i=new Uint32Array(512),n=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(i[l]=0,i[l|256]=32768,n[l]=24,n[l|256]=24):c<-14?(i[l]=1024>>-c-14,i[l|256]=1024>>-c-14|32768,n[l]=-c-1,n[l|256]=-c-1):c<=15?(i[l]=c+15<<10,i[l|256]=c+15<<10|32768,n[l]=13,n[l|256]=13):c<128?(i[l]=31744,i[l|256]=64512,n[l]=24,n[l|256]=24):(i[l]=31744,i[l|256]=64512,n[l]=13,n[l|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;(c&8388608)===0;)c<<=1,h-=8388608;c&=-8388609,h+=947912704,s[l]=c|h}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:n,mantissaTable:s,exponentTable:a,offsetTable:o}}function bn(r){Math.abs(r)>65504&&Ye("DataUtils.toHalfFloat(): Value out of range."),r=dt(r,-65504,65504),Gs.floatView[0]=r;const e=Gs.uint32View[0],t=e>>23&511;return Gs.baseTable[t]+((e&8388607)>>Gs.shiftTable[t])}function Mc(r){const e=r>>10;return Gs.uint32View[0]=Gs.mantissaTable[Gs.offsetTable[e]+(r&1023)]+Gs.exponentTable[e],Gs.floatView[0]}class wc{static toHalfFloat(e){return bn(e)}static fromHalfFloat(e){return Mc(e)}}const wi=new T,Gd=new be;let Zw=0;class St{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Zw++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=gc,this.updateRanges=[],this.gpuType=oi,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,i){e*=this.itemSize,i*=t.itemSize;for(let n=0,s=this.itemSize;n<s;n++)this.array[e+n]=t.array[i+n];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)Gd.fromBufferAttribute(this,t),Gd.applyMatrix3(e),this.setXY(t,Gd.x,Gd.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)wi.fromBufferAttribute(this,t),wi.applyMatrix3(e),this.setXYZ(t,wi.x,wi.y,wi.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)wi.fromBufferAttribute(this,t),wi.applyMatrix4(e),this.setXYZ(t,wi.x,wi.y,wi.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)wi.fromBufferAttribute(this,t),wi.applyNormalMatrix(e),this.setXYZ(t,wi.x,wi.y,wi.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)wi.fromBufferAttribute(this,t),wi.transformDirection(e),this.setXYZ(t,wi.x,wi.y,wi.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=cn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=gt(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=cn(t,this.array)),t}setX(e,t){return this.normalized&&(t=gt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=cn(t,this.array)),t}setY(e,t){return this.normalized&&(t=gt(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=cn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=gt(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=cn(t,this.array)),t}setW(e,t){return this.normalized&&(t=gt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=gt(t,this.array),i=gt(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,n){return e*=this.itemSize,this.normalized&&(t=gt(t,this.array),i=gt(i,this.array),n=gt(n,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this}setXYZW(e,t,i,n,s){return e*=this.itemSize,this.normalized&&(t=gt(t,this.array),i=gt(i,this.array),n=gt(n,this.array),s=gt(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this.array[e+3]=s,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!==gc&&(e.usage=this.usage),e}}class Jw extends St{constructor(e,t,i){super(new Int8Array(e),t,i)}}class $w extends St{constructor(e,t,i){super(new Uint8Array(e),t,i)}}class eS extends St{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}}class tS extends St{constructor(e,t,i){super(new Int16Array(e),t,i)}}class qf extends St{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class iS extends St{constructor(e,t,i){super(new Int32Array(e),t,i)}}class Xf extends St{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class nS extends St{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=Mc(this.array[e*this.itemSize]);return this.normalized&&(t=cn(t,this.array)),t}setX(e,t){return this.normalized&&(t=gt(t,this.array)),this.array[e*this.itemSize]=bn(t),this}getY(e){let t=Mc(this.array[e*this.itemSize+1]);return this.normalized&&(t=cn(t,this.array)),t}setY(e,t){return this.normalized&&(t=gt(t,this.array)),this.array[e*this.itemSize+1]=bn(t),this}getZ(e){let t=Mc(this.array[e*this.itemSize+2]);return this.normalized&&(t=cn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=gt(t,this.array)),this.array[e*this.itemSize+2]=bn(t),this}getW(e){let t=Mc(this.array[e*this.itemSize+3]);return this.normalized&&(t=cn(t,this.array)),t}setW(e,t){return this.normalized&&(t=gt(t,this.array)),this.array[e*this.itemSize+3]=bn(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=gt(t,this.array),i=gt(i,this.array)),this.array[e+0]=bn(t),this.array[e+1]=bn(i),this}setXYZ(e,t,i,n){return e*=this.itemSize,this.normalized&&(t=gt(t,this.array),i=gt(i,this.array),n=gt(n,this.array)),this.array[e+0]=bn(t),this.array[e+1]=bn(i),this.array[e+2]=bn(n),this}setXYZW(e,t,i,n,s){return e*=this.itemSize,this.normalized&&(t=gt(t,this.array),i=gt(i,this.array),n=gt(n,this.array),s=gt(s,this.array)),this.array[e+0]=bn(t),this.array[e+1]=bn(i),this.array[e+2]=bn(n),this.array[e+3]=bn(s),this}}class tt extends St{constructor(e,t,i){super(new Float32Array(e),t,i)}}const sS=new Ft,Sc=new T,Yf=new T;class Gi{constructor(e=new T,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 i=this.center;t!==void 0?i.copy(t):sS.setFromPoints(e).getCenter(i);let n=0;for(let s=0,a=e.length;s<a;s++)n=Math.max(n,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(n),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 i=this.center.distanceToSquared(e);return t.copy(e),i>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;Sc.subVectors(e,this.center);const t=Sc.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),n=(i-this.radius)*.5;this.center.addScaledVector(Sc,n/i),this.radius+=n}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):(Yf.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Sc.copy(e.center).add(Yf)),this.expandByPoint(Sc.copy(e.center).sub(Yf))),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}}let rS=0;const Wn=new Ke,Kf=new Mt,Go=new T,Bn=new Ft,Cc=new Ft,Vi=new T;class ot extends is{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:rS++}),this.uuid=Rn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(gw(e)?Xf:qf)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}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 i=this.attributes.normal;if(i!==void 0){const s=new ft().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Wn.makeRotationFromQuaternion(e),this.applyMatrix4(Wn),this}rotateX(e){return Wn.makeRotationX(e),this.applyMatrix4(Wn),this}rotateY(e){return Wn.makeRotationY(e),this.applyMatrix4(Wn),this}rotateZ(e){return Wn.makeRotationZ(e),this.applyMatrix4(Wn),this}translate(e,t,i){return Wn.makeTranslation(e,t,i),this.applyMatrix4(Wn),this}scale(e,t,i){return Wn.makeScale(e,t,i),this.applyMatrix4(Wn),this}lookAt(e){return Kf.lookAt(e),Kf.updateMatrix(),this.applyMatrix4(Kf.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Go).negate(),this.translate(Go.x,Go.y,Go.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let n=0,s=e.length;n<s;n++){const a=e[n];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new tt(i,3))}else{const i=Math.min(e.length,t.count);for(let n=0;n<i;n++){const s=e[n];t.setXYZ(n,s.x,s.y,s.z||0)}e.length>t.count&&Ye("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 Ft);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ct("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new T(-1/0,-1/0,-1/0),new T(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,n=t.length;i<n;i++){const s=t[i];Bn.setFromBufferAttribute(s),this.morphTargetsRelative?(Vi.addVectors(this.boundingBox.min,Bn.min),this.boundingBox.expandByPoint(Vi),Vi.addVectors(this.boundingBox.max,Bn.max),this.boundingBox.expandByPoint(Vi)):(this.boundingBox.expandByPoint(Bn.min),this.boundingBox.expandByPoint(Bn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ct('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 Gi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ct("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new T,1/0);return}if(e){const i=this.boundingSphere.center;if(Bn.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];Cc.setFromBufferAttribute(o),this.morphTargetsRelative?(Vi.addVectors(Bn.min,Cc.min),Bn.expandByPoint(Vi),Vi.addVectors(Bn.max,Cc.max),Bn.expandByPoint(Vi)):(Bn.expandByPoint(Cc.min),Bn.expandByPoint(Cc.max))}Bn.getCenter(i);let n=0;for(let s=0,a=e.count;s<a;s++)Vi.fromBufferAttribute(e,s),n=Math.max(n,i.distanceToSquared(Vi));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)Vi.fromBufferAttribute(o,c),l&&(Go.fromBufferAttribute(e,c),Vi.add(Go)),n=Math.max(n,i.distanceToSquared(Vi))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&ct('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){ct("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,n=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new St(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let w=0;w<i.count;w++)o[w]=new T,l[w]=new T;const c=new T,h=new T,d=new T,p=new be,u=new be,A=new be,m=new T,g=new T;function f(w,E,I){c.fromBufferAttribute(i,w),h.fromBufferAttribute(i,E),d.fromBufferAttribute(i,I),p.fromBufferAttribute(s,w),u.fromBufferAttribute(s,E),A.fromBufferAttribute(s,I),h.sub(c),d.sub(c),u.sub(p),A.sub(p);const B=1/(u.x*A.y-A.x*u.y);isFinite(B)&&(m.copy(h).multiplyScalar(A.y).addScaledVector(d,-u.y).multiplyScalar(B),g.copy(d).multiplyScalar(u.x).addScaledVector(h,-A.x).multiplyScalar(B),o[w].add(m),o[E].add(m),o[I].add(m),l[w].add(g),l[E].add(g),l[I].add(g))}let v=this.groups;v.length===0&&(v=[{start:0,count:e.count}]);for(let w=0,E=v.length;w<E;++w){const I=v[w],B=I.start,R=I.count;for(let U=B,C=B+R;U<C;U+=3)f(e.getX(U+0),e.getX(U+1),e.getX(U+2))}const b=new T,y=new T,M=new T,_=new T;function S(w){M.fromBufferAttribute(n,w),_.copy(M);const E=o[w];b.copy(E),b.sub(M.multiplyScalar(M.dot(E))).normalize(),y.crossVectors(_,E);const B=y.dot(l[w])<0?-1:1;a.setXYZW(w,b.x,b.y,b.z,B)}for(let w=0,E=v.length;w<E;++w){const I=v[w],B=I.start,R=I.count;for(let U=B,C=B+R;U<C;U+=3)S(e.getX(U+0)),S(e.getX(U+1)),S(e.getX(U+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new St(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let p=0,u=i.count;p<u;p++)i.setXYZ(p,0,0,0);const n=new T,s=new T,a=new T,o=new T,l=new T,c=new T,h=new T,d=new T;if(e)for(let p=0,u=e.count;p<u;p+=3){const A=e.getX(p+0),m=e.getX(p+1),g=e.getX(p+2);n.fromBufferAttribute(t,A),s.fromBufferAttribute(t,m),a.fromBufferAttribute(t,g),h.subVectors(a,s),d.subVectors(n,s),h.cross(d),o.fromBufferAttribute(i,A),l.fromBufferAttribute(i,m),c.fromBufferAttribute(i,g),o.add(h),l.add(h),c.add(h),i.setXYZ(A,o.x,o.y,o.z),i.setXYZ(m,l.x,l.y,l.z),i.setXYZ(g,c.x,c.y,c.z)}else for(let p=0,u=t.count;p<u;p+=3)n.fromBufferAttribute(t,p+0),s.fromBufferAttribute(t,p+1),a.fromBufferAttribute(t,p+2),h.subVectors(a,s),d.subVectors(n,s),h.cross(d),i.setXYZ(p+0,h.x,h.y,h.z),i.setXYZ(p+1,h.x,h.y,h.z),i.setXYZ(p+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Vi.fromBufferAttribute(e,t),Vi.normalize(),e.setXYZ(t,Vi.x,Vi.y,Vi.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,d=o.normalized,p=new c.constructor(l.length*h);let u=0,A=0;for(let m=0,g=l.length;m<g;m++){o.isInterleavedBufferAttribute?u=l[m]*o.data.stride+o.offset:u=l[m]*h;for(let f=0;f<h;f++)p[A++]=c[u++]}return new St(p,h,d)}if(this.index===null)return Ye("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new ot,i=this.index.array,n=this.attributes;for(const o in n){const l=n[o],c=e(l,i);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let h=0,d=c.length;h<d;h++){const p=c[h],u=e(p,i);l.push(u)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.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 l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);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 i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const n={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let d=0,p=c.length;d<p;d++){const u=c[d];h.push(u.toJSON(e.data))}h.length>0&&(n[l]=h,s=!0)}s&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.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 i=e.index;i!==null&&this.setIndex(i.clone());const n=e.attributes;for(const c in n){const h=n[c];this.setAttribute(c,h.clone(t))}const s=e.morphAttributes;for(const c in s){const h=[],d=s[c];for(let p=0,u=d.length;p<u;p++)h.push(d[p].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,h=a.length;c<h;c++){const d=a[c];this.addGroup(d.start,d.count,d.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Vo{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=gc,this.updateRanges=[],this.version=0,this.uuid=Rn()}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,i){e*=this.stride,i*=t.stride;for(let n=0,s=this.stride;n<s;n++)this.array[e+n]=t.array[i+n];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=Rn()),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]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}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=Rn()),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 hn=new T;class Vs{constructor(e,t,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=n}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,i=this.data.count;t<i;t++)hn.fromBufferAttribute(this,t),hn.applyMatrix4(e),this.setXYZ(t,hn.x,hn.y,hn.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)hn.fromBufferAttribute(this,t),hn.applyNormalMatrix(e),this.setXYZ(t,hn.x,hn.y,hn.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)hn.fromBufferAttribute(this,t),hn.transformDirection(e),this.setXYZ(t,hn.x,hn.y,hn.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=cn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=gt(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=gt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=gt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=gt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=gt(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=cn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=cn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=cn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=cn(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=gt(t,this.array),i=gt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=gt(t,this.array),i=gt(i,this.array),n=gt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this}setXYZW(e,t,i,n,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=gt(t,this.array),i=gt(i,this.array),n=gt(n,this.array),s=gt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this.data.array[e+3]=s,this}clone(e){if(e===void 0){vc("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[n+s])}return new St(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 Vs(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){vc("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[n+s])}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}}}let aS=0;class Bi extends is{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:aS++}),this.uuid=Rn(),this.name="",this.type="Material",this.blending=na,this.side=Gn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Wh,this.blendDst=jh,this.blendEquation=gn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new We(0,0,0),this.blendAlpha=0,this.depthFunc=sa,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=If,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=pa,this.stencilZFail=pa,this.stencilZPass=pa,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 i=e[t];if(i===void 0){Ye(`Material: parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){Ye(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==na&&(i.blending=this.blending),this.side!==Gn&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Wh&&(i.blendSrc=this.blendSrc),this.blendDst!==jh&&(i.blendDst=this.blendDst),this.blendEquation!==gn&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==sa&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==If&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==pa&&(i.stencilFail=this.stencilFail),this.stencilZFail!==pa&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==pa&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function n(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=n(e.textures),a=n(e.images);s.length>0&&(i.textures=s),a.length>0&&(i.images=a)}return i}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 i=null;if(t!==null){const n=t.length;i=new Array(n);for(let s=0;s!==n;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Vd extends Bi{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new We(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 Qo;const Tc=new T,Wo=new T,jo=new T,qo=new be,Ic=new be,Sv=new Ke,Qd=new T,Pc=new T,Wd=new T,Cv=new be,Zf=new be,Tv=new be;class Rc extends Mt{constructor(e=new Vd){if(super(),this.isSprite=!0,this.type="Sprite",Qo===void 0){Qo=new ot;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new Vo(t,5);Qo.setIndex([0,1,2,0,2,3]),Qo.setAttribute("position",new Vs(i,3,0,!1)),Qo.setAttribute("uv",new Vs(i,2,3,!1))}this.geometry=Qo,this.material=e,this.center=new be(.5,.5),this.count=1}raycast(e,t){e.camera===null&&ct('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Wo.setFromMatrixScale(this.matrixWorld),Sv.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),jo.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Wo.multiplyScalar(-jo.z);const i=this.material.rotation;let n,s;i!==0&&(s=Math.cos(i),n=Math.sin(i));const a=this.center;jd(Qd.set(-.5,-.5,0),jo,a,Wo,n,s),jd(Pc.set(.5,-.5,0),jo,a,Wo,n,s),jd(Wd.set(.5,.5,0),jo,a,Wo,n,s),Cv.set(0,0),Zf.set(1,0),Tv.set(1,1);let o=e.ray.intersectTriangle(Qd,Pc,Wd,!1,Tc);if(o===null&&(jd(Pc.set(-.5,.5,0),jo,a,Wo,n,s),Zf.set(0,1),o=e.ray.intersectTriangle(Qd,Wd,Pc,!1,Tc),o===null))return;const l=e.ray.origin.distanceTo(Tc);l<e.near||l>e.far||t.push({distance:l,point:Tc.clone(),uv:vn.getInterpolation(Tc,Qd,Pc,Wd,Cv,Zf,Tv,new be),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 jd(r,e,t,i,n,s){qo.subVectors(r,t).addScalar(.5).multiply(i),n!==void 0?(Ic.x=s*qo.x-n*qo.y,Ic.y=n*qo.x+s*qo.y):Ic.copy(qo),r.copy(e),r.x+=Ic.x,r.y+=Ic.y,r.applyMatrix4(Sv)}const qd=new T,Iv=new T;class Pv extends Mt{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 i=0,n=t.length;i<n;i++){const s=t[i];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);const n=this.levels;let s;for(s=0;s<n.length&&!(t<n[s].distance);s++);return n.splice(s,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let i=0;i<t.length;i++)if(t[i].distance===e){const n=t.splice(i,1);return this.remove(n[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let i,n;for(i=1,n=t.length;i<n;i++){let s=t[i].distance;if(t[i].object.visible&&(s-=s*t[i].hysteresis),e<s)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){qd.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(qd);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){qd.setFromMatrixPosition(e.matrixWorld),Iv.setFromMatrixPosition(this.matrixWorld);const i=qd.distanceTo(Iv)/e.zoom;t[0].object.visible=!0;let n,s;for(n=1,s=t.length;n<s;n++){let a=t[n].distance;if(t[n].object.visible&&(a-=a*t[n].hysteresis),i>=a)t[n-1].object.visible=!1,t[n].object.visible=!0;else break}for(this._currentLevel=n-1;n<s;n++)t[n].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const i=this.levels;for(let n=0,s=i.length;n<s;n++){const a=i[n];t.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return t}}const Qs=new T,Jf=new T,Xd=new T,Tr=new T,$f=new T,Yd=new T,em=new T;class Ir{constructor(e=new T,t=new T(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,Qs)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Qs.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Qs.copy(this.origin).addScaledVector(this.direction,t),Qs.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){Jf.copy(e).add(t).multiplyScalar(.5),Xd.copy(t).sub(e).normalize(),Tr.copy(this.origin).sub(Jf);const s=e.distanceTo(t)*.5,a=-this.direction.dot(Xd),o=Tr.dot(this.direction),l=-Tr.dot(Xd),c=Tr.lengthSq(),h=Math.abs(1-a*a);let d,p,u,A;if(h>0)if(d=a*l-o,p=a*o-l,A=s*h,d>=0)if(p>=-A)if(p<=A){const m=1/h;d*=m,p*=m,u=d*(d+a*p+2*o)+p*(a*d+p+2*l)+c}else p=s,d=Math.max(0,-(a*p+o)),u=-d*d+p*(p+2*l)+c;else p=-s,d=Math.max(0,-(a*p+o)),u=-d*d+p*(p+2*l)+c;else p<=-A?(d=Math.max(0,-(-a*s+o)),p=d>0?-s:Math.min(Math.max(-s,-l),s),u=-d*d+p*(p+2*l)+c):p<=A?(d=0,p=Math.min(Math.max(-s,-l),s),u=p*(p+2*l)+c):(d=Math.max(0,-(a*s+o)),p=d>0?s:Math.min(Math.max(-s,-l),s),u=-d*d+p*(p+2*l)+c);else p=a>0?-s:s,d=Math.max(0,-(a*p+o)),u=-d*d+p*(p+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),n&&n.copy(Jf).addScaledVector(Xd,p),u}intersectSphere(e,t){Qs.subVectors(e.center,this.origin);const i=Qs.dot(this.direction),n=Qs.dot(Qs)-i*i,s=e.radius*e.radius;if(n>s)return null;const a=Math.sqrt(s-n),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,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 i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,n,s,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,p=this.origin;return c>=0?(i=(e.min.x-p.x)*c,n=(e.max.x-p.x)*c):(i=(e.max.x-p.x)*c,n=(e.min.x-p.x)*c),h>=0?(s=(e.min.y-p.y)*h,a=(e.max.y-p.y)*h):(s=(e.max.y-p.y)*h,a=(e.min.y-p.y)*h),i>a||s>n||((s>i||isNaN(i))&&(i=s),(a<n||isNaN(n))&&(n=a),d>=0?(o=(e.min.z-p.z)*d,l=(e.max.z-p.z)*d):(o=(e.max.z-p.z)*d,l=(e.min.z-p.z)*d),i>l||o>n)||((o>i||i!==i)&&(i=o),(l<n||n!==n)&&(n=l),n<0)?null:this.at(i>=0?i:n,t)}intersectsBox(e){return this.intersectBox(e,Qs)!==null}intersectTriangle(e,t,i,n,s){$f.subVectors(t,e),Yd.subVectors(i,e),em.crossVectors($f,Yd);let a=this.direction.dot(em),o;if(a>0){if(n)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Tr.subVectors(this.origin,e);const l=o*this.direction.dot(Yd.crossVectors(Tr,Yd));if(l<0)return null;const c=o*this.direction.dot($f.cross(Tr));if(c<0||l+c>a)return null;const h=-o*Tr.dot(em);return h<0?null:this.at(h/a,s)}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 Rt extends Bi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new We(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 Di,this.combine=Kl,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 Rv=new Ke,ba=new Ir,Kd=new Gi,Dv=new T,Zd=new T,Jd=new T,$d=new T,tm=new T,eu=new T,Bv=new T,tu=new T;class Ge extends Mt{constructor(e=new ot,t=new Rt){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,i=Object.keys(t);if(i.length>0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=n.length;s<a;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const i=this.geometry,n=i.attributes.position,s=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(n,e);const o=this.morphTargetInfluences;if(s&&o){eu.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=o[l],d=s[l];h!==0&&(tm.fromBufferAttribute(d,e),a?eu.addScaledVector(tm,h):eu.addScaledVector(tm.sub(t),h))}t.add(eu)}return t}raycast(e,t){const i=this.geometry,n=this.material,s=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Kd.copy(i.boundingSphere),Kd.applyMatrix4(s),ba.copy(e.ray).recast(e.near),!(Kd.containsPoint(ba.origin)===!1&&(ba.intersectSphere(Kd,Dv)===null||ba.origin.distanceToSquared(Dv)>(e.far-e.near)**2))&&(Rv.copy(s).invert(),ba.copy(e.ray).applyMatrix4(Rv),!(i.boundingBox!==null&&ba.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,ba)))}_computeIntersections(e,t,i){let n;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,d=s.attributes.normal,p=s.groups,u=s.drawRange;if(o!==null)if(Array.isArray(a))for(let A=0,m=p.length;A<m;A++){const g=p[A],f=a[g.materialIndex],v=Math.max(g.start,u.start),b=Math.min(o.count,Math.min(g.start+g.count,u.start+u.count));for(let y=v,M=b;y<M;y+=3){const _=o.getX(y),S=o.getX(y+1),w=o.getX(y+2);n=iu(this,f,e,i,c,h,d,_,S,w),n&&(n.faceIndex=Math.floor(y/3),n.face.materialIndex=g.materialIndex,t.push(n))}}else{const A=Math.max(0,u.start),m=Math.min(o.count,u.start+u.count);for(let g=A,f=m;g<f;g+=3){const v=o.getX(g),b=o.getX(g+1),y=o.getX(g+2);n=iu(this,a,e,i,c,h,d,v,b,y),n&&(n.faceIndex=Math.floor(g/3),t.push(n))}}else if(l!==void 0)if(Array.isArray(a))for(let A=0,m=p.length;A<m;A++){const g=p[A],f=a[g.materialIndex],v=Math.max(g.start,u.start),b=Math.min(l.count,Math.min(g.start+g.count,u.start+u.count));for(let y=v,M=b;y<M;y+=3){const _=y,S=y+1,w=y+2;n=iu(this,f,e,i,c,h,d,_,S,w),n&&(n.faceIndex=Math.floor(y/3),n.face.materialIndex=g.materialIndex,t.push(n))}}else{const A=Math.max(0,u.start),m=Math.min(l.count,u.start+u.count);for(let g=A,f=m;g<f;g+=3){const v=g,b=g+1,y=g+2;n=iu(this,a,e,i,c,h,d,v,b,y),n&&(n.faceIndex=Math.floor(g/3),t.push(n))}}}}function oS(r,e,t,i,n,s,a,o){let l;if(e.side===qi?l=i.intersectTriangle(a,s,n,!0,o):l=i.intersectTriangle(n,s,a,e.side===Gn,o),l===null)return null;tu.copy(o),tu.applyMatrix4(r.matrixWorld);const c=t.ray.origin.distanceTo(tu);return c<t.near||c>t.far?null:{distance:c,point:tu.clone(),object:r}}function iu(r,e,t,i,n,s,a,o,l,c){r.getVertexPosition(o,Zd),r.getVertexPosition(l,Jd),r.getVertexPosition(c,$d);const h=oS(r,e,t,i,Zd,Jd,$d,Bv);if(h){const d=new T;vn.getBarycoord(Bv,Zd,Jd,$d,d),n&&(h.uv=vn.getInterpolatedAttribute(n,o,l,c,d,new be)),s&&(h.uv1=vn.getInterpolatedAttribute(s,o,l,c,d,new be)),a&&(h.normal=vn.getInterpolatedAttribute(a,o,l,c,d,new T),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const p={a:o,b:l,c,normal:new T,materialIndex:0};vn.getNormal(Zd,Jd,$d,p.normal),h.face=p,h.barycoord=d}return h}const Lv=new T,kv=new Gt,Nv=new Gt,lS=new T,Uv=new Ke,nu=new T,im=new Gi,Fv=new Ke,nm=new Ir;class sm extends Ge{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=_f,this.bindMatrix=new Ke,this.bindMatrixInverse=new Ke,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Ft),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,nu),this.boundingBox.expandByPoint(nu)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Gi),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,nu),this.boundingSphere.expandByPoint(nu)}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 i=this.material,n=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),im.copy(this.boundingSphere),im.applyMatrix4(n),e.ray.intersectsSphere(im)!==!1&&(Fv.copy(n).invert(),nm.copy(e.ray).applyMatrix4(Fv),!(this.boundingBox!==null&&nm.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,nm)))}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 Gt,t=this.geometry.attributes.skinWeight;for(let i=0,n=t.count;i<n;i++){e.fromBufferAttribute(t,i);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===_f?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===YA?this.bindMatrixInverse.copy(this.bindMatrix).invert():Ye("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,n=this.geometry;kv.fromBufferAttribute(n.attributes.skinIndex,e),Nv.fromBufferAttribute(n.attributes.skinWeight,e),Lv.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=Nv.getComponent(s);if(a!==0){const o=kv.getComponent(s);Uv.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(lS.copy(Lv).applyMatrix4(Uv),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class su extends Mt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class dn extends ii{constructor(e=null,t=1,i=1,n,s,a,o,l,c=Ht,h=Ht,d,p){super(null,a,o,l,c,h,n,s,d,p),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Ov=new Ke,cS=new Ke;class Dc{constructor(e=[],t=[]){this.uuid=Rn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Ye("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,n=this.bones.length;i<n;i++)this.boneInverses.push(new Ke)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new Ke;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:cS;Ov.multiplyMatrices(o,t[s]),Ov.toArray(i,s*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new Dc(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 i=new dn(t,e,e,hi,oi);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,n=e.bones.length;i<n;i++){const s=e.bones[i];let a=t[s];a===void 0&&(Ye("Skeleton: No bone found with UUID:",s),a=new su),this.bones.push(a),this.boneInverses.push(new Ke().fromArray(e.boneInverses[i]))}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,i=this.boneInverses;for(let n=0,s=t.length;n<s;n++){const a=t[n];e.bones.push(a.uuid);const o=i[n];e.boneInverses.push(o.toArray())}return e}}class Pr extends St{constructor(e,t,i,n=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}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 Xo=new Ke,zv=new Ke,ru=[],Hv=new Ft,hS=new Ke,Bc=new Ge,Lc=new Gi;class ni extends Ge{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Pr(new Float32Array(i*16),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<i;n++)this.setMatrixAt(n,hS)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Ft),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Xo),Hv.copy(e.boundingBox).applyMatrix4(Xo),this.boundingBox.union(Hv)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Gi),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Xo),Lc.copy(e.boundingSphere).applyMatrix4(Xo),this.boundingSphere.union(Lc)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.previousInstanceMatrix!==null&&(this.previousInstanceMatrix=e.previousInstanceMatrix.clone()),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 i=t.morphTargetInfluences,n=this.morphTexture.source.data.data,s=i.length+1,a=e*s+1;for(let o=0;o<i.length;o++)i[o]=n[a+o]}raycast(e,t){const i=this.matrixWorld,n=this.count;if(Bc.geometry=this.geometry,Bc.material=this.material,Bc.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Lc.copy(this.boundingSphere),Lc.applyMatrix4(i),e.ray.intersectsSphere(Lc)!==!1))for(let s=0;s<n;s++){this.getMatrixAt(s,Xo),zv.multiplyMatrices(i,Xo),Bc.matrixWorld=zv,Bc.raycast(e,ru);for(let a=0,o=ru.length;a<o;a++){const l=ru[a];l.instanceId=s,l.object=this,t.push(l)}ru.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Pr(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 i=t.morphTargetInfluences,n=i.length+1;this.morphTexture===null&&(this.morphTexture=new dn(new Float32Array(n*this.count),n,this.count,Es,oi));const s=this.morphTexture.source.data.data;let a=0;for(let c=0;c<i.length;c++)a+=i[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=n*e;s[l]=o,s.set(i,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const rm=new T,dS=new T,uS=new ft;class li{constructor(e=new T(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,i,n){return this.normal.set(e,t,i),this.constant=n,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const n=rm.subVectors(i,t).cross(dS.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(n,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 i=e.delta(rm),n=this.normal.dot(i);if(n===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/n;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<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 i=t||uS.getNormalMatrix(e),n=this.coplanarPoint(rm).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(s),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 ya=new Gi,pS=new be(.5,.5),au=new T;class Yo{constructor(e=new li,t=new li,i=new li,n=new li,s=new li,a=new li){this.planes=[e,t,i,n,s,a]}set(e,t,i,n,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(n),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Pn,i=!1){const n=this.planes,s=e.elements,a=s[0],o=s[1],l=s[2],c=s[3],h=s[4],d=s[5],p=s[6],u=s[7],A=s[8],m=s[9],g=s[10],f=s[11],v=s[12],b=s[13],y=s[14],M=s[15];if(n[0].setComponents(c-a,u-h,f-A,M-v).normalize(),n[1].setComponents(c+a,u+h,f+A,M+v).normalize(),n[2].setComponents(c+o,u+d,f+m,M+b).normalize(),n[3].setComponents(c-o,u-d,f-m,M-b).normalize(),i)n[4].setComponents(l,p,g,y).normalize(),n[5].setComponents(c-l,u-p,f-g,M-y).normalize();else if(n[4].setComponents(c-l,u-p,f-g,M-y).normalize(),t===Pn)n[5].setComponents(c+l,u+p,f+g,M+y).normalize();else if(t===fa)n[5].setComponents(l,p,g,y).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(),ya.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),ya.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ya)}intersectsSprite(e){ya.center.set(0,0,0);const t=pS.distanceTo(e.center);return ya.radius=.7071067811865476+t,ya.applyMatrix4(e.matrixWorld),this.intersectsSphere(ya)}intersectsSphere(e){const t=this.planes,i=e.center,n=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<n)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const n=t[i];if(au.x=n.normal.x>0?e.max.x:e.min.x,au.y=n.normal.y>0?e.max.y:e.min.y,au.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(au)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const Ms=new Ke,ws=new Yo;class ou{constructor(){this.coordinateSystem=Pn}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const n=t.cameras[i];if(Ms.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),ws.setFromProjectionMatrix(Ms,n.coordinateSystem,n.reversedDepth),ws.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const n=t.cameras[i];if(Ms.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),ws.setFromProjectionMatrix(Ms,n.coordinateSystem,n.reversedDepth),ws.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const n=t.cameras[i];if(Ms.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),ws.setFromProjectionMatrix(Ms,n.coordinateSystem,n.reversedDepth),ws.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const n=t.cameras[i];if(Ms.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),ws.setFromProjectionMatrix(Ms,n.coordinateSystem,n.reversedDepth),ws.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const n=t.cameras[i];if(Ms.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),ws.setFromProjectionMatrix(Ms,n.coordinateSystem,n.reversedDepth),ws.containsPoint(e))return!0}return!1}clone(){return new ou}}function am(r,e){return r-e}function fS(r,e){return r.z-e.z}function mS(r,e){return e.z-r.z}class gS{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,i,n){const s=this.pool,a=this.list;this.index>=s.length&&s.push({start:-1,count:-1,z:-1,index:-1});const o=s[this.index];a.push(o),this.index++,o.start=e,o.count=t,o.z=i,o.index=n}reset(){this.list.length=0,this.index=0}}const yn=new Ke,AS=new We(1,1,1),Gv=new Yo,vS=new ou,lu=new Ft,xa=new Gi,kc=new T,Vv=new T,bS=new T,om=new gS,tn=new Ge,cu=[];function yS(r,e,t=0){const i=e.itemSize;if(r.isInterleavedBufferAttribute||r.array.constructor!==e.array.constructor){const n=r.count;for(let s=0;s<n;s++)for(let a=0;a<i;a++)e.setComponent(s+t,a,r.getComponent(s,a))}else e.array.set(r.array,t*i);e.needsUpdate=!0}function _a(r,e){if(r.constructor!==e.constructor){const t=Math.min(r.length,e.length);for(let i=0;i<t;i++)e[i]=r[i]}else{const t=Math.min(r.length,e.length);e.set(new r.constructor(r.buffer,0,t))}}class Qv extends Ge{constructor(e,t,i=t*2,n){super(new ot,n),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=i,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),i=new dn(t,e,e,hi,oi);this._matricesTexture=i}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),i=new dn(t,e,e,tc,Vn);this._indirectTexture=i}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),i=new dn(t,e,e,hi,oi);i.colorSpace=Et.workingColorSpace,this._colorsTexture=i}_initializeGeometry(e){const t=this.geometry,i=this._maxVertexCount,n=this._maxIndexCount;if(this._geometryInitialized===!1){for(const s in e.attributes){const a=e.getAttribute(s),{array:o,itemSize:l,normalized:c}=a,h=new o.constructor(i*l),d=new St(h,l,c);t.setAttribute(s,d)}if(e.getIndex()!==null){const s=i>65535?new Uint32Array(n):new Uint16Array(n);t.setIndex(new St(s,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 i in t.attributes){if(!e.hasAttribute(i))throw new Error(`THREE.BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const n=e.getAttribute(i),s=t.getAttribute(i);if(n.itemSize!==s.itemSize||n.normalized!==s.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 Ft);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let i=0,n=t.length;i<n;i++){if(t[i].active===!1)continue;const s=t[i].geometryIndex;this.getMatrixAt(i,yn),this.getBoundingBoxAt(s,lu).applyMatrix4(yn),e.union(lu)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Gi);const e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let i=0,n=t.length;i<n;i++){if(t[i].active===!1)continue;const s=t[i].geometryIndex;this.getMatrixAt(i,yn),this.getBoundingSphereAt(s,xa).applyMatrix4(yn),e.union(xa)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const i={visible:!0,active:!0,geometryIndex:e};let n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(am),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=i):(n=this._instanceInfo.length,this._instanceInfo.push(i));const s=this._matricesTexture;yn.identity().toArray(s.image.data,n*16),s.needsUpdate=!0;const a=this._colorsTexture;return a&&(AS.toArray(a.image.data,n*4),a.needsUpdate=!0),this._visibilityChanged=!0,n}addGeometry(e,t=-1,i=-1){this._initializeGeometry(e),this._validateGeometry(e);const n={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},s=this._geometryInfo;n.vertexStart=this._nextVertexStart,n.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const a=e.getIndex();if(a!==null&&(n.indexStart=this._nextIndexStart,n.reservedIndexCount=i===-1?a.count:i),n.indexStart!==-1&&n.indexStart+n.reservedIndexCount>this._maxIndexCount||n.vertexStart+n.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let l;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(am),l=this._availableGeometryIds.shift(),s[l]=n):(l=this._geometryCount,this._geometryCount++,s.push(n)),this.setGeometryAt(l,e),this._nextIndexStart=n.indexStart+n.reservedIndexCount,this._nextVertexStart=n.vertexStart+n.reservedVertexCount,l}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,n=i.getIndex()!==null,s=i.getIndex(),a=t.getIndex(),o=this._geometryInfo[e];if(n&&a.count>o.reservedIndexCount||t.attributes.position.count>o.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.reservedVertexCount;o.vertexCount=t.getAttribute("position").count;for(const h in i.attributes){const d=t.getAttribute(h),p=i.getAttribute(h);yS(d,p,l);const u=d.itemSize;for(let A=d.count,m=c;A<m;A++){const g=l+A;for(let f=0;f<u;f++)p.setComponent(g,f,0)}p.needsUpdate=!0,p.addUpdateRange(l*u,c*u)}if(n){const h=o.indexStart,d=o.reservedIndexCount;o.indexCount=t.getIndex().count;for(let p=0;p<a.count;p++)s.setX(h+p,l+a.getX(p));for(let p=a.count,u=d;p<u;p++)s.setX(h+p,l);s.needsUpdate=!0,s.addUpdateRange(h,o.reservedIndexCount)}return o.start=n?o.indexStart:o.vertexStart,o.count=n?o.indexCount:o.vertexCount,o.boundingBox=null,t.boundingBox!==null&&(o.boundingBox=t.boundingBox.clone()),o.boundingSphere=null,t.boundingSphere!==null&&(o.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 i=this._instanceInfo;for(let n=0,s=i.length;n<s;n++)i[n].active&&i[n].geometryIndex===e&&this.deleteInstance(n);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 i=this._geometryInfo,n=i.map((a,o)=>o).sort((a,o)=>i[a].vertexStart-i[o].vertexStart),s=this.geometry;for(let a=0,o=i.length;a<o;a++){const l=n[a],c=i[l];if(c.active!==!1){if(s.index!==null){if(c.indexStart!==t){const{indexStart:h,vertexStart:d,reservedIndexCount:p}=c,u=s.index,A=u.array,m=e-d;for(let g=h;g<h+p;g++)A[g]=A[g]+m;u.array.copyWithin(t,h,h+p),u.addUpdateRange(t,p),u.needsUpdate=!0,c.indexStart=t}t+=c.reservedIndexCount}if(c.vertexStart!==e){const{vertexStart:h,reservedVertexCount:d}=c,p=s.attributes;for(const u in p){const A=p[u],{array:m,itemSize:g}=A;m.copyWithin(e*g,h*g,(h+d)*g),A.addUpdateRange(e*g,d*g),A.needsUpdate=!0}c.vertexStart=e}e+=c.reservedVertexCount,c.start=s.index?c.indexStart:c.vertexStart}}return this._nextIndexStart=t,this._nextVertexStart=e,this._visibilityChanged=!0,this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const i=this.geometry,n=this._geometryInfo[e];if(n.boundingBox===null){const s=new Ft,a=i.index,o=i.attributes.position;for(let l=n.start,c=n.start+n.count;l<c;l++){let h=l;a&&(h=a.getX(h)),s.expandByPoint(kc.fromBufferAttribute(o,h))}n.boundingBox=s}return t.copy(n.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const i=this.geometry,n=this._geometryInfo[e];if(n.boundingSphere===null){const s=new Gi;this.getBoundingBoxAt(e,lu),lu.getCenter(s.center);const a=i.index,o=i.attributes.position;let l=0;for(let c=n.start,h=n.start+n.count;c<h;c++){let d=c;a&&(d=a.getX(d)),kc.fromBufferAttribute(o,d),l=Math.max(l,s.center.distanceToSquared(kc))}s.radius=Math.sqrt(l),n.boundingSphere=s}return t.copy(n.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const i=this._matricesTexture,n=this._matricesTexture.image.data;return t.toArray(n,e*16),i.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 i=this._geometryInfo[e];return t.vertexStart=i.vertexStart,t.vertexCount=i.vertexCount,t.reservedVertexCount=i.reservedVertexCount,t.indexStart=i.indexStart,t.indexCount=i.indexCount,t.reservedIndexCount=i.reservedIndexCount,t.start=i.start,t.count=i.count,t}setInstanceCount(e){const t=this._availableInstanceIds,i=this._instanceInfo;for(t.sort(am);t[t.length-1]===i.length-1;)i.pop(),t.pop();if(e<i.length)throw new Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);const n=new Int32Array(e),s=new Int32Array(e);_a(this._multiDrawCounts,n),_a(this._multiDrawStarts,s),this._multiDrawCounts=n,this._multiDrawStarts=s,this._maxInstanceCount=e;const a=this._indirectTexture,o=this._matricesTexture,l=this._colorsTexture;a.dispose(),this._initIndirectTexture(),_a(a.image.data,this._indirectTexture.image.data),o.dispose(),this._initMatricesTexture(),_a(o.image.data,this._matricesTexture.image.data),l&&(l.dispose(),this._initColorsTexture(),_a(l.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){const i=[...this._geometryInfo].filter(o=>o.active);if(Math.max(...i.map(o=>o.vertexStart+o.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(...i.map(l=>l.indexStart+l.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const s=this.geometry;s.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new ot,this._initializeGeometry(s));const a=this.geometry;s.index&&_a(s.index.array,a.index.array);for(const o in s.attributes)_a(s.attributes[o].array,a.attributes[o].array)}raycast(e,t){const i=this._instanceInfo,n=this._geometryInfo,s=this.matrixWorld,a=this.geometry;tn.material=this.material,tn.geometry.index=a.index,tn.geometry.attributes=a.attributes,tn.geometry.boundingBox===null&&(tn.geometry.boundingBox=new Ft),tn.geometry.boundingSphere===null&&(tn.geometry.boundingSphere=new Gi);for(let o=0,l=i.length;o<l;o++){if(!i[o].visible||!i[o].active)continue;const c=i[o].geometryIndex,h=n[c];tn.geometry.setDrawRange(h.start,h.count),this.getMatrixAt(o,tn.matrixWorld).premultiply(s),this.getBoundingBoxAt(c,tn.geometry.boundingBox),this.getBoundingSphereAt(c,tn.geometry.boundingSphere),tn.raycast(e,cu);for(let d=0,p=cu.length;d<p;d++){const u=cu[d];u.object=this,u.batchId=o,t.push(u)}cu.length=0}tn.material=null,tn.geometry.index=null,tn.geometry.attributes={},tn.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=>({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...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,i,n,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=n.getIndex();let o=a===null?1:a.array.BYTES_PER_ELEMENT,l=1;s.wireframe&&(l=2,o=n.attributes.position.count>65535?4:2);const c=this._instanceInfo,h=this._multiDrawStarts,d=this._multiDrawCounts,p=this._geometryInfo,u=this.perObjectFrustumCulled,A=this._indirectTexture,m=A.image.data,g=i.isArrayCamera?vS:Gv;u&&!i.isArrayCamera&&(yn.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),Gv.setFromProjectionMatrix(yn,i.coordinateSystem,i.reversedDepth));let f=0;if(this.sortObjects){yn.copy(this.matrixWorld).invert(),kc.setFromMatrixPosition(i.matrixWorld).applyMatrix4(yn),Vv.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(yn);for(let y=0,M=c.length;y<M;y++)if(c[y].visible&&c[y].active){const _=c[y].geometryIndex;this.getMatrixAt(y,yn),this.getBoundingSphereAt(_,xa).applyMatrix4(yn);let S=!1;if(u&&(S=!g.intersectsSphere(xa,i)),!S){const w=p[_],E=bS.subVectors(xa.center,kc).dot(Vv);om.push(w.start,w.count,E,y)}}const v=om.list,b=this.customSort;b===null?v.sort(s.transparent?mS:fS):b.call(this,v,i);for(let y=0,M=v.length;y<M;y++){const _=v[y];h[f]=_.start*o*l,d[f]=_.count*l,m[f]=_.index,f++}om.reset()}else for(let v=0,b=c.length;v<b;v++)if(c[v].visible&&c[v].active){const y=c[v].geometryIndex;let M=!1;if(u&&(this.getMatrixAt(v,yn),this.getBoundingSphereAt(y,xa).applyMatrix4(yn),M=!g.intersectsSphere(xa,i)),!M){const _=p[y];h[f]=_.start*o*l,d[f]=_.count*l,m[f]=v,f++}}A.needsUpdate=!0,this._multiDrawCount=f,this._visibilityChanged=!1}onBeforeShadow(e,t,i,n,s,a){this.onBeforeRender(e,null,n,s,a)}}class si extends Bi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new We(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 hu=new T,du=new T,Wv=new Ke,Nc=new Ir,uu=new Gi,lm=new T,jv=new T;class di extends Mt{constructor(e=new ot,t=new si){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,i=[0];for(let n=1,s=t.count;n<s;n++)hu.fromBufferAttribute(t,n-1),du.fromBufferAttribute(t,n),i[n]=i[n-1],i[n]+=hu.distanceTo(du);e.setAttribute("lineDistance",new tt(i,1))}else Ye("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,s=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),uu.copy(i.boundingSphere),uu.applyMatrix4(n),uu.radius+=s,e.ray.intersectsSphere(uu)===!1)return;Wv.copy(n).invert(),Nc.copy(e.ray).applyMatrix4(Wv);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=i.index,p=i.attributes.position;if(h!==null){const u=Math.max(0,a.start),A=Math.min(h.count,a.start+a.count);for(let m=u,g=A-1;m<g;m+=c){const f=h.getX(m),v=h.getX(m+1),b=pu(this,e,Nc,l,f,v,m);b&&t.push(b)}if(this.isLineLoop){const m=h.getX(A-1),g=h.getX(u),f=pu(this,e,Nc,l,m,g,A-1);f&&t.push(f)}}else{const u=Math.max(0,a.start),A=Math.min(p.count,a.start+a.count);for(let m=u,g=A-1;m<g;m+=c){const f=pu(this,e,Nc,l,m,m+1,m);f&&t.push(f)}if(this.isLineLoop){const m=pu(this,e,Nc,l,A-1,u,A-1);m&&t.push(m)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=n.length;s<a;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function pu(r,e,t,i,n,s,a){const o=r.geometry.attributes.position;if(hu.fromBufferAttribute(o,n),du.fromBufferAttribute(o,s),t.distanceSqToSegment(hu,du,lm,jv)>i)return;lm.applyMatrix4(r.matrixWorld);const c=e.ray.origin.distanceTo(lm);if(!(c<e.near||c>e.far))return{distance:c,point:jv.clone().applyMatrix4(r.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:r}}const qv=new T,Xv=new T;class vi extends di{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,i=[];for(let n=0,s=t.count;n<s;n+=2)qv.fromBufferAttribute(t,n),Xv.fromBufferAttribute(t,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+qv.distanceTo(Xv);e.setAttribute("lineDistance",new tt(i,1))}else Ye("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class cm extends di{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class fu extends Bi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new We(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 Yv=new Ke,hm=new Ir,mu=new Gi,gu=new T;class Au extends Mt{constructor(e=new ot,t=new fu){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 i=this.geometry,n=this.matrixWorld,s=e.params.Points.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),mu.copy(i.boundingSphere),mu.applyMatrix4(n),mu.radius+=s,e.ray.intersectsSphere(mu)===!1)return;Yv.copy(n).invert(),hm.copy(e.ray).applyMatrix4(Yv);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=i.index,d=i.attributes.position;if(c!==null){const p=Math.max(0,a.start),u=Math.min(c.count,a.start+a.count);for(let A=p,m=u;A<m;A++){const g=c.getX(A);gu.fromBufferAttribute(d,g),Kv(gu,g,l,n,e,t,this)}}else{const p=Math.max(0,a.start),u=Math.min(d.count,a.start+a.count);for(let A=p,m=u;A<m;A++)gu.fromBufferAttribute(d,A),Kv(gu,A,l,n,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=n.length;s<a;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function Kv(r,e,t,i,n,s,a){const o=hm.distanceSqToPoint(r);if(o<t){const l=new T;hm.closestPointToPoint(r,l),l.applyMatrix4(i);const c=n.ray.origin.distanceTo(l);if(c<n.near||c>n.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Zv extends ii{constructor(e,t,i,n,s=_t,a=_t,o,l,c){super(e,t,i,n,s,a,o,l,c),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const h=this;function d(){h.needsUpdate=!0,h._requestVideoFrameCallbackId=e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(d))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class xS extends Zv{constructor(e,t,i,n,s,a,o,l){super({},e,t,i,n,s,a,o,l),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class _S extends ii{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Ht,this.minFilter=Ht,this.generateMipmaps=!1,this.needsUpdate=!0}}class Ko extends ii{constructor(e,t,i,n,s,a,o,l,c,h,d,p){super(null,a,o,l,c,h,n,s,d,p),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class Jv extends Ko{constructor(e,t,i,n,s,a){super(e,t,i,s,a),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=ln,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class $v extends Ko{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,ys),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class Uc extends ii{constructor(e=[],t=ys,i,n,s,a,o,l,c,h){super(e,t,i,n,s,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class eb extends ii{constructor(e,t,i,n,s,a,o,l,c){super(e,t,i,n,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Rr extends ii{constructor(e,t,i=Vn,n,s,a,o=Ht,l=Ht,c,h=xs,d=1){if(h!==xs&&h!==_s)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const p={width:e,height:t,depth:d};super(p,n,s,a,o,l,h,i,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Er(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 tb extends Rr{constructor(e,t=Vn,i=ys,n,s,a=Ht,o=Ht,l,c=xs){const h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,t,i,n,s,a,o,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class dm extends ii{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class ri extends ot{constructor(e=1,t=1,i=1,n=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:n,heightSegments:s,depthSegments:a};const o=this;n=Math.floor(n),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],h=[],d=[];let p=0,u=0;A("z","y","x",-1,-1,i,t,e,a,s,0),A("z","y","x",1,-1,i,t,-e,a,s,1),A("x","z","y",1,1,e,i,t,n,a,2),A("x","z","y",1,-1,e,i,-t,n,a,3),A("x","y","z",1,-1,e,t,i,n,s,4),A("x","y","z",-1,-1,e,t,-i,n,s,5),this.setIndex(l),this.setAttribute("position",new tt(c,3)),this.setAttribute("normal",new tt(h,3)),this.setAttribute("uv",new tt(d,2));function A(m,g,f,v,b,y,M,_,S,w,E){const I=y/S,B=M/w,R=y/2,U=M/2,C=_/2,F=S+1,O=w+1;let H=0,j=0;const G=new T;for(let re=0;re<O;re++){const q=re*B-U;for(let Y=0;Y<F;Y++){const ye=Y*I-R;G[m]=ye*v,G[g]=q*b,G[f]=C,c.push(G.x,G.y,G.z),G[m]=0,G[g]=0,G[f]=_>0?1:-1,h.push(G.x,G.y,G.z),d.push(Y/S),d.push(1-re/w),H+=1}}for(let re=0;re<w;re++)for(let q=0;q<S;q++){const Y=p+q+F*re,ye=p+q+F*(re+1),Me=p+(q+1)+F*(re+1),xe=p+(q+1)+F*re;l.push(Y,ye,xe),l.push(ye,Me,xe),j+=6}o.addGroup(u,j,E),u+=j,p+=H}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ri(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class vu extends ot{constructor(e=1,t=1,i=4,n=8,s=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:i,radialSegments:n,heightSegments:s},t=Math.max(0,t),i=Math.max(1,Math.floor(i)),n=Math.max(3,Math.floor(n)),s=Math.max(1,Math.floor(s));const a=[],o=[],l=[],c=[],h=t/2,d=Math.PI/2*e,p=t,u=2*d+p,A=i*2+s,m=n+1,g=new T,f=new T;for(let v=0;v<=A;v++){let b=0,y=0,M=0,_=0;if(v<=i){const E=v/i,I=E*Math.PI/2;y=-h-e*Math.cos(I),M=e*Math.sin(I),_=-e*Math.cos(I),b=E*d}else if(v<=i+s){const E=(v-i)/s;y=-h+E*t,M=e,_=0,b=d+E*p}else{const E=(v-i-s)/i,I=E*Math.PI/2;y=h+e*Math.sin(I),M=e*Math.cos(I),_=e*Math.sin(I),b=d+p+E*d}const S=Math.max(0,Math.min(1,b/u));let w=0;v===0?w=.5/n:v===A&&(w=-.5/n);for(let E=0;E<=n;E++){const I=E/n,B=I*Math.PI*2,R=Math.sin(B),U=Math.cos(B);f.x=-M*U,f.y=y,f.z=M*R,o.push(f.x,f.y,f.z),g.set(-M*U,_,M*R),g.normalize(),l.push(g.x,g.y,g.z),c.push(I+w,S)}if(v>0){const E=(v-1)*m;for(let I=0;I<n;I++){const B=E+I,R=E+I+1,U=v*m+I,C=v*m+I+1;a.push(B,R,U),a.push(R,C,U)}}}this.setIndex(a),this.setAttribute("position",new tt(o,3)),this.setAttribute("normal",new tt(l,3)),this.setAttribute("uv",new tt(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new vu(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class bu extends ot{constructor(e=1,t=32,i=0,n=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:n},t=Math.max(3,t);const s=[],a=[],o=[],l=[],c=new T,h=new be;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let d=0,p=3;d<=t;d++,p+=3){const u=i+d/t*n;c.x=e*Math.cos(u),c.y=e*Math.sin(u),a.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(a[p]/e+1)/2,h.y=(a[p+1]/e+1)/2,l.push(h.x,h.y)}for(let d=1;d<=t;d++)s.push(d,d+1,0);this.setIndex(s),this.setAttribute("position",new tt(a,3)),this.setAttribute("normal",new tt(o,3)),this.setAttribute("uv",new tt(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bu(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Li extends ot{constructor(e=1,t=1,i=1,n=32,s=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:n,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:l};const c=this;n=Math.floor(n),s=Math.floor(s);const h=[],d=[],p=[],u=[];let A=0;const m=[],g=i/2;let f=0;v(),a===!1&&(e>0&&b(!0),t>0&&b(!1)),this.setIndex(h),this.setAttribute("position",new tt(d,3)),this.setAttribute("normal",new tt(p,3)),this.setAttribute("uv",new tt(u,2));function v(){const y=new T,M=new T;let _=0;const S=(t-e)/i;for(let w=0;w<=s;w++){const E=[],I=w/s,B=I*(t-e)+e;for(let R=0;R<=n;R++){const U=R/n,C=U*l+o,F=Math.sin(C),O=Math.cos(C);M.x=B*F,M.y=-I*i+g,M.z=B*O,d.push(M.x,M.y,M.z),y.set(F,S,O).normalize(),p.push(y.x,y.y,y.z),u.push(U,1-I),E.push(A++)}m.push(E)}for(let w=0;w<n;w++)for(let E=0;E<s;E++){const I=m[E][w],B=m[E+1][w],R=m[E+1][w+1],U=m[E][w+1];(e>0||E!==0)&&(h.push(I,B,U),_+=3),(t>0||E!==s-1)&&(h.push(B,R,U),_+=3)}c.addGroup(f,_,0),f+=_}function b(y){const M=A,_=new be,S=new T;let w=0;const E=y===!0?e:t,I=y===!0?1:-1;for(let R=1;R<=n;R++)d.push(0,g*I,0),p.push(0,I,0),u.push(.5,.5),A++;const B=A;for(let R=0;R<=n;R++){const C=R/n*l+o,F=Math.cos(C),O=Math.sin(C);S.x=E*O,S.y=g*I,S.z=E*F,d.push(S.x,S.y,S.z),p.push(0,I,0),_.x=F*.5+.5,_.y=O*.5*I+.5,u.push(_.x,_.y),A++}for(let R=0;R<n;R++){const U=M+R,C=B+R;y===!0?h.push(C,C+1,U):h.push(C+1,C,U),w+=3}c.addGroup(f,w,y===!0?1:2),f+=w}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Li(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Fc extends Li{constructor(e=1,t=1,i=32,n=1,s=!1,a=0,o=Math.PI*2){super(0,e,t,i,n,s,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:n,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Fc(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Dr extends ot{constructor(e=[],t=[],i=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:n};const s=[],a=[];o(n),c(i),h(),this.setAttribute("position",new tt(s,3)),this.setAttribute("normal",new tt(s.slice(),3)),this.setAttribute("uv",new tt(a,2)),n===0?this.computeVertexNormals():this.normalizeNormals();function o(v){const b=new T,y=new T,M=new T;for(let _=0;_<t.length;_+=3)u(t[_+0],b),u(t[_+1],y),u(t[_+2],M),l(b,y,M,v)}function l(v,b,y,M){const _=M+1,S=[];for(let w=0;w<=_;w++){S[w]=[];const E=v.clone().lerp(y,w/_),I=b.clone().lerp(y,w/_),B=_-w;for(let R=0;R<=B;R++)R===0&&w===_?S[w][R]=E:S[w][R]=E.clone().lerp(I,R/B)}for(let w=0;w<_;w++)for(let E=0;E<2*(_-w)-1;E++){const I=Math.floor(E/2);E%2===0?(p(S[w][I+1]),p(S[w+1][I]),p(S[w][I])):(p(S[w][I+1]),p(S[w+1][I+1]),p(S[w+1][I]))}}function c(v){const b=new T;for(let y=0;y<s.length;y+=3)b.x=s[y+0],b.y=s[y+1],b.z=s[y+2],b.normalize().multiplyScalar(v),s[y+0]=b.x,s[y+1]=b.y,s[y+2]=b.z}function h(){const v=new T;for(let b=0;b<s.length;b+=3){v.x=s[b+0],v.y=s[b+1],v.z=s[b+2];const y=g(v)/2/Math.PI+.5,M=f(v)/Math.PI+.5;a.push(y,1-M)}A(),d()}function d(){for(let v=0;v<a.length;v+=6){const b=a[v+0],y=a[v+2],M=a[v+4],_=Math.max(b,y,M),S=Math.min(b,y,M);_>.9&&S<.1&&(b<.2&&(a[v+0]+=1),y<.2&&(a[v+2]+=1),M<.2&&(a[v+4]+=1))}}function p(v){s.push(v.x,v.y,v.z)}function u(v,b){const y=v*3;b.x=e[y+0],b.y=e[y+1],b.z=e[y+2]}function A(){const v=new T,b=new T,y=new T,M=new T,_=new be,S=new be,w=new be;for(let E=0,I=0;E<s.length;E+=9,I+=6){v.set(s[E+0],s[E+1],s[E+2]),b.set(s[E+3],s[E+4],s[E+5]),y.set(s[E+6],s[E+7],s[E+8]),_.set(a[I+0],a[I+1]),S.set(a[I+2],a[I+3]),w.set(a[I+4],a[I+5]),M.copy(v).add(b).add(y).divideScalar(3);const B=g(M);m(_,I+0,v,B),m(S,I+2,b,B),m(w,I+4,y,B)}}function m(v,b,y,M){M<0&&v.x===1&&(a[b]=v.x-1),y.x===0&&y.z===0&&(a[b]=M/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function f(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Dr(e.vertices,e.indices,e.radius,e.detail)}}class yu extends Dr{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,n=1/i,s=[-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,-n,-i,0,-n,i,0,n,-i,0,n,i,-n,-i,0,-n,i,0,n,-i,0,n,i,0,-i,0,-n,i,0,-n,-i,0,n,i,0,n],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(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new yu(e.radius,e.detail)}}const xu=new T,_u=new T,um=new T,Eu=new vn;class ib extends ot{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const n=Math.pow(10,4),s=Math.cos(ma*t),a=e.getIndex(),o=e.getAttribute("position"),l=a?a.count:o.count,c=[0,0,0],h=["a","b","c"],d=new Array(3),p={},u=[];for(let A=0;A<l;A+=3){a?(c[0]=a.getX(A),c[1]=a.getX(A+1),c[2]=a.getX(A+2)):(c[0]=A,c[1]=A+1,c[2]=A+2);const{a:m,b:g,c:f}=Eu;if(m.fromBufferAttribute(o,c[0]),g.fromBufferAttribute(o,c[1]),f.fromBufferAttribute(o,c[2]),Eu.getNormal(um),d[0]=`${Math.round(m.x*n)},${Math.round(m.y*n)},${Math.round(m.z*n)}`,d[1]=`${Math.round(g.x*n)},${Math.round(g.y*n)},${Math.round(g.z*n)}`,d[2]=`${Math.round(f.x*n)},${Math.round(f.y*n)},${Math.round(f.z*n)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let v=0;v<3;v++){const b=(v+1)%3,y=d[v],M=d[b],_=Eu[h[v]],S=Eu[h[b]],w=`${y}_${M}`,E=`${M}_${y}`;E in p&&p[E]?(um.dot(p[E].normal)<=s&&(u.push(_.x,_.y,_.z),u.push(S.x,S.y,S.z)),p[E]=null):w in p||(p[w]={index0:c[v],index1:c[b],normal:um.clone()})}}for(const A in p)if(p[A]){const{index0:m,index1:g}=p[A];xu.fromBufferAttribute(o,m),_u.fromBufferAttribute(o,g),u.push(xu.x,xu.y,xu.z),u.push(_u.x,_u.y,_u.z)}this.setAttribute("position",new tt(u,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class as{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){Ye("Curve: .getPoint() not implemented.")}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/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 i,n=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)i=this.getPoint(a/e),s+=i.distanceTo(n),t.push(s),n=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const i=this.getLengths();let n=0;const s=i.length;let a;t?a=t:a=e*i[s-1];let o=0,l=s-1,c;for(;o<=l;)if(n=Math.floor(o+(l-o)/2),c=i[n]-a,c<0)o=n+1;else if(c>0)l=n-1;else{l=n;break}if(n=l,i[n]===a)return n/(s-1);const h=i[n],p=i[n+1]-h,u=(a-h)/p;return(n+u)/(s-1)}getTangent(e,t){let n=e-1e-4,s=e+1e-4;n<0&&(n=0),s>1&&(s=1);const a=this.getPoint(n),o=this.getPoint(s),l=t||(a.isVector2?new be:new T);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new T,n=[],s=[],a=[],o=new T,l=new Ke;for(let u=0;u<=e;u++){const A=u/e;n[u]=this.getTangentAt(A,new T)}s[0]=new T,a[0]=new T;let c=Number.MAX_VALUE;const h=Math.abs(n[0].x),d=Math.abs(n[0].y),p=Math.abs(n[0].z);h<=c&&(c=h,i.set(1,0,0)),d<=c&&(c=d,i.set(0,1,0)),p<=c&&i.set(0,0,1),o.crossVectors(n[0],i).normalize(),s[0].crossVectors(n[0],o),a[0].crossVectors(n[0],s[0]);for(let u=1;u<=e;u++){if(s[u]=s[u-1].clone(),a[u]=a[u-1].clone(),o.crossVectors(n[u-1],n[u]),o.length()>Number.EPSILON){o.normalize();const A=Math.acos(dt(n[u-1].dot(n[u]),-1,1));s[u].applyMatrix4(l.makeRotationAxis(o,A))}a[u].crossVectors(n[u],s[u])}if(t===!0){let u=Math.acos(dt(s[0].dot(s[e]),-1,1));u/=e,n[0].dot(o.crossVectors(s[0],s[e]))>0&&(u=-u);for(let A=1;A<=e;A++)s[A].applyMatrix4(l.makeRotationAxis(n[A],u*A)),a[A].crossVectors(n[A],s[A])}return{tangents:n,normals:s,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 Oc extends as{constructor(e=0,t=0,i=1,n=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=n,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new be){const i=t,n=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=n;for(;s>n;)s-=n;s<Number.EPSILON&&(a?s=0:s=n),this.aClockwise===!0&&!a&&(s===n?s=-n:s=s-n);const o=this.aStartAngle+e*s;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const h=Math.cos(this.aRotation),d=Math.sin(this.aRotation),p=l-this.aX,u=c-this.aY;l=p*h-u*d+this.aX,c=p*d+u*h+this.aY}return i.set(l,c)}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 nb extends Oc{constructor(e,t,i,n,s,a){super(e,t,i,i,n,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function pm(){let r=0,e=0,t=0,i=0;function n(s,a,o,l){r=s,e=o,t=-3*s+3*a-2*o-l,i=2*s-2*a+o+l}return{initCatmullRom:function(s,a,o,l,c){n(a,o,c*(o-s),c*(l-a))},initNonuniformCatmullRom:function(s,a,o,l,c,h,d){let p=(a-s)/c-(o-s)/(c+h)+(o-a)/h,u=(o-a)/h-(l-a)/(h+d)+(l-o)/d;p*=h,u*=h,n(a,o,p,u)},calc:function(s){const a=s*s,o=a*s;return r+e*s+t*a+i*o}}}const Mu=new T,fm=new pm,mm=new pm,gm=new pm;class sb extends as{constructor(e=[],t=!1,i="centripetal",n=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=n}getPoint(e,t=new T){const i=t,n=this.points,s=n.length,a=(s-(this.closed?0:1))*e;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,h;this.closed||o>0?c=n[(o-1)%s]:(Mu.subVectors(n[0],n[1]).add(n[0]),c=Mu);const d=n[o%s],p=n[(o+1)%s];if(this.closed||o+2<s?h=n[(o+2)%s]:(Mu.subVectors(n[s-1],n[s-2]).add(n[s-1]),h=Mu),this.curveType==="centripetal"||this.curveType==="chordal"){const u=this.curveType==="chordal"?.5:.25;let A=Math.pow(c.distanceToSquared(d),u),m=Math.pow(d.distanceToSquared(p),u),g=Math.pow(p.distanceToSquared(h),u);m<1e-4&&(m=1),A<1e-4&&(A=m),g<1e-4&&(g=m),fm.initNonuniformCatmullRom(c.x,d.x,p.x,h.x,A,m,g),mm.initNonuniformCatmullRom(c.y,d.y,p.y,h.y,A,m,g),gm.initNonuniformCatmullRom(c.z,d.z,p.z,h.z,A,m,g)}else this.curveType==="catmullrom"&&(fm.initCatmullRom(c.x,d.x,p.x,h.x,this.tension),mm.initCatmullRom(c.y,d.y,p.y,h.y,this.tension),gm.initCatmullRom(c.z,d.z,p.z,h.z,this.tension));return i.set(fm.calc(l),mm.calc(l),gm.calc(l)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const n=e.points[t];this.points.push(n.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,i=this.points.length;t<i;t++){const n=this.points[t];e.points.push(n.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,i=e.points.length;t<i;t++){const n=e.points[t];this.points.push(new T().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function rb(r,e,t,i,n){const s=(i-e)*.5,a=(n-t)*.5,o=r*r,l=r*o;return(2*t-2*i+s+a)*l+(-3*t+3*i-2*s-a)*o+s*r+t}function ES(r,e){const t=1-r;return t*t*e}function MS(r,e){return 2*(1-r)*r*e}function wS(r,e){return r*r*e}function zc(r,e,t,i){return ES(r,e)+MS(r,t)+wS(r,i)}function SS(r,e){const t=1-r;return t*t*t*e}function CS(r,e){const t=1-r;return 3*t*t*r*e}function TS(r,e){return 3*(1-r)*r*r*e}function IS(r,e){return r*r*r*e}function Hc(r,e,t,i,n){return SS(r,e)+CS(r,t)+TS(r,i)+IS(r,n)}class Am extends as{constructor(e=new be,t=new be,i=new be,n=new be){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=n}getPoint(e,t=new be){const i=t,n=this.v0,s=this.v1,a=this.v2,o=this.v3;return i.set(Hc(e,n.x,s.x,a.x,o.x),Hc(e,n.y,s.y,a.y,o.y)),i}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 ab extends as{constructor(e=new T,t=new T,i=new T,n=new T){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=n}getPoint(e,t=new T){const i=t,n=this.v0,s=this.v1,a=this.v2,o=this.v3;return i.set(Hc(e,n.x,s.x,a.x,o.x),Hc(e,n.y,s.y,a.y,o.y),Hc(e,n.z,s.z,a.z,o.z)),i}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 vm extends as{constructor(e=new be,t=new be){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new be){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new be){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 ob extends as{constructor(e=new T,t=new T){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new T){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new T){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 bm extends as{constructor(e=new be,t=new be,i=new be){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new be){const i=t,n=this.v0,s=this.v1,a=this.v2;return i.set(zc(e,n.x,s.x,a.x),zc(e,n.y,s.y,a.y)),i}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 ym extends as{constructor(e=new T,t=new T,i=new T){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new T){const i=t,n=this.v0,s=this.v1,a=this.v2;return i.set(zc(e,n.x,s.x,a.x),zc(e,n.y,s.y,a.y),zc(e,n.z,s.z,a.z)),i}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 xm extends as{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new be){const i=t,n=this.points,s=(n.length-1)*e,a=Math.floor(s),o=s-a,l=n[a===0?a:a-1],c=n[a],h=n[a>n.length-2?n.length-1:a+1],d=n[a>n.length-3?n.length-1:a+2];return i.set(rb(o,l.x,c.x,h.x,d.x),rb(o,l.y,c.y,h.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const n=e.points[t];this.points.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const n=e.points[t];this.points.push(new be().fromArray(n))}return this}}var wu=Object.freeze({__proto__:null,ArcCurve:nb,CatmullRomCurve3:sb,CubicBezierCurve:Am,CubicBezierCurve3:ab,EllipseCurve:Oc,LineCurve:vm,LineCurve3:ob,QuadraticBezierCurve:bm,QuadraticBezierCurve3:ym,SplineCurve:xm});class lb extends as{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 i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new wu[i](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),n=this.getCurveLengths();let s=0;for(;s<n.length;){if(n[s]>=i){const a=n[s]-i,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}s++}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 i=0,n=this.curves.length;i<n;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let n=0,s=this.curves;n<s.length;n++){const a=s[n],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,l=a.getPoints(o);for(let c=0;c<l.length;c++){const h=l[c];i&&i.equals(h)||(t.push(h),i=h)}}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,i=e.curves.length;t<i;t++){const n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const n=e.curves[t];this.curves.push(new wu[n.type]().fromJSON(n))}return this}}class Gc extends lb{constructor(e){super(),this.type="Path",this.currentPoint=new be,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;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 i=new vm(this.currentPoint.clone(),new be(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,n){const s=new bm(this.currentPoint.clone(),new be(e,t),new be(i,n));return this.curves.push(s),this.currentPoint.set(i,n),this}bezierCurveTo(e,t,i,n,s,a){const o=new Am(this.currentPoint.clone(),new be(e,t),new be(i,n),new be(s,a));return this.curves.push(o),this.currentPoint.set(s,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new xm(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,n,s,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,i,n,s,a),this}absarc(e,t,i,n,s,a){return this.absellipse(e,t,i,i,n,s,a),this}ellipse(e,t,i,n,s,a,o,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+c,t+h,i,n,s,a,o,l),this}absellipse(e,t,i,n,s,a,o,l){const c=new Oc(e,t,i,n,s,a,o,l);if(this.curves.length>0){const d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),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 Ws extends Gc{constructor(e){super(e),this.uuid=Rn(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,n=this.holes.length;i<n;i++)t[i]=this.holes[i].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,i=e.holes.length;t<i;t++){const n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const n=e.holes[t];this.holes.push(new Gc().fromJSON(n))}return this}}function PS(r,e,t=2){const i=e&&e.length,n=i?e[0]*t:r.length;let s=cb(r,0,n,t,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,c;if(i&&(s=kS(r,e,s,t)),r.length>80*t){o=r[0],l=r[1];let h=o,d=l;for(let p=t;p<n;p+=t){const u=r[p],A=r[p+1];u<o&&(o=u),A<l&&(l=A),u>h&&(h=u),A>d&&(d=A)}c=Math.max(h-o,d-l),c=c!==0?32767/c:0}return Vc(s,a,t,o,l,c,0),a}function cb(r,e,t,i,n){let s;if(n===jS(r,e,t,i)>0)for(let a=e;a<t;a+=i)s=pb(a/i|0,r[a],r[a+1],s);else for(let a=t-i;a>=e;a-=i)s=pb(a/i|0,r[a],r[a+1],s);return s&&Zo(s,s.next)&&(jc(s),s=s.next),s}function Ea(r,e){if(!r)return r;e||(e=r);let t=r,i;do if(i=!1,!t.steiner&&(Zo(t,t.next)||ui(t.prev,t,t.next)===0)){if(jc(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Vc(r,e,t,i,n,s,a){if(!r)return;!a&&s&&zS(r,i,n,s);let o=r;for(;r.prev!==r.next;){const l=r.prev,c=r.next;if(s?DS(r,i,n,s):RS(r)){e.push(l.i,r.i,c.i),jc(r),r=c.next,o=c.next;continue}if(r=c,r===o){a?a===1?(r=BS(Ea(r),e),Vc(r,e,t,i,n,s,2)):a===2&&LS(r,e,t,i,n,s):Vc(Ea(r),e,t,i,n,s,1);break}}}function RS(r){const e=r.prev,t=r,i=r.next;if(ui(e,t,i)>=0)return!1;const n=e.x,s=t.x,a=i.x,o=e.y,l=t.y,c=i.y,h=Math.min(n,s,a),d=Math.min(o,l,c),p=Math.max(n,s,a),u=Math.max(o,l,c);let A=i.next;for(;A!==e;){if(A.x>=h&&A.x<=p&&A.y>=d&&A.y<=u&&Qc(n,o,s,l,a,c,A.x,A.y)&&ui(A.prev,A,A.next)>=0)return!1;A=A.next}return!0}function DS(r,e,t,i){const n=r.prev,s=r,a=r.next;if(ui(n,s,a)>=0)return!1;const o=n.x,l=s.x,c=a.x,h=n.y,d=s.y,p=a.y,u=Math.min(o,l,c),A=Math.min(h,d,p),m=Math.max(o,l,c),g=Math.max(h,d,p),f=_m(u,A,e,t,i),v=_m(m,g,e,t,i);let b=r.prevZ,y=r.nextZ;for(;b&&b.z>=f&&y&&y.z<=v;){if(b.x>=u&&b.x<=m&&b.y>=A&&b.y<=g&&b!==n&&b!==a&&Qc(o,h,l,d,c,p,b.x,b.y)&&ui(b.prev,b,b.next)>=0||(b=b.prevZ,y.x>=u&&y.x<=m&&y.y>=A&&y.y<=g&&y!==n&&y!==a&&Qc(o,h,l,d,c,p,y.x,y.y)&&ui(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;b&&b.z>=f;){if(b.x>=u&&b.x<=m&&b.y>=A&&b.y<=g&&b!==n&&b!==a&&Qc(o,h,l,d,c,p,b.x,b.y)&&ui(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;y&&y.z<=v;){if(y.x>=u&&y.x<=m&&y.y>=A&&y.y<=g&&y!==n&&y!==a&&Qc(o,h,l,d,c,p,y.x,y.y)&&ui(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function BS(r,e){let t=r;do{const i=t.prev,n=t.next.next;!Zo(i,n)&&db(i,t,t.next,n)&&Wc(i,n)&&Wc(n,i)&&(e.push(i.i,t.i,n.i),jc(t),jc(t.next),t=r=n),t=t.next}while(t!==r);return Ea(t)}function LS(r,e,t,i,n,s){let a=r;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&VS(a,o)){let l=ub(a,o);a=Ea(a,a.next),l=Ea(l,l.next),Vc(a,e,t,i,n,s,0),Vc(l,e,t,i,n,s,0);return}o=o.next}a=a.next}while(a!==r)}function kS(r,e,t,i){const n=[];for(let s=0,a=e.length;s<a;s++){const o=e[s]*i,l=s<a-1?e[s+1]*i:r.length,c=cb(r,o,l,i,!1);c===c.next&&(c.steiner=!0),n.push(GS(c))}n.sort(NS);for(let s=0;s<n.length;s++)t=US(n[s],t);return t}function NS(r,e){let t=r.x-e.x;if(t===0&&(t=r.y-e.y,t===0)){const i=(r.next.y-r.y)/(r.next.x-r.x),n=(e.next.y-e.y)/(e.next.x-e.x);t=i-n}return t}function US(r,e){const t=FS(r,e);if(!t)return e;const i=ub(t,r);return Ea(i,i.next),Ea(t,t.next)}function FS(r,e){let t=e;const i=r.x,n=r.y;let s=-1/0,a;if(Zo(r,t))return t;do{if(Zo(r,t.next))return t.next;if(n<=t.y&&n>=t.next.y&&t.next.y!==t.y){const d=t.x+(n-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>s&&(s=d,a=t.x<t.next.x?t:t.next,d===i))return a}t=t.next}while(t!==e);if(!a)return null;const o=a,l=a.x,c=a.y;let h=1/0;t=a;do{if(i>=t.x&&t.x>=l&&i!==t.x&&hb(n<c?i:s,n,l,c,n<c?s:i,n,t.x,t.y)){const d=Math.abs(n-t.y)/(i-t.x);Wc(t,r)&&(d<h||d===h&&(t.x>a.x||t.x===a.x&&OS(a,t)))&&(a=t,h=d)}t=t.next}while(t!==o);return a}function OS(r,e){return ui(r.prev,r,e.prev)<0&&ui(e.next,r,r.next)<0}function zS(r,e,t,i){let n=r;do n.z===0&&(n.z=_m(n.x,n.y,e,t,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==r);n.prevZ.nextZ=null,n.prevZ=null,HS(n)}function HS(r){let e,t=1;do{let i=r,n;r=null;let s=null;for(e=0;i;){e++;let a=i,o=0;for(let c=0;c<t&&(o++,a=a.nextZ,!!a);c++);let l=t;for(;o>0||l>0&&a;)o!==0&&(l===0||!a||i.z<=a.z)?(n=i,i=i.nextZ,o--):(n=a,a=a.nextZ,l--),s?s.nextZ=n:r=n,n.prevZ=s,s=n;i=a}s.nextZ=null,t*=2}while(e>1);return r}function _m(r,e,t,i,n){return r=(r-t)*n|0,e=(e-i)*n|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function GS(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function hb(r,e,t,i,n,s,a,o){return(n-a)*(e-o)>=(r-a)*(s-o)&&(r-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(n-a)*(i-o)}function Qc(r,e,t,i,n,s,a,o){return!(r===a&&e===o)&&hb(r,e,t,i,n,s,a,o)}function VS(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!QS(r,e)&&(Wc(r,e)&&Wc(e,r)&&WS(r,e)&&(ui(r.prev,r,e.prev)||ui(r,e.prev,e))||Zo(r,e)&&ui(r.prev,r,r.next)>0&&ui(e.prev,e,e.next)>0)}function ui(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function Zo(r,e){return r.x===e.x&&r.y===e.y}function db(r,e,t,i){const n=Cu(ui(r,e,t)),s=Cu(ui(r,e,i)),a=Cu(ui(t,i,r)),o=Cu(ui(t,i,e));return!!(n!==s&&a!==o||n===0&&Su(r,t,e)||s===0&&Su(r,i,e)||a===0&&Su(t,r,i)||o===0&&Su(t,e,i))}function Su(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function Cu(r){return r>0?1:r<0?-1:0}function QS(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&db(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function Wc(r,e){return ui(r.prev,r,r.next)<0?ui(r,e,r.next)>=0&&ui(r,r.prev,e)>=0:ui(r,e,r.prev)<0||ui(r,r.next,e)<0}function WS(r,e){let t=r,i=!1;const n=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&n<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==r);return i}function ub(r,e){const t=Em(r.i,r.x,r.y),i=Em(e.i,e.x,e.y),n=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=n,n.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function pb(r,e,t,i){const n=Em(r,e,t);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function jc(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Em(r,e,t){return{i:r,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function jS(r,e,t,i){let n=0;for(let s=e,a=t-i;s<t;s+=i)n+=(r[a]-r[s])*(r[s+1]+r[a+1]),a=s;return n}class qS{static triangulate(e,t,i=2){return PS(e,t,i)}}class os{static area(e){const t=e.length;let i=0;for(let n=t-1,s=0;s<t;n=s++)i+=e[n].x*e[s].y-e[s].x*e[n].y;return i*.5}static isClockWise(e){return os.area(e)<0}static triangulateShape(e,t){const i=[],n=[],s=[];fb(e),mb(i,e);let a=e.length;t.forEach(fb);for(let l=0;l<t.length;l++)n.push(a),a+=t[l].length,mb(i,t[l]);const o=qS.triangulate(i,n);for(let l=0;l<o.length;l+=3)s.push(o.slice(l,l+3));return s}}function fb(r){const e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function mb(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}class Jo extends ot{constructor(e=new Ws([new be(.5,.5),new be(-.5,.5),new be(-.5,-.5),new be(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,n=[],s=[];for(let o=0,l=e.length;o<l;o++){const c=e[o];a(c)}this.setAttribute("position",new tt(n,3)),this.setAttribute("uv",new tt(s,2)),this.computeVertexNormals();function a(o){const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,h=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1;let p=t.bevelEnabled!==void 0?t.bevelEnabled:!0,u=t.bevelThickness!==void 0?t.bevelThickness:.2,A=t.bevelSize!==void 0?t.bevelSize:u-.1,m=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3;const f=t.extrudePath,v=t.UVGenerator!==void 0?t.UVGenerator:XS;let b,y=!1,M,_,S,w;if(f){b=f.getSpacedPoints(h),y=!0,p=!1;const D=f.isCatmullRomCurve3?f.closed:!1;M=f.computeFrenetFrames(h,D),_=new T,S=new T,w=new T}p||(g=0,u=0,A=0,m=0);const E=o.extractPoints(c);let I=E.shape;const B=E.holes;if(!os.isClockWise(I)){I=I.reverse();for(let D=0,ae=B.length;D<ae;D++){const $=B[D];os.isClockWise($)&&(B[D]=$.reverse())}}function U(D){const $=10000000000000001e-36;let Q=D[0];for(let L=1;L<=D.length;L++){const te=L%D.length,de=D[te],V=de.x-Q.x,ee=de.y-Q.y,P=V*V+ee*ee,x=Math.max(Math.abs(de.x),Math.abs(de.y),Math.abs(Q.x),Math.abs(Q.y)),N=$*x*x;if(P<=N){D.splice(te,1),L--;continue}Q=de}}U(I),B.forEach(U);const C=B.length,F=I;for(let D=0;D<C;D++){const ae=B[D];I=I.concat(ae)}function O(D,ae,$){return ae||ct("ExtrudeGeometry: vec does not exist"),D.clone().addScaledVector(ae,$)}const H=I.length;function j(D,ae,$){let Q,L,te;const de=D.x-ae.x,V=D.y-ae.y,ee=$.x-D.x,P=$.y-D.y,x=de*de+V*V,N=de*P-V*ee;if(Math.abs(N)>Number.EPSILON){const X=Math.sqrt(x),Z=Math.sqrt(ee*ee+P*P),K=ae.x-V/X,Ie=ae.y+de/X,ge=$.x-P/Z,ke=$.y+ee/Z,Oe=((ge-K)*P-(ke-Ie)*ee)/(de*P-V*ee);Q=K+de*Oe-D.x,L=Ie+V*Oe-D.y;const le=Q*Q+L*L;if(le<=2)return new be(Q,L);te=Math.sqrt(le/2)}else{let X=!1;de>Number.EPSILON?ee>Number.EPSILON&&(X=!0):de<-Number.EPSILON?ee<-Number.EPSILON&&(X=!0):Math.sign(V)===Math.sign(P)&&(X=!0),X?(Q=-V,L=de,te=Math.sqrt(x)):(Q=de,L=V,te=Math.sqrt(x/2))}return new be(Q/te,L/te)}const G=[];for(let D=0,ae=F.length,$=ae-1,Q=D+1;D<ae;D++,$++,Q++)$===ae&&($=0),Q===ae&&(Q=0),G[D]=j(F[D],F[$],F[Q]);const re=[];let q,Y=G.concat();for(let D=0,ae=C;D<ae;D++){const $=B[D];q=[];for(let Q=0,L=$.length,te=L-1,de=Q+1;Q<L;Q++,te++,de++)te===L&&(te=0),de===L&&(de=0),q[Q]=j($[Q],$[te],$[de]);re.push(q),Y=Y.concat(q)}let ye;if(g===0)ye=os.triangulateShape(F,B);else{const D=[],ae=[];for(let $=0;$<g;$++){const Q=$/g,L=u*Math.cos(Q*Math.PI/2),te=A*Math.sin(Q*Math.PI/2)+m;for(let de=0,V=F.length;de<V;de++){const ee=O(F[de],G[de],te);Pe(ee.x,ee.y,-L),Q===0&&D.push(ee)}for(let de=0,V=C;de<V;de++){const ee=B[de];q=re[de];const P=[];for(let x=0,N=ee.length;x<N;x++){const X=O(ee[x],q[x],te);Pe(X.x,X.y,-L),Q===0&&P.push(X)}Q===0&&ae.push(P)}}ye=os.triangulateShape(D,ae)}const Me=ye.length,xe=A+m;for(let D=0;D<H;D++){const ae=p?O(I[D],Y[D],xe):I[D];y?(S.copy(M.normals[0]).multiplyScalar(ae.x),_.copy(M.binormals[0]).multiplyScalar(ae.y),w.copy(b[0]).add(S).add(_),Pe(w.x,w.y,w.z)):Pe(ae.x,ae.y,0)}for(let D=1;D<=h;D++)for(let ae=0;ae<H;ae++){const $=p?O(I[ae],Y[ae],xe):I[ae];y?(S.copy(M.normals[D]).multiplyScalar($.x),_.copy(M.binormals[D]).multiplyScalar($.y),w.copy(b[D]).add(S).add(_),Pe(w.x,w.y,w.z)):Pe($.x,$.y,d/h*D)}for(let D=g-1;D>=0;D--){const ae=D/g,$=u*Math.cos(ae*Math.PI/2),Q=A*Math.sin(ae*Math.PI/2)+m;for(let L=0,te=F.length;L<te;L++){const de=O(F[L],G[L],Q);Pe(de.x,de.y,d+$)}for(let L=0,te=B.length;L<te;L++){const de=B[L];q=re[L];for(let V=0,ee=de.length;V<ee;V++){const P=O(de[V],q[V],Q);y?Pe(P.x,P.y+b[h-1].y,b[h-1].x+$):Pe(P.x,P.y,d+$)}}}J(),oe();function J(){const D=n.length/3;if(p){let ae=0,$=H*ae;for(let Q=0;Q<Me;Q++){const L=ye[Q];Be(L[2]+$,L[1]+$,L[0]+$)}ae=h+g*2,$=H*ae;for(let Q=0;Q<Me;Q++){const L=ye[Q];Be(L[0]+$,L[1]+$,L[2]+$)}}else{for(let ae=0;ae<Me;ae++){const $=ye[ae];Be($[2],$[1],$[0])}for(let ae=0;ae<Me;ae++){const $=ye[ae];Be($[0]+H*h,$[1]+H*h,$[2]+H*h)}}i.addGroup(D,n.length/3-D,0)}function oe(){const D=n.length/3;let ae=0;ue(F,ae),ae+=F.length;for(let $=0,Q=B.length;$<Q;$++){const L=B[$];ue(L,ae),ae+=L.length}i.addGroup(D,n.length/3-D,1)}function ue(D,ae){let $=D.length;for(;--$>=0;){const Q=$;let L=$-1;L<0&&(L=D.length-1);for(let te=0,de=h+g*2;te<de;te++){const V=H*te,ee=H*(te+1),P=ae+Q+V,x=ae+L+V,N=ae+L+ee,X=ae+Q+ee;Ue(P,x,N,X)}}}function Pe(D,ae,$){l.push(D),l.push(ae),l.push($)}function Be(D,ae,$){it(D),it(ae),it($);const Q=n.length/3,L=v.generateTopUV(i,n,Q-3,Q-2,Q-1);qe(L[0]),qe(L[1]),qe(L[2])}function Ue(D,ae,$,Q){it(D),it(ae),it(Q),it(ae),it($),it(Q);const L=n.length/3,te=v.generateSideWallUV(i,n,L-6,L-3,L-2,L-1);qe(te[0]),qe(te[1]),qe(te[3]),qe(te[1]),qe(te[2]),qe(te[3])}function it(D){n.push(l[D*3+0]),n.push(l[D*3+1]),n.push(l[D*3+2])}function qe(D){s.push(D.x),s.push(D.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return YS(t,i,e)}static fromJSON(e,t){const i=[];for(let s=0,a=e.shapes.length;s<a;s++){const o=t[e.shapes[s]];i.push(o)}const n=e.options.extrudePath;return n!==void 0&&(e.options.extrudePath=new wu[n.type]().fromJSON(n)),new Jo(i,e.options)}}const XS={generateTopUV:function(r,e,t,i,n){const s=e[t*3],a=e[t*3+1],o=e[i*3],l=e[i*3+1],c=e[n*3],h=e[n*3+1];return[new be(s,a),new be(o,l),new be(c,h)]},generateSideWallUV:function(r,e,t,i,n,s){const a=e[t*3],o=e[t*3+1],l=e[t*3+2],c=e[i*3],h=e[i*3+1],d=e[i*3+2],p=e[n*3],u=e[n*3+1],A=e[n*3+2],m=e[s*3],g=e[s*3+1],f=e[s*3+2];return Math.abs(o-h)<Math.abs(a-c)?[new be(a,1-l),new be(c,1-d),new be(p,1-A),new be(m,1-f)]:[new be(o,1-l),new be(h,1-d),new be(u,1-A),new be(g,1-f)]}};function YS(r,e,t){if(t.shapes=[],Array.isArray(r))for(let i=0,n=r.length;i<n;i++){const s=r[i];t.shapes.push(s.uuid)}else t.shapes.push(r.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class Tu extends Dr{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,n=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[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(n,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Tu(e.radius,e.detail)}}class Iu extends ot{constructor(e=[new be(0,-.5),new be(.5,0),new be(0,.5)],t=12,i=0,n=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:n},t=Math.floor(t),n=dt(n,0,Math.PI*2);const s=[],a=[],o=[],l=[],c=[],h=1/t,d=new T,p=new be,u=new T,A=new T,m=new T;let g=0,f=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:g=e[v+1].x-e[v].x,f=e[v+1].y-e[v].y,u.x=f*1,u.y=-g,u.z=f*0,m.copy(u),u.normalize(),l.push(u.x,u.y,u.z);break;case e.length-1:l.push(m.x,m.y,m.z);break;default:g=e[v+1].x-e[v].x,f=e[v+1].y-e[v].y,u.x=f*1,u.y=-g,u.z=f*0,A.copy(u),u.x+=m.x,u.y+=m.y,u.z+=m.z,u.normalize(),l.push(u.x,u.y,u.z),m.copy(A)}for(let v=0;v<=t;v++){const b=i+v*h*n,y=Math.sin(b),M=Math.cos(b);for(let _=0;_<=e.length-1;_++){d.x=e[_].x*y,d.y=e[_].y,d.z=e[_].x*M,a.push(d.x,d.y,d.z),p.x=v/t,p.y=_/(e.length-1),o.push(p.x,p.y);const S=l[3*_+0]*y,w=l[3*_+1],E=l[3*_+0]*M;c.push(S,w,E)}}for(let v=0;v<t;v++)for(let b=0;b<e.length-1;b++){const y=b+v*e.length,M=y,_=y+e.length,S=y+e.length+1,w=y+1;s.push(M,_,w),s.push(S,w,_)}this.setIndex(s),this.setAttribute("position",new tt(a,3)),this.setAttribute("uv",new tt(o,2)),this.setAttribute("normal",new tt(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Iu(e.points,e.segments,e.phiStart,e.phiLength)}}class js extends Dr{constructor(e=1,t=0){const i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],n=[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(i,n,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new js(e.radius,e.detail)}}class jn extends ot{constructor(e=1,t=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:n};const s=e/2,a=t/2,o=Math.floor(i),l=Math.floor(n),c=o+1,h=l+1,d=e/o,p=t/l,u=[],A=[],m=[],g=[];for(let f=0;f<h;f++){const v=f*p-a;for(let b=0;b<c;b++){const y=b*d-s;A.push(y,-v,0),m.push(0,0,1),g.push(b/o),g.push(1-f/l)}}for(let f=0;f<l;f++)for(let v=0;v<o;v++){const b=v+c*f,y=v+c*(f+1),M=v+1+c*(f+1),_=v+1+c*f;u.push(b,y,_),u.push(y,M,_)}this.setIndex(u),this.setAttribute("position",new tt(A,3)),this.setAttribute("normal",new tt(m,3)),this.setAttribute("uv",new tt(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new jn(e.width,e.height,e.widthSegments,e.heightSegments)}}class Pu extends ot{constructor(e=.5,t=1,i=32,n=1,s=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:n,thetaStart:s,thetaLength:a},i=Math.max(3,i),n=Math.max(1,n);const o=[],l=[],c=[],h=[];let d=e;const p=(t-e)/n,u=new T,A=new be;for(let m=0;m<=n;m++){for(let g=0;g<=i;g++){const f=s+g/i*a;u.x=d*Math.cos(f),u.y=d*Math.sin(f),l.push(u.x,u.y,u.z),c.push(0,0,1),A.x=(u.x/t+1)/2,A.y=(u.y/t+1)/2,h.push(A.x,A.y)}d+=p}for(let m=0;m<n;m++){const g=m*(i+1);for(let f=0;f<i;f++){const v=f+g,b=v,y=v+i+1,M=v+i+2,_=v+1;o.push(b,y,_),o.push(y,M,_)}}this.setIndex(o),this.setAttribute("position",new tt(l,3)),this.setAttribute("normal",new tt(c,3)),this.setAttribute("uv",new tt(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Pu(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class qc extends ot{constructor(e=new Ws([new be(0,.5),new be(-.5,-.5),new be(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],n=[],s=[],a=[];let o=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let h=0;h<e.length;h++)c(e[h]),this.addGroup(o,l,h),o+=l,l=0;this.setIndex(i),this.setAttribute("position",new tt(n,3)),this.setAttribute("normal",new tt(s,3)),this.setAttribute("uv",new tt(a,2));function c(h){const d=n.length/3,p=h.extractPoints(t);let u=p.shape;const A=p.holes;os.isClockWise(u)===!1&&(u=u.reverse());for(let g=0,f=A.length;g<f;g++){const v=A[g];os.isClockWise(v)===!0&&(A[g]=v.reverse())}const m=os.triangulateShape(u,A);for(let g=0,f=A.length;g<f;g++){const v=A[g];u=u.concat(v)}for(let g=0,f=u.length;g<f;g++){const v=u[g];n.push(v.x,v.y,0),s.push(0,0,1),a.push(v.x,v.y)}for(let g=0,f=m.length;g<f;g++){const v=m[g],b=v[0]+d,y=v[1]+d,M=v[2]+d;i.push(b,y,M),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return KS(t,e)}static fromJSON(e,t){const i=[];for(let n=0,s=e.shapes.length;n<s;n++){const a=t[e.shapes[n]];i.push(a)}return new qc(i,e.curveSegments)}}function KS(r,e){if(e.shapes=[],Array.isArray(r))for(let t=0,i=r.length;t<i;t++){const n=r[t];e.shapes.push(n.uuid)}else e.shapes.push(r.uuid);return e}class Br extends ot{constructor(e=1,t=32,i=16,n=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:n,phiLength:s,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(a+o,Math.PI);let c=0;const h=[],d=new T,p=new T,u=[],A=[],m=[],g=[];for(let f=0;f<=i;f++){const v=[],b=f/i;let y=0;f===0&&a===0?y=.5/t:f===i&&l===Math.PI&&(y=-.5/t);for(let M=0;M<=t;M++){const _=M/t;d.x=-e*Math.cos(n+_*s)*Math.sin(a+b*o),d.y=e*Math.cos(a+b*o),d.z=e*Math.sin(n+_*s)*Math.sin(a+b*o),A.push(d.x,d.y,d.z),p.copy(d).normalize(),m.push(p.x,p.y,p.z),g.push(_+y,1-b),v.push(c++)}h.push(v)}for(let f=0;f<i;f++)for(let v=0;v<t;v++){const b=h[f][v+1],y=h[f][v],M=h[f+1][v],_=h[f+1][v+1];(f!==0||a>0)&&u.push(b,y,_),(f!==i-1||l<Math.PI)&&u.push(y,M,_)}this.setIndex(u),this.setAttribute("position",new tt(A,3)),this.setAttribute("normal",new tt(m,3)),this.setAttribute("uv",new tt(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Br(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Ru extends Dr{constructor(e=1,t=0){const i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],n=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,n,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Ru(e.radius,e.detail)}}class qs extends ot{constructor(e=1,t=.4,i=12,n=48,s=Math.PI*2,a=0,o=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:n,arc:s,thetaStart:a,thetaLength:o},i=Math.floor(i),n=Math.floor(n);const l=[],c=[],h=[],d=[],p=new T,u=new T,A=new T;for(let m=0;m<=i;m++){const g=a+m/i*o;for(let f=0;f<=n;f++){const v=f/n*s;u.x=(e+t*Math.cos(g))*Math.cos(v),u.y=(e+t*Math.cos(g))*Math.sin(v),u.z=t*Math.sin(g),c.push(u.x,u.y,u.z),p.x=e*Math.cos(v),p.y=e*Math.sin(v),A.subVectors(u,p).normalize(),h.push(A.x,A.y,A.z),d.push(f/n),d.push(m/i)}}for(let m=1;m<=i;m++)for(let g=1;g<=n;g++){const f=(n+1)*m+g-1,v=(n+1)*(m-1)+g-1,b=(n+1)*(m-1)+g,y=(n+1)*m+g;l.push(f,v,y),l.push(v,b,y)}this.setIndex(l),this.setAttribute("position",new tt(c,3)),this.setAttribute("normal",new tt(h,3)),this.setAttribute("uv",new tt(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new qs(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Du extends ot{constructor(e=1,t=.4,i=64,n=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:n,p:s,q:a},i=Math.floor(i),n=Math.floor(n);const o=[],l=[],c=[],h=[],d=new T,p=new T,u=new T,A=new T,m=new T,g=new T,f=new T;for(let b=0;b<=i;++b){const y=b/i*s*Math.PI*2;v(y,s,a,e,u),v(y+.01,s,a,e,A),g.subVectors(A,u),f.addVectors(A,u),m.crossVectors(g,f),f.crossVectors(m,g),m.normalize(),f.normalize();for(let M=0;M<=n;++M){const _=M/n*Math.PI*2,S=-t*Math.cos(_),w=t*Math.sin(_);d.x=u.x+(S*f.x+w*m.x),d.y=u.y+(S*f.y+w*m.y),d.z=u.z+(S*f.z+w*m.z),l.push(d.x,d.y,d.z),p.subVectors(d,u).normalize(),c.push(p.x,p.y,p.z),h.push(b/i),h.push(M/n)}}for(let b=1;b<=i;b++)for(let y=1;y<=n;y++){const M=(n+1)*(b-1)+(y-1),_=(n+1)*b+(y-1),S=(n+1)*b+y,w=(n+1)*(b-1)+y;o.push(M,_,w),o.push(_,S,w)}this.setIndex(o),this.setAttribute("position",new tt(l,3)),this.setAttribute("normal",new tt(c,3)),this.setAttribute("uv",new tt(h,2));function v(b,y,M,_,S){const w=Math.cos(b),E=Math.sin(b),I=M/y*b,B=Math.cos(I);S.x=_*(2+B)*.5*w,S.y=_*(2+B)*E*.5,S.z=_*Math.sin(I)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Du(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Bu extends ot{constructor(e=new ym(new T(-1,-1,0),new T(-1,1,0),new T(1,1,0)),t=64,i=1,n=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:n,closed:s};const a=e.computeFrenetFrames(t,s);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const o=new T,l=new T,c=new be;let h=new T;const d=[],p=[],u=[],A=[];m(),this.setIndex(A),this.setAttribute("position",new tt(d,3)),this.setAttribute("normal",new tt(p,3)),this.setAttribute("uv",new tt(u,2));function m(){for(let b=0;b<t;b++)g(b);g(s===!1?t:0),v(),f()}function g(b){h=e.getPointAt(b/t,h);const y=a.normals[b],M=a.binormals[b];for(let _=0;_<=n;_++){const S=_/n*Math.PI*2,w=Math.sin(S),E=-Math.cos(S);l.x=E*y.x+w*M.x,l.y=E*y.y+w*M.y,l.z=E*y.z+w*M.z,l.normalize(),p.push(l.x,l.y,l.z),o.x=h.x+i*l.x,o.y=h.y+i*l.y,o.z=h.z+i*l.z,d.push(o.x,o.y,o.z)}}function f(){for(let b=1;b<=t;b++)for(let y=1;y<=n;y++){const M=(n+1)*(b-1)+(y-1),_=(n+1)*b+(y-1),S=(n+1)*b+y,w=(n+1)*(b-1)+y;A.push(M,_,w),A.push(_,S,w)}}function v(){for(let b=0;b<=t;b++)for(let y=0;y<=n;y++)c.x=b/t,c.y=y/n,u.push(c.x,c.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 Bu(new wu[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class gb extends ot{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],i=new Set,n=new T,s=new T;if(e.index!==null){const a=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let c=0,h=l.length;c<h;++c){const d=l[c],p=d.start,u=d.count;for(let A=p,m=p+u;A<m;A+=3)for(let g=0;g<3;g++){const f=o.getX(A+g),v=o.getX(A+(g+1)%3);n.fromBufferAttribute(a,f),s.fromBufferAttribute(a,v),Ab(n,s,i)===!0&&(t.push(n.x,n.y,n.z),t.push(s.x,s.y,s.z))}}}else{const a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let c=0;c<3;c++){const h=3*o+c,d=3*o+(c+1)%3;n.fromBufferAttribute(a,h),s.fromBufferAttribute(a,d),Ab(n,s,i)===!0&&(t.push(n.x,n.y,n.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new tt(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Ab(r,e,t){const i=`${r.x},${r.y},${r.z}-${e.x},${e.y},${e.z}`,n=`${e.x},${e.y},${e.z}-${r.x},${r.y},${r.z}`;return t.has(i)===!0||t.has(n)===!0?!1:(t.add(i),t.add(n),!0)}var vb=Object.freeze({__proto__:null,BoxGeometry:ri,CapsuleGeometry:vu,CircleGeometry:bu,ConeGeometry:Fc,CylinderGeometry:Li,DodecahedronGeometry:yu,EdgesGeometry:ib,ExtrudeGeometry:Jo,IcosahedronGeometry:Tu,LatheGeometry:Iu,OctahedronGeometry:js,PlaneGeometry:jn,PolyhedronGeometry:Dr,RingGeometry:Pu,ShapeGeometry:qc,SphereGeometry:Br,TetrahedronGeometry:Ru,TorusGeometry:qs,TorusKnotGeometry:Du,TubeGeometry:Bu,WireframeGeometry:gb});class bb extends Bi{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new We(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}}function $o(r){const e={};for(const t in r){e[t]={};for(const i in r[t]){const n=r[t][i];n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)?n.isRenderTargetTexture?(Ye("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=n.clone():Array.isArray(n)?e[t][i]=n.slice():e[t][i]=n}}return e}function un(r){const e={};for(let t=0;t<r.length;t++){const i=$o(r[t]);for(const n in i)e[n]=i[n]}return e}function ZS(r){const e=[];for(let t=0;t<r.length;t++)e.push(r[t].clone());return e}function yb(r){const e=r.getRenderTarget();return e===null?r.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Et.workingColorSpace}const nn={clone:$o,merge:un};var JS=`void main() {
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,$S=`void main() {
|
||
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
||
}`;class ei extends Bi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=JS,this.fragmentShader=$S,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=$o(e.uniforms),this.uniformsGroups=ZS(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const n in this.uniforms){const a=this.uniforms[n].value;a&&a.isTexture?t.uniforms[n]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[n]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[n]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[n]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[n]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[n]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[n]={type:"m4",value:a.toArray()}:t.uniforms[n]={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 i={};for(const n in this.extensions)this.extensions[n]===!0&&(i[n]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class Lu extends ei{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Ma extends Bi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new We(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 We(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=xr,this.normalScale=new be(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 Di,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 qn extends Ma{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 be(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return dt(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 We(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 We(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new We(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 xb extends Bi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new We(16777215),this.specular=new We(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new We(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=xr,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Di,this.combine=Kl,this.reflectivity=1,this.envMapIntensity=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.envMapIntensity=e.envMapIntensity,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 _b extends Bi{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new We(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new We(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=xr,this.normalScale=new be(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 ku extends Bi{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=xr,this.normalScale=new be(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 Mm extends Bi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new We(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new We(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=xr,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Di,this.combine=Kl,this.reflectivity=1,this.envMapIntensity=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.envMapIntensity=e.envMapIntensity,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 wm extends Bi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=ev,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 Sm extends Bi{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 Eb extends Bi{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new We(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=xr,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Mb extends si{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 wa(r,e){return!r||r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function wb(r){function e(n,s){return r[n]-r[s]}const t=r.length,i=new Array(t);for(let n=0;n!==t;++n)i[n]=n;return i.sort(e),i}function Cm(r,e,t){const i=r.length,n=new r.constructor(i);for(let s=0,a=0;a!==i;++s){const o=t[s]*e;for(let l=0;l!==e;++l)n[a++]=r[o+l]}return n}function Tm(r,e,t,i){let n=1,s=r[0];for(;s!==void 0&&s[i]===void 0;)s=r[n++];if(s===void 0)return;let a=s[i];if(a!==void 0)if(Array.isArray(a))do a=s[i],a!==void 0&&(e.push(s.time),t.push(...a)),s=r[n++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[i],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=r[n++];while(s!==void 0);else do a=s[i],a!==void 0&&(e.push(s.time),t.push(a)),s=r[n++];while(s!==void 0)}function eC(r,e,t,i,n=30){const s=r.clone();s.name=e;const a=[];for(let l=0;l<s.tracks.length;++l){const c=s.tracks[l],h=c.getValueSize(),d=[],p=[];for(let u=0;u<c.times.length;++u){const A=c.times[u]*n;if(!(A<t||A>=i)){d.push(c.times[u]);for(let m=0;m<h;++m)p.push(c.values[u*h+m])}}d.length!==0&&(c.times=wa(d,c.times.constructor),c.values=wa(p,c.values.constructor),a.push(c))}s.tracks=a;let o=1/0;for(let l=0;l<s.tracks.length;++l)o>s.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*o);return s.resetDuration(),s}function tC(r,e=0,t=r,i=30){i<=0&&(i=30);const n=t.tracks.length,s=e/i;for(let a=0;a<n;++a){const o=t.tracks[a],l=o.ValueTypeName;if(l==="bool"||l==="string")continue;const c=r.tracks.find(function(f){return f.name===o.name&&f.ValueTypeName===l});if(c===void 0)continue;let h=0;const d=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=d/3);let p=0;const u=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(p=u/3);const A=o.times.length-1;let m;if(s<=o.times[0]){const f=h,v=d-h;m=o.values.slice(f,v)}else if(s>=o.times[A]){const f=A*d+h,v=f+d-h;m=o.values.slice(f,v)}else{const f=o.createInterpolant(),v=h,b=d-h;f.evaluate(s),m=f.resultBuffer.slice(v,b)}l==="quaternion"&&new Tt().fromArray(m).normalize().conjugate().toArray(m);const g=c.times.length;for(let f=0;f<g;++f){const v=f*u+p;if(l==="quaternion")Tt.multiplyQuaternionsFlat(c.values,v,m,0,c.values,v);else{const b=u-p*2;for(let y=0;y<b;++y)c.values[v+y]-=m[y]}}}return r.blendMode=Cf,r}class iC{static convertArray(e,t){return wa(e,t)}static isTypedArray(e){return lv(e)}static getKeyframeOrder(e){return wb(e)}static sortedArray(e,t,i){return Cm(e,t,i)}static flattenJSON(e,t,i,n){Tm(e,t,i,n)}static subclip(e,t,i,n,s=30){return eC(e,t,i,n,s)}static makeClipAdditive(e,t=0,i=e,n=30){return tC(e,t,i,n)}}class Sa{constructor(e,t,i,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,n=t[i],s=t[i-1];e:{t:{let a;i:{n:if(!(e<n)){for(let o=i+2;;){if(n===void 0){if(e<s)break n;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(s=n,n=t[++i],e<n)break t}a=t.length;break i}if(!(e>=s)){const o=t[1];e<o&&(i=2,s=o);for(let l=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(n=s,s=t[--i-1],e>=s)break t}a=i,i=0;break i}break e}for(;i<a;){const o=i+a>>>1;e<t[o]?a=o:i=o+1}if(n=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,n)}return this.interpolate_(i,s,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,s=e*n;for(let a=0;a!==n;++a)t[a]=i[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Sb extends Sa{constructor(e,t,i,n){super(e,t,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:da,endingEnd:da}}intervalChanged_(e,t,i){const n=this.parameterPositions;let s=e-2,a=e+1,o=n[s],l=n[a];if(o===void 0)switch(this.getSettings_().endingStart){case ua:s=e,o=2*t-i;break;case fc:s=n.length-2,o=t+n[s]-n[s+1];break;default:s=e,o=i}if(l===void 0)switch(this.getSettings_().endingEnd){case ua:a=e,l=2*i-t;break;case fc:a=1,l=i+n[1]-n[0];break;default:a=e-1,l=t}const c=(i-t)*.5,h=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-i),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(e,t,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this._offsetPrev,d=this._offsetNext,p=this._weightPrev,u=this._weightNext,A=(i-t)/(n-t),m=A*A,g=m*A,f=-p*g+2*p*m-p*A,v=(1+p)*g+(-1.5-2*p)*m+(-.5+p)*A+1,b=(-1-u)*g+(1.5+u)*m+.5*A,y=u*g-u*m;for(let M=0;M!==o;++M)s[M]=f*a[h+M]+v*a[c+M]+b*a[l+M]+y*a[d+M];return s}}class Im extends Sa{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=(i-t)/(n-t),d=1-h;for(let p=0;p!==o;++p)s[p]=a[c+p]*d+a[l+p]*h;return s}}class Cb extends Sa{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class Tb extends Sa{interpolate_(e,t,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this.settings||this.DefaultSettings_,d=h.inTangents,p=h.outTangents;if(!d||!p){const m=(i-t)/(n-t),g=1-m;for(let f=0;f!==o;++f)s[f]=a[c+f]*g+a[l+f]*m;return s}const u=o*2,A=e-1;for(let m=0;m!==o;++m){const g=a[c+m],f=a[l+m],v=A*u+m*2,b=p[v],y=p[v+1],M=e*u+m*2,_=d[M],S=d[M+1];let w=(i-t)/(n-t),E,I,B,R,U;for(let C=0;C<8;C++){E=w*w,I=E*w,B=1-w,R=B*B,U=R*B;const O=U*t+3*R*w*b+3*B*E*_+I*n-i;if(Math.abs(O)<1e-10)break;const H=3*R*(b-t)+6*B*w*(_-b)+3*E*(n-_);if(Math.abs(H)<1e-10)break;w=w-O/H,w=Math.max(0,Math.min(1,w))}s[m]=U*g+3*R*w*y+3*B*E*S+I*f}return s}}class Xn{constructor(e,t,i,n){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=wa(t,this.TimeBufferType),this.values=wa(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:wa(e.times,Array),values:wa(e.values,Array)};const n=e.getInterpolation();n!==e.DefaultInterpolation&&(i.interpolation=n)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new Cb(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Im(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Sb(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){const t=new Tb(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.settings=this.settings),t}setInterpolation(e){let t;switch(e){case To:t=this.InterpolantFactoryMethodDiscrete;break;case Io:t=this.InterpolantFactoryMethodLinear;break;case Sd:t=this.InterpolantFactoryMethodSmooth;break;case Sf:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){const i="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(i);return Ye("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return To;case this.InterpolantFactoryMethodLinear:return Io;case this.InterpolantFactoryMethodSmooth:return Sd;case this.InterpolantFactoryMethodBezier:return Sf}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]*=e}return this}trim(e,t){const i=this.times,n=i.length;let s=0,a=n-1;for(;s!==n&&i[s]<e;)++s;for(;a!==-1&&i[a]>t;)--a;if(++a,s!==0||a!==n){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=i.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(ct("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,n=this.values,s=i.length;s===0&&(ct("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=i[o];if(typeof l=="number"&&isNaN(l)){ct("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){ct("KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(n!==void 0&&lv(n))for(let o=0,l=n.length;o!==l;++o){const c=n[o];if(isNaN(c)){ct("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),n=this.getInterpolation()===Sd,s=e.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=e[o],h=e[o+1];if(c!==h&&(o!==1||c!==e[0]))if(n)l=!0;else{const d=o*i,p=d-i,u=d+i;for(let A=0;A!==i;++A){const m=t[d+A];if(m!==t[p+A]||m!==t[u+A]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const d=o*i,p=a*i;for(let u=0;u!==i;++u)t[p+u]=t[d+u]}++a}}if(s>0){e[a]=e[s];for(let o=s*i,l=a*i,c=0;c!==i;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,n=new i(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}Xn.prototype.ValueTypeName="",Xn.prototype.TimeBufferType=Float32Array,Xn.prototype.ValueBufferType=Float32Array,Xn.prototype.DefaultInterpolation=Io;class Ca extends Xn{constructor(e,t,i){super(e,t,i)}}Ca.prototype.ValueTypeName="bool",Ca.prototype.ValueBufferType=Array,Ca.prototype.DefaultInterpolation=To,Ca.prototype.InterpolantFactoryMethodLinear=void 0,Ca.prototype.InterpolantFactoryMethodSmooth=void 0;class Pm extends Xn{constructor(e,t,i,n){super(e,t,i,n)}}Pm.prototype.ValueTypeName="color";class Ta extends Xn{constructor(e,t,i,n){super(e,t,i,n)}}Ta.prototype.ValueTypeName="number";class Ib extends Sa{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(i-t)/(n-t);let c=e*o;for(let h=c+o;c!==h;c+=4)Tt.slerpFlat(s,0,a,c-o,a,c,l);return s}}class Ia extends Xn{constructor(e,t,i,n){super(e,t,i,n)}InterpolantFactoryMethodLinear(e){return new Ib(this.times,this.values,this.getValueSize(),e)}}Ia.prototype.ValueTypeName="quaternion",Ia.prototype.InterpolantFactoryMethodSmooth=void 0;class Pa extends Xn{constructor(e,t,i){super(e,t,i)}}Pa.prototype.ValueTypeName="string",Pa.prototype.ValueBufferType=Array,Pa.prototype.DefaultInterpolation=To,Pa.prototype.InterpolantFactoryMethodLinear=void 0,Pa.prototype.InterpolantFactoryMethodSmooth=void 0;class Ra extends Xn{constructor(e,t,i,n){super(e,t,i,n)}}Ra.prototype.ValueTypeName="vector";class el{constructor(e="",t=-1,i=[],n=Cd){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=Rn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,n=1/(e.fps||1);for(let a=0,o=i.length;a!==o;++a)t.push(sC(i[a]).scale(n));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s.userData=JSON.parse(e.userData||"{}"),s}static toJSON(e){const t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let s=0,a=i.length;s!==a;++s)t.push(Xn.toJSON(i[s]));return n}static CreateFromMorphTargetSequence(e,t,i,n){const s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const h=wb(l);l=Cm(l,1,h),c=Cm(c,1,h),!n&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new Ta(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const n=e;i=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<i.length;n++)if(i[n].name===t)return i[n];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const n={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],h=c.name.match(s);if(h&&h.length>1){const d=h[1];let p=n[d];p||(n[d]=p=[]),p.push(c)}}const a=[];for(const o in n)a.push(this.CreateFromMorphTargetSequence(o,n[o],t,i));return a}static parseAnimation(e,t){if(Ye("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return ct("AnimationClip: No animation in JSONLoader data."),null;const i=function(d,p,u,A,m){if(u.length!==0){const g=[],f=[];Tm(u,g,f,A),g.length!==0&&m.push(new d(p,g,f))}},n=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let d=0;d<c.length;d++){const p=c[d].keys;if(!(!p||p.length===0))if(p[0].morphTargets){const u={};let A;for(A=0;A<p.length;A++)if(p[A].morphTargets)for(let m=0;m<p[A].morphTargets.length;m++)u[p[A].morphTargets[m]]=-1;for(const m in u){const g=[],f=[];for(let v=0;v!==p[A].morphTargets.length;++v){const b=p[A];g.push(b.time),f.push(b.morphTarget===m?1:0)}n.push(new Ta(".morphTargetInfluence["+m+"]",g,f))}l=u.length*a}else{const u=".bones["+t[d].name+"]";i(Ra,u+".position",p,"pos",n),i(Ia,u+".quaternion",p,"rot",n),i(Ra,u+".scale",p,"scl",n)}}return n.length===0?null:new this(s,l,n,o)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,n=e.length;i!==n;++i){const s=this.tracks[i];t=Math.max(t,s.times[s.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 i=0;i<this.tracks.length;i++)e.push(this.tracks[i].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 nC(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ta;case"vector":case"vector2":case"vector3":case"vector4":return Ra;case"color":return Pm;case"quaternion":return Ia;case"bool":case"boolean":return Ca;case"string":return Pa}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function sC(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=nC(r.type);if(r.times===void 0){const t=[],i=[];Tm(r.keys,t,i,"value"),r.times=t,r.values=i}return e.parse!==void 0?e.parse(r):new e(r.name,r.times,r.values,r.interpolation)}const Ss={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(Pb(r)||(this.files[r]=e))},get:function(r){if(this.enabled!==!1&&!Pb(r))return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};function Pb(r){try{const e=r.slice(r.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}class Rm{constructor(e,t,i){const n=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this._abortController=null,this.itemStart=function(h){o++,s===!1&&n.onStart!==void 0&&n.onStart(h,a,o),s=!0},this.itemEnd=function(h){a++,n.onProgress!==void 0&&n.onProgress(h,a,o),a===o&&(s=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(h){n.onError!==void 0&&n.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,d){return c.push(h,d),this},this.removeHandler=function(h){const d=c.indexOf(h);return d!==-1&&c.splice(d,2),this},this.getHandler=function(h){for(let d=0,p=c.length;d<p;d+=2){const u=c[d],A=c[d+1];if(u.global&&(u.lastIndex=0),u.test(h))return A}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 Rb=new Rm;class Qi{constructor(e){this.manager=e!==void 0?e:Rb,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){const i=this;return new Promise(function(n,s){i.load(e,n,t,s)})}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}}Qi.DEFAULT_MATERIAL_NAME="__DEFAULT";const Xs={};class rC extends Error{constructor(e,t){super(e),this.response=t}}class Yi extends Qi{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=Ss.get(`file:${e}`);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Xs[e]!==void 0){Xs[e].push({onLoad:t,onProgress:i,onError:n});return}Xs[e]=[],Xs[e].push({onLoad:t,onProgress:i,onError:n});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}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&Ye("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=Xs[e],d=c.body.getReader(),p=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),u=p?parseInt(p):0,A=u!==0;let m=0;const g=new ReadableStream({start(f){v();function v(){d.read().then(({done:b,value:y})=>{if(b)f.close();else{m+=y.byteLength;const M=new ProgressEvent("progress",{lengthComputable:A,loaded:m,total:u});for(let _=0,S=h.length;_<S;_++){const w=h[_];w.onProgress&&w.onProgress(M)}f.enqueue(y),v()}},b=>{f.error(b)})}}});return new Response(g)}else throw new rC(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o==="")return c.text();{const d=/charset="?([^;"\s]*)"?/i.exec(o),p=d&&d[1]?d[1].toLowerCase():void 0,u=new TextDecoder(p);return c.arrayBuffer().then(A=>u.decode(A))}}}).then(c=>{Ss.add(`file:${e}`,c);const h=Xs[e];delete Xs[e];for(let d=0,p=h.length;d<p;d++){const u=h[d];u.onLoad&&u.onLoad(c)}}).catch(c=>{const h=Xs[e];if(h===void 0)throw this.manager.itemError(e),c;delete Xs[e];for(let d=0,p=h.length;d<p;d++){const u=h[d];u.onError&&u.onError(c)}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 aC extends Qi{constructor(e){super(e)}load(e,t,i,n){const s=this,a=new Yi(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){n?n(l):ct(l),s.manager.itemError(e)}},i,n)}parse(e){const t=[];for(let i=0;i<e.length;i++){const n=el.parse(e[i]);t.push(n)}return t}}class oC extends Qi{constructor(e){super(e)}load(e,t,i,n){const s=this,a=[],o=new Ko,l=new Yi(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(s.withCredentials);let c=0;function h(d){l.load(e[d],function(p){const u=s.parse(p,!0);a[d]={width:u.width,height:u.height,format:u.format,mipmaps:u.mipmaps},c+=1,c===6&&(u.mipmapCount===1&&(o.minFilter=_t),o.image=a,o.format=u.format,o.needsUpdate=!0,t&&t(o))},i,n)}if(Array.isArray(e))for(let d=0,p=e.length;d<p;++d)h(d);else l.load(e,function(d){const p=s.parse(d,!0);if(p.isCubemap){const u=p.mipmaps.length/p.mipmapCount;for(let A=0;A<u;A++){a[A]={mipmaps:[]};for(let m=0;m<p.mipmapCount;m++)a[A].mipmaps.push(p.mipmaps[A*p.mipmapCount+m]),a[A].format=p.format,a[A].width=p.width,a[A].height=p.height}o.image=a}else o.image.width=p.width,o.image.height=p.height,o.mipmaps=p.mipmaps;p.mipmapCount===1&&(o.minFilter=_t),o.format=p.format,o.needsUpdate=!0,t&&t(o)},i,n);return o}}const tl=new WeakMap;class Xc extends Qi{constructor(e){super(e)}load(e,t,i,n){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=Ss.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0);else{let d=tl.get(a);d===void 0&&(d=[],tl.set(a,d)),d.push({onLoad:t,onError:n})}return a}const o=Ac("img");function l(){h(),t&&t(this);const d=tl.get(this)||[];for(let p=0;p<d.length;p++){const u=d[p];u.onLoad&&u.onLoad(this)}tl.delete(this),s.manager.itemEnd(e)}function c(d){h(),n&&n(d),Ss.remove(`image:${e}`);const p=tl.get(this)||[];for(let u=0;u<p.length;u++){const A=p[u];A.onError&&A.onError(d)}tl.delete(this),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),Ss.add(`image:${e}`,o),s.manager.itemStart(e),o.src=e,o}}class lC extends Qi{constructor(e){super(e)}load(e,t,i,n){const s=new Uc;s.colorSpace=Jt;const a=new Xc(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function l(c){a.load(e[c],function(h){s.images[c]=h,o++,o===6&&(s.needsUpdate=!0,t&&t(s))},void 0,n)}for(let c=0;c<e.length;++c)l(c);return s}}class Db extends Qi{constructor(e){super(e)}load(e,t,i,n){const s=this,a=new dn,o=new Yi(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(s.withCredentials),o.load(e,function(l){let c;try{c=s.parse(l)}catch(h){if(n!==void 0)n(h);else{h(h);return}}c.image!==void 0?a.image=c.image:c.data!==void 0&&(a.image.width=c.width,a.image.height=c.height,a.image.data=c.data),a.wrapS=c.wrapS!==void 0?c.wrapS:ln,a.wrapT=c.wrapT!==void 0?c.wrapT:ln,a.magFilter=c.magFilter!==void 0?c.magFilter:_t,a.minFilter=c.minFilter!==void 0?c.minFilter:_t,a.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(a.colorSpace=c.colorSpace),c.flipY!==void 0&&(a.flipY=c.flipY),c.format!==void 0&&(a.format=c.format),c.type!==void 0&&(a.type=c.type),c.mipmaps!==void 0&&(a.mipmaps=c.mipmaps,a.minFilter=An),c.mipmapCount===1&&(a.minFilter=_t),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c)},i,n),a}}class Da extends Qi{constructor(e){super(e)}load(e,t,i,n){const s=new ii,a=new Xc(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},i,n),s}}class Lr extends Mt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new We(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class Bb extends Lr{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Mt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new We(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}const Dm=new Ke,Lb=new T,kb=new T;class Bm{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new be(512,512),this.mapType=ut,this.map=null,this.mapPass=null,this.matrix=new Ke,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Yo,this._frameExtents=new be(1,1),this._viewportCount=1,this._viewports=[new Gt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;Lb.setFromMatrixPosition(e.matrixWorld),t.position.copy(Lb),kb.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(kb),t.updateMatrixWorld(),Dm.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Dm,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===fa||t.reversedDepth?i.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Dm)}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.biasNode=e.biasNode,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}}const Nu=new T,Uu=new Tt,Cs=new T;class Fu extends Mt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ke,this.projectionMatrix=new Ke,this.projectionMatrixInverse=new Ke,this.coordinateSystem=Pn,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.matrixWorld.decompose(Nu,Uu,Cs),Cs.x===1&&Cs.y===1&&Cs.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Nu,Uu,Cs.set(1,1,1)).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorld.decompose(Nu,Uu,Cs),Cs.x===1&&Cs.y===1&&Cs.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Nu,Uu,Cs.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const kr=new T,Nb=new be,Ub=new be;class pi extends Fu{constructor(e=50,t=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,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=Ro*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(ma*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Ro*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,i){kr.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(kr.x,kr.y).multiplyScalar(-e/kr.z),kr.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(kr.x,kr.y).multiplyScalar(-e/kr.z)}getViewSize(e,t){return this.getViewBounds(e,Nb,Ub),t.subVectors(Ub,Nb)}setViewOffset(e,t,i,n,s,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=i,this.view.offsetY=n,this.view.width=s,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,i=2*t,n=this.aspect*i,s=-.5*n;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*n/l,t-=a.offsetY*i/c,n*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+n,t,t-i,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}}class cC extends Bm{constructor(){super(new pi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,i=Ro*2*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height*this.aspect,s=e.distance||t.far;(i!==t.fov||n!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=n,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Lm extends Lr{constructor(e,t,i=0,n=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Mt.DEFAULT_UP),this.updateMatrix(),this.target=new Mt,this.distance=i,this.angle=n,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new cC}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class hC extends Bm{constructor(){super(new pi(90,1,.5,500)),this.isPointLightShadow=!0}}class km extends Lr{constructor(e,t,i=0,n=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new hC}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class Ki extends Fu{constructor(e=-1,t=1,i=1,n=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=s,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,i,n,s,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=i,this.view.offsetY=n,this.view.width=s,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),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let s=i-e,a=i+e,o=n+t,l=n-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,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 dC extends Bm{constructor(){super(new Ki(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Nr extends Lr{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Mt.DEFAULT_UP),this.updateMatrix(),this.target=new Mt,this.shadow=new dC}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class il extends Lr{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Fb extends Lr{constructor(e,t,i=10,n=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=n}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 Nm{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new T)}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 i=e.x,n=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*n),t.addScaledVector(a[2],.488603*s),t.addScaledVector(a[3],.488603*i),t.addScaledVector(a[4],1.092548*(i*n)),t.addScaledVector(a[5],1.092548*(n*s)),t.addScaledVector(a[6],.315392*(3*s*s-1)),t.addScaledVector(a[7],1.092548*(i*s)),t.addScaledVector(a[8],.546274*(i*i-n*n)),t}getIrradianceAt(e,t){const i=e.x,n=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*n),t.addScaledVector(a[2],2*.511664*s),t.addScaledVector(a[3],2*.511664*i),t.addScaledVector(a[4],2*.429043*i*n),t.addScaledVector(a[5],2*.429043*n*s),t.addScaledVector(a[6],.743125*s*s-.247708),t.addScaledVector(a[7],2*.429043*i*s),t.addScaledVector(a[8],.429043*(i*i-n*n)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],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 i=this.coefficients;for(let n=0;n<9;n++)i[n].fromArray(e,t+n*3);return this}toArray(e=[],t=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].toArray(e,t+n*3);return e}static getBasisAt(e,t){const i=e.x,n=e.y,s=e.z;t[0]=.282095,t[1]=.488603*n,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*n,t[5]=1.092548*n*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-n*n)}}class Ob extends Lr{constructor(e=new Nm,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class Ou extends Qi{constructor(e){super(e),this.textures={}}load(e,t,i,n){const s=this,a=new Yi(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){n?n(l):ct(l),s.manager.itemError(e)}},i,n)}parse(e){const t=this.textures;function i(s){return t[s]===void 0&&Ye("MaterialLoader: Undefined texture",s),t[s]}const n=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(n.uuid=e.uuid),e.name!==void 0&&(n.name=e.name),e.color!==void 0&&n.color!==void 0&&n.color.setHex(e.color),e.roughness!==void 0&&(n.roughness=e.roughness),e.metalness!==void 0&&(n.metalness=e.metalness),e.sheen!==void 0&&(n.sheen=e.sheen),e.sheenColor!==void 0&&(n.sheenColor=new We().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(n.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&n.emissive!==void 0&&n.emissive.setHex(e.emissive),e.specular!==void 0&&n.specular!==void 0&&n.specular.setHex(e.specular),e.specularIntensity!==void 0&&(n.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&n.specularColor!==void 0&&n.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(n.shininess=e.shininess),e.clearcoat!==void 0&&(n.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(n.dispersion=e.dispersion),e.iridescence!==void 0&&(n.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(n.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(n.transmission=e.transmission),e.thickness!==void 0&&(n.thickness=e.thickness),e.attenuationDistance!==void 0&&(n.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&n.attenuationColor!==void 0&&n.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(n.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(n.fog=e.fog),e.flatShading!==void 0&&(n.flatShading=e.flatShading),e.blending!==void 0&&(n.blending=e.blending),e.combine!==void 0&&(n.combine=e.combine),e.side!==void 0&&(n.side=e.side),e.shadowSide!==void 0&&(n.shadowSide=e.shadowSide),e.opacity!==void 0&&(n.opacity=e.opacity),e.transparent!==void 0&&(n.transparent=e.transparent),e.alphaTest!==void 0&&(n.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(n.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(n.depthFunc=e.depthFunc),e.depthTest!==void 0&&(n.depthTest=e.depthTest),e.depthWrite!==void 0&&(n.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(n.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(n.blendSrc=e.blendSrc),e.blendDst!==void 0&&(n.blendDst=e.blendDst),e.blendEquation!==void 0&&(n.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(n.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(n.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(n.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&n.blendColor!==void 0&&n.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(n.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(n.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(n.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(n.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(n.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(n.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(n.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(n.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(n.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(n.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(n.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(n.rotation=e.rotation),e.linewidth!==void 0&&(n.linewidth=e.linewidth),e.dashSize!==void 0&&(n.dashSize=e.dashSize),e.gapSize!==void 0&&(n.gapSize=e.gapSize),e.scale!==void 0&&(n.scale=e.scale),e.polygonOffset!==void 0&&(n.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(n.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(n.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(n.dithering=e.dithering),e.alphaToCoverage!==void 0&&(n.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(n.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(n.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(n.allowOverride=e.allowOverride),e.visible!==void 0&&(n.visible=e.visible),e.toneMapped!==void 0&&(n.toneMapped=e.toneMapped),e.userData!==void 0&&(n.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?n.vertexColors=e.vertexColors>0:n.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const a=e.uniforms[s];switch(n.uniforms[s]={},a.type){case"t":n.uniforms[s].value=i(a.value);break;case"c":n.uniforms[s].value=new We().setHex(a.value);break;case"v2":n.uniforms[s].value=new be().fromArray(a.value);break;case"v3":n.uniforms[s].value=new T().fromArray(a.value);break;case"v4":n.uniforms[s].value=new Gt().fromArray(a.value);break;case"m3":n.uniforms[s].value=new ft().fromArray(a.value);break;case"m4":n.uniforms[s].value=new Ke().fromArray(a.value);break;default:n.uniforms[s].value=a.value}}if(e.defines!==void 0&&(n.defines=e.defines),e.vertexShader!==void 0&&(n.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(n.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(n.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)n.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(n.lights=e.lights),e.clipping!==void 0&&(n.clipping=e.clipping),e.size!==void 0&&(n.size=e.size),e.sizeAttenuation!==void 0&&(n.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(n.map=i(e.map)),e.matcap!==void 0&&(n.matcap=i(e.matcap)),e.alphaMap!==void 0&&(n.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(n.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(n.bumpScale=e.bumpScale),e.normalMap!==void 0&&(n.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(n.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),n.normalScale=new be().fromArray(s)}return e.displacementMap!==void 0&&(n.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(n.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(n.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(n.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(n.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(n.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(n.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(n.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(n.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(n.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(n.envMap=i(e.envMap)),e.envMapRotation!==void 0&&n.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(n.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(n.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(n.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(n.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(n.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(n.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(n.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(n.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(n.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(n.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(n.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(n.clearcoatNormalScale=new be().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(n.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(n.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(n.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(n.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(n.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(n.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(n.sheenRoughnessMap=i(e.sheenRoughnessMap)),n}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return Ou.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:bb,SpriteMaterial:Vd,RawShaderMaterial:Lu,ShaderMaterial:ei,PointsMaterial:fu,MeshPhysicalMaterial:qn,MeshStandardMaterial:Ma,MeshPhongMaterial:xb,MeshToonMaterial:_b,MeshNormalMaterial:ku,MeshLambertMaterial:Mm,MeshDepthMaterial:wm,MeshDistanceMaterial:Sm,MeshBasicMaterial:Rt,MeshMatcapMaterial:Eb,LineDashedMaterial:Mb,LineBasicMaterial:si,Material:Bi};return new t[e]}}class Ur{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 zb extends ot{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 Hb extends Qi{constructor(e){super(e)}load(e,t,i,n){const s=this,a=new Yi(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){n?n(l):ct(l),s.manager.itemError(e)}},i,n)}parse(e){const t={},i={};function n(u,A){if(t[A]!==void 0)return t[A];const g=u.interleavedBuffers[A],f=s(u,g.buffer),v=Po(g.type,f),b=new Vo(v,g.stride);return b.uuid=g.uuid,t[A]=b,b}function s(u,A){if(i[A]!==void 0)return i[A];const g=u.arrayBuffers[A],f=new Uint32Array(g).buffer;return i[A]=f,f}const a=e.isInstancedBufferGeometry?new zb:new ot,o=e.data.index;if(o!==void 0){const u=Po(o.type,o.array);a.setIndex(new St(u,1))}const l=e.data.attributes;for(const u in l){const A=l[u];let m;if(A.isInterleavedBufferAttribute){const g=n(e.data,A.data);m=new Vs(g,A.itemSize,A.offset,A.normalized)}else{const g=Po(A.type,A.array),f=A.isInstancedBufferAttribute?Pr:St;m=new f(g,A.itemSize,A.normalized)}A.name!==void 0&&(m.name=A.name),A.usage!==void 0&&m.setUsage(A.usage),a.setAttribute(u,m)}const c=e.data.morphAttributes;if(c)for(const u in c){const A=c[u],m=[];for(let g=0,f=A.length;g<f;g++){const v=A[g];let b;if(v.isInterleavedBufferAttribute){const y=n(e.data,v.data);b=new Vs(y,v.itemSize,v.offset,v.normalized)}else{const y=Po(v.type,v.array);b=new St(y,v.itemSize,v.normalized)}v.name!==void 0&&(b.name=v.name),m.push(b)}a.morphAttributes[u]=m}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);const d=e.data.groups||e.data.drawcalls||e.data.offsets;if(d!==void 0)for(let u=0,A=d.length;u!==A;++u){const m=d[u];a.addGroup(m.start,m.count,m.materialIndex)}const p=e.data.boundingSphere;return p!==void 0&&(a.boundingSphere=new Gi().fromJSON(p)),e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class uC extends Qi{constructor(e){super(e)}load(e,t,i,n){const s=this,a=this.path===""?Ur.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const o=new Yi(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){let c=null;try{c=JSON.parse(l)}catch(d){n!==void 0&&n(d),d("ObjectLoader: Can't parse "+e+".",d.message);return}const h=c.metadata;if(h===void 0||h.type===void 0||h.type.toLowerCase()==="geometry"){n!==void 0&&n(new Error("THREE.ObjectLoader: Can't load "+e)),ct("ObjectLoader: Can't load "+e);return}s.parse(c,t)},i,n)}async loadAsync(e,t){const i=this,n=this.path===""?Ur.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||n;const s=new Yi(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const a=await s.loadAsync(e,t);let o;try{o=JSON.parse(a)}catch(c){throw new Error("ObjectLoader: Can't parse "+e+". "+c.message)}const l=o.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(o)}parse(e,t){const i=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,n),a=this.parseImages(e.images,function(){t!==void 0&&t(c)}),o=this.parseTextures(e.textures,a),l=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,s,l,o,i),h=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,h),this.bindLightTargets(c),t!==void 0){let d=!1;for(const p in a)if(a[p].data instanceof HTMLImageElement){d=!0;break}d===!1&&t(c)}return c}async parseAsync(e){const t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),n=this.parseGeometries(e.geometries,i),s=await this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,s),o=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,n,o,a,t),c=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,c),this.bindLightTargets(l),l}parseShapes(e){const t={};if(e!==void 0)for(let i=0,n=e.length;i<n;i++){const s=new Ws().fromJSON(e[i]);t[s.uuid]=s}return t}parseSkeletons(e,t){const i={},n={};if(t.traverse(function(s){s.isBone&&(n[s.uuid]=s)}),e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=new Dc().fromJSON(e[s],n);i[o.uuid]=o}return i}parseGeometries(e,t){const i={};if(e!==void 0){const n=new Hb;for(let s=0,a=e.length;s<a;s++){let o;const l=e[s];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":o=n.parse(l);break;default:l.type in vb?o=vb[l.type].fromJSON(l,t):Ye(`ObjectLoader: Unsupported geometry type "${l.type}"`)}o.uuid=l.uuid,l.name!==void 0&&(o.name=l.name),l.userData!==void 0&&(o.userData=l.userData),i[l.uuid]=o}}return i}parseMaterials(e,t){const i={},n={};if(e!==void 0){const s=new Ou;s.setTextures(t);for(let a=0,o=e.length;a<o;a++){const l=e[a];i[l.uuid]===void 0&&(i[l.uuid]=s.parse(l)),n[l.uuid]=i[l.uuid]}}return n}parseAnimations(e){const t={};if(e!==void 0)for(let i=0;i<e.length;i++){const n=e[i],s=el.parse(n);t[s.uuid]=s}return t}parseImages(e,t){const i=this,n={};let s;function a(l){return i.manager.itemStart(l),s.load(l,function(){i.manager.itemEnd(l)},void 0,function(){i.manager.itemError(l),i.manager.itemEnd(l)})}function o(l){if(typeof l=="string"){const c=l,h=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:i.resourcePath+c;return a(h)}else return l.data?{data:Po(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new Rm(t);s=new Xc(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,h=e.length;c<h;c++){const d=e[c],p=d.url;if(Array.isArray(p)){const u=[];for(let A=0,m=p.length;A<m;A++){const g=p[A],f=o(g);f!==null&&(f instanceof HTMLImageElement?u.push(f):u.push(new dn(f.data,f.width,f.height)))}n[d.uuid]=new Er(u)}else{const u=o(d.url);n[d.uuid]=new Er(u)}}}return n}async parseImagesAsync(e){const t=this,i={};let n;async function s(a){if(typeof a=="string"){const o=a,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(o)?o:t.resourcePath+o;return await n.loadAsync(l)}else return a.data?{data:Po(a.type,a.data),width:a.width,height:a.height}:null}if(e!==void 0&&e.length>0){n=new Xc(this.manager),n.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a<o;a++){const l=e[a],c=l.url;if(Array.isArray(c)){const h=[];for(let d=0,p=c.length;d<p;d++){const u=c[d],A=await s(u);A!==null&&(A instanceof HTMLImageElement?h.push(A):h.push(new dn(A.data,A.width,A.height)))}i[l.uuid]=new Er(h)}else{const h=await s(l.url);i[l.uuid]=new Er(h)}}}return i}parseTextures(e,t){function i(s,a){return typeof s=="number"?s:(Ye("ObjectLoader.parseTexture: Constant should be in numeric form.",s),a[s])}const n={};if(e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=e[s];o.image===void 0&&Ye('ObjectLoader: No "image" specified for',o.uuid),t[o.image]===void 0&&Ye("ObjectLoader: Undefined image",o.image);const l=t[o.image],c=l.data;let h;Array.isArray(c)?(h=new Uc,c.length===6&&(h.needsUpdate=!0)):(c&&c.data?h=new dn:h=new ii,c&&(h.needsUpdate=!0)),h.source=l,h.uuid=o.uuid,o.name!==void 0&&(h.name=o.name),o.mapping!==void 0&&(h.mapping=i(o.mapping,pC)),o.channel!==void 0&&(h.channel=o.channel),o.offset!==void 0&&h.offset.fromArray(o.offset),o.repeat!==void 0&&h.repeat.fromArray(o.repeat),o.center!==void 0&&h.center.fromArray(o.center),o.rotation!==void 0&&(h.rotation=o.rotation),o.wrap!==void 0&&(h.wrapS=i(o.wrap[0],Gb),h.wrapT=i(o.wrap[1],Gb)),o.format!==void 0&&(h.format=o.format),o.internalFormat!==void 0&&(h.internalFormat=o.internalFormat),o.type!==void 0&&(h.type=o.type),o.colorSpace!==void 0&&(h.colorSpace=o.colorSpace),o.minFilter!==void 0&&(h.minFilter=i(o.minFilter,Vb)),o.magFilter!==void 0&&(h.magFilter=i(o.magFilter,Vb)),o.anisotropy!==void 0&&(h.anisotropy=o.anisotropy),o.flipY!==void 0&&(h.flipY=o.flipY),o.generateMipmaps!==void 0&&(h.generateMipmaps=o.generateMipmaps),o.premultiplyAlpha!==void 0&&(h.premultiplyAlpha=o.premultiplyAlpha),o.unpackAlignment!==void 0&&(h.unpackAlignment=o.unpackAlignment),o.compareFunction!==void 0&&(h.compareFunction=o.compareFunction),o.userData!==void 0&&(h.userData=o.userData),n[o.uuid]=h}return n}parseObject(e,t,i,n,s){let a;function o(p){return t[p]===void 0&&Ye("ObjectLoader: Undefined geometry",p),t[p]}function l(p){if(p!==void 0){if(Array.isArray(p)){const u=[];for(let A=0,m=p.length;A<m;A++){const g=p[A];i[g]===void 0&&Ye("ObjectLoader: Undefined material",g),u.push(i[g])}return u}return i[p]===void 0&&Ye("ObjectLoader: Undefined material",p),i[p]}}function c(p){return n[p]===void 0&&Ye("ObjectLoader: Undefined texture",p),n[p]}let h,d;switch(e.type){case"Scene":a=new ga,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new We(e.background):a.background=c(e.background)),e.environment!==void 0&&(a.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?a.fog=new Fd(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new Ud(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 pi(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 Ki(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 il(e.color,e.intensity);break;case"DirectionalLight":a=new Nr(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new km(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new Fb(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 Bb(e.color,e.groundColor,e.intensity);break;case"LightProbe":const p=new Nm().fromArray(e.sh);a=new Ob(p,e.intensity);break;case"SkinnedMesh":h=o(e.geometry),d=l(e.material),a=new sm(h,d),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":h=o(e.geometry),d=l(e.material),a=new Ge(h,d);break;case"InstancedMesh":h=o(e.geometry),d=l(e.material);const u=e.count,A=e.instanceMatrix,m=e.instanceColor;a=new ni(h,d,u),a.instanceMatrix=new Pr(new Float32Array(A.array),16),m!==void 0&&(a.instanceColor=new Pr(new Float32Array(m.array),m.itemSize));break;case"BatchedMesh":h=o(e.geometry),d=l(e.material),a=new Qv(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,d),a.geometry=h,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._geometryInfo=e.geometryInfo.map(g=>{let f=null,v=null;return g.boundingBox!==void 0&&(f=new Ft().fromJSON(g.boundingBox)),g.boundingSphere!==void 0&&(v=new Gi().fromJSON(g.boundingSphere)),{...g,boundingBox:f,boundingSphere:v}}),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=c(e.matricesTexture.uuid),a._indirectTexture=c(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=c(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(a.boundingSphere=new Gi().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(a.boundingBox=new Ft().fromJSON(e.boundingBox));break;case"LOD":a=new Pv;break;case"Line":a=new di(o(e.geometry),l(e.material));break;case"LineLoop":a=new cm(o(e.geometry),l(e.material));break;case"LineSegments":a=new vi(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":a=new Au(o(e.geometry),l(e.material));break;case"Sprite":a=new Rc(l(e.material));break;case"Group":a=new Mi;break;case"Bone":a=new su;break;default:a=new Mt}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.pivot!==void 0&&(a.pivot=new T().fromArray(e.pivot)),e.morphTargetDictionary!==void 0&&(a.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),e.morphTargetInfluences!==void 0&&(a.morphTargetInfluences=e.morphTargetInfluences.slice()),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.static!==void 0&&(a.static=e.static),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const p=e.children;for(let u=0;u<p.length;u++)a.add(this.parseObject(p[u],t,i,n,s))}if(e.animations!==void 0){const p=e.animations;for(let u=0;u<p.length;u++){const A=p[u];a.animations.push(s[A])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);const p=e.levels;for(let u=0;u<p.length;u++){const A=p[u],m=a.getObjectByProperty("uuid",A.object);m!==void 0&&a.addLevel(m,A.distance,A.hysteresis)}}return a}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){const n=t[i.skeleton];n===void 0?Ye("ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(n,i.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const i=t.target,n=e.getObjectByProperty("uuid",i);n!==void 0?t.target=n:t.target=new Mt}})}}const pC={UVMapping:ad,CubeReflectionMapping:ys,CubeRefractionMapping:gr,EquirectangularReflectionMapping:bo,EquirectangularRefractionMapping:Zl,CubeUVReflectionMapping:yo},Gb={RepeatWrapping:Ji,ClampToEdgeWrapping:ln,MirroredRepeatWrapping:xo},Vb={NearestFilter:Ht,NearestMipmapNearestFilter:Jl,NearestMipmapLinearFilter:aa,LinearFilter:_t,LinearMipmapNearestFilter:_o,LinearMipmapLinearFilter:An},Um=new WeakMap;class Qb extends Qi{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&Ye("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Ye("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=Ss.get(`image-bitmap:${e}`);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{if(Um.has(a)===!0)n&&n(Um.get(a)),s.manager.itemError(e),s.manager.itemEnd(e);else return t&&t(c),s.manager.itemEnd(e),c});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return Ss.add(`image-bitmap:${e}`,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){n&&n(c),Um.set(l,c),Ss.remove(`image-bitmap:${e}`),s.manager.itemError(e),s.manager.itemEnd(e)});Ss.add(`image-bitmap:${e}`,l),s.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let zu;class Fm{static getContext(){return zu===void 0&&(zu=new(window.AudioContext||window.webkitAudioContext)),zu}static setContext(e){zu=e}}class fC extends Qi{constructor(e){super(e)}load(e,t,i,n){const s=this,a=new Yi(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{const c=l.slice(0);Fm.getContext().decodeAudioData(c,function(d){t(d)}).catch(o)}catch(c){o(c)}},i,n);function o(l){n?n(l):ct(l),s.manager.itemError(e)}}}const Wb=new Ke,jb=new Ke,Ba=new Ke;class mC{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new pi,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new pi,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,Ba.copy(e.projectionMatrix);const n=t.eyeSep/2,s=n*t.near/t.focus,a=t.near*Math.tan(ma*t.fov*.5)/t.zoom;let o,l;jb.elements[12]=-n,Wb.elements[12]=n,o=-a*t.aspect+s,l=a*t.aspect+s,Ba.elements[0]=2*t.near/(l-o),Ba.elements[8]=(l+o)/(l-o),this.cameraL.projectionMatrix.copy(Ba),o=-a*t.aspect-s,l=a*t.aspect-s,Ba.elements[0]=2*t.near/(l-o),Ba.elements[8]=(l+o)/(l-o),this.cameraR.projectionMatrix.copy(Ba)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(jb),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Wb)}}const nl=-90,sl=1;class qb extends Mt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new pi(nl,sl,e,t);n.layers=this.layers,this.add(n);const s=new pi(nl,sl,e,t);s.layers=this.layers,this.add(s);const a=new pi(nl,sl,e,t);a.layers=this.layers,this.add(a);const o=new pi(nl,sl,e,t);o.layers=this.layers,this.add(o);const l=new pi(nl,sl,e,t);l.layers=this.layers,this.add(l);const c=new pi(nl,sl,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,n,s,a,o,l]=t;for(const c of t)this.remove(c);if(e===Pn)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===fa)i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:n}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,h]=this.children,d=e.getRenderTarget(),p=e.getActiveCubeFace(),u=e.getActiveMipmapLevel(),A=e.xr.enabled;e.xr.enabled=!1;const m=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let g=!1;e.isWebGLRenderer===!0?g=e.state.buffers.depth.getReversed():g=e.reversedDepthBuffer,e.setRenderTarget(i,0,n),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(i,1,n),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,2,n),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,n),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(i,4,n),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),i.texture.generateMipmaps=m,e.setRenderTarget(i,5,n),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(d,p,u),e.xr.enabled=A,i.texture.needsPMREMUpdate=!0}}class Xb extends pi{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Om{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=gC.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 gC(){this._document.hidden===!1&&this.reset()}const La=new T,zm=new Tt,AC=new T,ka=new T,Na=new T;class vC extends Mt{constructor(){super(),this.type="AudioListener",this.context=Fm.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._timer=new Om}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),this._timer.update();const t=this.context.listener;if(this.timeDelta=this._timer.getDelta(),this.matrixWorld.decompose(La,zm,AC),ka.set(0,0,-1).applyQuaternion(zm),Na.set(0,1,0).applyQuaternion(zm),t.positionX){const i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(La.x,i),t.positionY.linearRampToValueAtTime(La.y,i),t.positionZ.linearRampToValueAtTime(La.z,i),t.forwardX.linearRampToValueAtTime(ka.x,i),t.forwardY.linearRampToValueAtTime(ka.y,i),t.forwardZ.linearRampToValueAtTime(ka.z,i),t.upX.linearRampToValueAtTime(Na.x,i),t.upY.linearRampToValueAtTime(Na.y,i),t.upZ.linearRampToValueAtTime(Na.z,i)}else t.setPosition(La.x,La.y,La.z),t.setOrientation(ka.x,ka.y,ka.z,Na.x,Na.y,Na.z)}}class Yb extends Mt{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){Ye("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){Ye("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){Ye("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){Ye("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){Ye("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?(Ye("Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){Ye("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"?(Ye("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 Ua=new T,Kb=new Tt,bC=new T,Fa=new T;class yC extends Yb{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,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Ua,Kb,bC),Fa.set(0,0,1).applyQuaternion(Kb);const t=this.panner;if(t.positionX){const i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Ua.x,i),t.positionY.linearRampToValueAtTime(Ua.y,i),t.positionZ.linearRampToValueAtTime(Ua.z,i),t.orientationX.linearRampToValueAtTime(Fa.x,i),t.orientationY.linearRampToValueAtTime(Fa.y,i),t.orientationZ.linearRampToValueAtTime(Fa.z,i)}else t.setPosition(Ua.x,Ua.y,Ua.z),t.setOrientation(Fa.x,Fa.y,Fa.z)}}class xC{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 i=0;i<t.length;i++)e+=t[i];return e/t.length}}class Zb{constructor(e,t,i){this.binding=e,this.valueSize=i;let n,s,a;switch(t){case"quaternion":n=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":n=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:n=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=s,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 i=this.buffer,n=this.valueSize,s=e*n+n;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==n;++o)i[s+o]=i[o];a=t}else{a+=t;const o=t/a;this._mixBufferRegion(i,s,0,o,n)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,i=this.valueSize,n=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,n,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,i=this.buffer,n=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=t*this._origIndex;this._mixBufferRegion(i,n,l,1-s,t)}a>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(i[l]!==i[l+t]){o.setValue(i,n);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,n=i*this._origIndex;e.getValue(t,n);for(let s=i,a=n;s!==a;++s)t[s]=t[n+s%i];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 i=e;i<t;i++)this.buffer[i]=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 i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,n,s){if(n>=.5)for(let a=0;a!==s;++a)e[t+a]=e[i+a]}_slerp(e,t,i,n){Tt.slerpFlat(e,t,e,t,e,i,n)}_slerpAdditive(e,t,i,n,s){const a=this._workIndex*s;Tt.multiplyQuaternionsFlat(e,a,e,t,e,i),Tt.slerpFlat(e,t,e,t,e,a,n)}_lerp(e,t,i,n,s){const a=1-n;for(let o=0;o!==s;++o){const l=t+o;e[l]=e[l]*a+e[i+o]*n}}_lerpAdditive(e,t,i,n,s){for(let a=0;a!==s;++a){const o=t+a;e[o]=e[o]+e[i+a]*n}}}const Hm="\\[\\]\\.:\\/",_C=new RegExp("["+Hm+"]","g"),Gm="[^"+Hm+"]",EC="[^"+Hm.replace("\\.","")+"]",MC=/((?:WC+[\/:])*)/.source.replace("WC",Gm),wC=/(WCOD+)?/.source.replace("WCOD",EC),SC=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Gm),CC=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Gm),TC=new RegExp("^"+MC+wC+SC+CC+"$"),IC=["material","materials","bones","map"];class PC{constructor(e,t,i){const n=i||Lt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];n!==void 0&&n.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,s=i.length;n!==s;++n)i[n].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class Lt{constructor(e,t,i){this.path=t,this.parsedPath=i||Lt.parseTrackName(t),this.node=Lt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Lt.Composite(e,t,i):new Lt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(_C,"")}static parseTrackName(e){const t=TC.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const s=i.nodeName.substring(n+1);IC.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(s){for(let a=0;a<s.length;a++){const o=s[a];if(o.name===t||o.uuid===t)return o;const l=i(o.children);if(l)return l}return null},n=i(e.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)e[t++]=i[n]}_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 i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=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,i=t.objectName,n=t.propertyName;let s=t.propertyIndex;if(e||(e=Lt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ye("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let c=t.objectIndex;switch(i){case"materials":if(!e.material){ct("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){ct("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){ct("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===c){c=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){ct("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){ct("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[i]===void 0){ct("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(c!==void 0){if(e[c]===void 0){ct("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[n];if(a===void 0){const c=t.nodeName;ct("PropertyBinding: Trying to update property for track: "+c+"."+n+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(n==="morphTargetInfluences"){if(!e.geometry){ct("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){ct("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=n;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Lt.Composite=PC,Lt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Lt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Lt.prototype.GetterByBindingType=[Lt.prototype._getValue_direct,Lt.prototype._getValue_array,Lt.prototype._getValue_arrayElement,Lt.prototype._getValue_toArray],Lt.prototype.SetterByBindingTypeAndVersioning=[[Lt.prototype._setValue_direct,Lt.prototype._setValue_direct_setNeedsUpdate,Lt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Lt.prototype._setValue_array,Lt.prototype._setValue_array_setNeedsUpdate,Lt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Lt.prototype._setValue_arrayElement,Lt.prototype._setValue_arrayElement_setNeedsUpdate,Lt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Lt.prototype._setValue_fromArray,Lt.prototype._setValue_fromArray_setNeedsUpdate,Lt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class RC{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Rn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let i=0,n=arguments.length;i!==n;++i)e[arguments[i].uuid]=i;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,i=this._paths,n=this._parsedPaths,s=this._bindings,a=s.length;let o,l=e.length,c=this.nCachedObjects_;for(let h=0,d=arguments.length;h!==d;++h){const p=arguments[h],u=p.uuid;let A=t[u];if(A===void 0){A=l++,t[u]=A,e.push(p);for(let m=0,g=a;m!==g;++m)s[m].push(new Lt(p,i[m],n[m]))}else if(A<c){o=e[A];const m=--c,g=e[m];t[g.uuid]=A,e[A]=g,t[u]=m,e[m]=p;for(let f=0,v=a;f!==v;++f){const b=s[f],y=b[m];let M=b[A];b[A]=y,M===void 0&&(M=new Lt(p,i[f],n[f])),b[m]=M}}else e[A]!==o&&ct("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length;let s=this.nCachedObjects_;for(let a=0,o=arguments.length;a!==o;++a){const l=arguments[a],c=l.uuid,h=t[c];if(h!==void 0&&h>=s){const d=s++,p=e[d];t[p.uuid]=h,e[h]=p,t[c]=d,e[d]=l;for(let u=0,A=n;u!==A;++u){const m=i[u],g=m[d],f=m[h];m[h]=g,m[d]=f}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length;let s=this.nCachedObjects_,a=e.length;for(let o=0,l=arguments.length;o!==l;++o){const c=arguments[o],h=c.uuid,d=t[h];if(d!==void 0)if(delete t[h],d<s){const p=--s,u=e[p],A=--a,m=e[A];t[u.uuid]=d,e[d]=u,t[m.uuid]=p,e[p]=m,e.pop();for(let g=0,f=n;g!==f;++g){const v=i[g],b=v[p],y=v[A];v[d]=b,v[p]=y,v.pop()}}else{const p=--a,u=e[p];p>0&&(t[u.uuid]=d),e[d]=u,e.pop();for(let A=0,m=n;A!==m;++A){const g=i[A];g[d]=g[p],g.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const i=this._bindingsIndicesByPath;let n=i[e];const s=this._bindings;if(n!==void 0)return s[n];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,h=this.nCachedObjects_,d=new Array(c);n=s.length,i[e]=n,a.push(e),o.push(t),s.push(d);for(let p=h,u=l.length;p!==u;++p){const A=l[p];d[p]=new Lt(A,e,t)}return d}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const n=this._paths,s=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=e[o];t[c]=i,a[i]=l,a.pop(),s[i]=s[o],s.pop(),n[i]=n[o],n.pop()}}}class Jb{constructor(e,t,i=null,n=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=n;const s=t.tracks,a=s.length,o=new Array(a),l={endingStart:da,endingEnd:da};for(let c=0;c!==a;++c){const h=s[c].createInterpolant(null);o[c]=h,h.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=ZA,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,i=!1){if(e.fadeOut(t),this.fadeIn(t),i===!0){const n=this._clip.duration,s=e._clip.duration,a=s/n,o=n/s;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,i=!1){return e.crossFadeFrom(this,t,i)}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,i){const n=this._mixer,s=n.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=n._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+i,c[0]=e/a,c[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,i,n){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const l=(e-s)*i;l<0||i===0?t=0:(this._startTime=null,t=i*l)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Cf:for(let h=0,d=l.length;h!==d;++h)l[h].evaluate(a),c[h].accumulateAdditive(o);break;case Cd:default:for(let h=0,d=l.length;h!==d;++h)l[h].evaluate(a),c[h].accumulate(n,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const n=i.evaluate(e)[0];t*=n,e>i.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const n=i.evaluate(e)[0];t*=n,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let n=this.time+e,s=this._loopCount;const a=i===JA;if(e===0)return s===-1?n:a&&(s&1)===1?t-n:n;if(i===KA){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=t)n=t;else if(n<0)n=0;else{this.time=n;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),n>=t||n<0){const o=Math.floor(n/t);n-=t*o,s+=Math.abs(o);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?t:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=n;if(a&&(s&1)===1)return t-n}return n}_setEndings(e,t,i){const n=this._interpolantSettings;i?(n.endingStart=ua,n.endingEnd=ua):(e?n.endingStart=this.zeroSlopeAtStart?ua:da:n.endingStart=fc,t?n.endingEnd=this.zeroSlopeAtEnd?ua:da:n.endingEnd=fc)}_scheduleFading(e,t,i){const n=this._mixer,s=n.time;let a=this._weightInterpolant;a===null&&(a=n._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=t,o[1]=s+e,l[1]=i,this}}const DC=new Float32Array(1);class BC extends is{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){const i=e._localRoot||this._root,n=e._clip.tracks,s=n.length,a=e._propertyBindings,o=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName;let h=c[l];h===void 0&&(h={},c[l]=h);for(let d=0;d!==s;++d){const p=n[d],u=p.name;let A=h[u];if(A!==void 0)++A.referenceCount,a[d]=A;else{if(A=a[d],A!==void 0){A._cacheIndex===null&&(++A.referenceCount,this._addInactiveBinding(A,l,u));continue}const m=t&&t._propertyBindings[d].binding.parsedPath;A=new Zb(Lt.create(i,u,m),p.ValueTypeName,p.getValueSize()),++A.referenceCount,this._addInactiveBinding(A,l,u),a[d]=A}o[d].resultBuffer=A.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,n=e._clip.uuid,s=this._actionsByClip[n];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,n,i)}const t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){const s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){const s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){const n=this._actions,s=this._actionsByClip;let a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{const o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=n.length,n.push(e),a.actionByRoot[i]=e}_removeInactiveAction(e){const t=this._actions,i=t[t.length-1],n=e._cacheIndex;i._cacheIndex=n,t[n]=i,t.pop(),e._cacheIndex=null;const s=e._clip.uuid,a=this._actionsByClip,o=a[s],l=o.knownActions,c=l[l.length-1],h=e._byClipCacheIndex;c._byClipCacheIndex=h,l[h]=c,l.pop(),e._byClipCacheIndex=null;const d=o.actionByRoot,p=(e._localRoot||this._root).uuid;delete d[p],l.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){const s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,n=this._nActiveActions++,s=t[n];e._cacheIndex=n,t[n]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,n=--this._nActiveActions,s=t[n];e._cacheIndex=n,t[n]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){const n=this._bindingsByRootAndName,s=this._bindings;let a=n[t];a===void 0&&(a={},n[t]=a),a[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,n=i.rootNode.uuid,s=i.path,a=this._bindingsByRootAndName,o=a[n],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete o[s],Object.keys(o).length===0&&delete a[n]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,n=this._nActiveBindings++,s=t[n];e._cacheIndex=n,t[n]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,n=--this._nActiveBindings,s=t[n];e._cacheIndex=n,t[n]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return i===void 0&&(i=new Im(new Float32Array(2),new Float32Array(2),1,DC),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,n=--this._nActiveControlInterpolants,s=t[n];e.__cacheIndex=n,t[n]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){const n=t||this._root,s=n.uuid;let a=typeof e=="string"?el.findByName(n,e):e;const o=a!==null?a.uuid:e,l=this._actionsByClip[o];let c=null;if(i===void 0&&(a!==null?i=a.blendMode:i=Cd),l!==void 0){const d=l.actionByRoot[s];if(d!==void 0&&d.blendMode===i)return d;c=l.knownActions[0],a===null&&(a=c._clip)}if(a===null)return null;const h=new Jb(this,a,t,i);return this._bindAction(h,c),this._addInactiveAction(h,o,s),h}existingAction(e,t){const i=t||this._root,n=i.uuid,s=typeof e=="string"?el.findByName(i,e):e,a=s?s.uuid:e,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[n]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,n=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(n,e,s,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].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,i=e.uuid,n=this._actionsByClip,s=n[i];if(s!==void 0){const a=s.knownActions;for(let o=0,l=a.length;o!==l;++o){const c=a[o];this._deactivateAction(c);const h=c._cacheIndex,d=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,d._cacheIndex=h,t[h]=d,t.pop(),this._removeInactiveBindingsForAction(c)}delete n[i]}}uncacheRoot(e){const t=e.uuid,i=this._actionsByClip;for(const a in i){const o=i[a].actionByRoot,l=o[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const n=this._bindingsByRootAndName,s=n[t];if(s!==void 0)for(const a in s){const o=s[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}class LC extends Nf{constructor(e=1,t=1,i=1,n={}){super(e,t,n),this.isRenderTarget3D=!0,this.depth=i,this.texture=new xc(null,e,t,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}}class Vm{constructor(e){this.value=e}clone(){return new Vm(this.value.clone===void 0?this.value:this.value.clone())}}let kC=0;class NC extends is{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:kC++}),this.name="",this.usage=gc,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 i=0,n=t.length;i<n;i++){const s=Array.isArray(t[i])?t[i]:[t[i]];for(let a=0;a<s.length;a++)this.uniforms.push(s[a].clone())}return this}clone(){return new this.constructor().copy(this)}}class UC extends Vo{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}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 FC{constructor(e,t,i,n,s,a=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=n,this.count=s,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 $b=new Ke;class Ln{constructor(e,t,i=0,n=1/0){this.ray=new Ir(e,t),this.near=i,this.far=n,this.camera=null,this.layers=new Bd,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):ct("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return $b.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4($b),this}intersectObject(e,t=!0,i=[]){return Qm(e,this,i,t),i.sort(e1),i}intersectObjects(e,t=!0,i=[]){for(let n=0,s=e.length;n<s;n++)Qm(e[n],this,i,t);return i.sort(e1),i}}function e1(r,e){return r.distance-e.distance}function Qm(r,e,t,i){let n=!0;if(r.layers.test(e.layers)&&r.raycast(e,t)===!1&&(n=!1),n===!0&&i===!0){const s=r.children;for(let a=0,o=s.length;a<o;a++)Qm(s[a],e,t,!0)}}class t1{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1,Ye("THREE.Clock: This module has been deprecated. Please use THREE.Timer instead.")}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}}class rl{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=dt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(dt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class OC{constructor(e=1,t=0,i=0){this.radius=e,this.theta=t,this.y=i}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,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,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}}class Wm{constructor(e,t,i,n){Wm.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,n)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,n){const s=this.elements;return s[0]=e,s[2]=t,s[1]=i,s[3]=n,this}}const i1=new be;class zC{constructor(e=new be(1/0,1/0),t=new be(-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,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=i1.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),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,i1).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 n1=new T,Hu=new T,al=new T,ol=new T,jm=new T,HC=new T,GC=new T;class VC{constructor(e=new T,t=new T){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){n1.subVectors(e,this.start),Hu.subVectors(this.end,this.start);const i=Hu.dot(Hu);let s=Hu.dot(n1)/i;return t&&(s=dt(s,0,1)),s}closestPointToPoint(e,t,i){const n=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(n).add(this.start)}distanceSqToLine3(e,t=HC,i=GC){const n=10000000000000001e-32;let s,a;const o=this.start,l=e.start,c=this.end,h=e.end;al.subVectors(c,o),ol.subVectors(h,l),jm.subVectors(o,l);const d=al.dot(al),p=ol.dot(ol),u=ol.dot(jm);if(d<=n&&p<=n)return t.copy(o),i.copy(l),t.sub(i),t.dot(t);if(d<=n)s=0,a=u/p,a=dt(a,0,1);else{const A=al.dot(jm);if(p<=n)a=0,s=dt(-A/d,0,1);else{const m=al.dot(ol),g=d*p-m*m;g!==0?s=dt((m*u-A*p)/g,0,1):s=0,a=(m*s+u)/p,a<0?(a=0,s=dt(-A/d,0,1)):a>1&&(a=1,s=dt((m-A)/d,0,1))}}return t.copy(o).addScaledVector(al,s),i.copy(l).addScaledVector(ol,a),t.distanceToSquared(i)}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 s1=new T;class QC extends Mt{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new ot,n=[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,o=1,l=32;a<l;a++,o++){const c=a/l*Math.PI*2,h=o/l*Math.PI*2;n.push(Math.cos(c),Math.sin(c),1,Math.cos(h),Math.sin(h),1)}i.setAttribute("position",new tt(n,3));const s=new si({fog:!1,toneMapped:!1});this.cone=new vi(i,s),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),s1.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(s1),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Fr=new T,Gu=new Ke,qm=new Ke;class WC extends vi{constructor(e){const t=r1(e),i=new ot,n=[],s=[];for(let c=0;c<t.length;c++){const h=t[c];h.parent&&h.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),s.push(0,0,0),s.push(0,0,0))}i.setAttribute("position",new tt(n,3)),i.setAttribute("color",new tt(s,3));const a=new si({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,a),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1;const o=new We(255),l=new We(65280);this.setColors(o,l)}updateMatrixWorld(e){const t=this.bones,i=this.geometry,n=i.getAttribute("position");qm.copy(this.root.matrixWorld).invert();for(let s=0,a=0;s<t.length;s++){const o=t[s];o.parent&&o.parent.isBone&&(Gu.multiplyMatrices(qm,o.matrixWorld),Fr.setFromMatrixPosition(Gu),n.setXYZ(a,Fr.x,Fr.y,Fr.z),Gu.multiplyMatrices(qm,o.parent.matrixWorld),Fr.setFromMatrixPosition(Gu),n.setXYZ(a+1,Fr.x,Fr.y,Fr.z),a+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}setColors(e,t){const n=this.geometry.getAttribute("color");for(let s=0;s<n.count;s+=2)n.setXYZ(s,e.r,e.g,e.b),n.setXYZ(s+1,t.r,t.g,t.b);return n.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}function r1(r){const e=[];r.isBone===!0&&e.push(r);for(let t=0;t<r.children.length;t++)e.push(...r1(r.children[t]));return e}class jC extends Ge{constructor(e,t,i){const n=new Br(t,4,2),s=new Rt({wireframe:!0,fog:!1,toneMapped:!1});super(n,s),this.light=e,this.color=i,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 qC=new T,a1=new We,o1=new We;class XC extends Mt{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const n=new js(t);n.rotateY(Math.PI*.5),this.material=new Rt({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=n.getAttribute("position"),a=new Float32Array(s.count*3);n.setAttribute("color",new St(a,3)),this.add(new Ge(n,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");a1.copy(this.light.color),o1.copy(this.light.groundColor);for(let i=0,n=t.count;i<n;i++){const s=i<n/2?a1:o1;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(qC.setFromMatrixPosition(this.light.matrixWorld).negate())}}class YC extends vi{constructor(e=10,t=10,i=4473924,n=8947848){i=new We(i),n=new We(n);const s=t/2,a=e/t,o=e/2,l=[],c=[];for(let p=0,u=0,A=-o;p<=t;p++,A+=a){l.push(-o,0,A,o,0,A),l.push(A,0,-o,A,0,o);const m=p===s?i:n;m.toArray(c,u),u+=3,m.toArray(c,u),u+=3,m.toArray(c,u),u+=3,m.toArray(c,u),u+=3}const h=new ot;h.setAttribute("position",new tt(l,3)),h.setAttribute("color",new tt(c,3));const d=new si({vertexColors:!0,toneMapped:!1});super(h,d),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class KC extends vi{constructor(e=10,t=16,i=8,n=64,s=4473924,a=8947848){s=new We(s),a=new We(a);const o=[],l=[];if(t>1)for(let d=0;d<t;d++){const p=d/t*(Math.PI*2),u=Math.sin(p)*e,A=Math.cos(p)*e;o.push(0,0,0),o.push(u,0,A);const m=d&1?s:a;l.push(m.r,m.g,m.b),l.push(m.r,m.g,m.b)}for(let d=0;d<i;d++){const p=d&1?s:a,u=e-e/i*d;for(let A=0;A<n;A++){let m=A/n*(Math.PI*2),g=Math.sin(m)*u,f=Math.cos(m)*u;o.push(g,0,f),l.push(p.r,p.g,p.b),m=(A+1)/n*(Math.PI*2),g=Math.sin(m)*u,f=Math.cos(m)*u,o.push(g,0,f),l.push(p.r,p.g,p.b)}}const c=new ot;c.setAttribute("position",new tt(o,3)),c.setAttribute("color",new tt(l,3));const h=new si({vertexColors:!0,toneMapped:!1});super(c,h),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const l1=new T,Vu=new T,c1=new T;class ZC extends Mt{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let n=new ot;n.setAttribute("position",new tt([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const s=new si({fog:!1,toneMapped:!1});this.lightPlane=new di(n,s),this.add(this.lightPlane),n=new ot,n.setAttribute("position",new tt([0,0,0,0,0,1],3)),this.targetLine=new di(n,s),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),l1.setFromMatrixPosition(this.light.matrixWorld),Vu.setFromMatrixPosition(this.light.target.matrixWorld),c1.subVectors(Vu,l1),this.lightPlane.lookAt(Vu),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(Vu),this.targetLine.scale.z=c1.length()}}const Qu=new T,mi=new Fu;class JC extends vi{constructor(e){const t=new ot,i=new si({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],s=[],a={};o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4");function o(A,m){l(A),l(m)}function l(A){n.push(0,0,0),s.push(0,0,0),a[A]===void 0&&(a[A]=[]),a[A].push(n.length/3-1)}t.setAttribute("position",new tt(n,3)),t.setAttribute("color",new tt(s,3)),super(t,i),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 c=new We(16755200),h=new We(16711680),d=new We(43775),p=new We(16777215),u=new We(3355443);this.setColors(c,h,d,p,u)}setColors(e,t,i,n,s){const o=this.geometry.getAttribute("color");return o.setXYZ(0,e.r,e.g,e.b),o.setXYZ(1,e.r,e.g,e.b),o.setXYZ(2,e.r,e.g,e.b),o.setXYZ(3,e.r,e.g,e.b),o.setXYZ(4,e.r,e.g,e.b),o.setXYZ(5,e.r,e.g,e.b),o.setXYZ(6,e.r,e.g,e.b),o.setXYZ(7,e.r,e.g,e.b),o.setXYZ(8,e.r,e.g,e.b),o.setXYZ(9,e.r,e.g,e.b),o.setXYZ(10,e.r,e.g,e.b),o.setXYZ(11,e.r,e.g,e.b),o.setXYZ(12,e.r,e.g,e.b),o.setXYZ(13,e.r,e.g,e.b),o.setXYZ(14,e.r,e.g,e.b),o.setXYZ(15,e.r,e.g,e.b),o.setXYZ(16,e.r,e.g,e.b),o.setXYZ(17,e.r,e.g,e.b),o.setXYZ(18,e.r,e.g,e.b),o.setXYZ(19,e.r,e.g,e.b),o.setXYZ(20,e.r,e.g,e.b),o.setXYZ(21,e.r,e.g,e.b),o.setXYZ(22,e.r,e.g,e.b),o.setXYZ(23,e.r,e.g,e.b),o.setXYZ(24,t.r,t.g,t.b),o.setXYZ(25,t.r,t.g,t.b),o.setXYZ(26,t.r,t.g,t.b),o.setXYZ(27,t.r,t.g,t.b),o.setXYZ(28,t.r,t.g,t.b),o.setXYZ(29,t.r,t.g,t.b),o.setXYZ(30,t.r,t.g,t.b),o.setXYZ(31,t.r,t.g,t.b),o.setXYZ(32,i.r,i.g,i.b),o.setXYZ(33,i.r,i.g,i.b),o.setXYZ(34,i.r,i.g,i.b),o.setXYZ(35,i.r,i.g,i.b),o.setXYZ(36,i.r,i.g,i.b),o.setXYZ(37,i.r,i.g,i.b),o.setXYZ(38,n.r,n.g,n.b),o.setXYZ(39,n.r,n.g,n.b),o.setXYZ(40,s.r,s.g,s.b),o.setXYZ(41,s.r,s.g,s.b),o.setXYZ(42,s.r,s.g,s.b),o.setXYZ(43,s.r,s.g,s.b),o.setXYZ(44,s.r,s.g,s.b),o.setXYZ(45,s.r,s.g,s.b),o.setXYZ(46,s.r,s.g,s.b),o.setXYZ(47,s.r,s.g,s.b),o.setXYZ(48,s.r,s.g,s.b),o.setXYZ(49,s.r,s.g,s.b),o.needsUpdate=!0,this}update(){const e=this.geometry,t=this.pointMap,i=1,n=1;let s,a;if(mi.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)s=1,a=0;else if(this.camera.coordinateSystem===Pn)s=-1,a=1;else if(this.camera.coordinateSystem===fa)s=0,a=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);bi("c",t,e,mi,0,0,s),bi("t",t,e,mi,0,0,a),bi("n1",t,e,mi,-i,-n,s),bi("n2",t,e,mi,i,-n,s),bi("n3",t,e,mi,-i,n,s),bi("n4",t,e,mi,i,n,s),bi("f1",t,e,mi,-i,-n,a),bi("f2",t,e,mi,i,-n,a),bi("f3",t,e,mi,-i,n,a),bi("f4",t,e,mi,i,n,a),bi("u1",t,e,mi,i*.7,n*1.1,s),bi("u2",t,e,mi,-i*.7,n*1.1,s),bi("u3",t,e,mi,0,n*2,s),bi("cf1",t,e,mi,-i,0,a),bi("cf2",t,e,mi,i,0,a),bi("cf3",t,e,mi,0,-n,a),bi("cf4",t,e,mi,0,n,a),bi("cn1",t,e,mi,-i,0,s),bi("cn2",t,e,mi,i,0,s),bi("cn3",t,e,mi,0,-n,s),bi("cn4",t,e,mi,0,n,s),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function bi(r,e,t,i,n,s,a){Qu.set(n,s,a).unproject(i);const o=e[r];if(o!==void 0){const l=t.getAttribute("position");for(let c=0,h=o.length;c<h;c++)l.setXYZ(o[c],Qu.x,Qu.y,Qu.z)}}const Wu=new Ft;class $C extends vi{constructor(e,t=16776960){const i=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]),n=new Float32Array(24),s=new ot;s.setIndex(new St(i,1)),s.setAttribute("position",new St(n,3)),super(s,new si({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&Wu.setFromObject(this.object),Wu.isEmpty())return;const e=Wu.min,t=Wu.max,i=this.geometry.attributes.position,n=i.array;n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=e.x,n[4]=t.y,n[5]=t.z,n[6]=e.x,n[7]=e.y,n[8]=t.z,n[9]=t.x,n[10]=e.y,n[11]=t.z,n[12]=t.x,n[13]=t.y,n[14]=e.z,n[15]=e.x,n[16]=t.y,n[17]=e.z,n[18]=e.x,n[19]=e.y,n[20]=e.z,n[21]=t.x,n[22]=e.y,n[23]=e.z,i.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 e2 extends vi{constructor(e,t=16776960){const i=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]),n=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new ot;s.setIndex(new St(i,1)),s.setAttribute("position",new tt(n,3)),super(s,new si({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 t2 extends di{constructor(e,t=1,i=16776960){const n=i,s=[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 ot;a.setAttribute("position",new tt(s,3)),a.computeBoundingSphere(),super(a,new si({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new ot;l.setAttribute("position",new tt(o,3)),l.computeBoundingSphere(),this.add(new Ge(l,new Rt({color:n,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 h1=new T;let ju,Xm;class i2 extends Mt{constructor(e=new T(0,0,1),t=new T(0,0,0),i=1,n=16776960,s=i*.2,a=s*.2){super(),this.type="ArrowHelper",ju===void 0&&(ju=new ot,ju.setAttribute("position",new tt([0,0,0,0,1,0],3)),Xm=new Fc(.5,1,5,1),Xm.translate(0,-.5,0)),this.position.copy(t),this.line=new di(ju,new si({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ge(Xm,new Rt({color:n,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,s,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{h1.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(h1,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),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 d1 extends vi{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],n=new ot;n.setAttribute("position",new tt(t,3)),n.setAttribute("color",new tt(i,3));const s=new si({vertexColors:!0,toneMapped:!1});super(n,s),this.type="AxesHelper"}setColors(e,t,i){const n=new We,s=this.geometry.attributes.color.array;return n.set(e),n.toArray(s,0),n.toArray(s,3),n.set(t),n.toArray(s,6),n.toArray(s,9),n.set(i),n.toArray(s,12),n.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class u1{constructor(){this.type="ShapePath",this.color=new We,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Gc,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,n){return this.currentPath.quadraticCurveTo(e,t,i,n),this}bezierCurveTo(e,t,i,n,s,a){return this.currentPath.bezierCurveTo(e,t,i,n,s,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(f){const v=[];for(let b=0,y=f.length;b<y;b++){const M=f[b],_=new Ws;_.curves=M.curves,v.push(_)}return v}function i(f,v){const b=v.length;let y=!1;for(let M=b-1,_=0;_<b;M=_++){let S=v[M],w=v[_],E=w.x-S.x,I=w.y-S.y;if(Math.abs(I)>Number.EPSILON){if(I<0&&(S=v[_],E=-E,w=v[M],I=-I),f.y<S.y||f.y>w.y)continue;if(f.y===S.y){if(f.x===S.x)return!0}else{const B=I*(f.x-S.x)-E*(f.y-S.y);if(B===0)return!0;if(B<0)continue;y=!y}}else{if(f.y!==S.y)continue;if(w.x<=f.x&&f.x<=S.x||S.x<=f.x&&f.x<=w.x)return!0}}return y}const n=os.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,o,l;const c=[];if(s.length===1)return o=s[0],l=new Ws,l.curves=o.curves,c.push(l),c;let h=!n(s[0].getPoints());h=e?!h:h;const d=[],p=[];let u=[],A=0,m;p[A]=void 0,u[A]=[];for(let f=0,v=s.length;f<v;f++)o=s[f],m=o.getPoints(),a=n(m),a=e?!a:a,a?(!h&&p[A]&&A++,p[A]={s:new Ws,p:m},p[A].s.curves=o.curves,h&&A++,u[A]=[]):u[A].push({h:o,p:m[0]});if(!p[0])return t(s);if(p.length>1){let f=!1,v=0;for(let b=0,y=p.length;b<y;b++)d[b]=[];for(let b=0,y=p.length;b<y;b++){const M=u[b];for(let _=0;_<M.length;_++){const S=M[_];let w=!0;for(let E=0;E<p.length;E++)i(S.p,p[E].p)&&(b!==E&&v++,w?(w=!1,d[E].push(S)):f=!0);w&&d[b].push(S)}}v>0&&f===!1&&(u=d)}let g;for(let f=0,v=p.length;f<v;f++){l=p[f].s,c.push(l),g=u[f];for(let b=0,y=g.length;b<y;b++)l.holes.push(g[b].h)}return c}}class qu extends is{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){Ye("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function n2(r,e){const t=r.image&&r.image.width?r.image.width/r.image.height:1;return t>e?(r.repeat.x=1,r.repeat.y=t/e,r.offset.x=0,r.offset.y=(1-r.repeat.y)/2):(r.repeat.x=e/t,r.repeat.y=1,r.offset.x=(1-r.repeat.x)/2,r.offset.y=0),r}function s2(r,e){const t=r.image&&r.image.width?r.image.width/r.image.height:1;return t>e?(r.repeat.x=e/t,r.repeat.y=1,r.offset.x=(1-r.repeat.x)/2,r.offset.y=0):(r.repeat.x=1,r.repeat.y=t/e,r.offset.x=0,r.offset.y=(1-r.repeat.y)/2),r}function r2(r){return r.repeat.x=1,r.repeat.y=1,r.offset.x=0,r.offset.y=0,r}function Ym(r,e,t,i){const n=a2(i);switch(t){case wf:return r*e;case Es:return r*e/n.components*n.byteLength;case tc:return r*e/n.components*n.byteLength;case Qn:return r*e*2/n.components*n.byteLength;case hd:return r*e*2/n.components*n.byteLength;case Mo:return r*e*3/n.components*n.byteLength;case hi:return r*e*4/n.components*n.byteLength;case dd:return r*e*4/n.components*n.byteLength;case oa:case vr:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case ic:case br:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case ud:case wo:return Math.max(r,16)*Math.max(e,8)/4;case nc:case la:return Math.max(r,8)*Math.max(e,8)/2;case sc:case So:case rc:case ac:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case Co:case oc:case lc:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case yr:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case pd:return Math.floor((r+4)/5)*Math.floor((e+3)/4)*16;case fd:return Math.floor((r+4)/5)*Math.floor((e+4)/5)*16;case md:return Math.floor((r+5)/6)*Math.floor((e+4)/5)*16;case ca:return Math.floor((r+5)/6)*Math.floor((e+5)/6)*16;case gd:return Math.floor((r+7)/8)*Math.floor((e+4)/5)*16;case Ad:return Math.floor((r+7)/8)*Math.floor((e+5)/6)*16;case vd:return Math.floor((r+7)/8)*Math.floor((e+7)/8)*16;case bd:return Math.floor((r+9)/10)*Math.floor((e+4)/5)*16;case yd:return Math.floor((r+9)/10)*Math.floor((e+5)/6)*16;case xd:return Math.floor((r+9)/10)*Math.floor((e+7)/8)*16;case _d:return Math.floor((r+9)/10)*Math.floor((e+9)/10)*16;case Ed:return Math.floor((r+11)/12)*Math.floor((e+9)/10)*16;case Md:return Math.floor((r+11)/12)*Math.floor((e+11)/12)*16;case ha:case wd:case cc:return Math.ceil(r/4)*Math.ceil(e/4)*16;case hc:case dc:return Math.ceil(r/4)*Math.ceil(e/4)*8;case uc:case pc:return Math.ceil(r/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function a2(r){switch(r){case ut:case Ef:return{byteLength:1,components:1};case Eo:case Mf:case Zt:return{byteLength:2,components:1};case ld:case cd:return{byteLength:2,components:4};case Vn:case od:case oi:return{byteLength:4,components:1};case $l:case ec:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${r}.`)}class o2{static contain(e,t){return n2(e,t)}static cover(e,t){return s2(e,t)}static fill(e){return r2(e)}static getByteLength(e,t,i,n){return Ym(e,t,i,n)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Gh}})),typeof window<"u"&&(window.__THREE__?Ye("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Gh);function p1(){let r=null,e=!1,t=null,i=null;function n(s,a){t(s,a),i=r.requestAnimationFrame(n)}return{start:function(){e!==!0&&t!==null&&(i=r.requestAnimationFrame(n),e=!0)},stop:function(){r.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function l2(r){const e=new WeakMap;function t(o,l){const c=o.array,h=o.usage,d=c.byteLength,p=r.createBuffer();r.bindBuffer(l,p),r.bufferData(l,c,h),o.onUploadCallback();let u;if(c instanceof Float32Array)u=r.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)u=r.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?u=r.HALF_FLOAT:u=r.UNSIGNED_SHORT;else if(c instanceof Int16Array)u=r.SHORT;else if(c instanceof Uint32Array)u=r.UNSIGNED_INT;else if(c instanceof Int32Array)u=r.INT;else if(c instanceof Int8Array)u=r.BYTE;else if(c instanceof Uint8Array)u=r.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)u=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:p,type:u,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,c){const h=l.array,d=l.updateRanges;if(r.bindBuffer(c,o),d.length===0)r.bufferSubData(c,0,h);else{d.sort((u,A)=>u.start-A.start);let p=0;for(let u=1;u<d.length;u++){const A=d[p],m=d[u];m.start<=A.start+A.count+1?A.count=Math.max(A.count,m.start+m.count-A.start):(++p,d[p]=m)}d.length=p+1;for(let u=0,A=d.length;u<A;u++){const m=d[u];r.bufferSubData(c,m.start*h.BYTES_PER_ELEMENT,h,m.start,m.count)}l.clearUpdateRanges()}l.onUploadCallback()}function n(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(r.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=e.get(o);(!h||h.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.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.");i(c.buffer,o,l),c.version=o.version}}return{get:n,remove:s,update:a}}var c2=`#ifdef USE_ALPHAHASH
|
||
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
||
#endif`,h2=`#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`,d2=`#ifdef USE_ALPHAMAP
|
||
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
||
#endif`,u2=`#ifdef USE_ALPHAMAP
|
||
uniform sampler2D alphaMap;
|
||
#endif`,p2=`#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`,f2=`#ifdef USE_ALPHATEST
|
||
uniform float alphaTest;
|
||
#endif`,m2=`#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`,g2=`#ifdef USE_AOMAP
|
||
uniform sampler2D aoMap;
|
||
uniform float aoMapIntensity;
|
||
#endif`,A2=`#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;
|
||
vec4 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 );
|
||
}
|
||
#endif`,v2=`#ifdef USE_BATCHING
|
||
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
||
#endif`,b2=`vec3 transformed = vec3( position );
|
||
#ifdef USE_ALPHAHASH
|
||
vPosition = vec3( position );
|
||
#endif`,y2=`vec3 objectNormal = vec3( normal );
|
||
#ifdef USE_TANGENT
|
||
vec3 objectTangent = vec3( tangent.xyz );
|
||
#endif`,x2=`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`,_2=`#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`,E2=`#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`,M2=`#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`,w2=`#if NUM_CLIPPING_PLANES > 0
|
||
varying vec3 vClipPosition;
|
||
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
||
#endif`,S2=`#if NUM_CLIPPING_PLANES > 0
|
||
varying vec3 vClipPosition;
|
||
#endif`,C2=`#if NUM_CLIPPING_PLANES > 0
|
||
vClipPosition = - mvPosition.xyz;
|
||
#endif`,T2=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
||
diffuseColor *= vColor;
|
||
#endif`,I2=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
||
varying vec4 vColor;
|
||
#endif`,P2=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
||
varying vec4 vColor;
|
||
#endif`,R2=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
||
vColor = vec4( 1.0 );
|
||
#endif
|
||
#ifdef USE_COLOR_ALPHA
|
||
vColor *= color;
|
||
#elif defined( USE_COLOR )
|
||
vColor.rgb *= color;
|
||
#endif
|
||
#ifdef USE_INSTANCING_COLOR
|
||
vColor.rgb *= instanceColor.rgb;
|
||
#endif
|
||
#ifdef USE_BATCHING_COLOR
|
||
vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
|
||
#endif`,D2=`#define PI 3.141592653589793
|
||
#define PI2 6.283185307179586
|
||
#define PI_HALF 1.5707963267948966
|
||
#define RECIPROCAL_PI 0.3183098861837907
|
||
#define RECIPROCAL_PI2 0.15915494309189535
|
||
#define EPSILON 1e-6
|
||
#ifndef saturate
|
||
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
||
#endif
|
||
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
|
||
float pow2( const in float x ) { return x*x; }
|
||
vec3 pow2( const in vec3 x ) { return x*x; }
|
||
float pow3( const in float x ) { return x*x*x; }
|
||
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
|
||
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
|
||
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
|
||
highp float rand( const in vec2 uv ) {
|
||
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
|
||
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
|
||
return fract( sin( sn ) * c );
|
||
}
|
||
#ifdef HIGH_PRECISION
|
||
float precisionSafeLength( vec3 v ) { return length( v ); }
|
||
#else
|
||
float precisionSafeLength( vec3 v ) {
|
||
float maxComponent = max3( abs( v ) );
|
||
return length( v / maxComponent ) * maxComponent;
|
||
}
|
||
#endif
|
||
struct IncidentLight {
|
||
vec3 color;
|
||
vec3 direction;
|
||
bool visible;
|
||
};
|
||
struct ReflectedLight {
|
||
vec3 directDiffuse;
|
||
vec3 directSpecular;
|
||
vec3 indirectDiffuse;
|
||
vec3 indirectSpecular;
|
||
};
|
||
#ifdef USE_ALPHAHASH
|
||
varying vec3 vPosition;
|
||
#endif
|
||
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
||
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
||
}
|
||
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
|
||
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
|
||
}
|
||
bool isPerspectiveMatrix( mat4 m ) {
|
||
return m[ 2 ][ 3 ] == - 1.0;
|
||
}
|
||
vec2 equirectUv( in vec3 dir ) {
|
||
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
|
||
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
|
||
return vec2( u, v );
|
||
}
|
||
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
|
||
return RECIPROCAL_PI * diffuseColor;
|
||
}
|
||
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
||
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
||
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
||
}
|
||
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
||
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
||
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
||
} // validated`,B2=`#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`,L2=`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`,k2=`#ifdef USE_DISPLACEMENTMAP
|
||
uniform sampler2D displacementMap;
|
||
uniform float displacementScale;
|
||
uniform float displacementBias;
|
||
#endif`,N2=`#ifdef USE_DISPLACEMENTMAP
|
||
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
||
#endif`,U2=`#ifdef USE_EMISSIVEMAP
|
||
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
||
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
||
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
||
#endif
|
||
totalEmissiveRadiance *= emissiveColor.rgb;
|
||
#endif`,F2=`#ifdef USE_EMISSIVEMAP
|
||
uniform sampler2D emissiveMap;
|
||
#endif`,O2="gl_FragColor = linearToOutputTexel( gl_FragColor );",z2=`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 );
|
||
}`,H2=`#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 ) );
|
||
#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
|
||
#endif`,G2=`#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`,V2=`#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`,Q2=`#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`,W2=`#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`,j2=`#ifdef USE_FOG
|
||
vFogDepth = - mvPosition.z;
|
||
#endif`,q2=`#ifdef USE_FOG
|
||
varying float vFogDepth;
|
||
#endif`,X2=`#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`,Y2=`#ifdef USE_FOG
|
||
uniform vec3 fogColor;
|
||
varying float vFogDepth;
|
||
#ifdef FOG_EXP2
|
||
uniform float fogDensity;
|
||
#else
|
||
uniform float fogNear;
|
||
uniform float fogFar;
|
||
#endif
|
||
#endif`,K2=`#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
|
||
}`,Z2=`#ifdef USE_LIGHTMAP
|
||
uniform sampler2D lightMap;
|
||
uniform float lightMapIntensity;
|
||
#endif`,J2=`LambertMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;
|
||
material.specularStrength = specularStrength;`,$2=`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`,e3=`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`,t3=`#ifdef USE_ENVMAP
|
||
vec3 getIBLIrradiance( const in vec3 normal ) {
|
||
#ifdef ENVMAP_TYPE_CUBE_UV
|
||
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
||
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
|
||
return PI * envMapColor.rgb * envMapIntensity;
|
||
#else
|
||
return vec3( 0.0 );
|
||
#endif
|
||
}
|
||
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
|
||
#ifdef ENVMAP_TYPE_CUBE_UV
|
||
vec3 reflectVec = reflect( - viewDir, normal );
|
||
reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
|
||
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
|
||
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
|
||
return envMapColor.rgb * envMapIntensity;
|
||
#else
|
||
return vec3( 0.0 );
|
||
#endif
|
||
}
|
||
#ifdef USE_ANISOTROPY
|
||
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
|
||
#ifdef ENVMAP_TYPE_CUBE_UV
|
||
vec3 bentNormal = cross( bitangent, viewDir );
|
||
bentNormal = normalize( cross( bentNormal, bitangent ) );
|
||
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
|
||
return getIBLRadiance( viewDir, bentNormal, roughness );
|
||
#else
|
||
return vec3( 0.0 );
|
||
#endif
|
||
}
|
||
#endif
|
||
#endif`,i3=`ToonMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;`,n3=`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`,s3=`BlinnPhongMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;
|
||
material.specularColor = specular;
|
||
material.specularShininess = shininess;
|
||
material.specularStrength = specularStrength;`,r3=`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`,a3=`PhysicalMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;
|
||
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
||
material.metalness = metalnessFactor;
|
||
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
|
||
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
||
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
|
||
material.roughness = min( material.roughness, 1.0 );
|
||
#ifdef IOR
|
||
material.ior = ior;
|
||
#ifdef USE_SPECULAR
|
||
float specularIntensityFactor = specularIntensity;
|
||
vec3 specularColorFactor = specularColor;
|
||
#ifdef USE_SPECULAR_COLORMAP
|
||
specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
|
||
#endif
|
||
#ifdef USE_SPECULAR_INTENSITYMAP
|
||
specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
|
||
#endif
|
||
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
|
||
#else
|
||
float specularIntensityFactor = 1.0;
|
||
vec3 specularColorFactor = vec3( 1.0 );
|
||
material.specularF90 = 1.0;
|
||
#endif
|
||
material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;
|
||
material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
|
||
#else
|
||
material.specularColor = vec3( 0.04 );
|
||
material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
|
||
material.specularF90 = 1.0;
|
||
#endif
|
||
#ifdef USE_CLEARCOAT
|
||
material.clearcoat = clearcoat;
|
||
material.clearcoatRoughness = clearcoatRoughness;
|
||
material.clearcoatF0 = vec3( 0.04 );
|
||
material.clearcoatF90 = 1.0;
|
||
#ifdef USE_CLEARCOATMAP
|
||
material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
|
||
#endif
|
||
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
||
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
|
||
#endif
|
||
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
|
||
material.clearcoatRoughness += geometryRoughness;
|
||
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
|
||
#endif
|
||
#ifdef USE_DISPERSION
|
||
material.dispersion = dispersion;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE
|
||
material.iridescence = iridescence;
|
||
material.iridescenceIOR = iridescenceIOR;
|
||
#ifdef USE_IRIDESCENCEMAP
|
||
material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
|
||
#else
|
||
material.iridescenceThickness = iridescenceThicknessMaximum;
|
||
#endif
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
material.sheenColor = sheenColor;
|
||
#ifdef USE_SHEEN_COLORMAP
|
||
material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
|
||
#endif
|
||
material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );
|
||
#ifdef USE_SHEEN_ROUGHNESSMAP
|
||
material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
|
||
#endif
|
||
#endif
|
||
#ifdef USE_ANISOTROPY
|
||
#ifdef USE_ANISOTROPYMAP
|
||
mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
|
||
vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
|
||
vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
|
||
#else
|
||
vec2 anisotropyV = anisotropyVector;
|
||
#endif
|
||
material.anisotropy = length( anisotropyV );
|
||
if( material.anisotropy == 0.0 ) {
|
||
anisotropyV = vec2( 1.0, 0.0 );
|
||
} else {
|
||
anisotropyV /= material.anisotropy;
|
||
material.anisotropy = saturate( material.anisotropy );
|
||
}
|
||
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
||
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
||
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
||
#endif`,o3=`uniform sampler2D dfgLUT;
|
||
struct PhysicalMaterial {
|
||
vec3 diffuseColor;
|
||
vec3 diffuseContribution;
|
||
vec3 specularColor;
|
||
vec3 specularColorBlended;
|
||
float roughness;
|
||
float metalness;
|
||
float specularF90;
|
||
float dispersion;
|
||
#ifdef USE_CLEARCOAT
|
||
float clearcoat;
|
||
float clearcoatRoughness;
|
||
vec3 clearcoatF0;
|
||
float clearcoatF90;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE
|
||
float iridescence;
|
||
float iridescenceIOR;
|
||
float iridescenceThickness;
|
||
vec3 iridescenceFresnel;
|
||
vec3 iridescenceF0;
|
||
vec3 iridescenceFresnelDielectric;
|
||
vec3 iridescenceFresnelMetallic;
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
vec3 sheenColor;
|
||
float sheenRoughness;
|
||
#endif
|
||
#ifdef IOR
|
||
float ior;
|
||
#endif
|
||
#ifdef USE_TRANSMISSION
|
||
float transmission;
|
||
float transmissionAlpha;
|
||
float thickness;
|
||
float attenuationDistance;
|
||
vec3 attenuationColor;
|
||
#endif
|
||
#ifdef USE_ANISOTROPY
|
||
float anisotropy;
|
||
float alphaT;
|
||
vec3 anisotropyT;
|
||
vec3 anisotropyB;
|
||
#endif
|
||
};
|
||
vec3 clearcoatSpecularDirect = vec3( 0.0 );
|
||
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
|
||
vec3 sheenSpecularDirect = vec3( 0.0 );
|
||
vec3 sheenSpecularIndirect = vec3(0.0 );
|
||
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
|
||
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
|
||
float x2 = x * x;
|
||
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
|
||
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
|
||
}
|
||
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
|
||
float a2 = pow2( alpha );
|
||
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
||
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
|
||
return 0.5 / max( gv + gl, EPSILON );
|
||
}
|
||
float D_GGX( const in float alpha, const in float dotNH ) {
|
||
float a2 = pow2( alpha );
|
||
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
|
||
return RECIPROCAL_PI * a2 / pow2( denom );
|
||
}
|
||
#ifdef USE_ANISOTROPY
|
||
float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
|
||
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
|
||
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
|
||
float v = 0.5 / ( gv + gl );
|
||
return v;
|
||
}
|
||
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
|
||
float a2 = alphaT * alphaB;
|
||
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
|
||
highp float v2 = dot( v, v );
|
||
float w2 = a2 / v2;
|
||
return RECIPROCAL_PI * a2 * pow2 ( w2 );
|
||
}
|
||
#endif
|
||
#ifdef USE_CLEARCOAT
|
||
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
|
||
vec3 f0 = material.clearcoatF0;
|
||
float f90 = material.clearcoatF90;
|
||
float roughness = material.clearcoatRoughness;
|
||
float alpha = pow2( roughness );
|
||
vec3 halfDir = normalize( lightDir + viewDir );
|
||
float dotNL = saturate( dot( normal, lightDir ) );
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
float dotNH = saturate( dot( normal, halfDir ) );
|
||
float dotVH = saturate( dot( viewDir, halfDir ) );
|
||
vec3 F = F_Schlick( f0, f90, dotVH );
|
||
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
||
float D = D_GGX( alpha, dotNH );
|
||
return F * ( V * D );
|
||
}
|
||
#endif
|
||
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
|
||
vec3 f0 = material.specularColorBlended;
|
||
float f90 = material.specularF90;
|
||
float roughness = material.roughness;
|
||
float alpha = pow2( roughness );
|
||
vec3 halfDir = normalize( lightDir + viewDir );
|
||
float dotNL = saturate( dot( normal, lightDir ) );
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
float dotNH = saturate( dot( normal, halfDir ) );
|
||
float dotVH = saturate( dot( viewDir, halfDir ) );
|
||
vec3 F = F_Schlick( f0, f90, dotVH );
|
||
#ifdef USE_IRIDESCENCE
|
||
F = mix( F, material.iridescenceFresnel, material.iridescence );
|
||
#endif
|
||
#ifdef USE_ANISOTROPY
|
||
float dotTL = dot( material.anisotropyT, lightDir );
|
||
float dotTV = dot( material.anisotropyT, viewDir );
|
||
float dotTH = dot( material.anisotropyT, halfDir );
|
||
float dotBL = dot( material.anisotropyB, lightDir );
|
||
float dotBV = dot( material.anisotropyB, viewDir );
|
||
float dotBH = dot( material.anisotropyB, halfDir );
|
||
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
|
||
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
|
||
#else
|
||
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
||
float D = D_GGX( alpha, dotNH );
|
||
#endif
|
||
return F * ( V * D );
|
||
}
|
||
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
|
||
const float LUT_SIZE = 64.0;
|
||
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
|
||
const float LUT_BIAS = 0.5 / LUT_SIZE;
|
||
float dotNV = saturate( dot( N, V ) );
|
||
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
|
||
uv = uv * LUT_SCALE + LUT_BIAS;
|
||
return uv;
|
||
}
|
||
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
|
||
float l = length( f );
|
||
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
|
||
}
|
||
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
|
||
float x = dot( v1, v2 );
|
||
float y = abs( x );
|
||
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
|
||
float b = 3.4175940 + ( 4.1616724 + y ) * y;
|
||
float v = a / b;
|
||
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
|
||
return cross( v1, v2 ) * theta_sintheta;
|
||
}
|
||
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
|
||
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
|
||
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
|
||
vec3 lightNormal = cross( v1, v2 );
|
||
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
|
||
vec3 T1, T2;
|
||
T1 = normalize( V - N * dot( V, N ) );
|
||
T2 = - cross( N, T1 );
|
||
mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
|
||
vec3 coords[ 4 ];
|
||
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
|
||
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
|
||
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
|
||
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
|
||
coords[ 0 ] = normalize( coords[ 0 ] );
|
||
coords[ 1 ] = normalize( coords[ 1 ] );
|
||
coords[ 2 ] = normalize( coords[ 2 ] );
|
||
coords[ 3 ] = normalize( coords[ 3 ] );
|
||
vec3 vectorFormFactor = vec3( 0.0 );
|
||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
|
||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
|
||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
|
||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
|
||
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
|
||
return vec3( result );
|
||
}
|
||
#if defined( USE_SHEEN )
|
||
float D_Charlie( float roughness, float dotNH ) {
|
||
float alpha = pow2( roughness );
|
||
float invAlpha = 1.0 / alpha;
|
||
float cos2h = dotNH * dotNH;
|
||
float sin2h = max( 1.0 - cos2h, 0.0078125 );
|
||
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
|
||
}
|
||
float V_Neubelt( float dotNV, float dotNL ) {
|
||
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
|
||
}
|
||
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
|
||
vec3 halfDir = normalize( lightDir + viewDir );
|
||
float dotNL = saturate( dot( normal, lightDir ) );
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
float dotNH = saturate( dot( normal, halfDir ) );
|
||
float D = D_Charlie( sheenRoughness, dotNH );
|
||
float V = V_Neubelt( dotNV, dotNL );
|
||
return sheenColor * ( D * V );
|
||
}
|
||
#endif
|
||
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
float r2 = roughness * roughness;
|
||
float rInv = 1.0 / ( roughness + 0.1 );
|
||
float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;
|
||
float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;
|
||
float DG = exp( a * dotNV + b );
|
||
return saturate( DG );
|
||
}
|
||
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
|
||
return specularColor * fab.x + specularF90 * fab.y;
|
||
}
|
||
#ifdef USE_IRIDESCENCE
|
||
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
||
#else
|
||
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
||
#endif
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
|
||
#ifdef USE_IRIDESCENCE
|
||
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
|
||
#else
|
||
vec3 Fr = specularColor;
|
||
#endif
|
||
vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
|
||
float Ess = fab.x + fab.y;
|
||
float Ems = 1.0 - Ess;
|
||
vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
|
||
singleScatter += FssEss;
|
||
multiScatter += Fms * Ems;
|
||
}
|
||
vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
|
||
vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
|
||
float dotNL = saturate( dot( normal, lightDir ) );
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;
|
||
vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;
|
||
vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;
|
||
vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;
|
||
float Ess_V = dfgV.x + dfgV.y;
|
||
float Ess_L = dfgL.x + dfgL.y;
|
||
float Ems_V = 1.0 - Ess_V;
|
||
float Ems_L = 1.0 - Ess_L;
|
||
vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;
|
||
vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );
|
||
float compensationFactor = Ems_V * Ems_L;
|
||
vec3 multiScatter = Fms * compensationFactor;
|
||
return singleScatter + multiScatter;
|
||
}
|
||
#if NUM_RECT_AREA_LIGHTS > 0
|
||
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||
vec3 normal = geometryNormal;
|
||
vec3 viewDir = geometryViewDir;
|
||
vec3 position = geometryPosition;
|
||
vec3 lightPos = rectAreaLight.position;
|
||
vec3 halfWidth = rectAreaLight.halfWidth;
|
||
vec3 halfHeight = rectAreaLight.halfHeight;
|
||
vec3 lightColor = rectAreaLight.color;
|
||
float roughness = material.roughness;
|
||
vec3 rectCoords[ 4 ];
|
||
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
|
||
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
|
||
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
|
||
vec2 uv = LTC_Uv( normal, viewDir, roughness );
|
||
vec4 t1 = texture2D( ltc_1, uv );
|
||
vec4 t2 = texture2D( ltc_2, uv );
|
||
mat3 mInv = mat3(
|
||
vec3( t1.x, 0, t1.y ),
|
||
vec3( 0, 1, 0 ),
|
||
vec3( t1.z, 0, t1.w )
|
||
);
|
||
vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );
|
||
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
|
||
reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
|
||
#ifdef USE_CLEARCOAT
|
||
vec3 Ncc = geometryClearcoatNormal;
|
||
vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );
|
||
vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );
|
||
vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );
|
||
mat3 mInvClearcoat = mat3(
|
||
vec3( t1Clearcoat.x, 0, t1Clearcoat.y ),
|
||
vec3( 0, 1, 0 ),
|
||
vec3( t1Clearcoat.z, 0, t1Clearcoat.w )
|
||
);
|
||
vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;
|
||
clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );
|
||
#endif
|
||
}
|
||
#endif
|
||
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
||
vec3 irradiance = dotNL * directLight.color;
|
||
#ifdef USE_CLEARCOAT
|
||
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
|
||
vec3 ccIrradiance = dotNLcc * directLight.color;
|
||
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
|
||
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
|
||
|
||
float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
||
float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );
|
||
|
||
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );
|
||
|
||
irradiance *= sheenEnergyComp;
|
||
|
||
#endif
|
||
reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
|
||
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );
|
||
}
|
||
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||
vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );
|
||
#ifdef USE_SHEEN
|
||
float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
||
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
|
||
diffuse *= sheenEnergyComp;
|
||
#endif
|
||
reflectedLight.indirectDiffuse += diffuse;
|
||
}
|
||
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
|
||
#ifdef USE_CLEARCOAT
|
||
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;
|
||
#endif
|
||
vec3 singleScatteringDielectric = vec3( 0.0 );
|
||
vec3 multiScatteringDielectric = vec3( 0.0 );
|
||
vec3 singleScatteringMetallic = vec3( 0.0 );
|
||
vec3 multiScatteringMetallic = vec3( 0.0 );
|
||
#ifdef USE_IRIDESCENCE
|
||
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
|
||
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
|
||
#else
|
||
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
|
||
computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
|
||
#endif
|
||
vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );
|
||
vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );
|
||
vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;
|
||
vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );
|
||
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
||
vec3 indirectSpecular = radiance * singleScattering;
|
||
indirectSpecular += multiScattering * cosineWeightedIrradiance;
|
||
vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;
|
||
#ifdef USE_SHEEN
|
||
float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
||
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
|
||
indirectSpecular *= sheenEnergyComp;
|
||
indirectDiffuse *= sheenEnergyComp;
|
||
#endif
|
||
reflectedLight.indirectSpecular += indirectSpecular;
|
||
reflectedLight.indirectDiffuse += indirectDiffuse;
|
||
}
|
||
#define RE_Direct RE_Direct_Physical
|
||
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
|
||
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
|
||
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
||
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
||
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
||
}`,l3=`
|
||
vec3 geometryPosition = - vViewPosition;
|
||
vec3 geometryNormal = normal;
|
||
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
||
vec3 geometryClearcoatNormal = vec3( 0.0 );
|
||
#ifdef USE_CLEARCOAT
|
||
geometryClearcoatNormal = clearcoatNormal;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE
|
||
float dotNVi = saturate( dot( normal, geometryViewDir ) );
|
||
if ( material.iridescenceThickness == 0.0 ) {
|
||
material.iridescence = 0.0;
|
||
} else {
|
||
material.iridescence = saturate( material.iridescence );
|
||
}
|
||
if ( material.iridescence > 0.0 ) {
|
||
material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
|
||
material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );
|
||
material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );
|
||
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
|
||
}
|
||
#endif
|
||
IncidentLight directLight;
|
||
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
|
||
PointLight pointLight;
|
||
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
|
||
PointLightShadow pointLightShadow;
|
||
#endif
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
||
pointLight = pointLights[ i ];
|
||
getPointLightInfo( pointLight, geometryPosition, directLight );
|
||
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
|
||
pointLightShadow = pointLightShadows[ i ];
|
||
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
|
||
#endif
|
||
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
||
SpotLight spotLight;
|
||
vec4 spotColor;
|
||
vec3 spotLightCoord;
|
||
bool inSpotLightMap;
|
||
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
|
||
SpotLightShadow spotLightShadow;
|
||
#endif
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
||
spotLight = spotLights[ i ];
|
||
getSpotLightInfo( spotLight, geometryPosition, directLight );
|
||
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
||
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
|
||
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
||
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
|
||
#else
|
||
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
||
#endif
|
||
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
|
||
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
|
||
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
|
||
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
|
||
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
|
||
#endif
|
||
#undef SPOT_LIGHT_MAP_INDEX
|
||
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
||
spotLightShadow = spotLightShadows[ i ];
|
||
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
||
#endif
|
||
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
|
||
DirectionalLight directionalLight;
|
||
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
|
||
DirectionalLightShadow directionalLightShadow;
|
||
#endif
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
||
directionalLight = directionalLights[ i ];
|
||
getDirectionalLightInfo( directionalLight, directLight );
|
||
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
|
||
directionalLightShadow = directionalLightShadows[ i ];
|
||
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
||
#endif
|
||
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
|
||
RectAreaLight rectAreaLight;
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
|
||
rectAreaLight = rectAreaLights[ i ];
|
||
RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if defined( RE_IndirectDiffuse )
|
||
vec3 iblIrradiance = vec3( 0.0 );
|
||
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
|
||
#if defined( USE_LIGHT_PROBES )
|
||
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
|
||
#endif
|
||
#if ( NUM_HEMI_LIGHTS > 0 )
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
||
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#endif
|
||
#if defined( RE_IndirectSpecular )
|
||
vec3 radiance = vec3( 0.0 );
|
||
vec3 clearcoatRadiance = vec3( 0.0 );
|
||
#endif`,c3=`#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( ENVMAP_TYPE_CUBE_UV )
|
||
#if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )
|
||
iblIrradiance += getIBLIrradiance( geometryNormal );
|
||
#endif
|
||
#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`,h3=`#if defined( RE_IndirectDiffuse )
|
||
#if defined( LAMBERT ) || defined( PHONG )
|
||
irradiance += iblIrradiance;
|
||
#endif
|
||
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`,d3=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
||
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
||
#endif`,u3=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
||
uniform float logDepthBufFC;
|
||
varying float vFragDepth;
|
||
varying float vIsPerspective;
|
||
#endif`,p3=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
||
varying float vFragDepth;
|
||
varying float vIsPerspective;
|
||
#endif`,f3=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
||
vFragDepth = 1.0 + gl_Position.w;
|
||
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
||
#endif`,m3=`#ifdef USE_MAP
|
||
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
||
#ifdef DECODE_VIDEO_TEXTURE
|
||
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
||
#endif
|
||
diffuseColor *= sampledDiffuseColor;
|
||
#endif`,g3=`#ifdef USE_MAP
|
||
uniform sampler2D map;
|
||
#endif`,A3=`#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`,v3=`#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`,b3=`float metalnessFactor = metalness;
|
||
#ifdef USE_METALNESSMAP
|
||
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
||
metalnessFactor *= texelMetalness.b;
|
||
#endif`,y3=`#ifdef USE_METALNESSMAP
|
||
uniform sampler2D metalnessMap;
|
||
#endif`,x3=`#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`,_3=`#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`,E3=`#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`,M3=`#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`,w3=`#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`,S3=`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;`,C3=`#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`,T3=`#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#ifdef USE_TANGENT
|
||
varying vec3 vTangent;
|
||
varying vec3 vBitangent;
|
||
#endif
|
||
#endif`,I3=`#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#ifdef USE_TANGENT
|
||
varying vec3 vTangent;
|
||
varying vec3 vBitangent;
|
||
#endif
|
||
#endif`,P3=`#ifndef FLAT_SHADED
|
||
vNormal = normalize( transformedNormal );
|
||
#ifdef USE_TANGENT
|
||
vTangent = normalize( transformedTangent );
|
||
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
||
#endif
|
||
#endif`,R3=`#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`,D3=`#ifdef USE_CLEARCOAT
|
||
vec3 clearcoatNormal = nonPerturbedNormal;
|
||
#endif`,B3=`#ifdef USE_CLEARCOAT_NORMALMAP
|
||
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
||
clearcoatMapN.xy *= clearcoatNormalScale;
|
||
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
||
#endif`,L3=`#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`,k3=`#ifdef USE_IRIDESCENCEMAP
|
||
uniform sampler2D iridescenceMap;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
uniform sampler2D iridescenceThicknessMap;
|
||
#endif`,N3=`#ifdef OPAQUE
|
||
diffuseColor.a = 1.0;
|
||
#endif
|
||
#ifdef USE_TRANSMISSION
|
||
diffuseColor.a *= material.transmissionAlpha;
|
||
#endif
|
||
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,U3=`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 ) {
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
|
||
return depth * ( far - near ) - far;
|
||
#else
|
||
return depth * ( near - far ) - near;
|
||
#endif
|
||
}
|
||
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 ) {
|
||
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
return ( near * far ) / ( ( near - far ) * depth - near );
|
||
#else
|
||
return ( near * far ) / ( ( far - near ) * depth - far );
|
||
#endif
|
||
}`,F3=`#ifdef PREMULTIPLIED_ALPHA
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
#endif`,O3=`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;`,z3=`#ifdef DITHERING
|
||
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
||
#endif`,H3=`#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`,G3=`float roughnessFactor = roughness;
|
||
#ifdef USE_ROUGHNESSMAP
|
||
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
||
roughnessFactor *= texelRoughness.g;
|
||
#endif`,V3=`#ifdef USE_ROUGHNESSMAP
|
||
uniform sampler2D roughnessMap;
|
||
#endif`,Q3=`#if NUM_SPOT_LIGHT_COORDS > 0
|
||
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
||
#endif
|
||
#if NUM_SPOT_LIGHT_MAPS > 0
|
||
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
|
||
#endif
|
||
#ifdef USE_SHADOWMAP
|
||
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||
#if defined( SHADOWMAP_TYPE_PCF )
|
||
uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
||
#else
|
||
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
||
#endif
|
||
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
||
struct DirectionalLightShadow {
|
||
float shadowIntensity;
|
||
float shadowBias;
|
||
float shadowNormalBias;
|
||
float shadowRadius;
|
||
vec2 shadowMapSize;
|
||
};
|
||
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
||
#endif
|
||
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
||
#if defined( SHADOWMAP_TYPE_PCF )
|
||
uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
||
#else
|
||
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
||
#endif
|
||
struct SpotLightShadow {
|
||
float shadowIntensity;
|
||
float shadowBias;
|
||
float shadowNormalBias;
|
||
float shadowRadius;
|
||
vec2 shadowMapSize;
|
||
};
|
||
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
||
#endif
|
||
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||
#if defined( SHADOWMAP_TYPE_PCF )
|
||
uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
||
#elif defined( SHADOWMAP_TYPE_BASIC )
|
||
uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
||
#endif
|
||
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
||
struct PointLightShadow {
|
||
float shadowIntensity;
|
||
float shadowBias;
|
||
float shadowNormalBias;
|
||
float shadowRadius;
|
||
vec2 shadowMapSize;
|
||
float shadowCameraNear;
|
||
float shadowCameraFar;
|
||
};
|
||
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
||
#endif
|
||
#if defined( SHADOWMAP_TYPE_PCF )
|
||
float interleavedGradientNoise( vec2 position ) {
|
||
return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );
|
||
}
|
||
vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {
|
||
const float goldenAngle = 2.399963229728653;
|
||
float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );
|
||
float theta = float( sampleIndex ) * goldenAngle + phi;
|
||
return vec2( cos( theta ), sin( theta ) ) * r;
|
||
}
|
||
#endif
|
||
#if defined( SHADOWMAP_TYPE_PCF )
|
||
float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
||
float shadow = 1.0;
|
||
shadowCoord.xyz /= shadowCoord.w;
|
||
shadowCoord.z += shadowBias;
|
||
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
||
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
||
if ( frustumTest ) {
|
||
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
||
float radius = shadowRadius * texelSize.x;
|
||
float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;
|
||
shadow = (
|
||
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +
|
||
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +
|
||
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +
|
||
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +
|
||
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )
|
||
) * 0.2;
|
||
}
|
||
return mix( 1.0, shadow, shadowIntensity );
|
||
}
|
||
#elif defined( SHADOWMAP_TYPE_VSM )
|
||
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
||
float shadow = 1.0;
|
||
shadowCoord.xyz /= shadowCoord.w;
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
shadowCoord.z -= shadowBias;
|
||
#else
|
||
shadowCoord.z += shadowBias;
|
||
#endif
|
||
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
||
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
||
if ( frustumTest ) {
|
||
vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;
|
||
float mean = distribution.x;
|
||
float variance = distribution.y * distribution.y;
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
float hard_shadow = step( mean, shadowCoord.z );
|
||
#else
|
||
float hard_shadow = step( shadowCoord.z, mean );
|
||
#endif
|
||
|
||
if ( hard_shadow == 1.0 ) {
|
||
shadow = 1.0;
|
||
} else {
|
||
variance = max( variance, 0.0000001 );
|
||
float d = shadowCoord.z - mean;
|
||
float p_max = variance / ( variance + d * d );
|
||
p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );
|
||
shadow = max( hard_shadow, p_max );
|
||
}
|
||
}
|
||
return mix( 1.0, shadow, shadowIntensity );
|
||
}
|
||
#else
|
||
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
||
float shadow = 1.0;
|
||
shadowCoord.xyz /= shadowCoord.w;
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
shadowCoord.z -= shadowBias;
|
||
#else
|
||
shadowCoord.z += shadowBias;
|
||
#endif
|
||
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
||
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
||
if ( frustumTest ) {
|
||
float depth = texture2D( shadowMap, shadowCoord.xy ).r;
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
shadow = step( depth, shadowCoord.z );
|
||
#else
|
||
shadow = step( shadowCoord.z, depth );
|
||
#endif
|
||
}
|
||
return mix( 1.0, shadow, shadowIntensity );
|
||
}
|
||
#endif
|
||
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||
#if defined( SHADOWMAP_TYPE_PCF )
|
||
float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
||
float shadow = 1.0;
|
||
vec3 lightToPosition = shadowCoord.xyz;
|
||
vec3 bd3D = normalize( lightToPosition );
|
||
vec3 absVec = abs( lightToPosition );
|
||
float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
|
||
if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
|
||
dp -= shadowBias;
|
||
#else
|
||
float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
|
||
dp += shadowBias;
|
||
#endif
|
||
float texelSize = shadowRadius / shadowMapSize.x;
|
||
vec3 absDir = abs( bd3D );
|
||
vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );
|
||
tangent = normalize( cross( bd3D, tangent ) );
|
||
vec3 bitangent = cross( bd3D, tangent );
|
||
float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;
|
||
vec2 sample0 = vogelDiskSample( 0, 5, phi );
|
||
vec2 sample1 = vogelDiskSample( 1, 5, phi );
|
||
vec2 sample2 = vogelDiskSample( 2, 5, phi );
|
||
vec2 sample3 = vogelDiskSample( 3, 5, phi );
|
||
vec2 sample4 = vogelDiskSample( 4, 5, phi );
|
||
shadow = (
|
||
texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +
|
||
texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +
|
||
texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +
|
||
texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +
|
||
texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )
|
||
) * 0.2;
|
||
}
|
||
return mix( 1.0, shadow, shadowIntensity );
|
||
}
|
||
#elif defined( SHADOWMAP_TYPE_BASIC )
|
||
float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
||
float shadow = 1.0;
|
||
vec3 lightToPosition = shadowCoord.xyz;
|
||
vec3 absVec = abs( lightToPosition );
|
||
float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
|
||
if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
|
||
float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
|
||
dp += shadowBias;
|
||
vec3 bd3D = normalize( lightToPosition );
|
||
float depth = textureCube( shadowMap, bd3D ).r;
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
depth = 1.0 - depth;
|
||
#endif
|
||
shadow = step( dp, depth );
|
||
}
|
||
return mix( 1.0, shadow, shadowIntensity );
|
||
}
|
||
#endif
|
||
#endif
|
||
#endif`,W3=`#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`,j3=`#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`,q3=`float getShadowMask() {
|
||
float shadow = 1.0;
|
||
#ifdef USE_SHADOWMAP
|
||
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||
DirectionalLightShadow directionalLight;
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
||
directionalLight = directionalLightShadows[ i ];
|
||
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
||
SpotLightShadow spotLight;
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
|
||
spotLight = spotLightShadows[ i ];
|
||
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
|
||
PointLightShadow pointLight;
|
||
#pragma unroll_loop_start
|
||
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
||
pointLight = pointLightShadows[ i ];
|
||
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
|
||
}
|
||
#pragma unroll_loop_end
|
||
#endif
|
||
#endif
|
||
return shadow;
|
||
}`,X3=`#ifdef USE_SKINNING
|
||
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
||
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
||
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
||
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
||
#endif`,Y3=`#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`,K3=`#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`,Z3=`#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`,J3=`float specularStrength;
|
||
#ifdef USE_SPECULARMAP
|
||
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
||
specularStrength = texelSpecular.r;
|
||
#else
|
||
specularStrength = 1.0;
|
||
#endif`,$3=`#ifdef USE_SPECULARMAP
|
||
uniform sampler2D specularMap;
|
||
#endif`,eT=`#if defined( TONE_MAPPING )
|
||
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
||
#endif`,tT=`#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; }`,iT=`#ifdef USE_TRANSMISSION
|
||
material.transmission = transmission;
|
||
material.transmissionAlpha = 1.0;
|
||
material.thickness = thickness;
|
||
material.attenuationDistance = attenuationDistance;
|
||
material.attenuationColor = attenuationColor;
|
||
#ifdef USE_TRANSMISSIONMAP
|
||
material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
|
||
#endif
|
||
#ifdef USE_THICKNESSMAP
|
||
material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
|
||
#endif
|
||
vec3 pos = vWorldPosition;
|
||
vec3 v = normalize( cameraPosition - pos );
|
||
vec3 n = inverseTransformDirection( normal, viewMatrix );
|
||
vec4 transmitted = getIBLVolumeRefraction(
|
||
n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,
|
||
pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
|
||
material.attenuationColor, material.attenuationDistance );
|
||
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
||
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
||
#endif`,nT=`#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`,sT=`#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`,rT=`#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`,aT=`#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`,oT=`#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 yt={alphahash_fragment:c2,alphahash_pars_fragment:h2,alphamap_fragment:d2,alphamap_pars_fragment:u2,alphatest_fragment:p2,alphatest_pars_fragment:f2,aomap_fragment:m2,aomap_pars_fragment:g2,batching_pars_vertex:A2,batching_vertex:v2,begin_vertex:b2,beginnormal_vertex:y2,bsdfs:x2,iridescence_fragment:_2,bumpmap_pars_fragment:E2,clipping_planes_fragment:M2,clipping_planes_pars_fragment:w2,clipping_planes_pars_vertex:S2,clipping_planes_vertex:C2,color_fragment:T2,color_pars_fragment:I2,color_pars_vertex:P2,color_vertex:R2,common:D2,cube_uv_reflection_fragment:B2,defaultnormal_vertex:L2,displacementmap_pars_vertex:k2,displacementmap_vertex:N2,emissivemap_fragment:U2,emissivemap_pars_fragment:F2,colorspace_fragment:O2,colorspace_pars_fragment:z2,envmap_fragment:H2,envmap_common_pars_fragment:G2,envmap_pars_fragment:V2,envmap_pars_vertex:Q2,envmap_physical_pars_fragment:t3,envmap_vertex:W2,fog_vertex:j2,fog_pars_vertex:q2,fog_fragment:X2,fog_pars_fragment:Y2,gradientmap_pars_fragment:K2,lightmap_pars_fragment:Z2,lights_lambert_fragment:J2,lights_lambert_pars_fragment:$2,lights_pars_begin:e3,lights_toon_fragment:i3,lights_toon_pars_fragment:n3,lights_phong_fragment:s3,lights_phong_pars_fragment:r3,lights_physical_fragment:a3,lights_physical_pars_fragment:o3,lights_fragment_begin:l3,lights_fragment_maps:c3,lights_fragment_end:h3,logdepthbuf_fragment:d3,logdepthbuf_pars_fragment:u3,logdepthbuf_pars_vertex:p3,logdepthbuf_vertex:f3,map_fragment:m3,map_pars_fragment:g3,map_particle_fragment:A3,map_particle_pars_fragment:v3,metalnessmap_fragment:b3,metalnessmap_pars_fragment:y3,morphinstance_vertex:x3,morphcolor_vertex:_3,morphnormal_vertex:E3,morphtarget_pars_vertex:M3,morphtarget_vertex:w3,normal_fragment_begin:S3,normal_fragment_maps:C3,normal_pars_fragment:T3,normal_pars_vertex:I3,normal_vertex:P3,normalmap_pars_fragment:R3,clearcoat_normal_fragment_begin:D3,clearcoat_normal_fragment_maps:B3,clearcoat_pars_fragment:L3,iridescence_pars_fragment:k3,opaque_fragment:N3,packing:U3,premultiplied_alpha_fragment:F3,project_vertex:O3,dithering_fragment:z3,dithering_pars_fragment:H3,roughnessmap_fragment:G3,roughnessmap_pars_fragment:V3,shadowmap_pars_fragment:Q3,shadowmap_pars_vertex:W3,shadowmap_vertex:j3,shadowmask_pars_fragment:q3,skinbase_vertex:X3,skinning_pars_vertex:Y3,skinning_vertex:K3,skinnormal_vertex:Z3,specularmap_fragment:J3,specularmap_pars_fragment:$3,tonemapping_fragment:eT,tonemapping_pars_fragment:tT,transmission_fragment:iT,transmission_pars_fragment:nT,uv_pars_fragment:sT,uv_pars_vertex:rT,uv_vertex:aT,worldpos_vertex:oT,background_vert:`varying vec2 vUv;
|
||
uniform mat3 uvTransform;
|
||
void main() {
|
||
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
||
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
||
}`,background_frag:`uniform sampler2D t2D;
|
||
uniform float backgroundIntensity;
|
||
varying vec2 vUv;
|
||
void main() {
|
||
vec4 texColor = texture2D( t2D, vUv );
|
||
#ifdef DECODE_VIDEO_TEXTURE
|
||
texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
|
||
#endif
|
||
texColor.rgb *= backgroundIntensity;
|
||
gl_FragColor = texColor;
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
}`,backgroundCube_vert:`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
gl_Position.z = gl_Position.w;
|
||
}`,backgroundCube_frag:`#ifdef ENVMAP_TYPE_CUBE
|
||
uniform samplerCube envMap;
|
||
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
||
uniform sampler2D envMap;
|
||
#endif
|
||
uniform float flipEnvMap;
|
||
uniform float backgroundBlurriness;
|
||
uniform float backgroundIntensity;
|
||
uniform mat3 backgroundRotation;
|
||
varying vec3 vWorldDirection;
|
||
#include <cube_uv_reflection_fragment>
|
||
void main() {
|
||
#ifdef ENVMAP_TYPE_CUBE
|
||
vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
|
||
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
||
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
|
||
#else
|
||
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
||
#endif
|
||
texColor.rgb *= backgroundIntensity;
|
||
gl_FragColor = texColor;
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
}`,cube_vert:`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
gl_Position.z = gl_Position.w;
|
||
}`,cube_frag:`uniform samplerCube tCube;
|
||
uniform float tFlip;
|
||
uniform float opacity;
|
||
varying vec3 vWorldDirection;
|
||
void main() {
|
||
vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
|
||
gl_FragColor = texColor;
|
||
gl_FragColor.a *= opacity;
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
}`,depth_vert:`#include <common>
|
||
#include <batching_pars_vertex>
|
||
#include <uv_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
varying vec2 vHighPrecisionZW;
|
||
void main() {
|
||
#include <uv_vertex>
|
||
#include <batching_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <morphinstance_vertex>
|
||
#ifdef USE_DISPLACEMENTMAP
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinnormal_vertex>
|
||
#endif
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <skinning_vertex>
|
||
#include <displacementmap_vertex>
|
||
#include <project_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
vHighPrecisionZW = gl_Position.zw;
|
||
}`,depth_frag:`#if DEPTH_PACKING == 3200
|
||
uniform float opacity;
|
||
#endif
|
||
#include <common>
|
||
#include <packing>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
varying vec2 vHighPrecisionZW;
|
||
void main() {
|
||
vec4 diffuseColor = vec4( 1.0 );
|
||
#include <clipping_planes_fragment>
|
||
#if DEPTH_PACKING == 3200
|
||
diffuseColor.a = opacity;
|
||
#endif
|
||
#include <map_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_fragment>
|
||
#include <logdepthbuf_fragment>
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
|
||
#else
|
||
float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
|
||
#endif
|
||
#if DEPTH_PACKING == 3200
|
||
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
|
||
#elif DEPTH_PACKING == 3201
|
||
gl_FragColor = packDepthToRGBA( fragCoordZ );
|
||
#elif DEPTH_PACKING == 3202
|
||
gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
|
||
#elif DEPTH_PACKING == 3203
|
||
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
||
#endif
|
||
}`,distance_vert:`#define DISTANCE
|
||
varying vec3 vWorldPosition;
|
||
#include <common>
|
||
#include <batching_pars_vertex>
|
||
#include <uv_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
void main() {
|
||
#include <uv_vertex>
|
||
#include <batching_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <morphinstance_vertex>
|
||
#ifdef USE_DISPLACEMENTMAP
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinnormal_vertex>
|
||
#endif
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <skinning_vertex>
|
||
#include <displacementmap_vertex>
|
||
#include <project_vertex>
|
||
#include <worldpos_vertex>
|
||
#include <clipping_planes_vertex>
|
||
vWorldPosition = worldPosition.xyz;
|
||
}`,distance_frag:`#define DISTANCE
|
||
uniform vec3 referencePosition;
|
||
uniform float nearDistance;
|
||
uniform float farDistance;
|
||
varying vec3 vWorldPosition;
|
||
#include <common>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main () {
|
||
vec4 diffuseColor = vec4( 1.0 );
|
||
#include <clipping_planes_fragment>
|
||
#include <map_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_fragment>
|
||
float dist = length( vWorldPosition - referencePosition );
|
||
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
||
dist = saturate( dist );
|
||
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
|
||
}`,equirect_vert:`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
}`,equirect_frag:`uniform sampler2D tEquirect;
|
||
varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vec3 direction = normalize( vWorldDirection );
|
||
vec2 sampleUV = equirectUv( direction );
|
||
gl_FragColor = texture2D( tEquirect, sampleUV );
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
}`,linedashed_vert:`uniform float scale;
|
||
attribute float lineDistance;
|
||
varying float vLineDistance;
|
||
#include <common>
|
||
#include <uv_pars_vertex>
|
||
#include <color_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
void main() {
|
||
vLineDistance = scale * lineDistance;
|
||
#include <uv_vertex>
|
||
#include <color_vertex>
|
||
#include <morphinstance_vertex>
|
||
#include <morphcolor_vertex>
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <project_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
#include <fog_vertex>
|
||
}`,linedashed_frag:`uniform vec3 diffuse;
|
||
uniform float opacity;
|
||
uniform float dashSize;
|
||
uniform float totalSize;
|
||
varying float vLineDistance;
|
||
#include <common>
|
||
#include <color_pars_fragment>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
if ( mod( vLineDistance, totalSize ) > dashSize ) {
|
||
discard;
|
||
}
|
||
vec3 outgoingLight = vec3( 0.0 );
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <color_fragment>
|
||
outgoingLight = diffuseColor.rgb;
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
}`,meshbasic_vert:`#include <common>
|
||
#include <batching_pars_vertex>
|
||
#include <uv_pars_vertex>
|
||
#include <envmap_pars_vertex>
|
||
#include <color_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
void main() {
|
||
#include <uv_vertex>
|
||
#include <color_vertex>
|
||
#include <morphinstance_vertex>
|
||
#include <morphcolor_vertex>
|
||
#include <batching_vertex>
|
||
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#endif
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <skinning_vertex>
|
||
#include <project_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
#include <worldpos_vertex>
|
||
#include <envmap_vertex>
|
||
#include <fog_vertex>
|
||
}`,meshbasic_frag:`uniform vec3 diffuse;
|
||
uniform float opacity;
|
||
#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#endif
|
||
#include <common>
|
||
#include <dithering_pars_fragment>
|
||
#include <color_pars_fragment>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <aomap_pars_fragment>
|
||
#include <lightmap_pars_fragment>
|
||
#include <envmap_common_pars_fragment>
|
||
#include <envmap_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <specularmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <color_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_fragment>
|
||
#include <specularmap_fragment>
|
||
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
||
#ifdef USE_LIGHTMAP
|
||
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
||
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
|
||
#else
|
||
reflectedLight.indirectDiffuse += vec3( 1.0 );
|
||
#endif
|
||
#include <aomap_fragment>
|
||
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
|
||
vec3 outgoingLight = reflectedLight.indirectDiffuse;
|
||
#include <envmap_fragment>
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,meshlambert_vert:`#define LAMBERT
|
||
varying vec3 vViewPosition;
|
||
#include <common>
|
||
#include <batching_pars_vertex>
|
||
#include <uv_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <envmap_pars_vertex>
|
||
#include <color_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <normal_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
#include <shadowmap_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
void main() {
|
||
#include <uv_vertex>
|
||
#include <color_vertex>
|
||
#include <morphinstance_vertex>
|
||
#include <morphcolor_vertex>
|
||
#include <batching_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#include <normal_vertex>
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <skinning_vertex>
|
||
#include <displacementmap_vertex>
|
||
#include <project_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
vViewPosition = - mvPosition.xyz;
|
||
#include <worldpos_vertex>
|
||
#include <envmap_vertex>
|
||
#include <shadowmap_vertex>
|
||
#include <fog_vertex>
|
||
}`,meshlambert_frag:`#define LAMBERT
|
||
uniform vec3 diffuse;
|
||
uniform vec3 emissive;
|
||
uniform float opacity;
|
||
#include <common>
|
||
#include <dithering_pars_fragment>
|
||
#include <color_pars_fragment>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <aomap_pars_fragment>
|
||
#include <lightmap_pars_fragment>
|
||
#include <emissivemap_pars_fragment>
|
||
#include <cube_uv_reflection_fragment>
|
||
#include <envmap_common_pars_fragment>
|
||
#include <envmap_pars_fragment>
|
||
#include <envmap_physical_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <bsdfs>
|
||
#include <lights_pars_begin>
|
||
#include <normal_pars_fragment>
|
||
#include <lights_lambert_pars_fragment>
|
||
#include <shadowmap_pars_fragment>
|
||
#include <bumpmap_pars_fragment>
|
||
#include <normalmap_pars_fragment>
|
||
#include <specularmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
||
vec3 totalEmissiveRadiance = emissive;
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <color_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_fragment>
|
||
#include <specularmap_fragment>
|
||
#include <normal_fragment_begin>
|
||
#include <normal_fragment_maps>
|
||
#include <emissivemap_fragment>
|
||
#include <lights_lambert_fragment>
|
||
#include <lights_fragment_begin>
|
||
#include <lights_fragment_maps>
|
||
#include <lights_fragment_end>
|
||
#include <aomap_fragment>
|
||
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
||
#include <envmap_fragment>
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,meshmatcap_vert:`#define MATCAP
|
||
varying vec3 vViewPosition;
|
||
#include <common>
|
||
#include <batching_pars_vertex>
|
||
#include <uv_pars_vertex>
|
||
#include <color_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <normal_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
void main() {
|
||
#include <uv_vertex>
|
||
#include <color_vertex>
|
||
#include <morphinstance_vertex>
|
||
#include <morphcolor_vertex>
|
||
#include <batching_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#include <normal_vertex>
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <skinning_vertex>
|
||
#include <displacementmap_vertex>
|
||
#include <project_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
#include <fog_vertex>
|
||
vViewPosition = - mvPosition.xyz;
|
||
}`,meshmatcap_frag:`#define MATCAP
|
||
uniform vec3 diffuse;
|
||
uniform float opacity;
|
||
uniform sampler2D matcap;
|
||
varying vec3 vViewPosition;
|
||
#include <common>
|
||
#include <dithering_pars_fragment>
|
||
#include <color_pars_fragment>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <normal_pars_fragment>
|
||
#include <bumpmap_pars_fragment>
|
||
#include <normalmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <color_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_fragment>
|
||
#include <normal_fragment_begin>
|
||
#include <normal_fragment_maps>
|
||
vec3 viewDir = normalize( vViewPosition );
|
||
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
|
||
vec3 y = cross( viewDir, x );
|
||
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
|
||
#ifdef USE_MATCAP
|
||
vec4 matcapColor = texture2D( matcap, uv );
|
||
#else
|
||
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
|
||
#endif
|
||
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,meshnormal_vert:`#define NORMAL
|
||
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
||
varying vec3 vViewPosition;
|
||
#endif
|
||
#include <common>
|
||
#include <batching_pars_vertex>
|
||
#include <uv_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <normal_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
void main() {
|
||
#include <uv_vertex>
|
||
#include <batching_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphinstance_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#include <normal_vertex>
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <skinning_vertex>
|
||
#include <displacementmap_vertex>
|
||
#include <project_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
||
vViewPosition = - mvPosition.xyz;
|
||
#endif
|
||
}`,meshnormal_frag:`#define NORMAL
|
||
uniform float opacity;
|
||
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
||
varying vec3 vViewPosition;
|
||
#endif
|
||
#include <uv_pars_fragment>
|
||
#include <normal_pars_fragment>
|
||
#include <bumpmap_pars_fragment>
|
||
#include <normalmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
|
||
#include <clipping_planes_fragment>
|
||
#include <logdepthbuf_fragment>
|
||
#include <normal_fragment_begin>
|
||
#include <normal_fragment_maps>
|
||
gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );
|
||
#ifdef OPAQUE
|
||
gl_FragColor.a = 1.0;
|
||
#endif
|
||
}`,meshphong_vert:`#define PHONG
|
||
varying vec3 vViewPosition;
|
||
#include <common>
|
||
#include <batching_pars_vertex>
|
||
#include <uv_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <envmap_pars_vertex>
|
||
#include <color_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <normal_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
#include <shadowmap_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
void main() {
|
||
#include <uv_vertex>
|
||
#include <color_vertex>
|
||
#include <morphcolor_vertex>
|
||
#include <batching_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphinstance_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#include <normal_vertex>
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <skinning_vertex>
|
||
#include <displacementmap_vertex>
|
||
#include <project_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
vViewPosition = - mvPosition.xyz;
|
||
#include <worldpos_vertex>
|
||
#include <envmap_vertex>
|
||
#include <shadowmap_vertex>
|
||
#include <fog_vertex>
|
||
}`,meshphong_frag:`#define PHONG
|
||
uniform vec3 diffuse;
|
||
uniform vec3 emissive;
|
||
uniform vec3 specular;
|
||
uniform float shininess;
|
||
uniform float opacity;
|
||
#include <common>
|
||
#include <dithering_pars_fragment>
|
||
#include <color_pars_fragment>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <aomap_pars_fragment>
|
||
#include <lightmap_pars_fragment>
|
||
#include <emissivemap_pars_fragment>
|
||
#include <cube_uv_reflection_fragment>
|
||
#include <envmap_common_pars_fragment>
|
||
#include <envmap_pars_fragment>
|
||
#include <envmap_physical_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <bsdfs>
|
||
#include <lights_pars_begin>
|
||
#include <normal_pars_fragment>
|
||
#include <lights_phong_pars_fragment>
|
||
#include <shadowmap_pars_fragment>
|
||
#include <bumpmap_pars_fragment>
|
||
#include <normalmap_pars_fragment>
|
||
#include <specularmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
||
vec3 totalEmissiveRadiance = emissive;
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <color_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_fragment>
|
||
#include <specularmap_fragment>
|
||
#include <normal_fragment_begin>
|
||
#include <normal_fragment_maps>
|
||
#include <emissivemap_fragment>
|
||
#include <lights_phong_fragment>
|
||
#include <lights_fragment_begin>
|
||
#include <lights_fragment_maps>
|
||
#include <lights_fragment_end>
|
||
#include <aomap_fragment>
|
||
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
|
||
#include <envmap_fragment>
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,meshphysical_vert:`#define STANDARD
|
||
varying vec3 vViewPosition;
|
||
#ifdef USE_TRANSMISSION
|
||
varying vec3 vWorldPosition;
|
||
#endif
|
||
#include <common>
|
||
#include <batching_pars_vertex>
|
||
#include <uv_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <color_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <normal_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
#include <shadowmap_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
void main() {
|
||
#include <uv_vertex>
|
||
#include <color_vertex>
|
||
#include <morphinstance_vertex>
|
||
#include <morphcolor_vertex>
|
||
#include <batching_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#include <normal_vertex>
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <skinning_vertex>
|
||
#include <displacementmap_vertex>
|
||
#include <project_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
vViewPosition = - mvPosition.xyz;
|
||
#include <worldpos_vertex>
|
||
#include <shadowmap_vertex>
|
||
#include <fog_vertex>
|
||
#ifdef USE_TRANSMISSION
|
||
vWorldPosition = worldPosition.xyz;
|
||
#endif
|
||
}`,meshphysical_frag:`#define STANDARD
|
||
#ifdef PHYSICAL
|
||
#define IOR
|
||
#define USE_SPECULAR
|
||
#endif
|
||
uniform vec3 diffuse;
|
||
uniform vec3 emissive;
|
||
uniform float roughness;
|
||
uniform float metalness;
|
||
uniform float opacity;
|
||
#ifdef IOR
|
||
uniform float ior;
|
||
#endif
|
||
#ifdef USE_SPECULAR
|
||
uniform float specularIntensity;
|
||
uniform vec3 specularColor;
|
||
#ifdef USE_SPECULAR_COLORMAP
|
||
uniform sampler2D specularColorMap;
|
||
#endif
|
||
#ifdef USE_SPECULAR_INTENSITYMAP
|
||
uniform sampler2D specularIntensityMap;
|
||
#endif
|
||
#endif
|
||
#ifdef USE_CLEARCOAT
|
||
uniform float clearcoat;
|
||
uniform float clearcoatRoughness;
|
||
#endif
|
||
#ifdef USE_DISPERSION
|
||
uniform float dispersion;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE
|
||
uniform float iridescence;
|
||
uniform float iridescenceIOR;
|
||
uniform float iridescenceThicknessMinimum;
|
||
uniform float iridescenceThicknessMaximum;
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
uniform vec3 sheenColor;
|
||
uniform float sheenRoughness;
|
||
#ifdef USE_SHEEN_COLORMAP
|
||
uniform sampler2D sheenColorMap;
|
||
#endif
|
||
#ifdef USE_SHEEN_ROUGHNESSMAP
|
||
uniform sampler2D sheenRoughnessMap;
|
||
#endif
|
||
#endif
|
||
#ifdef USE_ANISOTROPY
|
||
uniform vec2 anisotropyVector;
|
||
#ifdef USE_ANISOTROPYMAP
|
||
uniform sampler2D anisotropyMap;
|
||
#endif
|
||
#endif
|
||
varying vec3 vViewPosition;
|
||
#include <common>
|
||
#include <dithering_pars_fragment>
|
||
#include <color_pars_fragment>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <aomap_pars_fragment>
|
||
#include <lightmap_pars_fragment>
|
||
#include <emissivemap_pars_fragment>
|
||
#include <iridescence_fragment>
|
||
#include <cube_uv_reflection_fragment>
|
||
#include <envmap_common_pars_fragment>
|
||
#include <envmap_physical_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <lights_pars_begin>
|
||
#include <normal_pars_fragment>
|
||
#include <lights_physical_pars_fragment>
|
||
#include <transmission_pars_fragment>
|
||
#include <shadowmap_pars_fragment>
|
||
#include <bumpmap_pars_fragment>
|
||
#include <normalmap_pars_fragment>
|
||
#include <clearcoat_pars_fragment>
|
||
#include <iridescence_pars_fragment>
|
||
#include <roughnessmap_pars_fragment>
|
||
#include <metalnessmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
||
vec3 totalEmissiveRadiance = emissive;
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <color_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_fragment>
|
||
#include <roughnessmap_fragment>
|
||
#include <metalnessmap_fragment>
|
||
#include <normal_fragment_begin>
|
||
#include <normal_fragment_maps>
|
||
#include <clearcoat_normal_fragment_begin>
|
||
#include <clearcoat_normal_fragment_maps>
|
||
#include <emissivemap_fragment>
|
||
#include <lights_physical_fragment>
|
||
#include <lights_fragment_begin>
|
||
#include <lights_fragment_maps>
|
||
#include <lights_fragment_end>
|
||
#include <aomap_fragment>
|
||
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
|
||
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
||
#include <transmission_fragment>
|
||
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
|
||
#ifdef USE_SHEEN
|
||
|
||
outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;
|
||
|
||
#endif
|
||
#ifdef USE_CLEARCOAT
|
||
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
|
||
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
||
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
|
||
#endif
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,meshtoon_vert:`#define TOON
|
||
varying vec3 vViewPosition;
|
||
#include <common>
|
||
#include <batching_pars_vertex>
|
||
#include <uv_pars_vertex>
|
||
#include <displacementmap_pars_vertex>
|
||
#include <color_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <normal_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
#include <shadowmap_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
void main() {
|
||
#include <uv_vertex>
|
||
#include <color_vertex>
|
||
#include <morphinstance_vertex>
|
||
#include <morphcolor_vertex>
|
||
#include <batching_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#include <normal_vertex>
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <skinning_vertex>
|
||
#include <displacementmap_vertex>
|
||
#include <project_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
vViewPosition = - mvPosition.xyz;
|
||
#include <worldpos_vertex>
|
||
#include <shadowmap_vertex>
|
||
#include <fog_vertex>
|
||
}`,meshtoon_frag:`#define TOON
|
||
uniform vec3 diffuse;
|
||
uniform vec3 emissive;
|
||
uniform float opacity;
|
||
#include <common>
|
||
#include <dithering_pars_fragment>
|
||
#include <color_pars_fragment>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <aomap_pars_fragment>
|
||
#include <lightmap_pars_fragment>
|
||
#include <emissivemap_pars_fragment>
|
||
#include <gradientmap_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <bsdfs>
|
||
#include <lights_pars_begin>
|
||
#include <normal_pars_fragment>
|
||
#include <lights_toon_pars_fragment>
|
||
#include <shadowmap_pars_fragment>
|
||
#include <bumpmap_pars_fragment>
|
||
#include <normalmap_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
||
vec3 totalEmissiveRadiance = emissive;
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <color_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_fragment>
|
||
#include <normal_fragment_begin>
|
||
#include <normal_fragment_maps>
|
||
#include <emissivemap_fragment>
|
||
#include <lights_toon_fragment>
|
||
#include <lights_fragment_begin>
|
||
#include <lights_fragment_maps>
|
||
#include <lights_fragment_end>
|
||
#include <aomap_fragment>
|
||
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
#include <dithering_fragment>
|
||
}`,points_vert:`uniform float size;
|
||
uniform float scale;
|
||
#include <common>
|
||
#include <color_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <clipping_planes_pars_vertex>
|
||
#ifdef USE_POINTS_UV
|
||
varying vec2 vUv;
|
||
uniform mat3 uvTransform;
|
||
#endif
|
||
void main() {
|
||
#ifdef USE_POINTS_UV
|
||
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
||
#endif
|
||
#include <color_vertex>
|
||
#include <morphinstance_vertex>
|
||
#include <morphcolor_vertex>
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <project_vertex>
|
||
gl_PointSize = size;
|
||
#ifdef USE_SIZEATTENUATION
|
||
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
||
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
|
||
#endif
|
||
#include <logdepthbuf_vertex>
|
||
#include <clipping_planes_vertex>
|
||
#include <worldpos_vertex>
|
||
#include <fog_vertex>
|
||
}`,points_frag:`uniform vec3 diffuse;
|
||
uniform float opacity;
|
||
#include <common>
|
||
#include <color_pars_fragment>
|
||
#include <map_particle_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
vec3 outgoingLight = vec3( 0.0 );
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_particle_fragment>
|
||
#include <color_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_fragment>
|
||
outgoingLight = diffuseColor.rgb;
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_fragment>
|
||
}`,shadow_vert:`#include <common>
|
||
#include <batching_pars_vertex>
|
||
#include <fog_pars_vertex>
|
||
#include <morphtarget_pars_vertex>
|
||
#include <skinning_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
#include <shadowmap_pars_vertex>
|
||
void main() {
|
||
#include <batching_vertex>
|
||
#include <beginnormal_vertex>
|
||
#include <morphinstance_vertex>
|
||
#include <morphnormal_vertex>
|
||
#include <skinbase_vertex>
|
||
#include <skinnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#include <begin_vertex>
|
||
#include <morphtarget_vertex>
|
||
#include <skinning_vertex>
|
||
#include <project_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <worldpos_vertex>
|
||
#include <shadowmap_vertex>
|
||
#include <fog_vertex>
|
||
}`,shadow_frag:`uniform vec3 color;
|
||
uniform float opacity;
|
||
#include <common>
|
||
#include <fog_pars_fragment>
|
||
#include <bsdfs>
|
||
#include <lights_pars_begin>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <shadowmap_pars_fragment>
|
||
#include <shadowmask_pars_fragment>
|
||
void main() {
|
||
#include <logdepthbuf_fragment>
|
||
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
#include <premultiplied_alpha_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>
|
||
}`},Ze={common:{diffuse:{value:new We(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ft},alphaMap:{value:null},alphaMapTransform:{value:new ft},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ft}},envmap:{envMap:{value:null},envMapRotation:{value:new ft},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ft}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ft}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ft},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ft},normalScale:{value:new be(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ft},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ft}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ft}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ft}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new We(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},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 We(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ft},alphaTest:{value:0},uvTransform:{value:new ft}},sprite:{diffuse:{value:new We(16777215)},opacity:{value:1},center:{value:new be(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ft},alphaMap:{value:null},alphaMapTransform:{value:new ft},alphaTest:{value:0}}},ls={basic:{uniforms:un([Ze.common,Ze.specularmap,Ze.envmap,Ze.aomap,Ze.lightmap,Ze.fog]),vertexShader:yt.meshbasic_vert,fragmentShader:yt.meshbasic_frag},lambert:{uniforms:un([Ze.common,Ze.specularmap,Ze.envmap,Ze.aomap,Ze.lightmap,Ze.emissivemap,Ze.bumpmap,Ze.normalmap,Ze.displacementmap,Ze.fog,Ze.lights,{emissive:{value:new We(0)},envMapIntensity:{value:1}}]),vertexShader:yt.meshlambert_vert,fragmentShader:yt.meshlambert_frag},phong:{uniforms:un([Ze.common,Ze.specularmap,Ze.envmap,Ze.aomap,Ze.lightmap,Ze.emissivemap,Ze.bumpmap,Ze.normalmap,Ze.displacementmap,Ze.fog,Ze.lights,{emissive:{value:new We(0)},specular:{value:new We(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:yt.meshphong_vert,fragmentShader:yt.meshphong_frag},standard:{uniforms:un([Ze.common,Ze.envmap,Ze.aomap,Ze.lightmap,Ze.emissivemap,Ze.bumpmap,Ze.normalmap,Ze.displacementmap,Ze.roughnessmap,Ze.metalnessmap,Ze.fog,Ze.lights,{emissive:{value:new We(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:yt.meshphysical_vert,fragmentShader:yt.meshphysical_frag},toon:{uniforms:un([Ze.common,Ze.aomap,Ze.lightmap,Ze.emissivemap,Ze.bumpmap,Ze.normalmap,Ze.displacementmap,Ze.gradientmap,Ze.fog,Ze.lights,{emissive:{value:new We(0)}}]),vertexShader:yt.meshtoon_vert,fragmentShader:yt.meshtoon_frag},matcap:{uniforms:un([Ze.common,Ze.bumpmap,Ze.normalmap,Ze.displacementmap,Ze.fog,{matcap:{value:null}}]),vertexShader:yt.meshmatcap_vert,fragmentShader:yt.meshmatcap_frag},points:{uniforms:un([Ze.points,Ze.fog]),vertexShader:yt.points_vert,fragmentShader:yt.points_frag},dashed:{uniforms:un([Ze.common,Ze.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:yt.linedashed_vert,fragmentShader:yt.linedashed_frag},depth:{uniforms:un([Ze.common,Ze.displacementmap]),vertexShader:yt.depth_vert,fragmentShader:yt.depth_frag},normal:{uniforms:un([Ze.common,Ze.bumpmap,Ze.normalmap,Ze.displacementmap,{opacity:{value:1}}]),vertexShader:yt.meshnormal_vert,fragmentShader:yt.meshnormal_frag},sprite:{uniforms:un([Ze.sprite,Ze.fog]),vertexShader:yt.sprite_vert,fragmentShader:yt.sprite_frag},background:{uniforms:{uvTransform:{value:new ft},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:yt.background_vert,fragmentShader:yt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ft}},vertexShader:yt.backgroundCube_vert,fragmentShader:yt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:yt.cube_vert,fragmentShader:yt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:yt.equirect_vert,fragmentShader:yt.equirect_frag},distance:{uniforms:un([Ze.common,Ze.displacementmap,{referencePosition:{value:new T},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:yt.distance_vert,fragmentShader:yt.distance_frag},shadow:{uniforms:un([Ze.lights,Ze.fog,{color:{value:new We(0)},opacity:{value:1}}]),vertexShader:yt.shadow_vert,fragmentShader:yt.shadow_frag}};ls.physical={uniforms:un([ls.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ft},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ft},clearcoatNormalScale:{value:new be(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ft},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ft},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ft},sheen:{value:0},sheenColor:{value:new We(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ft},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ft},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ft},transmissionSamplerSize:{value:new be},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ft},attenuationDistance:{value:0},attenuationColor:{value:new We(0)},specularColor:{value:new We(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ft},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ft},anisotropyVector:{value:new be},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ft}}]),vertexShader:yt.meshphysical_vert,fragmentShader:yt.meshphysical_frag};const Xu={r:0,b:0,g:0},Oa=new Di,lT=new Ke;function cT(r,e,t,i,n,s){const a=new We(0);let o=n===!0?0:1,l,c,h=null,d=0,p=null;function u(v){let b=v.isScene===!0?v.background:null;if(b&&b.isTexture){const y=v.backgroundBlurriness>0;b=e.get(b,y)}return b}function A(v){let b=!1;const y=u(v);y===null?g(a,o):y&&y.isColor&&(g(y,1),b=!0);const M=r.xr.getEnvironmentBlendMode();M==="additive"?t.buffers.color.setClear(0,0,0,1,s):M==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,s),(r.autoClear||b)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil))}function m(v,b){const y=u(b);y&&(y.isCubeTexture||y.mapping===yo)?(c===void 0&&(c=new Ge(new ri(1,1,1),new ei({name:"BackgroundCubeMaterial",uniforms:$o(ls.backgroundCube.uniforms),vertexShader:ls.backgroundCube.vertexShader,fragmentShader:ls.backgroundCube.fragmentShader,side:qi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(M,_,S){this.matrixWorld.copyPosition(S.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),Oa.copy(b.backgroundRotation),Oa.x*=-1,Oa.y*=-1,Oa.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(Oa.y*=-1,Oa.z*=-1),c.material.uniforms.envMap.value=y,c.material.uniforms.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,c.material.uniforms.backgroundBlurriness.value=b.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(lT.makeRotationFromEuler(Oa)),c.material.toneMapped=Et.getTransfer(y.colorSpace)!==Ut,(h!==y||d!==y.version||p!==r.toneMapping)&&(c.material.needsUpdate=!0,h=y,d=y.version,p=r.toneMapping),c.layers.enableAll(),v.unshift(c,c.geometry,c.material,0,0,null)):y&&y.isTexture&&(l===void 0&&(l=new Ge(new jn(2,2),new ei({name:"BackgroundMaterial",uniforms:$o(ls.background.uniforms),vertexShader:ls.background.vertexShader,fragmentShader:ls.background.fragmentShader,side:Gn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=y,l.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,l.material.toneMapped=Et.getTransfer(y.colorSpace)!==Ut,y.matrixAutoUpdate===!0&&y.updateMatrix(),l.material.uniforms.uvTransform.value.copy(y.matrix),(h!==y||d!==y.version||p!==r.toneMapping)&&(l.material.needsUpdate=!0,h=y,d=y.version,p=r.toneMapping),l.layers.enableAll(),v.unshift(l,l.geometry,l.material,0,0,null))}function g(v,b){v.getRGB(Xu,yb(r)),t.buffers.color.setClear(Xu.r,Xu.g,Xu.b,b,s)}function f(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(v,b=1){a.set(v),o=b,g(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(v){o=v,g(a,o)},render:A,addToRenderList:m,dispose:f}}function hT(r,e){const t=r.getParameter(r.MAX_VERTEX_ATTRIBS),i={},n=p(null);let s=n,a=!1;function o(B,R,U,C,F){let O=!1;const H=d(B,C,U,R);s!==H&&(s=H,c(s.object)),O=u(B,C,U,F),O&&A(B,C,U,F),F!==null&&e.update(F,r.ELEMENT_ARRAY_BUFFER),(O||a)&&(a=!1,y(B,R,U,C),F!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,e.get(F).buffer))}function l(){return r.createVertexArray()}function c(B){return r.bindVertexArray(B)}function h(B){return r.deleteVertexArray(B)}function d(B,R,U,C){const F=C.wireframe===!0;let O=i[R.id];O===void 0&&(O={},i[R.id]=O);const H=B.isInstancedMesh===!0?B.id:0;let j=O[H];j===void 0&&(j={},O[H]=j);let G=j[U.id];G===void 0&&(G={},j[U.id]=G);let re=G[F];return re===void 0&&(re=p(l()),G[F]=re),re}function p(B){const R=[],U=[],C=[];for(let F=0;F<t;F++)R[F]=0,U[F]=0,C[F]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:R,enabledAttributes:U,attributeDivisors:C,object:B,attributes:{},index:null}}function u(B,R,U,C){const F=s.attributes,O=R.attributes;let H=0;const j=U.getAttributes();for(const G in j)if(j[G].location>=0){const q=F[G];let Y=O[G];if(Y===void 0&&(G==="instanceMatrix"&&B.instanceMatrix&&(Y=B.instanceMatrix),G==="instanceColor"&&B.instanceColor&&(Y=B.instanceColor)),q===void 0||q.attribute!==Y||Y&&q.data!==Y.data)return!0;H++}return s.attributesNum!==H||s.index!==C}function A(B,R,U,C){const F={},O=R.attributes;let H=0;const j=U.getAttributes();for(const G in j)if(j[G].location>=0){let q=O[G];q===void 0&&(G==="instanceMatrix"&&B.instanceMatrix&&(q=B.instanceMatrix),G==="instanceColor"&&B.instanceColor&&(q=B.instanceColor));const Y={};Y.attribute=q,q&&q.data&&(Y.data=q.data),F[G]=Y,H++}s.attributes=F,s.attributesNum=H,s.index=C}function m(){const B=s.newAttributes;for(let R=0,U=B.length;R<U;R++)B[R]=0}function g(B){f(B,0)}function f(B,R){const U=s.newAttributes,C=s.enabledAttributes,F=s.attributeDivisors;U[B]=1,C[B]===0&&(r.enableVertexAttribArray(B),C[B]=1),F[B]!==R&&(r.vertexAttribDivisor(B,R),F[B]=R)}function v(){const B=s.newAttributes,R=s.enabledAttributes;for(let U=0,C=R.length;U<C;U++)R[U]!==B[U]&&(r.disableVertexAttribArray(U),R[U]=0)}function b(B,R,U,C,F,O,H){H===!0?r.vertexAttribIPointer(B,R,U,F,O):r.vertexAttribPointer(B,R,U,C,F,O)}function y(B,R,U,C){m();const F=C.attributes,O=U.getAttributes(),H=R.defaultAttributeValues;for(const j in O){const G=O[j];if(G.location>=0){let re=F[j];if(re===void 0&&(j==="instanceMatrix"&&B.instanceMatrix&&(re=B.instanceMatrix),j==="instanceColor"&&B.instanceColor&&(re=B.instanceColor)),re!==void 0){const q=re.normalized,Y=re.itemSize,ye=e.get(re);if(ye===void 0)continue;const Me=ye.buffer,xe=ye.type,J=ye.bytesPerElement,oe=xe===r.INT||xe===r.UNSIGNED_INT||re.gpuType===od;if(re.isInterleavedBufferAttribute){const ue=re.data,Pe=ue.stride,Be=re.offset;if(ue.isInstancedInterleavedBuffer){for(let Ue=0;Ue<G.locationSize;Ue++)f(G.location+Ue,ue.meshPerAttribute);B.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=ue.meshPerAttribute*ue.count)}else for(let Ue=0;Ue<G.locationSize;Ue++)g(G.location+Ue);r.bindBuffer(r.ARRAY_BUFFER,Me);for(let Ue=0;Ue<G.locationSize;Ue++)b(G.location+Ue,Y/G.locationSize,xe,q,Pe*J,(Be+Y/G.locationSize*Ue)*J,oe)}else{if(re.isInstancedBufferAttribute){for(let ue=0;ue<G.locationSize;ue++)f(G.location+ue,re.meshPerAttribute);B.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let ue=0;ue<G.locationSize;ue++)g(G.location+ue);r.bindBuffer(r.ARRAY_BUFFER,Me);for(let ue=0;ue<G.locationSize;ue++)b(G.location+ue,Y/G.locationSize,xe,q,Y*J,Y/G.locationSize*ue*J,oe)}}else if(H!==void 0){const q=H[j];if(q!==void 0)switch(q.length){case 2:r.vertexAttrib2fv(G.location,q);break;case 3:r.vertexAttrib3fv(G.location,q);break;case 4:r.vertexAttrib4fv(G.location,q);break;default:r.vertexAttrib1fv(G.location,q)}}}}v()}function M(){E();for(const B in i){const R=i[B];for(const U in R){const C=R[U];for(const F in C){const O=C[F];for(const H in O)h(O[H].object),delete O[H];delete C[F]}}delete i[B]}}function _(B){if(i[B.id]===void 0)return;const R=i[B.id];for(const U in R){const C=R[U];for(const F in C){const O=C[F];for(const H in O)h(O[H].object),delete O[H];delete C[F]}}delete i[B.id]}function S(B){for(const R in i){const U=i[R];for(const C in U){const F=U[C];if(F[B.id]===void 0)continue;const O=F[B.id];for(const H in O)h(O[H].object),delete O[H];delete F[B.id]}}}function w(B){for(const R in i){const U=i[R],C=B.isInstancedMesh===!0?B.id:0,F=U[C];if(F!==void 0){for(const O in F){const H=F[O];for(const j in H)h(H[j].object),delete H[j];delete F[O]}delete U[C],Object.keys(U).length===0&&delete i[R]}}}function E(){I(),a=!0,s!==n&&(s=n,c(s.object))}function I(){n.geometry=null,n.program=null,n.wireframe=!1}return{setup:o,reset:E,resetDefaultState:I,dispose:M,releaseStatesOfGeometry:_,releaseStatesOfObject:w,releaseStatesOfProgram:S,initAttributes:m,enableAttribute:g,disableUnusedAttributes:v}}function dT(r,e,t){let i;function n(c){i=c}function s(c,h){r.drawArrays(i,c,h),t.update(h,i,1)}function a(c,h,d){d!==0&&(r.drawArraysInstanced(i,c,h,d),t.update(h,i,d))}function o(c,h,d){if(d===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,h,0,d);let u=0;for(let A=0;A<d;A++)u+=h[A];t.update(u,i,1)}function l(c,h,d,p){if(d===0)return;const u=e.get("WEBGL_multi_draw");if(u===null)for(let A=0;A<c.length;A++)a(c[A],h[A],p[A]);else{u.multiDrawArraysInstancedWEBGL(i,c,0,h,0,p,0,d);let A=0;for(let m=0;m<d;m++)A+=h[m]*p[m];t.update(A,i,1)}}this.setMode=n,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function uT(r,e,t,i){let n;function s(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const S=e.get("EXT_texture_filter_anisotropic");n=r.getParameter(S.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function a(S){return!(S!==hi&&i.convert(S)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(S){const w=S===Zt&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(S!==ut&&i.convert(S)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)&&S!==oi&&!w)}function l(S){if(S==="highp"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";S="mediump"}return S==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(Ye("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const d=t.logarithmicDepthBuffer===!0,p=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),u=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),A=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=r.getParameter(r.MAX_TEXTURE_SIZE),g=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),f=r.getParameter(r.MAX_VERTEX_ATTRIBS),v=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),b=r.getParameter(r.MAX_VARYING_VECTORS),y=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),M=r.getParameter(r.MAX_SAMPLES),_=r.getParameter(r.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:p,maxTextures:u,maxVertexTextures:A,maxTextureSize:m,maxCubemapSize:g,maxAttributes:f,maxVertexUniforms:v,maxVaryings:b,maxFragmentUniforms:y,maxSamples:M,samples:_}}function pT(r){const e=this;let t=null,i=0,n=!1,s=!1;const a=new li,o=new ft,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,p){const u=d.length!==0||p||i!==0||n;return n=p,i=d.length,u},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,p){t=h(d,p,0)},this.setState=function(d,p,u){const A=d.clippingPlanes,m=d.clipIntersection,g=d.clipShadows,f=r.get(d);if(!n||A===null||A.length===0||s&&!g)s?h(null):c();else{const v=s?0:i,b=v*4;let y=f.clippingState||null;l.value=y,y=h(A,p,b,u);for(let M=0;M!==b;++M)y[M]=t[M];f.clippingState=y,this.numIntersection=m?this.numPlanes:0,this.numPlanes+=v}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(d,p,u,A){const m=d!==null?d.length:0;let g=null;if(m!==0){if(g=l.value,A!==!0||g===null){const f=u+m*4,v=p.matrixWorldInverse;o.getNormalMatrix(v),(g===null||g.length<f)&&(g=new Float32Array(f));for(let b=0,y=u;b!==m;++b,y+=4)a.copy(d[b]).applyMatrix4(v,o),a.normal.toArray(g,y),g[y+3]=a.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=m,e.numIntersection=0,g}}const Or=4,f1=[.125,.215,.35,.446,.526,.582],za=20,fT=256,Yc=new Ki,m1=new We;let Km=null,Zm=0,Jm=0,$m=!1;const mT=new T;class Kc{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,n=100,s={}){const{size:a=256,position:o=mT}=s;Km=this._renderer.getRenderTarget(),Zm=this._renderer.getActiveCubeFace(),Jm=this._renderer.getActiveMipmapLevel(),$m=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,n,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=v1(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=A1(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Km,Zm,Jm),this._renderer.xr.enabled=$m,e.scissorTest=!1,ll(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ys||e.mapping===gr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Km=this._renderer.getRenderTarget(),Zm=this._renderer.getActiveCubeFace(),Jm=this._renderer.getActiveMipmapLevel(),$m=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:_t,minFilter:_t,generateMipmaps:!1,type:Zt,format:hi,colorSpace:Ri,depthBuffer:!1},n=g1(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=g1(e,t,i);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=gT(s)),this._blurMaterial=vT(s,e,t),this._ggxMaterial=AT(s,e,t)}return n}_compileMaterial(e){const t=new Ge(new ot,e);this._renderer.compile(t,Yc)}_sceneToCubeUV(e,t,i,n,s){const l=new pi(90,1,t,i),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],d=this._renderer,p=d.autoClear,u=d.toneMapping;d.getClearColor(m1),d.toneMapping=Xi,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(n),d.clearDepth(),d.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Ge(new ri,new Rt({name:"PMREM.Background",side:qi,depthWrite:!1,depthTest:!1})));const m=this._backgroundBox,g=m.material;let f=!1;const v=e.background;v?v.isColor&&(g.color.copy(v),e.background=null,f=!0):(g.color.copy(m1),f=!0);for(let b=0;b<6;b++){const y=b%3;y===0?(l.up.set(0,c[b],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+h[b],s.y,s.z)):y===1?(l.up.set(0,0,c[b]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+h[b],s.z)):(l.up.set(0,c[b],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+h[b]));const M=this._cubeSize;ll(n,y*M,b>2?M:0,M,M),d.setRenderTarget(n),f&&d.render(m,l),d.render(e,l)}d.toneMapping=u,d.autoClear=p,e.background=v}_textureToCubeUV(e,t){const i=this._renderer,n=e.mapping===ys||e.mapping===gr;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=v1()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=A1());const s=n?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;ll(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,Yc)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const n=this._lodMeshes.length;for(let s=1;s<n;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=i}_applyGGXFilter(e,t,i){const n=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[i];o.material=a;const l=a.uniforms,c=i/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),d=Math.sqrt(c*c-h*h),p=0+c*1.25,u=d*p,{_lodMax:A}=this,m=this._sizeLods[i],g=3*m*(i>A-Or?i-A+Or:0),f=4*(this._cubeSize-m);l.envMap.value=e.texture,l.roughness.value=u,l.mipInt.value=A-t,ll(s,g,f,3*m,2*m),n.setRenderTarget(s),n.render(o,Yc),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=A-i,ll(e,g,f,3*m,2*m),n.setRenderTarget(e),n.render(o,Yc)}_blur(e,t,i,n,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,n,"latitudinal",s),this._halfBlur(a,e,i,i,n,"longitudinal",s)}_halfBlur(e,t,i,n,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&ct("blur direction must be either latitudinal or longitudinal!");const h=3,d=this._lodMeshes[n];d.material=c;const p=c.uniforms,u=this._sizeLods[i]-1,A=isFinite(s)?Math.PI/(2*u):2*Math.PI/(2*za-1),m=s/A,g=isFinite(s)?1+Math.floor(h*m):za;g>za&&Ye(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${za}`);const f=[];let v=0;for(let S=0;S<za;++S){const w=S/m,E=Math.exp(-w*w/2);f.push(E),S===0?v+=E:S<g&&(v+=2*E)}for(let S=0;S<f.length;S++)f[S]=f[S]/v;p.envMap.value=e.texture,p.samples.value=g,p.weights.value=f,p.latitudinal.value=a==="latitudinal",o&&(p.poleAxis.value=o);const{_lodMax:b}=this;p.dTheta.value=A,p.mipInt.value=b-i;const y=this._sizeLods[n],M=3*y*(n>b-Or?n-b+Or:0),_=4*(this._cubeSize-y);ll(t,M,_,3*y,2*y),l.setRenderTarget(t),l.render(d,Yc)}}function gT(r){const e=[],t=[],i=[];let n=r;const s=r-Or+1+f1.length;for(let a=0;a<s;a++){const o=Math.pow(2,n);e.push(o);let l=1/o;a>r-Or?l=f1[a-r+Or-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),h=-c,d=1+c,p=[h,h,d,h,d,d,h,h,d,d,h,d],u=6,A=6,m=3,g=2,f=1,v=new Float32Array(m*A*u),b=new Float32Array(g*A*u),y=new Float32Array(f*A*u);for(let _=0;_<u;_++){const S=_%3*2/3-1,w=_>2?0:-1,E=[S,w,0,S+2/3,w,0,S+2/3,w+1,0,S,w,0,S+2/3,w+1,0,S,w+1,0];v.set(E,m*A*_),b.set(p,g*A*_);const I=[_,_,_,_,_,_];y.set(I,f*A*_)}const M=new ot;M.setAttribute("position",new St(v,m)),M.setAttribute("uv",new St(b,g)),M.setAttribute("faceIndex",new St(y,f)),i.push(new Ge(M,null)),n>Or&&n--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function g1(r,e,t){const i=new Ei(r,e,t);return i.texture.mapping=yo,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function ll(r,e,t,i,n){r.viewport.set(e,t,i,n),r.scissor.set(e,t,i,n)}function AT(r,e,t){return new ei({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:fT,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Yu(),fragmentShader:`
|
||
|
||
precision highp float;
|
||
precision highp int;
|
||
|
||
varying vec3 vOutputDirection;
|
||
|
||
uniform sampler2D envMap;
|
||
uniform float roughness;
|
||
uniform float mipInt;
|
||
|
||
#define ENVMAP_TYPE_CUBE_UV
|
||
#include <cube_uv_reflection_fragment>
|
||
|
||
#define PI 3.14159265359
|
||
|
||
// Van der Corput radical inverse
|
||
float radicalInverse_VdC(uint bits) {
|
||
bits = (bits << 16u) | (bits >> 16u);
|
||
bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
|
||
bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
|
||
bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
|
||
bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
|
||
return float(bits) * 2.3283064365386963e-10; // / 0x100000000
|
||
}
|
||
|
||
// Hammersley sequence
|
||
vec2 hammersley(uint i, uint N) {
|
||
return vec2(float(i) / float(N), radicalInverse_VdC(i));
|
||
}
|
||
|
||
// GGX VNDF importance sampling (Eric Heitz 2018)
|
||
// "Sampling the GGX Distribution of Visible Normals"
|
||
// https://jcgt.org/published/0007/04/01/
|
||
vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
|
||
float alpha = roughness * roughness;
|
||
|
||
// Section 4.1: Orthonormal basis
|
||
vec3 T1 = vec3(1.0, 0.0, 0.0);
|
||
vec3 T2 = cross(V, T1);
|
||
|
||
// Section 4.2: Parameterization of projected area
|
||
float r = sqrt(Xi.x);
|
||
float phi = 2.0 * PI * Xi.y;
|
||
float t1 = r * cos(phi);
|
||
float t2 = r * sin(phi);
|
||
float s = 0.5 * (1.0 + V.z);
|
||
t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
|
||
|
||
// Section 4.3: Reprojection onto hemisphere
|
||
vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;
|
||
|
||
// Section 3.4: Transform back to ellipsoid configuration
|
||
return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
|
||
}
|
||
|
||
void main() {
|
||
vec3 N = normalize(vOutputDirection);
|
||
vec3 V = N; // Assume view direction equals normal for pre-filtering
|
||
|
||
vec3 prefilteredColor = vec3(0.0);
|
||
float totalWeight = 0.0;
|
||
|
||
// For very low roughness, just sample the environment directly
|
||
if (roughness < 0.001) {
|
||
gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
|
||
return;
|
||
}
|
||
|
||
// Tangent space basis for VNDF sampling
|
||
vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
|
||
vec3 tangent = normalize(cross(up, N));
|
||
vec3 bitangent = cross(N, tangent);
|
||
|
||
for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
|
||
vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
|
||
|
||
// For PMREM, V = N, so in tangent space V is always (0, 0, 1)
|
||
vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
|
||
|
||
// Transform H back to world space
|
||
vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
|
||
vec3 L = normalize(2.0 * dot(V, H) * H - V);
|
||
|
||
float NdotL = max(dot(N, L), 0.0);
|
||
|
||
if(NdotL > 0.0) {
|
||
// Sample environment at fixed mip level
|
||
// VNDF importance sampling handles the distribution filtering
|
||
vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
|
||
|
||
// Weight by NdotL for the split-sum approximation
|
||
// VNDF PDF naturally accounts for the visible microfacet distribution
|
||
prefilteredColor += sampleColor * NdotL;
|
||
totalWeight += NdotL;
|
||
}
|
||
}
|
||
|
||
if (totalWeight > 0.0) {
|
||
prefilteredColor = prefilteredColor / totalWeight;
|
||
}
|
||
|
||
gl_FragColor = vec4(prefilteredColor, 1.0);
|
||
}
|
||
`,blending:ti,depthTest:!1,depthWrite:!1})}function vT(r,e,t){const i=new Float32Array(za),n=new T(0,1,0);return new ei({name:"SphericalGaussianBlur",defines:{n:za,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:n}},vertexShader:Yu(),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:ti,depthTest:!1,depthWrite:!1})}function A1(){return new ei({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Yu(),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:ti,depthTest:!1,depthWrite:!1})}function v1(){return new ei({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Yu(),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:ti,depthTest:!1,depthWrite:!1})}function Yu(){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 );
|
||
|
||
}
|
||
`}class eg extends Ei{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},n=[i,i,i,i,i,i];this.texture=new Uc(n),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 i={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 );
|
||
|
||
}
|
||
`},n=new ri(5,5,5),s=new ei({name:"CubemapFromEquirect",uniforms:$o(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:qi,blending:ti});s.uniforms.tEquirect.value=t;const a=new Ge(n,s),o=t.minFilter;return t.minFilter===An&&(t.minFilter=_t),new qb(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,n=!0){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,n);e.setRenderTarget(s)}}function bT(r){let e=new WeakMap,t=new WeakMap,i=null;function n(p,u=!1){return p==null?null:u?a(p):s(p)}function s(p){if(p&&p.isTexture){const u=p.mapping;if(u===bo||u===Zl)if(e.has(p)){const A=e.get(p).texture;return o(A,p.mapping)}else{const A=p.image;if(A&&A.height>0){const m=new eg(A.height);return m.fromEquirectangularTexture(r,p),e.set(p,m),p.addEventListener("dispose",c),o(m.texture,p.mapping)}else return null}}return p}function a(p){if(p&&p.isTexture){const u=p.mapping,A=u===bo||u===Zl,m=u===ys||u===gr;if(A||m){let g=t.get(p);const f=g!==void 0?g.texture.pmremVersion:0;if(p.isRenderTargetTexture&&p.pmremVersion!==f)return i===null&&(i=new Kc(r)),g=A?i.fromEquirectangular(p,g):i.fromCubemap(p,g),g.texture.pmremVersion=p.pmremVersion,t.set(p,g),g.texture;if(g!==void 0)return g.texture;{const v=p.image;return A&&v&&v.height>0||m&&v&&l(v)?(i===null&&(i=new Kc(r)),g=A?i.fromEquirectangular(p):i.fromCubemap(p),g.texture.pmremVersion=p.pmremVersion,t.set(p,g),p.addEventListener("dispose",h),g.texture):null}}}return p}function o(p,u){return u===bo?p.mapping=ys:u===Zl&&(p.mapping=gr),p}function l(p){let u=0;const A=6;for(let m=0;m<A;m++)p[m]!==void 0&&u++;return u===A}function c(p){const u=p.target;u.removeEventListener("dispose",c);const A=e.get(u);A!==void 0&&(e.delete(u),A.dispose())}function h(p){const u=p.target;u.removeEventListener("dispose",h);const A=t.get(u);A!==void 0&&(t.delete(u),A.dispose())}function d(){e=new WeakMap,t=new WeakMap,i!==null&&(i.dispose(),i=null)}return{get:n,dispose:d}}function yT(r){const e={};function t(i){if(e[i]!==void 0)return e[i];const n=r.getExtension(i);return e[i]=n,n}return{has:function(i){return t(i)!==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(i){const n=t(i);return n===null&&bc("WebGLRenderer: "+i+" extension not supported."),n}}}function xT(r,e,t,i){const n={},s=new WeakMap;function a(d){const p=d.target;p.index!==null&&e.remove(p.index);for(const A in p.attributes)e.remove(p.attributes[A]);p.removeEventListener("dispose",a),delete n[p.id];const u=s.get(p);u&&(e.remove(u),s.delete(p)),i.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,t.memory.geometries--}function o(d,p){return n[p.id]===!0||(p.addEventListener("dispose",a),n[p.id]=!0,t.memory.geometries++),p}function l(d){const p=d.attributes;for(const u in p)e.update(p[u],r.ARRAY_BUFFER)}function c(d){const p=[],u=d.index,A=d.attributes.position;let m=0;if(A===void 0)return;if(u!==null){const v=u.array;m=u.version;for(let b=0,y=v.length;b<y;b+=3){const M=v[b+0],_=v[b+1],S=v[b+2];p.push(M,_,_,S,S,M)}}else{const v=A.array;m=A.version;for(let b=0,y=v.length/3-1;b<y;b+=3){const M=b+0,_=b+1,S=b+2;p.push(M,_,_,S,S,M)}}const g=new(A.count>=65535?Xf:qf)(p,1);g.version=m;const f=s.get(d);f&&e.remove(f),s.set(d,g)}function h(d){const p=s.get(d);if(p){const u=d.index;u!==null&&p.version<u.version&&c(d)}else c(d);return s.get(d)}return{get:o,update:l,getWireframeAttribute:h}}function _T(r,e,t){let i;function n(p){i=p}let s,a;function o(p){s=p.type,a=p.bytesPerElement}function l(p,u){r.drawElements(i,u,s,p*a),t.update(u,i,1)}function c(p,u,A){A!==0&&(r.drawElementsInstanced(i,u,s,p*a,A),t.update(u,i,A))}function h(p,u,A){if(A===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,u,0,s,p,0,A);let g=0;for(let f=0;f<A;f++)g+=u[f];t.update(g,i,1)}function d(p,u,A,m){if(A===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let f=0;f<p.length;f++)c(p[f]/a,u[f],m[f]);else{g.multiDrawElementsInstancedWEBGL(i,u,0,s,p,0,m,0,A);let f=0;for(let v=0;v<A;v++)f+=u[v]*m[v];t.update(f,i,1)}}this.setMode=n,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=d}function ET(r){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,a,o){switch(t.calls++,a){case r.TRIANGLES:t.triangles+=o*(s/3);break;case r.LINES:t.lines+=o*(s/2);break;case r.LINE_STRIP:t.lines+=o*(s-1);break;case r.LINE_LOOP:t.lines+=o*s;break;case r.POINTS:t.points+=o*s;break;default:ct("WebGLInfo: Unknown draw mode:",a);break}}function n(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:n,update:i}}function MT(r,e,t){const i=new WeakMap,n=new Gt;function s(a,o,l){const c=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=h!==void 0?h.length:0;let p=i.get(o);if(p===void 0||p.count!==d){let E=function(){S.dispose(),i.delete(o),o.removeEventListener("dispose",E)};p!==void 0&&p.texture.dispose();const u=o.morphAttributes.position!==void 0,A=o.morphAttributes.normal!==void 0,m=o.morphAttributes.color!==void 0,g=o.morphAttributes.position||[],f=o.morphAttributes.normal||[],v=o.morphAttributes.color||[];let b=0;u===!0&&(b=1),A===!0&&(b=2),m===!0&&(b=3);let y=o.attributes.position.count*b,M=1;y>e.maxTextureSize&&(M=Math.ceil(y/e.maxTextureSize),y=e.maxTextureSize);const _=new Float32Array(y*M*4*d),S=new Rd(_,y,M,d);S.type=oi,S.needsUpdate=!0;const w=b*4;for(let I=0;I<d;I++){const B=g[I],R=f[I],U=v[I],C=y*M*4*I;for(let F=0;F<B.count;F++){const O=F*w;u===!0&&(n.fromBufferAttribute(B,F),_[C+O+0]=n.x,_[C+O+1]=n.y,_[C+O+2]=n.z,_[C+O+3]=0),A===!0&&(n.fromBufferAttribute(R,F),_[C+O+4]=n.x,_[C+O+5]=n.y,_[C+O+6]=n.z,_[C+O+7]=0),m===!0&&(n.fromBufferAttribute(U,F),_[C+O+8]=n.x,_[C+O+9]=n.y,_[C+O+10]=n.z,_[C+O+11]=U.itemSize===4?n.w:1)}}p={count:d,texture:S,size:new be(y,M)},i.set(o,p),o.addEventListener("dispose",E)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(r,"morphTexture",a.morphTexture,t);else{let u=0;for(let m=0;m<c.length;m++)u+=c[m];const A=o.morphTargetsRelative?1:1-u;l.getUniforms().setValue(r,"morphTargetBaseInfluence",A),l.getUniforms().setValue(r,"morphTargetInfluences",c)}l.getUniforms().setValue(r,"morphTargetsTexture",p.texture,t),l.getUniforms().setValue(r,"morphTargetsTextureSize",p.size)}return{update:s}}function wT(r,e,t,i,n){let s=new WeakMap;function a(c){const h=n.render.frame,d=c.geometry,p=e.get(c,d);if(s.get(p)!==h&&(e.update(p),s.set(p,h)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),s.get(c)!==h&&(t.update(c.instanceMatrix,r.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,r.ARRAY_BUFFER),s.set(c,h))),c.isSkinnedMesh){const u=c.skeleton;s.get(u)!==h&&(u.update(),s.set(u,h))}return p}function o(){s=new WeakMap}function l(c){const h=c.target;h.removeEventListener("dispose",l),i.releaseStatesOfObject(h),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:a,dispose:o}}const ST={[ed]:"LINEAR_TONE_MAPPING",[td]:"REINHARD_TONE_MAPPING",[id]:"CINEON_TONE_MAPPING",[ra]:"ACES_FILMIC_TONE_MAPPING",[sd]:"AGX_TONE_MAPPING",[rd]:"NEUTRAL_TONE_MAPPING",[nd]:"CUSTOM_TONE_MAPPING"};function CT(r,e,t,i,n){const s=new Ei(e,t,{type:r,depthBuffer:i,stencilBuffer:n}),a=new Ei(e,t,{type:Zt,depthBuffer:!1,stencilBuffer:!1}),o=new ot;o.setAttribute("position",new tt([-1,3,0,-1,-1,0,3,-1,0],3)),o.setAttribute("uv",new tt([0,2,0,0,2,0],2));const l=new Lu({uniforms:{tDiffuse:{value:null}},vertexShader:`
|
||
precision highp float;
|
||
|
||
uniform mat4 modelViewMatrix;
|
||
uniform mat4 projectionMatrix;
|
||
|
||
attribute vec3 position;
|
||
attribute vec2 uv;
|
||
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,fragmentShader:`
|
||
precision highp float;
|
||
|
||
uniform sampler2D tDiffuse;
|
||
|
||
varying vec2 vUv;
|
||
|
||
#include <tonemapping_pars_fragment>
|
||
#include <colorspace_pars_fragment>
|
||
|
||
void main() {
|
||
gl_FragColor = texture2D( tDiffuse, vUv );
|
||
|
||
#ifdef LINEAR_TONE_MAPPING
|
||
gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
|
||
#elif defined( REINHARD_TONE_MAPPING )
|
||
gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
|
||
#elif defined( CINEON_TONE_MAPPING )
|
||
gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
|
||
#elif defined( ACES_FILMIC_TONE_MAPPING )
|
||
gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
|
||
#elif defined( AGX_TONE_MAPPING )
|
||
gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
|
||
#elif defined( NEUTRAL_TONE_MAPPING )
|
||
gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
|
||
#elif defined( CUSTOM_TONE_MAPPING )
|
||
gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
|
||
#endif
|
||
|
||
#ifdef SRGB_TRANSFER
|
||
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
||
#endif
|
||
}`,depthTest:!1,depthWrite:!1}),c=new Ge(o,l),h=new Ki(-1,1,1,-1,0,1);let d=null,p=null,u=!1,A,m=null,g=[],f=!1;this.setSize=function(v,b){s.setSize(v,b),a.setSize(v,b);for(let y=0;y<g.length;y++){const M=g[y];M.setSize&&M.setSize(v,b)}},this.setEffects=function(v){g=v,f=g.length>0&&g[0].isRenderPass===!0;const b=s.width,y=s.height;for(let M=0;M<g.length;M++){const _=g[M];_.setSize&&_.setSize(b,y)}},this.begin=function(v,b){if(u||v.toneMapping===Xi&&g.length===0)return!1;if(m=b,b!==null){const y=b.width,M=b.height;(s.width!==y||s.height!==M)&&this.setSize(y,M)}return f===!1&&v.setRenderTarget(s),A=v.toneMapping,v.toneMapping=Xi,!0},this.hasRenderPass=function(){return f},this.end=function(v,b){v.toneMapping=A,u=!0;let y=s,M=a;for(let _=0;_<g.length;_++){const S=g[_];if(S.enabled!==!1&&(S.render(v,M,y,b),S.needsSwap!==!1)){const w=y;y=M,M=w}}if(d!==v.outputColorSpace||p!==v.toneMapping){d=v.outputColorSpace,p=v.toneMapping,l.defines={},Et.getTransfer(d)===Ut&&(l.defines.SRGB_TRANSFER="");const _=ST[p];_&&(l.defines[_]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=y.texture,v.setRenderTarget(m),v.render(c,h),m=null,u=!1},this.isCompositing=function(){return u},this.dispose=function(){s.dispose(),a.dispose(),o.dispose(),l.dispose()}}const b1=new ii,tg=new Rr(1,1),y1=new Rd,x1=new xc,_1=new Uc,E1=[],M1=[],w1=new Float32Array(16),S1=new Float32Array(9),C1=new Float32Array(4);function cl(r,e,t){const i=r[0];if(i<=0||i>0)return r;const n=e*t;let s=E1[n];if(s===void 0&&(s=new Float32Array(n),E1[n]=s),e!==0){i.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,r[a].toArray(s,o)}return s}function ki(r,e){if(r.length!==e.length)return!1;for(let t=0,i=r.length;t<i;t++)if(r[t]!==e[t])return!1;return!0}function Ni(r,e){for(let t=0,i=e.length;t<i;t++)r[t]=e[t]}function Ku(r,e){let t=M1[e];t===void 0&&(t=new Int32Array(e),M1[e]=t);for(let i=0;i!==e;++i)t[i]=r.allocateTextureUnit();return t}function TT(r,e){const t=this.cache;t[0]!==e&&(r.uniform1f(this.addr,e),t[0]=e)}function IT(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ki(t,e))return;r.uniform2fv(this.addr,e),Ni(t,e)}}function PT(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.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)&&(r.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(ki(t,e))return;r.uniform3fv(this.addr,e),Ni(t,e)}}function RT(r,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)&&(r.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(ki(t,e))return;r.uniform4fv(this.addr,e),Ni(t,e)}}function DT(r,e){const t=this.cache,i=e.elements;if(i===void 0){if(ki(t,e))return;r.uniformMatrix2fv(this.addr,!1,e),Ni(t,e)}else{if(ki(t,i))return;C1.set(i),r.uniformMatrix2fv(this.addr,!1,C1),Ni(t,i)}}function BT(r,e){const t=this.cache,i=e.elements;if(i===void 0){if(ki(t,e))return;r.uniformMatrix3fv(this.addr,!1,e),Ni(t,e)}else{if(ki(t,i))return;S1.set(i),r.uniformMatrix3fv(this.addr,!1,S1),Ni(t,i)}}function LT(r,e){const t=this.cache,i=e.elements;if(i===void 0){if(ki(t,e))return;r.uniformMatrix4fv(this.addr,!1,e),Ni(t,e)}else{if(ki(t,i))return;w1.set(i),r.uniformMatrix4fv(this.addr,!1,w1),Ni(t,i)}}function kT(r,e){const t=this.cache;t[0]!==e&&(r.uniform1i(this.addr,e),t[0]=e)}function NT(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ki(t,e))return;r.uniform2iv(this.addr,e),Ni(t,e)}}function UT(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(ki(t,e))return;r.uniform3iv(this.addr,e),Ni(t,e)}}function FT(r,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)&&(r.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(ki(t,e))return;r.uniform4iv(this.addr,e),Ni(t,e)}}function OT(r,e){const t=this.cache;t[0]!==e&&(r.uniform1ui(this.addr,e),t[0]=e)}function zT(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ki(t,e))return;r.uniform2uiv(this.addr,e),Ni(t,e)}}function HT(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(ki(t,e))return;r.uniform3uiv(this.addr,e),Ni(t,e)}}function GT(r,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)&&(r.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(ki(t,e))return;r.uniform4uiv(this.addr,e),Ni(t,e)}}function VT(r,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(r.uniform1i(this.addr,n),i[0]=n);let s;this.type===r.SAMPLER_2D_SHADOW?(tg.compareFunction=t.isReversedDepthBuffer()?Pd:Id,s=tg):s=b1,t.setTexture2D(e||s,n)}function QT(r,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(r.uniform1i(this.addr,n),i[0]=n),t.setTexture3D(e||x1,n)}function WT(r,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(r.uniform1i(this.addr,n),i[0]=n),t.setTextureCube(e||_1,n)}function jT(r,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(r.uniform1i(this.addr,n),i[0]=n),t.setTexture2DArray(e||y1,n)}function qT(r){switch(r){case 5126:return TT;case 35664:return IT;case 35665:return PT;case 35666:return RT;case 35674:return DT;case 35675:return BT;case 35676:return LT;case 5124:case 35670:return kT;case 35667:case 35671:return NT;case 35668:case 35672:return UT;case 35669:case 35673:return FT;case 5125:return OT;case 36294:return zT;case 36295:return HT;case 36296:return GT;case 35678:case 36198:case 36298:case 36306:case 35682:return VT;case 35679:case 36299:case 36307:return QT;case 35680:case 36300:case 36308:case 36293:return WT;case 36289:case 36303:case 36311:case 36292:return jT}}function XT(r,e){r.uniform1fv(this.addr,e)}function YT(r,e){const t=cl(e,this.size,2);r.uniform2fv(this.addr,t)}function KT(r,e){const t=cl(e,this.size,3);r.uniform3fv(this.addr,t)}function ZT(r,e){const t=cl(e,this.size,4);r.uniform4fv(this.addr,t)}function JT(r,e){const t=cl(e,this.size,4);r.uniformMatrix2fv(this.addr,!1,t)}function $T(r,e){const t=cl(e,this.size,9);r.uniformMatrix3fv(this.addr,!1,t)}function eI(r,e){const t=cl(e,this.size,16);r.uniformMatrix4fv(this.addr,!1,t)}function tI(r,e){r.uniform1iv(this.addr,e)}function iI(r,e){r.uniform2iv(this.addr,e)}function nI(r,e){r.uniform3iv(this.addr,e)}function sI(r,e){r.uniform4iv(this.addr,e)}function rI(r,e){r.uniform1uiv(this.addr,e)}function aI(r,e){r.uniform2uiv(this.addr,e)}function oI(r,e){r.uniform3uiv(this.addr,e)}function lI(r,e){r.uniform4uiv(this.addr,e)}function cI(r,e,t){const i=this.cache,n=e.length,s=Ku(t,n);ki(i,s)||(r.uniform1iv(this.addr,s),Ni(i,s));let a;this.type===r.SAMPLER_2D_SHADOW?a=tg:a=b1;for(let o=0;o!==n;++o)t.setTexture2D(e[o]||a,s[o])}function hI(r,e,t){const i=this.cache,n=e.length,s=Ku(t,n);ki(i,s)||(r.uniform1iv(this.addr,s),Ni(i,s));for(let a=0;a!==n;++a)t.setTexture3D(e[a]||x1,s[a])}function dI(r,e,t){const i=this.cache,n=e.length,s=Ku(t,n);ki(i,s)||(r.uniform1iv(this.addr,s),Ni(i,s));for(let a=0;a!==n;++a)t.setTextureCube(e[a]||_1,s[a])}function uI(r,e,t){const i=this.cache,n=e.length,s=Ku(t,n);ki(i,s)||(r.uniform1iv(this.addr,s),Ni(i,s));for(let a=0;a!==n;++a)t.setTexture2DArray(e[a]||y1,s[a])}function pI(r){switch(r){case 5126:return XT;case 35664:return YT;case 35665:return KT;case 35666:return ZT;case 35674:return JT;case 35675:return $T;case 35676:return eI;case 5124:case 35670:return tI;case 35667:case 35671:return iI;case 35668:case 35672:return nI;case 35669:case 35673:return sI;case 5125:return rI;case 36294:return aI;case 36295:return oI;case 36296:return lI;case 35678:case 36198:case 36298:case 36306:case 35682:return cI;case 35679:case 36299:case 36307:return hI;case 35680:case 36300:case 36308:case 36293:return dI;case 36289:case 36303:case 36311:case 36292:return uI}}class fI{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=qT(t.type)}}class mI{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=pI(t.type)}}class gI{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const n=this.seq;for(let s=0,a=n.length;s!==a;++s){const o=n[s];o.setValue(e,t[o.id],i)}}}const ig=/(\w+)(\])?(\[|\.)?/g;function T1(r,e){r.seq.push(e),r.map[e.id]=e}function AI(r,e,t){const i=r.name,n=i.length;for(ig.lastIndex=0;;){const s=ig.exec(i),a=ig.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===n){T1(t,c===void 0?new fI(o,r,e):new mI(o,r,e));break}else{let d=t.map[o];d===void 0&&(d=new gI(o),T1(t,d)),t=d}}}class Zu{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<i;++a){const o=e.getActiveUniform(t,a),l=e.getUniformLocation(t,o.name);AI(o,l,this)}const n=[],s=[];for(const a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?n.push(a):s.push(a);n.length>0&&(this.seq=n.concat(s))}setValue(e,t,i,n){const s=this.map[t];s!==void 0&&s.setValue(e,i,n)}setOptional(e,t,i){const n=t[i];n!==void 0&&this.setValue(e,i,n)}static upload(e,t,i,n){for(let s=0,a=t.length;s!==a;++s){const o=t[s],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,n)}}static seqWithValue(e,t){const i=[];for(let n=0,s=e.length;n!==s;++n){const a=e[n];a.id in t&&i.push(a)}return i}}function I1(r,e,t){const i=r.createShader(e);return r.shaderSource(i,t),r.compileShader(i),i}const vI=37297;let bI=0;function yI(r,e){const t=r.split(`
|
||
`),i=[],n=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=n;a<s;a++){const o=a+1;i.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return i.join(`
|
||
`)}const P1=new ft;function xI(r){Et._getMatrix(P1,Et.workingColorSpace,r);const e=`mat3( ${P1.elements.map(t=>t.toFixed(4))} )`;switch(Et.getTransfer(r)){case mc:return[e,"LinearTransferOETF"];case Ut:return[e,"sRGBTransferOETF"];default:return Ye("WebGLProgram: Unsupported color space: ",r),[e,"LinearTransferOETF"]}}function R1(r,e,t){const i=r.getShaderParameter(e,r.COMPILE_STATUS),s=(r.getShaderInfoLog(e)||"").trim();if(i&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
|
||
|
||
`+s+`
|
||
|
||
`+yI(r.getShaderSource(e),o)}else return s}function _I(r,e){const t=xI(e);return[`vec4 ${r}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
||
`)}const EI={[ed]:"Linear",[td]:"Reinhard",[id]:"Cineon",[ra]:"ACESFilmic",[sd]:"AgX",[rd]:"Neutral",[nd]:"Custom"};function MI(r,e){const t=EI[e];return t===void 0?(Ye("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+r+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+r+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Ju=new T;function wI(){Et.getLuminanceCoefficients(Ju);const r=Ju.x.toFixed(4),e=Ju.y.toFixed(4),t=Ju.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${r}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
||
`)}function SI(r){return[r.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",r.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Zc).join(`
|
||
`)}function CI(r){const e=[];for(const t in r){const i=r[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
|
||
`)}function TI(r,e){const t={},i=r.getProgramParameter(e,r.ACTIVE_ATTRIBUTES);for(let n=0;n<i;n++){const s=r.getActiveAttrib(e,n),a=s.name;let o=1;s.type===r.FLOAT_MAT2&&(o=2),s.type===r.FLOAT_MAT3&&(o=3),s.type===r.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:r.getAttribLocation(e,a),locationSize:o}}return t}function Zc(r){return r!==""}function D1(r,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return r.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 B1(r,e){return r.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const II=/^[ \t]*#include +<([\w\d./]+)>/gm;function ng(r){return r.replace(II,RI)}const PI=new Map;function RI(r,e){let t=yt[e];if(t===void 0){const i=PI.get(e);if(i!==void 0)t=yt[i],Ye('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return ng(t)}const DI=/#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 L1(r){return r.replace(DI,BI)}function BI(r,e,t,i){let n="";for(let s=parseInt(e);s<parseInt(t);s++)n+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return n}function k1(r){let e=`precision ${r.precision} float;
|
||
precision ${r.precision} int;
|
||
precision ${r.precision} sampler2D;
|
||
precision ${r.precision} samplerCube;
|
||
precision ${r.precision} sampler3D;
|
||
precision ${r.precision} sampler2DArray;
|
||
precision ${r.precision} sampler2DShadow;
|
||
precision ${r.precision} samplerCubeShadow;
|
||
precision ${r.precision} sampler2DArrayShadow;
|
||
precision ${r.precision} isampler2D;
|
||
precision ${r.precision} isampler3D;
|
||
precision ${r.precision} isamplerCube;
|
||
precision ${r.precision} isampler2DArray;
|
||
precision ${r.precision} usampler2D;
|
||
precision ${r.precision} usampler3D;
|
||
precision ${r.precision} usamplerCube;
|
||
precision ${r.precision} usampler2DArray;
|
||
`;return r.precision==="highp"?e+=`
|
||
#define HIGH_PRECISION`:r.precision==="mediump"?e+=`
|
||
#define MEDIUM_PRECISION`:r.precision==="lowp"&&(e+=`
|
||
#define LOW_PRECISION`),e}const LI={[ql]:"SHADOWMAP_TYPE_PCF",[vo]:"SHADOWMAP_TYPE_VSM"};function kI(r){return LI[r.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const NI={[ys]:"ENVMAP_TYPE_CUBE",[gr]:"ENVMAP_TYPE_CUBE",[yo]:"ENVMAP_TYPE_CUBE_UV"};function UI(r){return r.envMap===!1?"ENVMAP_TYPE_CUBE":NI[r.envMapMode]||"ENVMAP_TYPE_CUBE"}const FI={[gr]:"ENVMAP_MODE_REFRACTION"};function OI(r){return r.envMap===!1?"ENVMAP_MODE_REFLECTION":FI[r.envMapMode]||"ENVMAP_MODE_REFLECTION"}const zI={[Kl]:"ENVMAP_BLENDING_MULTIPLY",[qA]:"ENVMAP_BLENDING_MIX",[XA]:"ENVMAP_BLENDING_ADD"};function HI(r){return r.envMap===!1?"ENVMAP_BLENDING_NONE":zI[r.combine]||"ENVMAP_BLENDING_NONE"}function GI(r){const e=r.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function VI(r,e,t,i){const n=r.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=kI(t),c=UI(t),h=OI(t),d=HI(t),p=GI(t),u=SI(t),A=CI(s),m=n.createProgram();let g,f,v=t.glslVersion?"#version "+t.glslVersion+`
|
||
`:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,A].filter(Zc).join(`
|
||
`),g.length>0&&(g+=`
|
||
`),f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,A].filter(Zc).join(`
|
||
`),f.length>0&&(f+=`
|
||
`)):(g=[k1(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,A,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 "+h:"",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 "+l:"",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(Zc).join(`
|
||
`),f=[k1(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,A,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 "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+d:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.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?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#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 "+l:"",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!==Xi?"#define TONE_MAPPING":"",t.toneMapping!==Xi?yt.tonemapping_pars_fragment:"",t.toneMapping!==Xi?MI("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",yt.colorspace_pars_fragment,_I("linearToOutputTexel",t.outputColorSpace),wI(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
||
`].filter(Zc).join(`
|
||
`)),a=ng(a),a=D1(a,t),a=B1(a,t),o=ng(o),o=D1(o,t),o=B1(o,t),a=L1(a),o=L1(o),t.isRawShaderMaterial!==!0&&(v=`#version 300 es
|
||
`,g=[u,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
||
`)+`
|
||
`+g,f=["#define varying in",t.glslVersion===Pf?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Pf?"":"#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(`
|
||
`)+`
|
||
`+f);const b=v+g+a,y=v+f+o,M=I1(n,n.VERTEX_SHADER,b),_=I1(n,n.FRAGMENT_SHADER,y);n.attachShader(m,M),n.attachShader(m,_),t.index0AttributeName!==void 0?n.bindAttribLocation(m,0,t.index0AttributeName):t.morphTargets===!0&&n.bindAttribLocation(m,0,"position"),n.linkProgram(m);function S(B){if(r.debug.checkShaderErrors){const R=n.getProgramInfoLog(m)||"",U=n.getShaderInfoLog(M)||"",C=n.getShaderInfoLog(_)||"",F=R.trim(),O=U.trim(),H=C.trim();let j=!0,G=!0;if(n.getProgramParameter(m,n.LINK_STATUS)===!1)if(j=!1,typeof r.debug.onShaderError=="function")r.debug.onShaderError(n,m,M,_);else{const re=R1(n,M,"vertex"),q=R1(n,_,"fragment");ct("THREE.WebGLProgram: Shader Error "+n.getError()+" - VALIDATE_STATUS "+n.getProgramParameter(m,n.VALIDATE_STATUS)+`
|
||
|
||
Material Name: `+B.name+`
|
||
Material Type: `+B.type+`
|
||
|
||
Program Info Log: `+F+`
|
||
`+re+`
|
||
`+q)}else F!==""?Ye("WebGLProgram: Program Info Log:",F):(O===""||H==="")&&(G=!1);G&&(B.diagnostics={runnable:j,programLog:F,vertexShader:{log:O,prefix:g},fragmentShader:{log:H,prefix:f}})}n.deleteShader(M),n.deleteShader(_),w=new Zu(n,m),E=TI(n,m)}let w;this.getUniforms=function(){return w===void 0&&S(this),w};let E;this.getAttributes=function(){return E===void 0&&S(this),E};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=n.getProgramParameter(m,vI)),I},this.destroy=function(){i.releaseStatesOfProgram(this),n.deleteProgram(m),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=bI++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=M,this.fragmentShader=_,this}let QI=0;class WI{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,n=this._getShaderStage(t),s=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return a.has(n)===!1&&(a.add(n),n.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.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 i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new jI(e),t.set(e,i)),i}}class jI{constructor(e){this.id=QI++,this.code=e,this.usedTimes=0}}function qI(r,e,t,i,n,s){const a=new Bd,o=new WI,l=new Set,c=[],h=new Map,d=i.logarithmicDepthBuffer;let p=i.precision;const u={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function A(w){return l.add(w),w===0?"uv":`uv${w}`}function m(w,E,I,B,R){const U=B.fog,C=R.geometry,F=w.isMeshStandardMaterial||w.isMeshLambertMaterial||w.isMeshPhongMaterial?B.environment:null,O=w.isMeshStandardMaterial||w.isMeshLambertMaterial&&!w.envMap||w.isMeshPhongMaterial&&!w.envMap,H=e.get(w.envMap||F,O),j=H&&H.mapping===yo?H.image.height:null,G=u[w.type];w.precision!==null&&(p=i.getMaxPrecision(w.precision),p!==w.precision&&Ye("WebGLProgram.getParameters:",w.precision,"not supported, using",p,"instead."));const re=C.morphAttributes.position||C.morphAttributes.normal||C.morphAttributes.color,q=re!==void 0?re.length:0;let Y=0;C.morphAttributes.position!==void 0&&(Y=1),C.morphAttributes.normal!==void 0&&(Y=2),C.morphAttributes.color!==void 0&&(Y=3);let ye,Me,xe,J;if(G){const et=ls[G];ye=et.vertexShader,Me=et.fragmentShader}else ye=w.vertexShader,Me=w.fragmentShader,o.update(w),xe=o.getVertexShaderID(w),J=o.getFragmentShaderID(w);const oe=r.getRenderTarget(),ue=r.state.buffers.depth.getReversed(),Pe=R.isInstancedMesh===!0,Be=R.isBatchedMesh===!0,Ue=!!w.map,it=!!w.matcap,qe=!!H,D=!!w.aoMap,ae=!!w.lightMap,$=!!w.bumpMap,Q=!!w.normalMap,L=!!w.displacementMap,te=!!w.emissiveMap,de=!!w.metalnessMap,V=!!w.roughnessMap,ee=w.anisotropy>0,P=w.clearcoat>0,x=w.dispersion>0,N=w.iridescence>0,X=w.sheen>0,Z=w.transmission>0,K=ee&&!!w.anisotropyMap,Ie=P&&!!w.clearcoatMap,ge=P&&!!w.clearcoatNormalMap,ke=P&&!!w.clearcoatRoughnessMap,Oe=N&&!!w.iridescenceMap,le=N&&!!w.iridescenceThicknessMap,Ae=X&&!!w.sheenColorMap,ze=X&&!!w.sheenRoughnessMap,Ne=!!w.specularMap,we=!!w.specularColorMap,je=!!w.specularIntensityMap,z=Z&&!!w.transmissionMap,ve=Z&&!!w.thicknessMap,me=!!w.gradientMap,Re=!!w.alphaMap,pe=w.alphaTest>0,ne=!!w.alphaHash,Le=!!w.extensions;let Qe=Xi;w.toneMapped&&(oe===null||oe.isXRRenderTarget===!0)&&(Qe=r.toneMapping);const pt={shaderID:G,shaderType:w.type,shaderName:w.name,vertexShader:ye,fragmentShader:Me,defines:w.defines,customVertexShaderID:xe,customFragmentShaderID:J,isRawShaderMaterial:w.isRawShaderMaterial===!0,glslVersion:w.glslVersion,precision:p,batching:Be,batchingColor:Be&&R._colorsTexture!==null,instancing:Pe,instancingColor:Pe&&R.instanceColor!==null,instancingMorph:Pe&&R.morphTexture!==null,outputColorSpace:oe===null?r.outputColorSpace:oe.isXRRenderTarget===!0?oe.texture.colorSpace:Ri,alphaToCoverage:!!w.alphaToCoverage,map:Ue,matcap:it,envMap:qe,envMapMode:qe&&H.mapping,envMapCubeUVHeight:j,aoMap:D,lightMap:ae,bumpMap:$,normalMap:Q,displacementMap:L,emissiveMap:te,normalMapObjectSpace:Q&&w.normalMapType===tv,normalMapTangentSpace:Q&&w.normalMapType===xr,metalnessMap:de,roughnessMap:V,anisotropy:ee,anisotropyMap:K,clearcoat:P,clearcoatMap:Ie,clearcoatNormalMap:ge,clearcoatRoughnessMap:ke,dispersion:x,iridescence:N,iridescenceMap:Oe,iridescenceThicknessMap:le,sheen:X,sheenColorMap:Ae,sheenRoughnessMap:ze,specularMap:Ne,specularColorMap:we,specularIntensityMap:je,transmission:Z,transmissionMap:z,thicknessMap:ve,gradientMap:me,opaque:w.transparent===!1&&w.blending===na&&w.alphaToCoverage===!1,alphaMap:Re,alphaTest:pe,alphaHash:ne,combine:w.combine,mapUv:Ue&&A(w.map.channel),aoMapUv:D&&A(w.aoMap.channel),lightMapUv:ae&&A(w.lightMap.channel),bumpMapUv:$&&A(w.bumpMap.channel),normalMapUv:Q&&A(w.normalMap.channel),displacementMapUv:L&&A(w.displacementMap.channel),emissiveMapUv:te&&A(w.emissiveMap.channel),metalnessMapUv:de&&A(w.metalnessMap.channel),roughnessMapUv:V&&A(w.roughnessMap.channel),anisotropyMapUv:K&&A(w.anisotropyMap.channel),clearcoatMapUv:Ie&&A(w.clearcoatMap.channel),clearcoatNormalMapUv:ge&&A(w.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ke&&A(w.clearcoatRoughnessMap.channel),iridescenceMapUv:Oe&&A(w.iridescenceMap.channel),iridescenceThicknessMapUv:le&&A(w.iridescenceThicknessMap.channel),sheenColorMapUv:Ae&&A(w.sheenColorMap.channel),sheenRoughnessMapUv:ze&&A(w.sheenRoughnessMap.channel),specularMapUv:Ne&&A(w.specularMap.channel),specularColorMapUv:we&&A(w.specularColorMap.channel),specularIntensityMapUv:je&&A(w.specularIntensityMap.channel),transmissionMapUv:z&&A(w.transmissionMap.channel),thicknessMapUv:ve&&A(w.thicknessMap.channel),alphaMapUv:Re&&A(w.alphaMap.channel),vertexTangents:!!C.attributes.tangent&&(Q||ee),vertexColors:w.vertexColors,vertexAlphas:w.vertexColors===!0&&!!C.attributes.color&&C.attributes.color.itemSize===4,pointsUvs:R.isPoints===!0&&!!C.attributes.uv&&(Ue||Re),fog:!!U,useFog:w.fog===!0,fogExp2:!!U&&U.isFogExp2,flatShading:w.wireframe===!1&&(w.flatShading===!0||C.attributes.normal===void 0&&Q===!1&&(w.isMeshLambertMaterial||w.isMeshPhongMaterial||w.isMeshStandardMaterial||w.isMeshPhysicalMaterial)),sizeAttenuation:w.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:ue,skinning:R.isSkinnedMesh===!0,morphTargets:C.morphAttributes.position!==void 0,morphNormals:C.morphAttributes.normal!==void 0,morphColors:C.morphAttributes.color!==void 0,morphTargetsCount:q,morphTextureStride:Y,numDirLights:E.directional.length,numPointLights:E.point.length,numSpotLights:E.spot.length,numSpotLightMaps:E.spotLightMap.length,numRectAreaLights:E.rectArea.length,numHemiLights:E.hemi.length,numDirLightShadows:E.directionalShadowMap.length,numPointLightShadows:E.pointShadowMap.length,numSpotLightShadows:E.spotShadowMap.length,numSpotLightShadowsWithMaps:E.numSpotLightShadowsWithMaps,numLightProbes:E.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:w.dithering,shadowMapEnabled:r.shadowMap.enabled&&I.length>0,shadowMapType:r.shadowMap.type,toneMapping:Qe,decodeVideoTexture:Ue&&w.map.isVideoTexture===!0&&Et.getTransfer(w.map.colorSpace)===Ut,decodeVideoTextureEmissive:te&&w.emissiveMap.isVideoTexture===!0&&Et.getTransfer(w.emissiveMap.colorSpace)===Ut,premultipliedAlpha:w.premultipliedAlpha,doubleSided:w.side===Vt,flipSided:w.side===qi,useDepthPacking:w.depthPacking>=0,depthPacking:w.depthPacking||0,index0AttributeName:w.index0AttributeName,extensionClipCullDistance:Le&&w.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Le&&w.extensions.multiDraw===!0||Be)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:w.customProgramCacheKey()};return pt.vertexUv1s=l.has(1),pt.vertexUv2s=l.has(2),pt.vertexUv3s=l.has(3),l.clear(),pt}function g(w){const E=[];if(w.shaderID?E.push(w.shaderID):(E.push(w.customVertexShaderID),E.push(w.customFragmentShaderID)),w.defines!==void 0)for(const I in w.defines)E.push(I),E.push(w.defines[I]);return w.isRawShaderMaterial===!1&&(f(E,w),v(E,w),E.push(r.outputColorSpace)),E.push(w.customProgramCacheKey),E.join()}function f(w,E){w.push(E.precision),w.push(E.outputColorSpace),w.push(E.envMapMode),w.push(E.envMapCubeUVHeight),w.push(E.mapUv),w.push(E.alphaMapUv),w.push(E.lightMapUv),w.push(E.aoMapUv),w.push(E.bumpMapUv),w.push(E.normalMapUv),w.push(E.displacementMapUv),w.push(E.emissiveMapUv),w.push(E.metalnessMapUv),w.push(E.roughnessMapUv),w.push(E.anisotropyMapUv),w.push(E.clearcoatMapUv),w.push(E.clearcoatNormalMapUv),w.push(E.clearcoatRoughnessMapUv),w.push(E.iridescenceMapUv),w.push(E.iridescenceThicknessMapUv),w.push(E.sheenColorMapUv),w.push(E.sheenRoughnessMapUv),w.push(E.specularMapUv),w.push(E.specularColorMapUv),w.push(E.specularIntensityMapUv),w.push(E.transmissionMapUv),w.push(E.thicknessMapUv),w.push(E.combine),w.push(E.fogExp2),w.push(E.sizeAttenuation),w.push(E.morphTargetsCount),w.push(E.morphAttributeCount),w.push(E.numDirLights),w.push(E.numPointLights),w.push(E.numSpotLights),w.push(E.numSpotLightMaps),w.push(E.numHemiLights),w.push(E.numRectAreaLights),w.push(E.numDirLightShadows),w.push(E.numPointLightShadows),w.push(E.numSpotLightShadows),w.push(E.numSpotLightShadowsWithMaps),w.push(E.numLightProbes),w.push(E.shadowMapType),w.push(E.toneMapping),w.push(E.numClippingPlanes),w.push(E.numClipIntersection),w.push(E.depthPacking)}function v(w,E){a.disableAll(),E.instancing&&a.enable(0),E.instancingColor&&a.enable(1),E.instancingMorph&&a.enable(2),E.matcap&&a.enable(3),E.envMap&&a.enable(4),E.normalMapObjectSpace&&a.enable(5),E.normalMapTangentSpace&&a.enable(6),E.clearcoat&&a.enable(7),E.iridescence&&a.enable(8),E.alphaTest&&a.enable(9),E.vertexColors&&a.enable(10),E.vertexAlphas&&a.enable(11),E.vertexUv1s&&a.enable(12),E.vertexUv2s&&a.enable(13),E.vertexUv3s&&a.enable(14),E.vertexTangents&&a.enable(15),E.anisotropy&&a.enable(16),E.alphaHash&&a.enable(17),E.batching&&a.enable(18),E.dispersion&&a.enable(19),E.batchingColor&&a.enable(20),E.gradientMap&&a.enable(21),w.push(a.mask),a.disableAll(),E.fog&&a.enable(0),E.useFog&&a.enable(1),E.flatShading&&a.enable(2),E.logarithmicDepthBuffer&&a.enable(3),E.reversedDepthBuffer&&a.enable(4),E.skinning&&a.enable(5),E.morphTargets&&a.enable(6),E.morphNormals&&a.enable(7),E.morphColors&&a.enable(8),E.premultipliedAlpha&&a.enable(9),E.shadowMapEnabled&&a.enable(10),E.doubleSided&&a.enable(11),E.flipSided&&a.enable(12),E.useDepthPacking&&a.enable(13),E.dithering&&a.enable(14),E.transmission&&a.enable(15),E.sheen&&a.enable(16),E.opaque&&a.enable(17),E.pointsUvs&&a.enable(18),E.decodeVideoTexture&&a.enable(19),E.decodeVideoTextureEmissive&&a.enable(20),E.alphaToCoverage&&a.enable(21),w.push(a.mask)}function b(w){const E=u[w.type];let I;if(E){const B=ls[E];I=nn.clone(B.uniforms)}else I=w.uniforms;return I}function y(w,E){let I=h.get(E);return I!==void 0?++I.usedTimes:(I=new VI(r,E,w,n),c.push(I),h.set(E,I)),I}function M(w){if(--w.usedTimes===0){const E=c.indexOf(w);c[E]=c[c.length-1],c.pop(),h.delete(w.cacheKey),w.destroy()}}function _(w){o.remove(w)}function S(){o.dispose()}return{getParameters:m,getProgramCacheKey:g,getUniforms:b,acquireProgram:y,releaseProgram:M,releaseShaderCache:_,programs:c,dispose:S}}function XI(){let r=new WeakMap;function e(a){return r.has(a)}function t(a){let o=r.get(a);return o===void 0&&(o={},r.set(a,o)),o}function i(a){r.delete(a)}function n(a,o,l){r.get(a)[o]=l}function s(){r=new WeakMap}return{has:e,get:t,remove:i,update:n,dispose:s}}function YI(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.materialVariant!==e.materialVariant?r.materialVariant-e.materialVariant:r.z!==e.z?r.z-e.z:r.id-e.id}function N1(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function U1(){const r=[];let e=0;const t=[],i=[],n=[];function s(){e=0,t.length=0,i.length=0,n.length=0}function a(p){let u=0;return p.isInstancedMesh&&(u+=2),p.isSkinnedMesh&&(u+=1),u}function o(p,u,A,m,g,f){let v=r[e];return v===void 0?(v={id:p.id,object:p,geometry:u,material:A,materialVariant:a(p),groupOrder:m,renderOrder:p.renderOrder,z:g,group:f},r[e]=v):(v.id=p.id,v.object=p,v.geometry=u,v.material=A,v.materialVariant=a(p),v.groupOrder=m,v.renderOrder=p.renderOrder,v.z=g,v.group=f),e++,v}function l(p,u,A,m,g,f){const v=o(p,u,A,m,g,f);A.transmission>0?i.push(v):A.transparent===!0?n.push(v):t.push(v)}function c(p,u,A,m,g,f){const v=o(p,u,A,m,g,f);A.transmission>0?i.unshift(v):A.transparent===!0?n.unshift(v):t.unshift(v)}function h(p,u){t.length>1&&t.sort(p||YI),i.length>1&&i.sort(u||N1),n.length>1&&n.sort(u||N1)}function d(){for(let p=e,u=r.length;p<u;p++){const A=r[p];if(A.id===null)break;A.id=null,A.object=null,A.geometry=null,A.material=null,A.group=null}}return{opaque:t,transmissive:i,transparent:n,init:s,push:l,unshift:c,finish:d,sort:h}}function KI(){let r=new WeakMap;function e(i,n){const s=r.get(i);let a;return s===void 0?(a=new U1,r.set(i,[a])):n>=s.length?(a=new U1,s.push(a)):a=s[n],a}function t(){r=new WeakMap}return{get:e,dispose:t}}function ZI(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new T,color:new We};break;case"SpotLight":t={position:new T,direction:new T,color:new We,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new T,color:new We,distance:0,decay:0};break;case"HemisphereLight":t={direction:new T,skyColor:new We,groundColor:new We};break;case"RectAreaLight":t={color:new We,position:new T,halfWidth:new T,halfHeight:new T};break}return r[e.id]=t,t}}}function JI(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new be};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new be};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new be,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let $I=0;function eP(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function tP(r){const e=new ZI,t=JI(),i={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 c=0;c<9;c++)i.probe.push(new T);const n=new T,s=new Ke,a=new Ke;function o(c){let h=0,d=0,p=0;for(let E=0;E<9;E++)i.probe[E].set(0,0,0);let u=0,A=0,m=0,g=0,f=0,v=0,b=0,y=0,M=0,_=0,S=0;c.sort(eP);for(let E=0,I=c.length;E<I;E++){const B=c[E],R=B.color,U=B.intensity,C=B.distance;let F=null;if(B.shadow&&B.shadow.map&&(B.shadow.map.texture.format===Qn?F=B.shadow.map.texture:F=B.shadow.map.depthTexture||B.shadow.map.texture),B.isAmbientLight)h+=R.r*U,d+=R.g*U,p+=R.b*U;else if(B.isLightProbe){for(let O=0;O<9;O++)i.probe[O].addScaledVector(B.sh.coefficients[O],U);S++}else if(B.isDirectionalLight){const O=e.get(B);if(O.color.copy(B.color).multiplyScalar(B.intensity),B.castShadow){const H=B.shadow,j=t.get(B);j.shadowIntensity=H.intensity,j.shadowBias=H.bias,j.shadowNormalBias=H.normalBias,j.shadowRadius=H.radius,j.shadowMapSize=H.mapSize,i.directionalShadow[u]=j,i.directionalShadowMap[u]=F,i.directionalShadowMatrix[u]=B.shadow.matrix,v++}i.directional[u]=O,u++}else if(B.isSpotLight){const O=e.get(B);O.position.setFromMatrixPosition(B.matrixWorld),O.color.copy(R).multiplyScalar(U),O.distance=C,O.coneCos=Math.cos(B.angle),O.penumbraCos=Math.cos(B.angle*(1-B.penumbra)),O.decay=B.decay,i.spot[m]=O;const H=B.shadow;if(B.map&&(i.spotLightMap[M]=B.map,M++,H.updateMatrices(B),B.castShadow&&_++),i.spotLightMatrix[m]=H.matrix,B.castShadow){const j=t.get(B);j.shadowIntensity=H.intensity,j.shadowBias=H.bias,j.shadowNormalBias=H.normalBias,j.shadowRadius=H.radius,j.shadowMapSize=H.mapSize,i.spotShadow[m]=j,i.spotShadowMap[m]=F,y++}m++}else if(B.isRectAreaLight){const O=e.get(B);O.color.copy(R).multiplyScalar(U),O.halfWidth.set(B.width*.5,0,0),O.halfHeight.set(0,B.height*.5,0),i.rectArea[g]=O,g++}else if(B.isPointLight){const O=e.get(B);if(O.color.copy(B.color).multiplyScalar(B.intensity),O.distance=B.distance,O.decay=B.decay,B.castShadow){const H=B.shadow,j=t.get(B);j.shadowIntensity=H.intensity,j.shadowBias=H.bias,j.shadowNormalBias=H.normalBias,j.shadowRadius=H.radius,j.shadowMapSize=H.mapSize,j.shadowCameraNear=H.camera.near,j.shadowCameraFar=H.camera.far,i.pointShadow[A]=j,i.pointShadowMap[A]=F,i.pointShadowMatrix[A]=B.shadow.matrix,b++}i.point[A]=O,A++}else if(B.isHemisphereLight){const O=e.get(B);O.skyColor.copy(B.color).multiplyScalar(U),O.groundColor.copy(B.groundColor).multiplyScalar(U),i.hemi[f]=O,f++}}g>0&&(r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ze.LTC_FLOAT_1,i.rectAreaLTC2=Ze.LTC_FLOAT_2):(i.rectAreaLTC1=Ze.LTC_HALF_1,i.rectAreaLTC2=Ze.LTC_HALF_2)),i.ambient[0]=h,i.ambient[1]=d,i.ambient[2]=p;const w=i.hash;(w.directionalLength!==u||w.pointLength!==A||w.spotLength!==m||w.rectAreaLength!==g||w.hemiLength!==f||w.numDirectionalShadows!==v||w.numPointShadows!==b||w.numSpotShadows!==y||w.numSpotMaps!==M||w.numLightProbes!==S)&&(i.directional.length=u,i.spot.length=m,i.rectArea.length=g,i.point.length=A,i.hemi.length=f,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.pointShadow.length=b,i.pointShadowMap.length=b,i.spotShadow.length=y,i.spotShadowMap.length=y,i.directionalShadowMatrix.length=v,i.pointShadowMatrix.length=b,i.spotLightMatrix.length=y+M-_,i.spotLightMap.length=M,i.numSpotLightShadowsWithMaps=_,i.numLightProbes=S,w.directionalLength=u,w.pointLength=A,w.spotLength=m,w.rectAreaLength=g,w.hemiLength=f,w.numDirectionalShadows=v,w.numPointShadows=b,w.numSpotShadows=y,w.numSpotMaps=M,w.numLightProbes=S,i.version=$I++)}function l(c,h){let d=0,p=0,u=0,A=0,m=0;const g=h.matrixWorldInverse;for(let f=0,v=c.length;f<v;f++){const b=c[f];if(b.isDirectionalLight){const y=i.directional[d];y.direction.setFromMatrixPosition(b.matrixWorld),n.setFromMatrixPosition(b.target.matrixWorld),y.direction.sub(n),y.direction.transformDirection(g),d++}else if(b.isSpotLight){const y=i.spot[u];y.position.setFromMatrixPosition(b.matrixWorld),y.position.applyMatrix4(g),y.direction.setFromMatrixPosition(b.matrixWorld),n.setFromMatrixPosition(b.target.matrixWorld),y.direction.sub(n),y.direction.transformDirection(g),u++}else if(b.isRectAreaLight){const y=i.rectArea[A];y.position.setFromMatrixPosition(b.matrixWorld),y.position.applyMatrix4(g),a.identity(),s.copy(b.matrixWorld),s.premultiply(g),a.extractRotation(s),y.halfWidth.set(b.width*.5,0,0),y.halfHeight.set(0,b.height*.5,0),y.halfWidth.applyMatrix4(a),y.halfHeight.applyMatrix4(a),A++}else if(b.isPointLight){const y=i.point[p];y.position.setFromMatrixPosition(b.matrixWorld),y.position.applyMatrix4(g),p++}else if(b.isHemisphereLight){const y=i.hemi[m];y.direction.setFromMatrixPosition(b.matrixWorld),y.direction.transformDirection(g),m++}}}return{setup:o,setupView:l,state:i}}function F1(r){const e=new tP(r),t=[],i=[];function n(h){c.camera=h,t.length=0,i.length=0}function s(h){t.push(h)}function a(h){i.push(h)}function o(){e.setup(t)}function l(h){e.setupView(t,h)}const c={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:n,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function iP(r){let e=new WeakMap;function t(n,s=0){const a=e.get(n);let o;return a===void 0?(o=new F1(r),e.set(n,[o])):s>=a.length?(o=new F1(r),a.push(o)):o=a[s],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const nP=`void main() {
|
||
gl_Position = vec4( position, 1.0 );
|
||
}`,sP=`uniform sampler2D shadow_pass;
|
||
uniform vec2 resolution;
|
||
uniform float radius;
|
||
void main() {
|
||
const float samples = float( VSM_SAMPLES );
|
||
float mean = 0.0;
|
||
float squared_mean = 0.0;
|
||
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
|
||
float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
|
||
for ( float i = 0.0; i < samples; i ++ ) {
|
||
float uvOffset = uvStart + i * uvStride;
|
||
#ifdef HORIZONTAL_PASS
|
||
vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;
|
||
mean += distribution.x;
|
||
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
|
||
#else
|
||
float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;
|
||
mean += depth;
|
||
squared_mean += depth * depth;
|
||
#endif
|
||
}
|
||
mean = mean / samples;
|
||
squared_mean = squared_mean / samples;
|
||
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
|
||
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
|
||
}`,rP=[new T(1,0,0),new T(-1,0,0),new T(0,1,0),new T(0,-1,0),new T(0,0,1),new T(0,0,-1)],aP=[new T(0,-1,0),new T(0,-1,0),new T(0,0,1),new T(0,0,-1),new T(0,-1,0),new T(0,-1,0)],O1=new Ke,Jc=new T,sg=new T;function oP(r,e,t){let i=new Yo;const n=new be,s=new be,a=new Gt,o=new wm,l=new Sm,c={},h=t.maxTextureSize,d={[Gn]:qi,[qi]:Gn,[Vt]:Vt},p=new ei({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new be},radius:{value:4}},vertexShader:nP,fragmentShader:sP}),u=p.clone();u.defines.HORIZONTAL_PASS=1;const A=new ot;A.setAttribute("position",new St(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new Ge(A,p),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ql;let f=this.type;this.render=function(_,S,w){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||_.length===0)return;this.type===DA&&(Ye("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=ql);const E=r.getRenderTarget(),I=r.getActiveCubeFace(),B=r.getActiveMipmapLevel(),R=r.state;R.setBlending(ti),R.buffers.depth.getReversed()===!0?R.buffers.color.setClear(0,0,0,0):R.buffers.color.setClear(1,1,1,1),R.buffers.depth.setTest(!0),R.setScissorTest(!1);const U=f!==this.type;U&&S.traverse(function(C){C.material&&(Array.isArray(C.material)?C.material.forEach(F=>F.needsUpdate=!0):C.material.needsUpdate=!0)});for(let C=0,F=_.length;C<F;C++){const O=_[C],H=O.shadow;if(H===void 0){Ye("WebGLShadowMap:",O,"has no shadow.");continue}if(H.autoUpdate===!1&&H.needsUpdate===!1)continue;n.copy(H.mapSize);const j=H.getFrameExtents();n.multiply(j),s.copy(H.mapSize),(n.x>h||n.y>h)&&(n.x>h&&(s.x=Math.floor(h/j.x),n.x=s.x*j.x,H.mapSize.x=s.x),n.y>h&&(s.y=Math.floor(h/j.y),n.y=s.y*j.y,H.mapSize.y=s.y));const G=r.state.buffers.depth.getReversed();if(H.camera._reversedDepth=G,H.map===null||U===!0){if(H.map!==null&&(H.map.depthTexture!==null&&(H.map.depthTexture.dispose(),H.map.depthTexture=null),H.map.dispose()),this.type===vo){if(O.isPointLight){Ye("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}H.map=new Ei(n.x,n.y,{format:Qn,type:Zt,minFilter:_t,magFilter:_t,generateMipmaps:!1}),H.map.texture.name=O.name+".shadowMap",H.map.depthTexture=new Rr(n.x,n.y,oi),H.map.depthTexture.name=O.name+".shadowMapDepth",H.map.depthTexture.format=xs,H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=Ht,H.map.depthTexture.magFilter=Ht}else O.isPointLight?(H.map=new eg(n.x),H.map.depthTexture=new tb(n.x,Vn)):(H.map=new Ei(n.x,n.y),H.map.depthTexture=new Rr(n.x,n.y,Vn)),H.map.depthTexture.name=O.name+".shadowMap",H.map.depthTexture.format=xs,this.type===ql?(H.map.depthTexture.compareFunction=G?Pd:Id,H.map.depthTexture.minFilter=_t,H.map.depthTexture.magFilter=_t):(H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=Ht,H.map.depthTexture.magFilter=Ht);H.camera.updateProjectionMatrix()}const re=H.map.isWebGLCubeRenderTarget?6:1;for(let q=0;q<re;q++){if(H.map.isWebGLCubeRenderTarget)r.setRenderTarget(H.map,q),r.clear();else{q===0&&(r.setRenderTarget(H.map),r.clear());const Y=H.getViewport(q);a.set(s.x*Y.x,s.y*Y.y,s.x*Y.z,s.y*Y.w),R.viewport(a)}if(O.isPointLight){const Y=H.camera,ye=H.matrix,Me=O.distance||Y.far;Me!==Y.far&&(Y.far=Me,Y.updateProjectionMatrix()),Jc.setFromMatrixPosition(O.matrixWorld),Y.position.copy(Jc),sg.copy(Y.position),sg.add(rP[q]),Y.up.copy(aP[q]),Y.lookAt(sg),Y.updateMatrixWorld(),ye.makeTranslation(-Jc.x,-Jc.y,-Jc.z),O1.multiplyMatrices(Y.projectionMatrix,Y.matrixWorldInverse),H._frustum.setFromProjectionMatrix(O1,Y.coordinateSystem,Y.reversedDepth)}else H.updateMatrices(O);i=H.getFrustum(),y(S,w,H.camera,O,this.type)}H.isPointLightShadow!==!0&&this.type===vo&&v(H,w),H.needsUpdate=!1}f=this.type,g.needsUpdate=!1,r.setRenderTarget(E,I,B)};function v(_,S){const w=e.update(m);p.defines.VSM_SAMPLES!==_.blurSamples&&(p.defines.VSM_SAMPLES=_.blurSamples,u.defines.VSM_SAMPLES=_.blurSamples,p.needsUpdate=!0,u.needsUpdate=!0),_.mapPass===null&&(_.mapPass=new Ei(n.x,n.y,{format:Qn,type:Zt})),p.uniforms.shadow_pass.value=_.map.depthTexture,p.uniforms.resolution.value=_.mapSize,p.uniforms.radius.value=_.radius,r.setRenderTarget(_.mapPass),r.clear(),r.renderBufferDirect(S,null,w,p,m,null),u.uniforms.shadow_pass.value=_.mapPass.texture,u.uniforms.resolution.value=_.mapSize,u.uniforms.radius.value=_.radius,r.setRenderTarget(_.map),r.clear(),r.renderBufferDirect(S,null,w,u,m,null)}function b(_,S,w,E){let I=null;const B=w.isPointLight===!0?_.customDistanceMaterial:_.customDepthMaterial;if(B!==void 0)I=B;else if(I=w.isPointLight===!0?l:o,r.localClippingEnabled&&S.clipShadows===!0&&Array.isArray(S.clippingPlanes)&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0||S.map&&S.alphaTest>0||S.alphaToCoverage===!0){const R=I.uuid,U=S.uuid;let C=c[R];C===void 0&&(C={},c[R]=C);let F=C[U];F===void 0&&(F=I.clone(),C[U]=F,S.addEventListener("dispose",M)),I=F}if(I.visible=S.visible,I.wireframe=S.wireframe,E===vo?I.side=S.shadowSide!==null?S.shadowSide:S.side:I.side=S.shadowSide!==null?S.shadowSide:d[S.side],I.alphaMap=S.alphaMap,I.alphaTest=S.alphaToCoverage===!0?.5:S.alphaTest,I.map=S.map,I.clipShadows=S.clipShadows,I.clippingPlanes=S.clippingPlanes,I.clipIntersection=S.clipIntersection,I.displacementMap=S.displacementMap,I.displacementScale=S.displacementScale,I.displacementBias=S.displacementBias,I.wireframeLinewidth=S.wireframeLinewidth,I.linewidth=S.linewidth,w.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const R=r.properties.get(I);R.light=w}return I}function y(_,S,w,E,I){if(_.visible===!1)return;if(_.layers.test(S.layers)&&(_.isMesh||_.isLine||_.isPoints)&&(_.castShadow||_.receiveShadow&&I===vo)&&(!_.frustumCulled||i.intersectsObject(_))){_.modelViewMatrix.multiplyMatrices(w.matrixWorldInverse,_.matrixWorld);const U=e.update(_),C=_.material;if(Array.isArray(C)){const F=U.groups;for(let O=0,H=F.length;O<H;O++){const j=F[O],G=C[j.materialIndex];if(G&&G.visible){const re=b(_,G,E,I);_.onBeforeShadow(r,_,S,w,U,re,j),r.renderBufferDirect(w,null,U,re,_,j),_.onAfterShadow(r,_,S,w,U,re,j)}}}else if(C.visible){const F=b(_,C,E,I);_.onBeforeShadow(r,_,S,w,U,F,null),r.renderBufferDirect(w,null,U,F,_,null),_.onAfterShadow(r,_,S,w,U,F,null)}}const R=_.children;for(let U=0,C=R.length;U<C;U++)y(R[U],S,w,E,I)}function M(_){_.target.removeEventListener("dispose",M);for(const w in c){const E=c[w],I=_.target.uuid;I in E&&(E[I].dispose(),delete E[I])}}}function lP(r,e){function t(){let z=!1;const ve=new Gt;let me=null;const Re=new Gt(0,0,0,0);return{setMask:function(pe){me!==pe&&!z&&(r.colorMask(pe,pe,pe,pe),me=pe)},setLocked:function(pe){z=pe},setClear:function(pe,ne,Le,Qe,pt){pt===!0&&(pe*=Qe,ne*=Qe,Le*=Qe),ve.set(pe,ne,Le,Qe),Re.equals(ve)===!1&&(r.clearColor(pe,ne,Le,Qe),Re.copy(ve))},reset:function(){z=!1,me=null,Re.set(-1,0,0,0)}}}function i(){let z=!1,ve=!1,me=null,Re=null,pe=null;return{setReversed:function(ne){if(ve!==ne){const Le=e.get("EXT_clip_control");ne?Le.clipControlEXT(Le.LOWER_LEFT_EXT,Le.ZERO_TO_ONE_EXT):Le.clipControlEXT(Le.LOWER_LEFT_EXT,Le.NEGATIVE_ONE_TO_ONE_EXT),ve=ne;const Qe=pe;pe=null,this.setClear(Qe)}},getReversed:function(){return ve},setTest:function(ne){ne?oe(r.DEPTH_TEST):ue(r.DEPTH_TEST)},setMask:function(ne){me!==ne&&!z&&(r.depthMask(ne),me=ne)},setFunc:function(ne){if(ve&&(ne=xw[ne]),Re!==ne){switch(ne){case qh:r.depthFunc(r.NEVER);break;case Xh:r.depthFunc(r.ALWAYS);break;case Yh:r.depthFunc(r.LESS);break;case sa:r.depthFunc(r.LEQUAL);break;case Kh:r.depthFunc(r.EQUAL);break;case Zh:r.depthFunc(r.GEQUAL);break;case Jh:r.depthFunc(r.GREATER);break;case $h:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}Re=ne}},setLocked:function(ne){z=ne},setClear:function(ne){pe!==ne&&(pe=ne,ve&&(ne=1-ne),r.clearDepth(ne))},reset:function(){z=!1,me=null,Re=null,pe=null,ve=!1}}}function n(){let z=!1,ve=null,me=null,Re=null,pe=null,ne=null,Le=null,Qe=null,pt=null;return{setTest:function(et){z||(et?oe(r.STENCIL_TEST):ue(r.STENCIL_TEST))},setMask:function(et){ve!==et&&!z&&(r.stencilMask(et),ve=et)},setFunc:function(et,Ti,Ii){(me!==et||Re!==Ti||pe!==Ii)&&(r.stencilFunc(et,Ti,Ii),me=et,Re=Ti,pe=Ii)},setOp:function(et,Ti,Ii){(ne!==et||Le!==Ti||Qe!==Ii)&&(r.stencilOp(et,Ti,Ii),ne=et,Le=Ti,Qe=Ii)},setLocked:function(et){z=et},setClear:function(et){pt!==et&&(r.clearStencil(et),pt=et)},reset:function(){z=!1,ve=null,me=null,Re=null,pe=null,ne=null,Le=null,Qe=null,pt=null}}}const s=new t,a=new i,o=new n,l=new WeakMap,c=new WeakMap;let h={},d={},p=new WeakMap,u=[],A=null,m=!1,g=null,f=null,v=null,b=null,y=null,M=null,_=null,S=new We(0,0,0),w=0,E=!1,I=null,B=null,R=null,U=null,C=null;const F=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let O=!1,H=0;const j=r.getParameter(r.VERSION);j.indexOf("WebGL")!==-1?(H=parseFloat(/^WebGL (\d)/.exec(j)[1]),O=H>=1):j.indexOf("OpenGL ES")!==-1&&(H=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),O=H>=2);let G=null,re={};const q=r.getParameter(r.SCISSOR_BOX),Y=r.getParameter(r.VIEWPORT),ye=new Gt().fromArray(q),Me=new Gt().fromArray(Y);function xe(z,ve,me,Re){const pe=new Uint8Array(4),ne=r.createTexture();r.bindTexture(z,ne),r.texParameteri(z,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(z,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let Le=0;Le<me;Le++)z===r.TEXTURE_3D||z===r.TEXTURE_2D_ARRAY?r.texImage3D(ve,0,r.RGBA,1,1,Re,0,r.RGBA,r.UNSIGNED_BYTE,pe):r.texImage2D(ve+Le,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,pe);return ne}const J={};J[r.TEXTURE_2D]=xe(r.TEXTURE_2D,r.TEXTURE_2D,1),J[r.TEXTURE_CUBE_MAP]=xe(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),J[r.TEXTURE_2D_ARRAY]=xe(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),J[r.TEXTURE_3D]=xe(r.TEXTURE_3D,r.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),oe(r.DEPTH_TEST),a.setFunc(sa),$(!1),Q(bf),oe(r.CULL_FACE),D(ti);function oe(z){h[z]!==!0&&(r.enable(z),h[z]=!0)}function ue(z){h[z]!==!1&&(r.disable(z),h[z]=!1)}function Pe(z,ve){return d[z]!==ve?(r.bindFramebuffer(z,ve),d[z]=ve,z===r.DRAW_FRAMEBUFFER&&(d[r.FRAMEBUFFER]=ve),z===r.FRAMEBUFFER&&(d[r.DRAW_FRAMEBUFFER]=ve),!0):!1}function Be(z,ve){let me=u,Re=!1;if(z){me=p.get(ve),me===void 0&&(me=[],p.set(ve,me));const pe=z.textures;if(me.length!==pe.length||me[0]!==r.COLOR_ATTACHMENT0){for(let ne=0,Le=pe.length;ne<Le;ne++)me[ne]=r.COLOR_ATTACHMENT0+ne;me.length=pe.length,Re=!0}}else me[0]!==r.BACK&&(me[0]=r.BACK,Re=!0);Re&&r.drawBuffers(me)}function Ue(z){return A!==z?(r.useProgram(z),A=z,!0):!1}const it={[gn]:r.FUNC_ADD,[BA]:r.FUNC_SUBTRACT,[LA]:r.FUNC_REVERSE_SUBTRACT};it[kA]=r.MIN,it[NA]=r.MAX;const qe={[mr]:r.ZERO,[UA]:r.ONE,[FA]:r.SRC_COLOR,[Wh]:r.SRC_ALPHA,[GA]:r.SRC_ALPHA_SATURATE,[Yl]:r.DST_COLOR,[Xl]:r.DST_ALPHA,[OA]:r.ONE_MINUS_SRC_COLOR,[jh]:r.ONE_MINUS_SRC_ALPHA,[HA]:r.ONE_MINUS_DST_COLOR,[zA]:r.ONE_MINUS_DST_ALPHA,[VA]:r.CONSTANT_COLOR,[QA]:r.ONE_MINUS_CONSTANT_COLOR,[WA]:r.CONSTANT_ALPHA,[jA]:r.ONE_MINUS_CONSTANT_ALPHA};function D(z,ve,me,Re,pe,ne,Le,Qe,pt,et){if(z===ti){m===!0&&(ue(r.BLEND),m=!1);return}if(m===!1&&(oe(r.BLEND),m=!0),z!==Qh){if(z!==g||et!==E){if((f!==gn||y!==gn)&&(r.blendEquation(r.FUNC_ADD),f=gn,y=gn),et)switch(z){case na:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Vh:r.blendFunc(r.ONE,r.ONE);break;case yf:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case xf:r.blendFuncSeparate(r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ZERO,r.ONE);break;default:ct("WebGLState: Invalid blending: ",z);break}else switch(z){case na:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Vh:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE,r.ONE,r.ONE);break;case yf:ct("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case xf:ct("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ct("WebGLState: Invalid blending: ",z);break}v=null,b=null,M=null,_=null,S.set(0,0,0),w=0,g=z,E=et}return}pe=pe||ve,ne=ne||me,Le=Le||Re,(ve!==f||pe!==y)&&(r.blendEquationSeparate(it[ve],it[pe]),f=ve,y=pe),(me!==v||Re!==b||ne!==M||Le!==_)&&(r.blendFuncSeparate(qe[me],qe[Re],qe[ne],qe[Le]),v=me,b=Re,M=ne,_=Le),(Qe.equals(S)===!1||pt!==w)&&(r.blendColor(Qe.r,Qe.g,Qe.b,pt),S.copy(Qe),w=pt),g=z,E=!1}function ae(z,ve){z.side===Vt?ue(r.CULL_FACE):oe(r.CULL_FACE);let me=z.side===qi;ve&&(me=!me),$(me),z.blending===na&&z.transparent===!1?D(ti):D(z.blending,z.blendEquation,z.blendSrc,z.blendDst,z.blendEquationAlpha,z.blendSrcAlpha,z.blendDstAlpha,z.blendColor,z.blendAlpha,z.premultipliedAlpha),a.setFunc(z.depthFunc),a.setTest(z.depthTest),a.setMask(z.depthWrite),s.setMask(z.colorWrite);const Re=z.stencilWrite;o.setTest(Re),Re&&(o.setMask(z.stencilWriteMask),o.setFunc(z.stencilFunc,z.stencilRef,z.stencilFuncMask),o.setOp(z.stencilFail,z.stencilZFail,z.stencilZPass)),te(z.polygonOffset,z.polygonOffsetFactor,z.polygonOffsetUnits),z.alphaToCoverage===!0?oe(r.SAMPLE_ALPHA_TO_COVERAGE):ue(r.SAMPLE_ALPHA_TO_COVERAGE)}function $(z){I!==z&&(z?r.frontFace(r.CW):r.frontFace(r.CCW),I=z)}function Q(z){z!==PA?(oe(r.CULL_FACE),z!==B&&(z===bf?r.cullFace(r.BACK):z===RA?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):ue(r.CULL_FACE),B=z}function L(z){z!==R&&(O&&r.lineWidth(z),R=z)}function te(z,ve,me){z?(oe(r.POLYGON_OFFSET_FILL),(U!==ve||C!==me)&&(U=ve,C=me,a.getReversed()&&(ve=-ve),r.polygonOffset(ve,me))):ue(r.POLYGON_OFFSET_FILL)}function de(z){z?oe(r.SCISSOR_TEST):ue(r.SCISSOR_TEST)}function V(z){z===void 0&&(z=r.TEXTURE0+F-1),G!==z&&(r.activeTexture(z),G=z)}function ee(z,ve,me){me===void 0&&(G===null?me=r.TEXTURE0+F-1:me=G);let Re=re[me];Re===void 0&&(Re={type:void 0,texture:void 0},re[me]=Re),(Re.type!==z||Re.texture!==ve)&&(G!==me&&(r.activeTexture(me),G=me),r.bindTexture(z,ve||J[z]),Re.type=z,Re.texture=ve)}function P(){const z=re[G];z!==void 0&&z.type!==void 0&&(r.bindTexture(z.type,null),z.type=void 0,z.texture=void 0)}function x(){try{r.compressedTexImage2D(...arguments)}catch(z){ct("WebGLState:",z)}}function N(){try{r.compressedTexImage3D(...arguments)}catch(z){ct("WebGLState:",z)}}function X(){try{r.texSubImage2D(...arguments)}catch(z){ct("WebGLState:",z)}}function Z(){try{r.texSubImage3D(...arguments)}catch(z){ct("WebGLState:",z)}}function K(){try{r.compressedTexSubImage2D(...arguments)}catch(z){ct("WebGLState:",z)}}function Ie(){try{r.compressedTexSubImage3D(...arguments)}catch(z){ct("WebGLState:",z)}}function ge(){try{r.texStorage2D(...arguments)}catch(z){ct("WebGLState:",z)}}function ke(){try{r.texStorage3D(...arguments)}catch(z){ct("WebGLState:",z)}}function Oe(){try{r.texImage2D(...arguments)}catch(z){ct("WebGLState:",z)}}function le(){try{r.texImage3D(...arguments)}catch(z){ct("WebGLState:",z)}}function Ae(z){ye.equals(z)===!1&&(r.scissor(z.x,z.y,z.z,z.w),ye.copy(z))}function ze(z){Me.equals(z)===!1&&(r.viewport(z.x,z.y,z.z,z.w),Me.copy(z))}function Ne(z,ve){let me=c.get(ve);me===void 0&&(me=new WeakMap,c.set(ve,me));let Re=me.get(z);Re===void 0&&(Re=r.getUniformBlockIndex(ve,z.name),me.set(z,Re))}function we(z,ve){const Re=c.get(ve).get(z);l.get(ve)!==Re&&(r.uniformBlockBinding(ve,Re,z.__bindingPointIndex),l.set(ve,Re))}function je(){r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SCISSOR_TEST),r.disable(r.STENCIL_TEST),r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.ONE,r.ZERO),r.blendFuncSeparate(r.ONE,r.ZERO,r.ONE,r.ZERO),r.blendColor(0,0,0,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(r.LESS),a.setReversed(!1),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(r.ALWAYS,0,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),r.clearStencil(0),r.cullFace(r.BACK),r.frontFace(r.CCW),r.polygonOffset(0,0),r.activeTexture(r.TEXTURE0),r.bindFramebuffer(r.FRAMEBUFFER,null),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(r.READ_FRAMEBUFFER,null),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),h={},G=null,re={},d={},p=new WeakMap,u=[],A=null,m=!1,g=null,f=null,v=null,b=null,y=null,M=null,_=null,S=new We(0,0,0),w=0,E=!1,I=null,B=null,R=null,U=null,C=null,ye.set(0,0,r.canvas.width,r.canvas.height),Me.set(0,0,r.canvas.width,r.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:oe,disable:ue,bindFramebuffer:Pe,drawBuffers:Be,useProgram:Ue,setBlending:D,setMaterial:ae,setFlipSided:$,setCullFace:Q,setLineWidth:L,setPolygonOffset:te,setScissorTest:de,activeTexture:V,bindTexture:ee,unbindTexture:P,compressedTexImage2D:x,compressedTexImage3D:N,texImage2D:Oe,texImage3D:le,updateUBOMapping:Ne,uniformBlockBinding:we,texStorage2D:ge,texStorage3D:ke,texSubImage2D:X,texSubImage3D:Z,compressedTexSubImage2D:K,compressedTexSubImage3D:Ie,scissor:Ae,viewport:ze,reset:je}}function cP(r,e,t,i,n,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new be,h=new WeakMap;let d;const p=new WeakMap;let u=!1;try{u=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function A(P,x){return u?new OffscreenCanvas(P,x):Ac("canvas")}function m(P,x,N){let X=1;const Z=ee(P);if((Z.width>N||Z.height>N)&&(X=N/Math.max(Z.width,Z.height)),X<1)if(typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&P instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&P instanceof ImageBitmap||typeof VideoFrame<"u"&&P instanceof VideoFrame){const K=Math.floor(X*Z.width),Ie=Math.floor(X*Z.height);d===void 0&&(d=A(K,Ie));const ge=x?A(K,Ie):d;return ge.width=K,ge.height=Ie,ge.getContext("2d").drawImage(P,0,0,K,Ie),Ye("WebGLRenderer: Texture has been resized from ("+Z.width+"x"+Z.height+") to ("+K+"x"+Ie+")."),ge}else return"data"in P&&Ye("WebGLRenderer: Image in DataTexture is too big ("+Z.width+"x"+Z.height+")."),P;return P}function g(P){return P.generateMipmaps}function f(P){r.generateMipmap(P)}function v(P){return P.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:P.isWebGL3DRenderTarget?r.TEXTURE_3D:P.isWebGLArrayRenderTarget||P.isCompressedArrayTexture?r.TEXTURE_2D_ARRAY:r.TEXTURE_2D}function b(P,x,N,X,Z=!1){if(P!==null){if(r[P]!==void 0)return r[P];Ye("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+P+"'")}let K=x;if(x===r.RED&&(N===r.FLOAT&&(K=r.R32F),N===r.HALF_FLOAT&&(K=r.R16F),N===r.UNSIGNED_BYTE&&(K=r.R8)),x===r.RED_INTEGER&&(N===r.UNSIGNED_BYTE&&(K=r.R8UI),N===r.UNSIGNED_SHORT&&(K=r.R16UI),N===r.UNSIGNED_INT&&(K=r.R32UI),N===r.BYTE&&(K=r.R8I),N===r.SHORT&&(K=r.R16I),N===r.INT&&(K=r.R32I)),x===r.RG&&(N===r.FLOAT&&(K=r.RG32F),N===r.HALF_FLOAT&&(K=r.RG16F),N===r.UNSIGNED_BYTE&&(K=r.RG8)),x===r.RG_INTEGER&&(N===r.UNSIGNED_BYTE&&(K=r.RG8UI),N===r.UNSIGNED_SHORT&&(K=r.RG16UI),N===r.UNSIGNED_INT&&(K=r.RG32UI),N===r.BYTE&&(K=r.RG8I),N===r.SHORT&&(K=r.RG16I),N===r.INT&&(K=r.RG32I)),x===r.RGB_INTEGER&&(N===r.UNSIGNED_BYTE&&(K=r.RGB8UI),N===r.UNSIGNED_SHORT&&(K=r.RGB16UI),N===r.UNSIGNED_INT&&(K=r.RGB32UI),N===r.BYTE&&(K=r.RGB8I),N===r.SHORT&&(K=r.RGB16I),N===r.INT&&(K=r.RGB32I)),x===r.RGBA_INTEGER&&(N===r.UNSIGNED_BYTE&&(K=r.RGBA8UI),N===r.UNSIGNED_SHORT&&(K=r.RGBA16UI),N===r.UNSIGNED_INT&&(K=r.RGBA32UI),N===r.BYTE&&(K=r.RGBA8I),N===r.SHORT&&(K=r.RGBA16I),N===r.INT&&(K=r.RGBA32I)),x===r.RGB&&(N===r.UNSIGNED_INT_5_9_9_9_REV&&(K=r.RGB9_E5),N===r.UNSIGNED_INT_10F_11F_11F_REV&&(K=r.R11F_G11F_B10F)),x===r.RGBA){const Ie=Z?mc:Et.getTransfer(X);N===r.FLOAT&&(K=r.RGBA32F),N===r.HALF_FLOAT&&(K=r.RGBA16F),N===r.UNSIGNED_BYTE&&(K=Ie===Ut?r.SRGB8_ALPHA8:r.RGBA8),N===r.UNSIGNED_SHORT_4_4_4_4&&(K=r.RGBA4),N===r.UNSIGNED_SHORT_5_5_5_1&&(K=r.RGB5_A1)}return(K===r.R16F||K===r.R32F||K===r.RG16F||K===r.RG32F||K===r.RGBA16F||K===r.RGBA32F)&&e.get("EXT_color_buffer_float"),K}function y(P,x){let N;return P?x===null||x===Vn||x===Ar?N=r.DEPTH24_STENCIL8:x===oi?N=r.DEPTH32F_STENCIL8:x===Eo&&(N=r.DEPTH24_STENCIL8,Ye("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===Vn||x===Ar?N=r.DEPTH_COMPONENT24:x===oi?N=r.DEPTH_COMPONENT32F:x===Eo&&(N=r.DEPTH_COMPONENT16),N}function M(P,x){return g(P)===!0||P.isFramebufferTexture&&P.minFilter!==Ht&&P.minFilter!==_t?Math.log2(Math.max(x.width,x.height))+1:P.mipmaps!==void 0&&P.mipmaps.length>0?P.mipmaps.length:P.isCompressedTexture&&Array.isArray(P.image)?x.mipmaps.length:1}function _(P){const x=P.target;x.removeEventListener("dispose",_),w(x),x.isVideoTexture&&h.delete(x)}function S(P){const x=P.target;x.removeEventListener("dispose",S),I(x)}function w(P){const x=i.get(P);if(x.__webglInit===void 0)return;const N=P.source,X=p.get(N);if(X){const Z=X[x.__cacheKey];Z.usedTimes--,Z.usedTimes===0&&E(P),Object.keys(X).length===0&&p.delete(N)}i.remove(P)}function E(P){const x=i.get(P);r.deleteTexture(x.__webglTexture);const N=P.source,X=p.get(N);delete X[x.__cacheKey],a.memory.textures--}function I(P){const x=i.get(P);if(P.depthTexture&&(P.depthTexture.dispose(),i.remove(P.depthTexture)),P.isWebGLCubeRenderTarget)for(let X=0;X<6;X++){if(Array.isArray(x.__webglFramebuffer[X]))for(let Z=0;Z<x.__webglFramebuffer[X].length;Z++)r.deleteFramebuffer(x.__webglFramebuffer[X][Z]);else r.deleteFramebuffer(x.__webglFramebuffer[X]);x.__webglDepthbuffer&&r.deleteRenderbuffer(x.__webglDepthbuffer[X])}else{if(Array.isArray(x.__webglFramebuffer))for(let X=0;X<x.__webglFramebuffer.length;X++)r.deleteFramebuffer(x.__webglFramebuffer[X]);else r.deleteFramebuffer(x.__webglFramebuffer);if(x.__webglDepthbuffer&&r.deleteRenderbuffer(x.__webglDepthbuffer),x.__webglMultisampledFramebuffer&&r.deleteFramebuffer(x.__webglMultisampledFramebuffer),x.__webglColorRenderbuffer)for(let X=0;X<x.__webglColorRenderbuffer.length;X++)x.__webglColorRenderbuffer[X]&&r.deleteRenderbuffer(x.__webglColorRenderbuffer[X]);x.__webglDepthRenderbuffer&&r.deleteRenderbuffer(x.__webglDepthRenderbuffer)}const N=P.textures;for(let X=0,Z=N.length;X<Z;X++){const K=i.get(N[X]);K.__webglTexture&&(r.deleteTexture(K.__webglTexture),a.memory.textures--),i.remove(N[X])}i.remove(P)}let B=0;function R(){B=0}function U(){const P=B;return P>=n.maxTextures&&Ye("WebGLTextures: Trying to use "+P+" texture units while this GPU supports only "+n.maxTextures),B+=1,P}function C(P){const x=[];return x.push(P.wrapS),x.push(P.wrapT),x.push(P.wrapR||0),x.push(P.magFilter),x.push(P.minFilter),x.push(P.anisotropy),x.push(P.internalFormat),x.push(P.format),x.push(P.type),x.push(P.generateMipmaps),x.push(P.premultiplyAlpha),x.push(P.flipY),x.push(P.unpackAlignment),x.push(P.colorSpace),x.join()}function F(P,x){const N=i.get(P);if(P.isVideoTexture&&de(P),P.isRenderTargetTexture===!1&&P.isExternalTexture!==!0&&P.version>0&&N.__version!==P.version){const X=P.image;if(X===null)Ye("WebGLRenderer: Texture marked for update but no image data found.");else if(X.complete===!1)Ye("WebGLRenderer: Texture marked for update but image is incomplete");else{J(N,P,x);return}}else P.isExternalTexture&&(N.__webglTexture=P.sourceTexture?P.sourceTexture:null);t.bindTexture(r.TEXTURE_2D,N.__webglTexture,r.TEXTURE0+x)}function O(P,x){const N=i.get(P);if(P.isRenderTargetTexture===!1&&P.version>0&&N.__version!==P.version){J(N,P,x);return}else P.isExternalTexture&&(N.__webglTexture=P.sourceTexture?P.sourceTexture:null);t.bindTexture(r.TEXTURE_2D_ARRAY,N.__webglTexture,r.TEXTURE0+x)}function H(P,x){const N=i.get(P);if(P.isRenderTargetTexture===!1&&P.version>0&&N.__version!==P.version){J(N,P,x);return}t.bindTexture(r.TEXTURE_3D,N.__webglTexture,r.TEXTURE0+x)}function j(P,x){const N=i.get(P);if(P.isCubeDepthTexture!==!0&&P.version>0&&N.__version!==P.version){oe(N,P,x);return}t.bindTexture(r.TEXTURE_CUBE_MAP,N.__webglTexture,r.TEXTURE0+x)}const G={[Ji]:r.REPEAT,[ln]:r.CLAMP_TO_EDGE,[xo]:r.MIRRORED_REPEAT},re={[Ht]:r.NEAREST,[Jl]:r.NEAREST_MIPMAP_NEAREST,[aa]:r.NEAREST_MIPMAP_LINEAR,[_t]:r.LINEAR,[_o]:r.LINEAR_MIPMAP_NEAREST,[An]:r.LINEAR_MIPMAP_LINEAR},q={[iv]:r.NEVER,[ov]:r.ALWAYS,[nv]:r.LESS,[Id]:r.LEQUAL,[sv]:r.EQUAL,[Pd]:r.GEQUAL,[rv]:r.GREATER,[av]:r.NOTEQUAL};function Y(P,x){if(x.type===oi&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===_t||x.magFilter===_o||x.magFilter===aa||x.magFilter===An||x.minFilter===_t||x.minFilter===_o||x.minFilter===aa||x.minFilter===An)&&Ye("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),r.texParameteri(P,r.TEXTURE_WRAP_S,G[x.wrapS]),r.texParameteri(P,r.TEXTURE_WRAP_T,G[x.wrapT]),(P===r.TEXTURE_3D||P===r.TEXTURE_2D_ARRAY)&&r.texParameteri(P,r.TEXTURE_WRAP_R,G[x.wrapR]),r.texParameteri(P,r.TEXTURE_MAG_FILTER,re[x.magFilter]),r.texParameteri(P,r.TEXTURE_MIN_FILTER,re[x.minFilter]),x.compareFunction&&(r.texParameteri(P,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(P,r.TEXTURE_COMPARE_FUNC,q[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===Ht||x.minFilter!==aa&&x.minFilter!==An||x.type===oi&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||i.get(x).__currentAnisotropy){const N=e.get("EXT_texture_filter_anisotropic");r.texParameterf(P,N.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,n.getMaxAnisotropy())),i.get(x).__currentAnisotropy=x.anisotropy}}}function ye(P,x){let N=!1;P.__webglInit===void 0&&(P.__webglInit=!0,x.addEventListener("dispose",_));const X=x.source;let Z=p.get(X);Z===void 0&&(Z={},p.set(X,Z));const K=C(x);if(K!==P.__cacheKey){Z[K]===void 0&&(Z[K]={texture:r.createTexture(),usedTimes:0},a.memory.textures++,N=!0),Z[K].usedTimes++;const Ie=Z[P.__cacheKey];Ie!==void 0&&(Z[P.__cacheKey].usedTimes--,Ie.usedTimes===0&&E(x)),P.__cacheKey=K,P.__webglTexture=Z[K].texture}return N}function Me(P,x,N){return Math.floor(Math.floor(P/N)/x)}function xe(P,x,N,X){const K=P.updateRanges;if(K.length===0)t.texSubImage2D(r.TEXTURE_2D,0,0,0,x.width,x.height,N,X,x.data);else{K.sort((le,Ae)=>le.start-Ae.start);let Ie=0;for(let le=1;le<K.length;le++){const Ae=K[Ie],ze=K[le],Ne=Ae.start+Ae.count,we=Me(ze.start,x.width,4),je=Me(Ae.start,x.width,4);ze.start<=Ne+1&&we===je&&Me(ze.start+ze.count-1,x.width,4)===we?Ae.count=Math.max(Ae.count,ze.start+ze.count-Ae.start):(++Ie,K[Ie]=ze)}K.length=Ie+1;const ge=r.getParameter(r.UNPACK_ROW_LENGTH),ke=r.getParameter(r.UNPACK_SKIP_PIXELS),Oe=r.getParameter(r.UNPACK_SKIP_ROWS);r.pixelStorei(r.UNPACK_ROW_LENGTH,x.width);for(let le=0,Ae=K.length;le<Ae;le++){const ze=K[le],Ne=Math.floor(ze.start/4),we=Math.ceil(ze.count/4),je=Ne%x.width,z=Math.floor(Ne/x.width),ve=we,me=1;r.pixelStorei(r.UNPACK_SKIP_PIXELS,je),r.pixelStorei(r.UNPACK_SKIP_ROWS,z),t.texSubImage2D(r.TEXTURE_2D,0,je,z,ve,me,N,X,x.data)}P.clearUpdateRanges(),r.pixelStorei(r.UNPACK_ROW_LENGTH,ge),r.pixelStorei(r.UNPACK_SKIP_PIXELS,ke),r.pixelStorei(r.UNPACK_SKIP_ROWS,Oe)}}function J(P,x,N){let X=r.TEXTURE_2D;(x.isDataArrayTexture||x.isCompressedArrayTexture)&&(X=r.TEXTURE_2D_ARRAY),x.isData3DTexture&&(X=r.TEXTURE_3D);const Z=ye(P,x),K=x.source;t.bindTexture(X,P.__webglTexture,r.TEXTURE0+N);const Ie=i.get(K);if(K.version!==Ie.__version||Z===!0){t.activeTexture(r.TEXTURE0+N);const ge=Et.getPrimaries(Et.workingColorSpace),ke=x.colorSpace===ts?null:Et.getPrimaries(x.colorSpace),Oe=x.colorSpace===ts||ge===ke?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,x.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,x.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,Oe);let le=m(x.image,!1,n.maxTextureSize);le=V(x,le);const Ae=s.convert(x.format,x.colorSpace),ze=s.convert(x.type);let Ne=b(x.internalFormat,Ae,ze,x.colorSpace,x.isVideoTexture);Y(X,x);let we;const je=x.mipmaps,z=x.isVideoTexture!==!0,ve=Ie.__version===void 0||Z===!0,me=K.dataReady,Re=M(x,le);if(x.isDepthTexture)Ne=y(x.format===_s,x.type),ve&&(z?t.texStorage2D(r.TEXTURE_2D,1,Ne,le.width,le.height):t.texImage2D(r.TEXTURE_2D,0,Ne,le.width,le.height,0,Ae,ze,null));else if(x.isDataTexture)if(je.length>0){z&&ve&&t.texStorage2D(r.TEXTURE_2D,Re,Ne,je[0].width,je[0].height);for(let pe=0,ne=je.length;pe<ne;pe++)we=je[pe],z?me&&t.texSubImage2D(r.TEXTURE_2D,pe,0,0,we.width,we.height,Ae,ze,we.data):t.texImage2D(r.TEXTURE_2D,pe,Ne,we.width,we.height,0,Ae,ze,we.data);x.generateMipmaps=!1}else z?(ve&&t.texStorage2D(r.TEXTURE_2D,Re,Ne,le.width,le.height),me&&xe(x,le,Ae,ze)):t.texImage2D(r.TEXTURE_2D,0,Ne,le.width,le.height,0,Ae,ze,le.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){z&&ve&&t.texStorage3D(r.TEXTURE_2D_ARRAY,Re,Ne,je[0].width,je[0].height,le.depth);for(let pe=0,ne=je.length;pe<ne;pe++)if(we=je[pe],x.format!==hi)if(Ae!==null)if(z){if(me)if(x.layerUpdates.size>0){const Le=Ym(we.width,we.height,x.format,x.type);for(const Qe of x.layerUpdates){const pt=we.data.subarray(Qe*Le/we.data.BYTES_PER_ELEMENT,(Qe+1)*Le/we.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,pe,0,0,Qe,we.width,we.height,1,Ae,pt)}x.clearLayerUpdates()}else t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,pe,0,0,0,we.width,we.height,le.depth,Ae,we.data)}else t.compressedTexImage3D(r.TEXTURE_2D_ARRAY,pe,Ne,we.width,we.height,le.depth,0,we.data,0,0);else Ye("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else z?me&&t.texSubImage3D(r.TEXTURE_2D_ARRAY,pe,0,0,0,we.width,we.height,le.depth,Ae,ze,we.data):t.texImage3D(r.TEXTURE_2D_ARRAY,pe,Ne,we.width,we.height,le.depth,0,Ae,ze,we.data)}else{z&&ve&&t.texStorage2D(r.TEXTURE_2D,Re,Ne,je[0].width,je[0].height);for(let pe=0,ne=je.length;pe<ne;pe++)we=je[pe],x.format!==hi?Ae!==null?z?me&&t.compressedTexSubImage2D(r.TEXTURE_2D,pe,0,0,we.width,we.height,Ae,we.data):t.compressedTexImage2D(r.TEXTURE_2D,pe,Ne,we.width,we.height,0,we.data):Ye("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):z?me&&t.texSubImage2D(r.TEXTURE_2D,pe,0,0,we.width,we.height,Ae,ze,we.data):t.texImage2D(r.TEXTURE_2D,pe,Ne,we.width,we.height,0,Ae,ze,we.data)}else if(x.isDataArrayTexture)if(z){if(ve&&t.texStorage3D(r.TEXTURE_2D_ARRAY,Re,Ne,le.width,le.height,le.depth),me)if(x.layerUpdates.size>0){const pe=Ym(le.width,le.height,x.format,x.type);for(const ne of x.layerUpdates){const Le=le.data.subarray(ne*pe/le.data.BYTES_PER_ELEMENT,(ne+1)*pe/le.data.BYTES_PER_ELEMENT);t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,ne,le.width,le.height,1,Ae,ze,Le)}x.clearLayerUpdates()}else t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,le.width,le.height,le.depth,Ae,ze,le.data)}else t.texImage3D(r.TEXTURE_2D_ARRAY,0,Ne,le.width,le.height,le.depth,0,Ae,ze,le.data);else if(x.isData3DTexture)z?(ve&&t.texStorage3D(r.TEXTURE_3D,Re,Ne,le.width,le.height,le.depth),me&&t.texSubImage3D(r.TEXTURE_3D,0,0,0,0,le.width,le.height,le.depth,Ae,ze,le.data)):t.texImage3D(r.TEXTURE_3D,0,Ne,le.width,le.height,le.depth,0,Ae,ze,le.data);else if(x.isFramebufferTexture){if(ve)if(z)t.texStorage2D(r.TEXTURE_2D,Re,Ne,le.width,le.height);else{let pe=le.width,ne=le.height;for(let Le=0;Le<Re;Le++)t.texImage2D(r.TEXTURE_2D,Le,Ne,pe,ne,0,Ae,ze,null),pe>>=1,ne>>=1}}else if(je.length>0){if(z&&ve){const pe=ee(je[0]);t.texStorage2D(r.TEXTURE_2D,Re,Ne,pe.width,pe.height)}for(let pe=0,ne=je.length;pe<ne;pe++)we=je[pe],z?me&&t.texSubImage2D(r.TEXTURE_2D,pe,0,0,Ae,ze,we):t.texImage2D(r.TEXTURE_2D,pe,Ne,Ae,ze,we);x.generateMipmaps=!1}else if(z){if(ve){const pe=ee(le);t.texStorage2D(r.TEXTURE_2D,Re,Ne,pe.width,pe.height)}me&&t.texSubImage2D(r.TEXTURE_2D,0,0,0,Ae,ze,le)}else t.texImage2D(r.TEXTURE_2D,0,Ne,Ae,ze,le);g(x)&&f(X),Ie.__version=K.version,x.onUpdate&&x.onUpdate(x)}P.__version=x.version}function oe(P,x,N){if(x.image.length!==6)return;const X=ye(P,x),Z=x.source;t.bindTexture(r.TEXTURE_CUBE_MAP,P.__webglTexture,r.TEXTURE0+N);const K=i.get(Z);if(Z.version!==K.__version||X===!0){t.activeTexture(r.TEXTURE0+N);const Ie=Et.getPrimaries(Et.workingColorSpace),ge=x.colorSpace===ts?null:Et.getPrimaries(x.colorSpace),ke=x.colorSpace===ts||Ie===ge?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,x.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,x.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,ke);const Oe=x.isCompressedTexture||x.image[0].isCompressedTexture,le=x.image[0]&&x.image[0].isDataTexture,Ae=[];for(let ne=0;ne<6;ne++)!Oe&&!le?Ae[ne]=m(x.image[ne],!0,n.maxCubemapSize):Ae[ne]=le?x.image[ne].image:x.image[ne],Ae[ne]=V(x,Ae[ne]);const ze=Ae[0],Ne=s.convert(x.format,x.colorSpace),we=s.convert(x.type),je=b(x.internalFormat,Ne,we,x.colorSpace),z=x.isVideoTexture!==!0,ve=K.__version===void 0||X===!0,me=Z.dataReady;let Re=M(x,ze);Y(r.TEXTURE_CUBE_MAP,x);let pe;if(Oe){z&&ve&&t.texStorage2D(r.TEXTURE_CUBE_MAP,Re,je,ze.width,ze.height);for(let ne=0;ne<6;ne++){pe=Ae[ne].mipmaps;for(let Le=0;Le<pe.length;Le++){const Qe=pe[Le];x.format!==hi?Ne!==null?z?me&&t.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Le,0,0,Qe.width,Qe.height,Ne,Qe.data):t.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Le,je,Qe.width,Qe.height,0,Qe.data):Ye("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):z?me&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Le,0,0,Qe.width,Qe.height,Ne,we,Qe.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Le,je,Qe.width,Qe.height,0,Ne,we,Qe.data)}}}else{if(pe=x.mipmaps,z&&ve){pe.length>0&&Re++;const ne=ee(Ae[0]);t.texStorage2D(r.TEXTURE_CUBE_MAP,Re,je,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(le){z?me&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Ae[ne].width,Ae[ne].height,Ne,we,Ae[ne].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,je,Ae[ne].width,Ae[ne].height,0,Ne,we,Ae[ne].data);for(let Le=0;Le<pe.length;Le++){const pt=pe[Le].image[ne].image;z?me&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Le+1,0,0,pt.width,pt.height,Ne,we,pt.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Le+1,je,pt.width,pt.height,0,Ne,we,pt.data)}}else{z?me&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Ne,we,Ae[ne]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,je,Ne,we,Ae[ne]);for(let Le=0;Le<pe.length;Le++){const Qe=pe[Le];z?me&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Le+1,0,0,Ne,we,Qe.image[ne]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Le+1,je,Ne,we,Qe.image[ne])}}}g(x)&&f(r.TEXTURE_CUBE_MAP),K.__version=Z.version,x.onUpdate&&x.onUpdate(x)}P.__version=x.version}function ue(P,x,N,X,Z,K){const Ie=s.convert(N.format,N.colorSpace),ge=s.convert(N.type),ke=b(N.internalFormat,Ie,ge,N.colorSpace),Oe=i.get(x),le=i.get(N);if(le.__renderTarget=x,!Oe.__hasExternalTextures){const Ae=Math.max(1,x.width>>K),ze=Math.max(1,x.height>>K);Z===r.TEXTURE_3D||Z===r.TEXTURE_2D_ARRAY?t.texImage3D(Z,K,ke,Ae,ze,x.depth,0,Ie,ge,null):t.texImage2D(Z,K,ke,Ae,ze,0,Ie,ge,null)}t.bindFramebuffer(r.FRAMEBUFFER,P),te(x)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,X,Z,le.__webglTexture,0,L(x)):(Z===r.TEXTURE_2D||Z>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&Z<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,X,Z,le.__webglTexture,K),t.bindFramebuffer(r.FRAMEBUFFER,null)}function Pe(P,x,N){if(r.bindRenderbuffer(r.RENDERBUFFER,P),x.depthBuffer){const X=x.depthTexture,Z=X&&X.isDepthTexture?X.type:null,K=y(x.stencilBuffer,Z),Ie=x.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;te(x)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,L(x),K,x.width,x.height):N?r.renderbufferStorageMultisample(r.RENDERBUFFER,L(x),K,x.width,x.height):r.renderbufferStorage(r.RENDERBUFFER,K,x.width,x.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,Ie,r.RENDERBUFFER,P)}else{const X=x.textures;for(let Z=0;Z<X.length;Z++){const K=X[Z],Ie=s.convert(K.format,K.colorSpace),ge=s.convert(K.type),ke=b(K.internalFormat,Ie,ge,K.colorSpace);te(x)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,L(x),ke,x.width,x.height):N?r.renderbufferStorageMultisample(r.RENDERBUFFER,L(x),ke,x.width,x.height):r.renderbufferStorage(r.RENDERBUFFER,ke,x.width,x.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function Be(P,x,N){const X=x.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(r.FRAMEBUFFER,P),!(x.depthTexture&&x.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const Z=i.get(x.depthTexture);if(Z.__renderTarget=x,(!Z.__webglTexture||x.depthTexture.image.width!==x.width||x.depthTexture.image.height!==x.height)&&(x.depthTexture.image.width=x.width,x.depthTexture.image.height=x.height,x.depthTexture.needsUpdate=!0),X){if(Z.__webglInit===void 0&&(Z.__webglInit=!0,x.depthTexture.addEventListener("dispose",_)),Z.__webglTexture===void 0){Z.__webglTexture=r.createTexture(),t.bindTexture(r.TEXTURE_CUBE_MAP,Z.__webglTexture),Y(r.TEXTURE_CUBE_MAP,x.depthTexture);const Oe=s.convert(x.depthTexture.format),le=s.convert(x.depthTexture.type);let Ae;x.depthTexture.format===xs?Ae=r.DEPTH_COMPONENT24:x.depthTexture.format===_s&&(Ae=r.DEPTH24_STENCIL8);for(let ze=0;ze<6;ze++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ze,0,Ae,x.width,x.height,0,Oe,le,null)}}else F(x.depthTexture,0);const K=Z.__webglTexture,Ie=L(x),ge=X?r.TEXTURE_CUBE_MAP_POSITIVE_X+N:r.TEXTURE_2D,ke=x.depthTexture.format===_s?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;if(x.depthTexture.format===xs)te(x)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,ke,ge,K,0,Ie):r.framebufferTexture2D(r.FRAMEBUFFER,ke,ge,K,0);else if(x.depthTexture.format===_s)te(x)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,ke,ge,K,0,Ie):r.framebufferTexture2D(r.FRAMEBUFFER,ke,ge,K,0);else throw new Error("Unknown depthTexture format")}function Ue(P){const x=i.get(P),N=P.isWebGLCubeRenderTarget===!0;if(x.__boundDepthTexture!==P.depthTexture){const X=P.depthTexture;if(x.__depthDisposeCallback&&x.__depthDisposeCallback(),X){const Z=()=>{delete x.__boundDepthTexture,delete x.__depthDisposeCallback,X.removeEventListener("dispose",Z)};X.addEventListener("dispose",Z),x.__depthDisposeCallback=Z}x.__boundDepthTexture=X}if(P.depthTexture&&!x.__autoAllocateDepthBuffer)if(N)for(let X=0;X<6;X++)Be(x.__webglFramebuffer[X],P,X);else{const X=P.texture.mipmaps;X&&X.length>0?Be(x.__webglFramebuffer[0],P,0):Be(x.__webglFramebuffer,P,0)}else if(N){x.__webglDepthbuffer=[];for(let X=0;X<6;X++)if(t.bindFramebuffer(r.FRAMEBUFFER,x.__webglFramebuffer[X]),x.__webglDepthbuffer[X]===void 0)x.__webglDepthbuffer[X]=r.createRenderbuffer(),Pe(x.__webglDepthbuffer[X],P,!1);else{const Z=P.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,K=x.__webglDepthbuffer[X];r.bindRenderbuffer(r.RENDERBUFFER,K),r.framebufferRenderbuffer(r.FRAMEBUFFER,Z,r.RENDERBUFFER,K)}}else{const X=P.texture.mipmaps;if(X&&X.length>0?t.bindFramebuffer(r.FRAMEBUFFER,x.__webglFramebuffer[0]):t.bindFramebuffer(r.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=r.createRenderbuffer(),Pe(x.__webglDepthbuffer,P,!1);else{const Z=P.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,K=x.__webglDepthbuffer;r.bindRenderbuffer(r.RENDERBUFFER,K),r.framebufferRenderbuffer(r.FRAMEBUFFER,Z,r.RENDERBUFFER,K)}}t.bindFramebuffer(r.FRAMEBUFFER,null)}function it(P,x,N){const X=i.get(P);x!==void 0&&ue(X.__webglFramebuffer,P,P.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),N!==void 0&&Ue(P)}function qe(P){const x=P.texture,N=i.get(P),X=i.get(x);P.addEventListener("dispose",S);const Z=P.textures,K=P.isWebGLCubeRenderTarget===!0,Ie=Z.length>1;if(Ie||(X.__webglTexture===void 0&&(X.__webglTexture=r.createTexture()),X.__version=x.version,a.memory.textures++),K){N.__webglFramebuffer=[];for(let ge=0;ge<6;ge++)if(x.mipmaps&&x.mipmaps.length>0){N.__webglFramebuffer[ge]=[];for(let ke=0;ke<x.mipmaps.length;ke++)N.__webglFramebuffer[ge][ke]=r.createFramebuffer()}else N.__webglFramebuffer[ge]=r.createFramebuffer()}else{if(x.mipmaps&&x.mipmaps.length>0){N.__webglFramebuffer=[];for(let ge=0;ge<x.mipmaps.length;ge++)N.__webglFramebuffer[ge]=r.createFramebuffer()}else N.__webglFramebuffer=r.createFramebuffer();if(Ie)for(let ge=0,ke=Z.length;ge<ke;ge++){const Oe=i.get(Z[ge]);Oe.__webglTexture===void 0&&(Oe.__webglTexture=r.createTexture(),a.memory.textures++)}if(P.samples>0&&te(P)===!1){N.__webglMultisampledFramebuffer=r.createFramebuffer(),N.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,N.__webglMultisampledFramebuffer);for(let ge=0;ge<Z.length;ge++){const ke=Z[ge];N.__webglColorRenderbuffer[ge]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,N.__webglColorRenderbuffer[ge]);const Oe=s.convert(ke.format,ke.colorSpace),le=s.convert(ke.type),Ae=b(ke.internalFormat,Oe,le,ke.colorSpace,P.isXRRenderTarget===!0),ze=L(P);r.renderbufferStorageMultisample(r.RENDERBUFFER,ze,Ae,P.width,P.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+ge,r.RENDERBUFFER,N.__webglColorRenderbuffer[ge])}r.bindRenderbuffer(r.RENDERBUFFER,null),P.depthBuffer&&(N.__webglDepthRenderbuffer=r.createRenderbuffer(),Pe(N.__webglDepthRenderbuffer,P,!0)),t.bindFramebuffer(r.FRAMEBUFFER,null)}}if(K){t.bindTexture(r.TEXTURE_CUBE_MAP,X.__webglTexture),Y(r.TEXTURE_CUBE_MAP,x);for(let ge=0;ge<6;ge++)if(x.mipmaps&&x.mipmaps.length>0)for(let ke=0;ke<x.mipmaps.length;ke++)ue(N.__webglFramebuffer[ge][ke],P,x,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+ge,ke);else ue(N.__webglFramebuffer[ge],P,x,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+ge,0);g(x)&&f(r.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Ie){for(let ge=0,ke=Z.length;ge<ke;ge++){const Oe=Z[ge],le=i.get(Oe);let Ae=r.TEXTURE_2D;(P.isWebGL3DRenderTarget||P.isWebGLArrayRenderTarget)&&(Ae=P.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),t.bindTexture(Ae,le.__webglTexture),Y(Ae,Oe),ue(N.__webglFramebuffer,P,Oe,r.COLOR_ATTACHMENT0+ge,Ae,0),g(Oe)&&f(Ae)}t.unbindTexture()}else{let ge=r.TEXTURE_2D;if((P.isWebGL3DRenderTarget||P.isWebGLArrayRenderTarget)&&(ge=P.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),t.bindTexture(ge,X.__webglTexture),Y(ge,x),x.mipmaps&&x.mipmaps.length>0)for(let ke=0;ke<x.mipmaps.length;ke++)ue(N.__webglFramebuffer[ke],P,x,r.COLOR_ATTACHMENT0,ge,ke);else ue(N.__webglFramebuffer,P,x,r.COLOR_ATTACHMENT0,ge,0);g(x)&&f(ge),t.unbindTexture()}P.depthBuffer&&Ue(P)}function D(P){const x=P.textures;for(let N=0,X=x.length;N<X;N++){const Z=x[N];if(g(Z)){const K=v(P),Ie=i.get(Z).__webglTexture;t.bindTexture(K,Ie),f(K),t.unbindTexture()}}}const ae=[],$=[];function Q(P){if(P.samples>0){if(te(P)===!1){const x=P.textures,N=P.width,X=P.height;let Z=r.COLOR_BUFFER_BIT;const K=P.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Ie=i.get(P),ge=x.length>1;if(ge)for(let Oe=0;Oe<x.length;Oe++)t.bindFramebuffer(r.FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Oe,r.RENDERBUFFER,null),t.bindFramebuffer(r.FRAMEBUFFER,Ie.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Oe,r.TEXTURE_2D,null,0);t.bindFramebuffer(r.READ_FRAMEBUFFER,Ie.__webglMultisampledFramebuffer);const ke=P.texture.mipmaps;ke&&ke.length>0?t.bindFramebuffer(r.DRAW_FRAMEBUFFER,Ie.__webglFramebuffer[0]):t.bindFramebuffer(r.DRAW_FRAMEBUFFER,Ie.__webglFramebuffer);for(let Oe=0;Oe<x.length;Oe++){if(P.resolveDepthBuffer&&(P.depthBuffer&&(Z|=r.DEPTH_BUFFER_BIT),P.stencilBuffer&&P.resolveStencilBuffer&&(Z|=r.STENCIL_BUFFER_BIT)),ge){r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,Ie.__webglColorRenderbuffer[Oe]);const le=i.get(x[Oe]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,le,0)}r.blitFramebuffer(0,0,N,X,0,0,N,X,Z,r.NEAREST),l===!0&&(ae.length=0,$.length=0,ae.push(r.COLOR_ATTACHMENT0+Oe),P.depthBuffer&&P.resolveDepthBuffer===!1&&(ae.push(K),$.push(K),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,$)),r.invalidateFramebuffer(r.READ_FRAMEBUFFER,ae))}if(t.bindFramebuffer(r.READ_FRAMEBUFFER,null),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),ge)for(let Oe=0;Oe<x.length;Oe++){t.bindFramebuffer(r.FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Oe,r.RENDERBUFFER,Ie.__webglColorRenderbuffer[Oe]);const le=i.get(x[Oe]).__webglTexture;t.bindFramebuffer(r.FRAMEBUFFER,Ie.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Oe,r.TEXTURE_2D,le,0)}t.bindFramebuffer(r.DRAW_FRAMEBUFFER,Ie.__webglMultisampledFramebuffer)}else if(P.depthBuffer&&P.resolveDepthBuffer===!1&&l){const x=P.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[x])}}}function L(P){return Math.min(n.maxSamples,P.samples)}function te(P){const x=i.get(P);return P.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function de(P){const x=a.render.frame;h.get(P)!==x&&(h.set(P,x),P.update())}function V(P,x){const N=P.colorSpace,X=P.format,Z=P.type;return P.isCompressedTexture===!0||P.isVideoTexture===!0||N!==Ri&&N!==ts&&(Et.getTransfer(N)===Ut?(X!==hi||Z!==ut)&&Ye("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ct("WebGLTextures: Unsupported texture color space:",N)),x}function ee(P){return typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement?(c.width=P.naturalWidth||P.width,c.height=P.naturalHeight||P.height):typeof VideoFrame<"u"&&P instanceof VideoFrame?(c.width=P.displayWidth,c.height=P.displayHeight):(c.width=P.width,c.height=P.height),c}this.allocateTextureUnit=U,this.resetTextureUnits=R,this.setTexture2D=F,this.setTexture2DArray=O,this.setTexture3D=H,this.setTextureCube=j,this.rebindTextures=it,this.setupRenderTarget=qe,this.updateRenderTargetMipmap=D,this.updateMultisampleRenderTarget=Q,this.setupDepthRenderbuffer=Ue,this.setupFrameBufferTexture=ue,this.useMultisampledRTT=te,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function z1(r,e){function t(i,n=ts){let s;const a=Et.getTransfer(n);if(i===ut)return r.UNSIGNED_BYTE;if(i===ld)return r.UNSIGNED_SHORT_4_4_4_4;if(i===cd)return r.UNSIGNED_SHORT_5_5_5_1;if(i===$l)return r.UNSIGNED_INT_5_9_9_9_REV;if(i===ec)return r.UNSIGNED_INT_10F_11F_11F_REV;if(i===Ef)return r.BYTE;if(i===Mf)return r.SHORT;if(i===Eo)return r.UNSIGNED_SHORT;if(i===od)return r.INT;if(i===Vn)return r.UNSIGNED_INT;if(i===oi)return r.FLOAT;if(i===Zt)return r.HALF_FLOAT;if(i===wf)return r.ALPHA;if(i===Mo)return r.RGB;if(i===hi)return r.RGBA;if(i===xs)return r.DEPTH_COMPONENT;if(i===_s)return r.DEPTH_STENCIL;if(i===Es)return r.RED;if(i===tc)return r.RED_INTEGER;if(i===Qn)return r.RG;if(i===hd)return r.RG_INTEGER;if(i===dd)return r.RGBA_INTEGER;if(i===oa||i===vr||i===ic||i===br)if(a===Ut)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===oa)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===vr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===ic)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===br)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===oa)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===vr)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===ic)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===br)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===nc||i===ud||i===la||i===wo)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===nc)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===ud)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===la)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===wo)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===sc||i===So||i===Co||i===rc||i===ac||i===oc||i===lc)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===sc||i===So)return a===Ut?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Co)return a===Ut?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===rc)return s.COMPRESSED_R11_EAC;if(i===ac)return s.COMPRESSED_SIGNED_R11_EAC;if(i===oc)return s.COMPRESSED_RG11_EAC;if(i===lc)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===yr||i===pd||i===fd||i===md||i===ca||i===gd||i===Ad||i===vd||i===bd||i===yd||i===xd||i===_d||i===Ed||i===Md)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===yr)return a===Ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===pd)return a===Ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===fd)return a===Ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===md)return a===Ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===ca)return a===Ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===gd)return a===Ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Ad)return a===Ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===vd)return a===Ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===bd)return a===Ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===yd)return a===Ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===xd)return a===Ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===_d)return a===Ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Ed)return a===Ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Md)return a===Ut?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===ha||i===wd||i===cc)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===ha)return a===Ut?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===wd)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===cc)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===hc||i===dc||i===uc||i===pc)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===hc)return s.COMPRESSED_RED_RGTC1_EXT;if(i===dc)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===uc)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===pc)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Ar?r.UNSIGNED_INT_24_8:r[i]!==void 0?r[i]:null}return{convert:t}}const hP=`
|
||
void main() {
|
||
|
||
gl_Position = vec4( position, 1.0 );
|
||
|
||
}`,dP=`
|
||
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 uP{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new dm(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new ei({vertexShader:hP,fragmentShader:dP,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ge(new jn(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class pP extends is{constructor(e,t){super();const i=this;let n=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,d=null,p=null,u=null,A=null;const m=typeof XRWebGLBinding<"u",g=new uP,f={},v=t.getContextAttributes();let b=null,y=null;const M=[],_=[],S=new be;let w=null;const E=new pi;E.viewport=new Gt;const I=new pi;I.viewport=new Gt;const B=[E,I],R=new Xb;let U=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(J){let oe=M[J];return oe===void 0&&(oe=new kd,M[J]=oe),oe.getTargetRaySpace()},this.getControllerGrip=function(J){let oe=M[J];return oe===void 0&&(oe=new kd,M[J]=oe),oe.getGripSpace()},this.getHand=function(J){let oe=M[J];return oe===void 0&&(oe=new kd,M[J]=oe),oe.getHandSpace()};function F(J){const oe=_.indexOf(J.inputSource);if(oe===-1)return;const ue=M[oe];ue!==void 0&&(ue.update(J.inputSource,J.frame,c||a),ue.dispatchEvent({type:J.type,data:J.inputSource}))}function O(){n.removeEventListener("select",F),n.removeEventListener("selectstart",F),n.removeEventListener("selectend",F),n.removeEventListener("squeeze",F),n.removeEventListener("squeezestart",F),n.removeEventListener("squeezeend",F),n.removeEventListener("end",O),n.removeEventListener("inputsourceschange",H);for(let J=0;J<M.length;J++){const oe=_[J];oe!==null&&(_[J]=null,M[J].disconnect(oe))}U=null,C=null,g.reset();for(const J in f)delete f[J];e.setRenderTarget(b),u=null,p=null,d=null,n=null,y=null,xe.stop(),i.isPresenting=!1,e.setPixelRatio(w),e.setSize(S.width,S.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(J){s=J,i.isPresenting===!0&&Ye("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(J){o=J,i.isPresenting===!0&&Ye("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(J){c=J},this.getBaseLayer=function(){return p!==null?p:u},this.getBinding=function(){return d===null&&m&&(d=new XRWebGLBinding(n,t)),d},this.getFrame=function(){return A},this.getSession=function(){return n},this.setSession=async function(J){if(n=J,n!==null){if(b=e.getRenderTarget(),n.addEventListener("select",F),n.addEventListener("selectstart",F),n.addEventListener("selectend",F),n.addEventListener("squeeze",F),n.addEventListener("squeezestart",F),n.addEventListener("squeezeend",F),n.addEventListener("end",O),n.addEventListener("inputsourceschange",H),v.xrCompatible!==!0&&await t.makeXRCompatible(),w=e.getPixelRatio(),e.getSize(S),m&&"createProjectionLayer"in XRWebGLBinding.prototype){let ue=null,Pe=null,Be=null;v.depth&&(Be=v.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ue=v.stencil?_s:xs,Pe=v.stencil?Ar:Vn);const Ue={colorFormat:t.RGBA8,depthFormat:Be,scaleFactor:s};d=this.getBinding(),p=d.createProjectionLayer(Ue),n.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),y=new Ei(p.textureWidth,p.textureHeight,{format:hi,type:ut,depthTexture:new Rr(p.textureWidth,p.textureHeight,Pe,void 0,void 0,void 0,void 0,void 0,void 0,ue),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}else{const ue={antialias:v.antialias,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:s};u=new XRWebGLLayer(n,t,ue),n.updateRenderState({baseLayer:u}),e.setPixelRatio(1),e.setSize(u.framebufferWidth,u.framebufferHeight,!1),y=new Ei(u.framebufferWidth,u.framebufferHeight,{format:hi,type:ut,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await n.requestReferenceSpace(o),xe.setContext(n),xe.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function H(J){for(let oe=0;oe<J.removed.length;oe++){const ue=J.removed[oe],Pe=_.indexOf(ue);Pe>=0&&(_[Pe]=null,M[Pe].disconnect(ue))}for(let oe=0;oe<J.added.length;oe++){const ue=J.added[oe];let Pe=_.indexOf(ue);if(Pe===-1){for(let Ue=0;Ue<M.length;Ue++)if(Ue>=_.length){_.push(ue),Pe=Ue;break}else if(_[Ue]===null){_[Ue]=ue,Pe=Ue;break}if(Pe===-1)break}const Be=M[Pe];Be&&Be.connect(ue)}}const j=new T,G=new T;function re(J,oe,ue){j.setFromMatrixPosition(oe.matrixWorld),G.setFromMatrixPosition(ue.matrixWorld);const Pe=j.distanceTo(G),Be=oe.projectionMatrix.elements,Ue=ue.projectionMatrix.elements,it=Be[14]/(Be[10]-1),qe=Be[14]/(Be[10]+1),D=(Be[9]+1)/Be[5],ae=(Be[9]-1)/Be[5],$=(Be[8]-1)/Be[0],Q=(Ue[8]+1)/Ue[0],L=it*$,te=it*Q,de=Pe/(-$+Q),V=de*-$;if(oe.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(V),J.translateZ(de),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert(),Be[10]===-1)J.projectionMatrix.copy(oe.projectionMatrix),J.projectionMatrixInverse.copy(oe.projectionMatrixInverse);else{const ee=it+de,P=qe+de,x=L-V,N=te+(Pe-V),X=D*qe/P*ee,Z=ae*qe/P*ee;J.projectionMatrix.makePerspective(x,N,X,Z,ee,P),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}}function q(J,oe){oe===null?J.matrixWorld.copy(J.matrix):J.matrixWorld.multiplyMatrices(oe.matrixWorld,J.matrix),J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(n===null)return;let oe=J.near,ue=J.far;g.texture!==null&&(g.depthNear>0&&(oe=g.depthNear),g.depthFar>0&&(ue=g.depthFar)),R.near=I.near=E.near=oe,R.far=I.far=E.far=ue,(U!==R.near||C!==R.far)&&(n.updateRenderState({depthNear:R.near,depthFar:R.far}),U=R.near,C=R.far),R.layers.mask=J.layers.mask|6,E.layers.mask=R.layers.mask&-5,I.layers.mask=R.layers.mask&-3;const Pe=J.parent,Be=R.cameras;q(R,Pe);for(let Ue=0;Ue<Be.length;Ue++)q(Be[Ue],Pe);Be.length===2?re(R,E,I):R.projectionMatrix.copy(E.projectionMatrix),Y(J,R,Pe)};function Y(J,oe,ue){ue===null?J.matrix.copy(oe.matrixWorld):(J.matrix.copy(ue.matrixWorld),J.matrix.invert(),J.matrix.multiply(oe.matrixWorld)),J.matrix.decompose(J.position,J.quaternion,J.scale),J.updateMatrixWorld(!0),J.projectionMatrix.copy(oe.projectionMatrix),J.projectionMatrixInverse.copy(oe.projectionMatrixInverse),J.isPerspectiveCamera&&(J.fov=Ro*2*Math.atan(1/J.projectionMatrix.elements[5]),J.zoom=1)}this.getCamera=function(){return R},this.getFoveation=function(){if(!(p===null&&u===null))return l},this.setFoveation=function(J){l=J,p!==null&&(p.fixedFoveation=J),u!==null&&u.fixedFoveation!==void 0&&(u.fixedFoveation=J)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(R)},this.getCameraTexture=function(J){return f[J]};let ye=null;function Me(J,oe){if(h=oe.getViewerPose(c||a),A=oe,h!==null){const ue=h.views;u!==null&&(e.setRenderTargetFramebuffer(y,u.framebuffer),e.setRenderTarget(y));let Pe=!1;ue.length!==R.cameras.length&&(R.cameras.length=0,Pe=!0);for(let qe=0;qe<ue.length;qe++){const D=ue[qe];let ae=null;if(u!==null)ae=u.getViewport(D);else{const Q=d.getViewSubImage(p,D);ae=Q.viewport,qe===0&&(e.setRenderTargetTextures(y,Q.colorTexture,Q.depthStencilTexture),e.setRenderTarget(y))}let $=B[qe];$===void 0&&($=new pi,$.layers.enable(qe),$.viewport=new Gt,B[qe]=$),$.matrix.fromArray(D.transform.matrix),$.matrix.decompose($.position,$.quaternion,$.scale),$.projectionMatrix.fromArray(D.projectionMatrix),$.projectionMatrixInverse.copy($.projectionMatrix).invert(),$.viewport.set(ae.x,ae.y,ae.width,ae.height),qe===0&&(R.matrix.copy($.matrix),R.matrix.decompose(R.position,R.quaternion,R.scale)),Pe===!0&&R.cameras.push($)}const Be=n.enabledFeatures;if(Be&&Be.includes("depth-sensing")&&n.depthUsage=="gpu-optimized"&&m){d=i.getBinding();const qe=d.getDepthInformation(ue[0]);qe&&qe.isValid&&qe.texture&&g.init(qe,n.renderState)}if(Be&&Be.includes("camera-access")&&m){e.state.unbindTexture(),d=i.getBinding();for(let qe=0;qe<ue.length;qe++){const D=ue[qe].camera;if(D){let ae=f[D];ae||(ae=new dm,f[D]=ae);const $=d.getCameraImage(D);ae.sourceTexture=$}}}}for(let ue=0;ue<M.length;ue++){const Pe=_[ue],Be=M[ue];Pe!==null&&Be!==void 0&&Be.update(Pe,oe,c||a)}ye&&ye(J,oe),oe.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:oe}),A=null}const xe=new p1;xe.setAnimationLoop(Me),this.setAnimationLoop=function(J){ye=J},this.dispose=function(){}}}const Ha=new Di,fP=new Ke;function mP(r,e){function t(g,f){g.matrixAutoUpdate===!0&&g.updateMatrix(),f.value.copy(g.matrix)}function i(g,f){f.color.getRGB(g.fogColor.value,yb(r)),f.isFog?(g.fogNear.value=f.near,g.fogFar.value=f.far):f.isFogExp2&&(g.fogDensity.value=f.density)}function n(g,f,v,b,y){f.isMeshBasicMaterial?s(g,f):f.isMeshLambertMaterial?(s(g,f),f.envMap&&(g.envMapIntensity.value=f.envMapIntensity)):f.isMeshToonMaterial?(s(g,f),d(g,f)):f.isMeshPhongMaterial?(s(g,f),h(g,f),f.envMap&&(g.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(s(g,f),p(g,f),f.isMeshPhysicalMaterial&&u(g,f,y)):f.isMeshMatcapMaterial?(s(g,f),A(g,f)):f.isMeshDepthMaterial?s(g,f):f.isMeshDistanceMaterial?(s(g,f),m(g,f)):f.isMeshNormalMaterial?s(g,f):f.isLineBasicMaterial?(a(g,f),f.isLineDashedMaterial&&o(g,f)):f.isPointsMaterial?l(g,f,v,b):f.isSpriteMaterial?c(g,f):f.isShadowMaterial?(g.color.value.copy(f.color),g.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function s(g,f){g.opacity.value=f.opacity,f.color&&g.diffuse.value.copy(f.color),f.emissive&&g.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(g.map.value=f.map,t(f.map,g.mapTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,t(f.alphaMap,g.alphaMapTransform)),f.bumpMap&&(g.bumpMap.value=f.bumpMap,t(f.bumpMap,g.bumpMapTransform),g.bumpScale.value=f.bumpScale,f.side===qi&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,t(f.normalMap,g.normalMapTransform),g.normalScale.value.copy(f.normalScale),f.side===qi&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,t(f.displacementMap,g.displacementMapTransform),g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias),f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,g.emissiveMapTransform)),f.specularMap&&(g.specularMap.value=f.specularMap,t(f.specularMap,g.specularMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest);const v=e.get(f),b=v.envMap,y=v.envMapRotation;b&&(g.envMap.value=b,Ha.copy(y),Ha.x*=-1,Ha.y*=-1,Ha.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(Ha.y*=-1,Ha.z*=-1),g.envMapRotation.value.setFromMatrix4(fP.makeRotationFromEuler(Ha)),g.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=f.reflectivity,g.ior.value=f.ior,g.refractionRatio.value=f.refractionRatio),f.lightMap&&(g.lightMap.value=f.lightMap,g.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,g.lightMapTransform)),f.aoMap&&(g.aoMap.value=f.aoMap,g.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,g.aoMapTransform))}function a(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,f.map&&(g.map.value=f.map,t(f.map,g.mapTransform))}function o(g,f){g.dashSize.value=f.dashSize,g.totalSize.value=f.dashSize+f.gapSize,g.scale.value=f.scale}function l(g,f,v,b){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.size.value=f.size*v,g.scale.value=b*.5,f.map&&(g.map.value=f.map,t(f.map,g.uvTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,t(f.alphaMap,g.alphaMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest)}function c(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.rotation.value=f.rotation,f.map&&(g.map.value=f.map,t(f.map,g.mapTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,t(f.alphaMap,g.alphaMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest)}function h(g,f){g.specular.value.copy(f.specular),g.shininess.value=Math.max(f.shininess,1e-4)}function d(g,f){f.gradientMap&&(g.gradientMap.value=f.gradientMap)}function p(g,f){g.metalness.value=f.metalness,f.metalnessMap&&(g.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,g.metalnessMapTransform)),g.roughness.value=f.roughness,f.roughnessMap&&(g.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,g.roughnessMapTransform)),f.envMap&&(g.envMapIntensity.value=f.envMapIntensity)}function u(g,f,v){g.ior.value=f.ior,f.sheen>0&&(g.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),g.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(g.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,g.sheenColorMapTransform)),f.sheenRoughnessMap&&(g.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,g.sheenRoughnessMapTransform))),f.clearcoat>0&&(g.clearcoat.value=f.clearcoat,g.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(g.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,g.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(g.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===qi&&g.clearcoatNormalScale.value.negate())),f.dispersion>0&&(g.dispersion.value=f.dispersion),f.iridescence>0&&(g.iridescence.value=f.iridescence,g.iridescenceIOR.value=f.iridescenceIOR,g.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(g.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,g.iridescenceMapTransform)),f.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),f.transmission>0&&(g.transmission.value=f.transmission,g.transmissionSamplerMap.value=v.texture,g.transmissionSamplerSize.value.set(v.width,v.height),f.transmissionMap&&(g.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,g.transmissionMapTransform)),g.thickness.value=f.thickness,f.thicknessMap&&(g.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=f.attenuationDistance,g.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(g.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(g.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=f.specularIntensity,g.specularColor.value.copy(f.specularColor),f.specularColorMap&&(g.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,g.specularColorMapTransform)),f.specularIntensityMap&&(g.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,g.specularIntensityMapTransform))}function A(g,f){f.matcap&&(g.matcap.value=f.matcap)}function m(g,f){const v=e.get(f).light;g.referencePosition.value.setFromMatrixPosition(v.matrixWorld),g.nearDistance.value=v.shadow.camera.near,g.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function gP(r,e,t,i){let n={},s={},a=[];const o=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function l(v,b){const y=b.program;i.uniformBlockBinding(v,y)}function c(v,b){let y=n[v.id];y===void 0&&(A(v),y=h(v),n[v.id]=y,v.addEventListener("dispose",g));const M=b.program;i.updateUBOMapping(v,M);const _=e.render.frame;s[v.id]!==_&&(p(v),s[v.id]=_)}function h(v){const b=d();v.__bindingPointIndex=b;const y=r.createBuffer(),M=v.__size,_=v.usage;return r.bindBuffer(r.UNIFORM_BUFFER,y),r.bufferData(r.UNIFORM_BUFFER,M,_),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,b,y),y}function d(){for(let v=0;v<o;v++)if(a.indexOf(v)===-1)return a.push(v),v;return ct("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(v){const b=n[v.id],y=v.uniforms,M=v.__cache;r.bindBuffer(r.UNIFORM_BUFFER,b);for(let _=0,S=y.length;_<S;_++){const w=Array.isArray(y[_])?y[_]:[y[_]];for(let E=0,I=w.length;E<I;E++){const B=w[E];if(u(B,_,E,M)===!0){const R=B.__offset,U=Array.isArray(B.value)?B.value:[B.value];let C=0;for(let F=0;F<U.length;F++){const O=U[F],H=m(O);typeof O=="number"||typeof O=="boolean"?(B.__data[0]=O,r.bufferSubData(r.UNIFORM_BUFFER,R+C,B.__data)):O.isMatrix3?(B.__data[0]=O.elements[0],B.__data[1]=O.elements[1],B.__data[2]=O.elements[2],B.__data[3]=0,B.__data[4]=O.elements[3],B.__data[5]=O.elements[4],B.__data[6]=O.elements[5],B.__data[7]=0,B.__data[8]=O.elements[6],B.__data[9]=O.elements[7],B.__data[10]=O.elements[8],B.__data[11]=0):(O.toArray(B.__data,C),C+=H.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,R,B.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function u(v,b,y,M){const _=v.value,S=b+"_"+y;if(M[S]===void 0)return typeof _=="number"||typeof _=="boolean"?M[S]=_:M[S]=_.clone(),!0;{const w=M[S];if(typeof _=="number"||typeof _=="boolean"){if(w!==_)return M[S]=_,!0}else if(w.equals(_)===!1)return w.copy(_),!0}return!1}function A(v){const b=v.uniforms;let y=0;const M=16;for(let S=0,w=b.length;S<w;S++){const E=Array.isArray(b[S])?b[S]:[b[S]];for(let I=0,B=E.length;I<B;I++){const R=E[I],U=Array.isArray(R.value)?R.value:[R.value];for(let C=0,F=U.length;C<F;C++){const O=U[C],H=m(O),j=y%M,G=j%H.boundary,re=j+G;y+=G,re!==0&&M-re<H.storage&&(y+=M-re),R.__data=new Float32Array(H.storage/Float32Array.BYTES_PER_ELEMENT),R.__offset=y,y+=H.storage}}}const _=y%M;return _>0&&(y+=M-_),v.__size=y,v.__cache={},this}function m(v){const b={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(b.boundary=4,b.storage=4):v.isVector2?(b.boundary=8,b.storage=8):v.isVector3||v.isColor?(b.boundary=16,b.storage=12):v.isVector4?(b.boundary=16,b.storage=16):v.isMatrix3?(b.boundary=48,b.storage=48):v.isMatrix4?(b.boundary=64,b.storage=64):v.isTexture?Ye("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Ye("WebGLRenderer: Unsupported uniform value type.",v),b}function g(v){const b=v.target;b.removeEventListener("dispose",g);const y=a.indexOf(b.__bindingPointIndex);a.splice(y,1),r.deleteBuffer(n[b.id]),delete n[b.id],delete s[b.id]}function f(){for(const v in n)r.deleteBuffer(n[v]);a=[],n={},s={}}return{bind:l,update:c,dispose:f}}const AP=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Ts=null;function vP(){return Ts===null&&(Ts=new dn(AP,16,16,Qn,Zt),Ts.name="DFG_LUT",Ts.minFilter=_t,Ts.magFilter=_t,Ts.wrapS=ln,Ts.wrapT=ln,Ts.generateMipmaps=!1,Ts.needsUpdate=!0),Ts}class $c{constructor(e={}){const{canvas:t=cv(),context:i=null,depth:n=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:p=!1,outputBufferType:u=ut}=e;this.isWebGLRenderer=!0;let A;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");A=i.getContextAttributes().alpha}else A=a;const m=u,g=new Set([dd,hd,tc]),f=new Set([ut,Vn,Eo,Ar,ld,cd]),v=new Uint32Array(4),b=new Int32Array(4);let y=null,M=null;const _=[],S=[];let w=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Xi,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const E=this;let I=!1;this._outputColorSpace=Jt;let B=0,R=0,U=null,C=-1,F=null;const O=new Gt,H=new Gt;let j=null;const G=new We(0);let re=0,q=t.width,Y=t.height,ye=1,Me=null,xe=null;const J=new Gt(0,0,q,Y),oe=new Gt(0,0,q,Y);let ue=!1;const Pe=new Yo;let Be=!1,Ue=!1;const it=new Ke,qe=new T,D=new Gt,ae={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let $=!1;function Q(){return U===null?ye:1}let L=i;function te(W,fe){return t.getContext(W,fe)}try{const W={alpha:!0,depth:n,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Gh}`),t.addEventListener("webglcontextlost",Le,!1),t.addEventListener("webglcontextrestored",Qe,!1),t.addEventListener("webglcontextcreationerror",pt,!1),L===null){const fe="webgl2";if(L=te(fe,W),L===null)throw te(fe)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(W){throw ct("WebGLRenderer: "+W.message),W}let de,V,ee,P,x,N,X,Z,K,Ie,ge,ke,Oe,le,Ae,ze,Ne,we,je,z,ve,me,Re;function pe(){de=new yT(L),de.init(),ve=new z1(L,de),V=new uT(L,de,e,ve),ee=new lP(L,de),V.reversedDepthBuffer&&p&&ee.buffers.depth.setReversed(!0),P=new ET(L),x=new XI,N=new cP(L,de,ee,x,V,ve,P),X=new bT(E),Z=new l2(L),me=new hT(L,Z),K=new xT(L,Z,P,me),Ie=new wT(L,K,Z,me,P),we=new MT(L,V,N),Ae=new pT(x),ge=new qI(E,X,de,V,me,Ae),ke=new mP(E,x),Oe=new KI,le=new iP(de),Ne=new cT(E,X,ee,Ie,A,l),ze=new oP(E,Ie,V),Re=new gP(L,P,V,ee),je=new dT(L,de,P),z=new _T(L,de,P),P.programs=ge.programs,E.capabilities=V,E.extensions=de,E.properties=x,E.renderLists=Oe,E.shadowMap=ze,E.state=ee,E.info=P}pe(),m!==ut&&(w=new CT(m,t.width,t.height,n,s));const ne=new pP(E,L);this.xr=ne,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){const W=de.get("WEBGL_lose_context");W&&W.loseContext()},this.forceContextRestore=function(){const W=de.get("WEBGL_lose_context");W&&W.restoreContext()},this.getPixelRatio=function(){return ye},this.setPixelRatio=function(W){W!==void 0&&(ye=W,this.setSize(q,Y,!1))},this.getSize=function(W){return W.set(q,Y)},this.setSize=function(W,fe,Te=!0){if(ne.isPresenting){Ye("WebGLRenderer: Can't change size while VR device is presenting.");return}q=W,Y=fe,t.width=Math.floor(W*ye),t.height=Math.floor(fe*ye),Te===!0&&(t.style.width=W+"px",t.style.height=fe+"px"),w!==null&&w.setSize(t.width,t.height),this.setViewport(0,0,W,fe)},this.getDrawingBufferSize=function(W){return W.set(q*ye,Y*ye).floor()},this.setDrawingBufferSize=function(W,fe,Te){q=W,Y=fe,ye=Te,t.width=Math.floor(W*Te),t.height=Math.floor(fe*Te),this.setViewport(0,0,W,fe)},this.setEffects=function(W){if(m===ut){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(W){for(let fe=0;fe<W.length;fe++)if(W[fe].isOutputPass===!0){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}w.setEffects(W||[])},this.getCurrentViewport=function(W){return W.copy(O)},this.getViewport=function(W){return W.copy(J)},this.setViewport=function(W,fe,Te,_e){W.isVector4?J.set(W.x,W.y,W.z,W.w):J.set(W,fe,Te,_e),ee.viewport(O.copy(J).multiplyScalar(ye).round())},this.getScissor=function(W){return W.copy(oe)},this.setScissor=function(W,fe,Te,_e){W.isVector4?oe.set(W.x,W.y,W.z,W.w):oe.set(W,fe,Te,_e),ee.scissor(H.copy(oe).multiplyScalar(ye).round())},this.getScissorTest=function(){return ue},this.setScissorTest=function(W){ee.setScissorTest(ue=W)},this.setOpaqueSort=function(W){Me=W},this.setTransparentSort=function(W){xe=W},this.getClearColor=function(W){return W.copy(Ne.getClearColor())},this.setClearColor=function(){Ne.setClearColor(...arguments)},this.getClearAlpha=function(){return Ne.getClearAlpha()},this.setClearAlpha=function(){Ne.setClearAlpha(...arguments)},this.clear=function(W=!0,fe=!0,Te=!0){let _e=0;if(W){let k=!1;if(U!==null){const ie=U.texture.format;k=g.has(ie)}if(k){const ie=U.texture.type,he=f.has(ie),ce=Ne.getClearColor(),se=Ne.getClearAlpha(),Se=ce.r,He=ce.g,Ve=ce.b;he?(v[0]=Se,v[1]=He,v[2]=Ve,v[3]=se,L.clearBufferuiv(L.COLOR,0,v)):(b[0]=Se,b[1]=He,b[2]=Ve,b[3]=se,L.clearBufferiv(L.COLOR,0,b))}else _e|=L.COLOR_BUFFER_BIT}fe&&(_e|=L.DEPTH_BUFFER_BIT),Te&&(_e|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),_e!==0&&L.clear(_e)},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",Le,!1),t.removeEventListener("webglcontextrestored",Qe,!1),t.removeEventListener("webglcontextcreationerror",pt,!1),Ne.dispose(),Oe.dispose(),le.dispose(),x.dispose(),X.dispose(),Ie.dispose(),me.dispose(),Re.dispose(),ge.dispose(),ne.dispose(),ne.removeEventListener("sessionstart",mf),ne.removeEventListener("sessionend",Uh),As.stop()};function Le(W){W.preventDefault(),vc("WebGLRenderer: Context Lost."),I=!0}function Qe(){vc("WebGLRenderer: Context Restored."),I=!1;const W=P.autoReset,fe=ze.enabled,Te=ze.autoUpdate,_e=ze.needsUpdate,k=ze.type;pe(),P.autoReset=W,ze.enabled=fe,ze.autoUpdate=Te,ze.needsUpdate=_e,ze.type=k}function pt(W){ct("WebGLRenderer: A WebGL context could not be created. Reason: ",W.statusMessage)}function et(W){const fe=W.target;fe.removeEventListener("dispose",et),Ti(fe)}function Ti(W){Ii(W),x.remove(W)}function Ii(W){const fe=x.get(W).programs;fe!==void 0&&(fe.forEach(function(Te){ge.releaseProgram(Te)}),W.isShaderMaterial&&ge.releaseShaderCache(W))}this.renderBufferDirect=function(W,fe,Te,_e,k,ie){fe===null&&(fe=ae);const he=k.isMesh&&k.matrixWorld.determinant()<0,ce=gf(W,fe,Te,_e,k);ee.setMaterial(_e,he);let se=Te.index,Se=1;if(_e.wireframe===!0){if(se=K.getWireframeAttribute(Te),se===void 0)return;Se=2}const He=Te.drawRange,Ve=Te.attributes.position;let Fe=He.start*Se,Je=(He.start+He.count)*Se;ie!==null&&(Fe=Math.max(Fe,ie.start*Se),Je=Math.min(Je,(ie.start+ie.count)*Se)),se!==null?(Fe=Math.max(Fe,0),Je=Math.min(Je,se.count)):Ve!=null&&(Fe=Math.max(Fe,0),Je=Math.min(Je,Ve.count));const rt=Je-Fe;if(rt<0||rt===1/0)return;me.setup(k,_e,ce,Te,se);let nt,at=je;if(se!==null&&(nt=Z.get(se),at=z,at.setIndex(nt)),k.isMesh)_e.wireframe===!0?(ee.setLineWidth(_e.wireframeLinewidth*Q()),at.setMode(L.LINES)):at.setMode(L.TRIANGLES);else if(k.isLine){let mt=_e.linewidth;mt===void 0&&(mt=1),ee.setLineWidth(mt*Q()),k.isLineSegments?at.setMode(L.LINES):k.isLineLoop?at.setMode(L.LINE_LOOP):at.setMode(L.LINE_STRIP)}else k.isPoints?at.setMode(L.POINTS):k.isSprite&&at.setMode(L.TRIANGLES);if(k.isBatchedMesh)if(k._multiDrawInstances!==null)bc("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),at.renderMultiDrawInstances(k._multiDrawStarts,k._multiDrawCounts,k._multiDrawCount,k._multiDrawInstances);else if(de.get("WEBGL_multi_draw"))at.renderMultiDraw(k._multiDrawStarts,k._multiDrawCounts,k._multiDrawCount);else{const mt=k._multiDrawStarts,Xe=k._multiDrawCounts,Pt=k._multiDrawCount,lt=se?Z.get(se).bytesPerElement:1,st=x.get(_e).currentProgram.getUniforms();for(let Yt=0;Yt<Pt;Yt++)st.setValue(L,"_gl_DrawID",Yt),at.render(mt[Yt]/lt,Xe[Yt])}else if(k.isInstancedMesh)at.renderInstances(Fe,rt,k.count);else if(Te.isInstancedBufferGeometry){const mt=Te._maxInstanceCount!==void 0?Te._maxInstanceCount:1/0,Xe=Math.min(Te.instanceCount,mt);at.renderInstances(Fe,rt,Xe)}else at.render(Fe,rt)};function Nh(W,fe,Te){W.transparent===!0&&W.side===Vt&&W.forceSinglePass===!1?(W.side=qi,W.needsUpdate=!0,mo(W,fe,Te),W.side=Gn,W.needsUpdate=!0,mo(W,fe,Te),W.side=Vt):mo(W,fe,Te)}this.compile=function(W,fe,Te=null){Te===null&&(Te=W),M=le.get(Te),M.init(fe),S.push(M),Te.traverseVisible(function(k){k.isLight&&k.layers.test(fe.layers)&&(M.pushLight(k),k.castShadow&&M.pushShadow(k))}),W!==Te&&W.traverseVisible(function(k){k.isLight&&k.layers.test(fe.layers)&&(M.pushLight(k),k.castShadow&&M.pushShadow(k))}),M.setupLights();const _e=new Set;return W.traverse(function(k){if(!(k.isMesh||k.isPoints||k.isLine||k.isSprite))return;const ie=k.material;if(ie)if(Array.isArray(ie))for(let he=0;he<ie.length;he++){const ce=ie[he];Nh(ce,Te,k),_e.add(ce)}else Nh(ie,Te,k),_e.add(ie)}),M=S.pop(),_e},this.compileAsync=function(W,fe,Te=null){const _e=this.compile(W,fe,Te);return new Promise(k=>{function ie(){if(_e.forEach(function(he){x.get(he).currentProgram.isReady()&&_e.delete(he)}),_e.size===0){k(W);return}setTimeout(ie,10)}de.get("KHR_parallel_shader_compile")!==null?ie():setTimeout(ie,10)})};let Vl=null;function MA(W){Vl&&Vl(W)}function mf(){As.stop()}function Uh(){As.start()}const As=new p1;As.setAnimationLoop(MA),typeof self<"u"&&As.setContext(self),this.setAnimationLoop=function(W){Vl=W,ne.setAnimationLoop(W),W===null?As.stop():As.start()},ne.addEventListener("sessionstart",mf),ne.addEventListener("sessionend",Uh),this.render=function(W,fe){if(fe!==void 0&&fe.isCamera!==!0){ct("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(I===!0)return;const Te=ne.enabled===!0&&ne.isPresenting===!0,_e=w!==null&&(U===null||Te)&&w.begin(E,U);if(W.matrixWorldAutoUpdate===!0&&W.updateMatrixWorld(),fe.parent===null&&fe.matrixWorldAutoUpdate===!0&&fe.updateMatrixWorld(),ne.enabled===!0&&ne.isPresenting===!0&&(w===null||w.isCompositing()===!1)&&(ne.cameraAutoUpdate===!0&&ne.updateCamera(fe),fe=ne.getCamera()),W.isScene===!0&&W.onBeforeRender(E,W,fe,U),M=le.get(W,S.length),M.init(fe),S.push(M),it.multiplyMatrices(fe.projectionMatrix,fe.matrixWorldInverse),Pe.setFromProjectionMatrix(it,Pn,fe.reversedDepth),Ue=this.localClippingEnabled,Be=Ae.init(this.clippingPlanes,Ue),y=Oe.get(W,_.length),y.init(),_.push(y),ne.enabled===!0&&ne.isPresenting===!0){const he=E.xr.getDepthSensingMesh();he!==null&&Fh(he,fe,-1/0,E.sortObjects)}Fh(W,fe,0,E.sortObjects),y.finish(),E.sortObjects===!0&&y.sort(Me,xe),$=ne.enabled===!1||ne.isPresenting===!1||ne.hasDepthSensing()===!1,$&&Ne.addToRenderList(y,W),this.info.render.frame++,Be===!0&&Ae.beginShadows();const k=M.state.shadowsArray;if(ze.render(k,W,fe),Be===!0&&Ae.endShadows(),this.info.autoReset===!0&&this.info.reset(),(_e&&w.hasRenderPass())===!1){const he=y.opaque,ce=y.transmissive;if(M.setupLights(),fe.isArrayCamera){const se=fe.cameras;if(ce.length>0)for(let Se=0,He=se.length;Se<He;Se++){const Ve=se[Se];zh(he,ce,W,Ve)}$&&Ne.render(W);for(let Se=0,He=se.length;Se<He;Se++){const Ve=se[Se];Oh(y,W,Ve,Ve.viewport)}}else ce.length>0&&zh(he,ce,W,fe),$&&Ne.render(W),Oh(y,W,fe)}U!==null&&R===0&&(N.updateMultisampleRenderTarget(U),N.updateRenderTargetMipmap(U)),_e&&w.end(E),W.isScene===!0&&W.onAfterRender(E,W,fe),me.resetDefaultState(),C=-1,F=null,S.pop(),S.length>0?(M=S[S.length-1],Be===!0&&Ae.setGlobalState(E.clippingPlanes,M.state.camera)):M=null,_.pop(),_.length>0?y=_[_.length-1]:y=null};function Fh(W,fe,Te,_e){if(W.visible===!1)return;if(W.layers.test(fe.layers)){if(W.isGroup)Te=W.renderOrder;else if(W.isLOD)W.autoUpdate===!0&&W.update(fe);else if(W.isLight)M.pushLight(W),W.castShadow&&M.pushShadow(W);else if(W.isSprite){if(!W.frustumCulled||Pe.intersectsSprite(W)){_e&&D.setFromMatrixPosition(W.matrixWorld).applyMatrix4(it);const he=Ie.update(W),ce=W.material;ce.visible&&y.push(W,he,ce,Te,D.z,null)}}else if((W.isMesh||W.isLine||W.isPoints)&&(!W.frustumCulled||Pe.intersectsObject(W))){const he=Ie.update(W),ce=W.material;if(_e&&(W.boundingSphere!==void 0?(W.boundingSphere===null&&W.computeBoundingSphere(),D.copy(W.boundingSphere.center)):(he.boundingSphere===null&&he.computeBoundingSphere(),D.copy(he.boundingSphere.center)),D.applyMatrix4(W.matrixWorld).applyMatrix4(it)),Array.isArray(ce)){const se=he.groups;for(let Se=0,He=se.length;Se<He;Se++){const Ve=se[Se],Fe=ce[Ve.materialIndex];Fe&&Fe.visible&&y.push(W,he,Fe,Te,D.z,Ve)}}else ce.visible&&y.push(W,he,ce,Te,D.z,null)}}const ie=W.children;for(let he=0,ce=ie.length;he<ce;he++)Fh(ie[he],fe,Te,_e)}function Oh(W,fe,Te,_e){const{opaque:k,transmissive:ie,transparent:he}=W;M.setupLightsView(Te),Be===!0&&Ae.setGlobalState(E.clippingPlanes,Te),_e&&ee.viewport(O.copy(_e)),k.length>0&&es(k,fe,Te),ie.length>0&&es(ie,fe,Te),he.length>0&&es(he,fe,Te),ee.buffers.depth.setTest(!0),ee.buffers.depth.setMask(!0),ee.buffers.color.setMask(!0),ee.setPolygonOffset(!1)}function zh(W,fe,Te,_e){if((Te.isScene===!0?Te.overrideMaterial:null)!==null)return;if(M.state.transmissionRenderTarget[_e.id]===void 0){const Fe=de.has("EXT_color_buffer_half_float")||de.has("EXT_color_buffer_float");M.state.transmissionRenderTarget[_e.id]=new Ei(1,1,{generateMipmaps:!0,type:Fe?Zt:ut,minFilter:An,samples:Math.max(4,V.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Et.workingColorSpace})}const ie=M.state.transmissionRenderTarget[_e.id],he=_e.viewport||O;ie.setSize(he.z*E.transmissionResolutionScale,he.w*E.transmissionResolutionScale);const ce=E.getRenderTarget(),se=E.getActiveCubeFace(),Se=E.getActiveMipmapLevel();E.setRenderTarget(ie),E.getClearColor(G),re=E.getClearAlpha(),re<1&&E.setClearColor(16777215,.5),E.clear(),$&&Ne.render(Te);const He=E.toneMapping;E.toneMapping=Xi;const Ve=_e.viewport;if(_e.viewport!==void 0&&(_e.viewport=void 0),M.setupLightsView(_e),Be===!0&&Ae.setGlobalState(E.clippingPlanes,_e),es(W,Te,_e),N.updateMultisampleRenderTarget(ie),N.updateRenderTargetMipmap(ie),de.has("WEBGL_multisampled_render_to_texture")===!1){let Fe=!1;for(let Je=0,rt=fe.length;Je<rt;Je++){const nt=fe[Je],{object:at,geometry:mt,material:Xe,group:Pt}=nt;if(Xe.side===Vt&&at.layers.test(_e.layers)){const lt=Xe.side;Xe.side=qi,Xe.needsUpdate=!0,Ql(at,Te,_e,mt,Xe,Pt),Xe.side=lt,Xe.needsUpdate=!0,Fe=!0}}Fe===!0&&(N.updateMultisampleRenderTarget(ie),N.updateRenderTargetMipmap(ie))}E.setRenderTarget(ce,se,Se),E.setClearColor(G,re),Ve!==void 0&&(_e.viewport=Ve),E.toneMapping=He}function es(W,fe,Te){const _e=fe.isScene===!0?fe.overrideMaterial:null;for(let k=0,ie=W.length;k<ie;k++){const he=W[k],{object:ce,geometry:se,group:Se}=he;let He=he.material;He.allowOverride===!0&&_e!==null&&(He=_e),ce.layers.test(Te.layers)&&Ql(ce,fe,Te,se,He,Se)}}function Ql(W,fe,Te,_e,k,ie){W.onBeforeRender(E,fe,Te,_e,k,ie),W.modelViewMatrix.multiplyMatrices(Te.matrixWorldInverse,W.matrixWorld),W.normalMatrix.getNormalMatrix(W.modelViewMatrix),k.onBeforeRender(E,fe,Te,_e,W,ie),k.transparent===!0&&k.side===Vt&&k.forceSinglePass===!1?(k.side=qi,k.needsUpdate=!0,E.renderBufferDirect(Te,fe,_e,k,W,ie),k.side=Gn,k.needsUpdate=!0,E.renderBufferDirect(Te,fe,_e,k,W,ie),k.side=Vt):E.renderBufferDirect(Te,fe,_e,k,W,ie),W.onAfterRender(E,fe,Te,_e,k,ie)}function mo(W,fe,Te){fe.isScene!==!0&&(fe=ae);const _e=x.get(W),k=M.state.lights,ie=M.state.shadowsArray,he=k.state.version,ce=ge.getParameters(W,k.state,ie,fe,Te),se=ge.getProgramCacheKey(ce);let Se=_e.programs;_e.environment=W.isMeshStandardMaterial||W.isMeshLambertMaterial||W.isMeshPhongMaterial?fe.environment:null,_e.fog=fe.fog;const He=W.isMeshStandardMaterial||W.isMeshLambertMaterial&&!W.envMap||W.isMeshPhongMaterial&&!W.envMap;_e.envMap=X.get(W.envMap||_e.environment,He),_e.envMapRotation=_e.environment!==null&&W.envMap===null?fe.environmentRotation:W.envMapRotation,Se===void 0&&(W.addEventListener("dispose",et),Se=new Map,_e.programs=Se);let Ve=Se.get(se);if(Ve!==void 0){if(_e.currentProgram===Ve&&_e.lightsStateVersion===he)return go(W,ce),Ve}else ce.uniforms=ge.getUniforms(W),W.onBeforeCompile(ce,E),Ve=ge.acquireProgram(ce,se),Se.set(se,Ve),_e.uniforms=ce.uniforms;const Fe=_e.uniforms;return(!W.isShaderMaterial&&!W.isRawShaderMaterial||W.clipping===!0)&&(Fe.clippingPlanes=Ae.uniform),go(W,ce),_e.needsLights=Af(W),_e.lightsStateVersion=he,_e.needsLights&&(Fe.ambientLightColor.value=k.state.ambient,Fe.lightProbe.value=k.state.probe,Fe.directionalLights.value=k.state.directional,Fe.directionalLightShadows.value=k.state.directionalShadow,Fe.spotLights.value=k.state.spot,Fe.spotLightShadows.value=k.state.spotShadow,Fe.rectAreaLights.value=k.state.rectArea,Fe.ltc_1.value=k.state.rectAreaLTC1,Fe.ltc_2.value=k.state.rectAreaLTC2,Fe.pointLights.value=k.state.point,Fe.pointLightShadows.value=k.state.pointShadow,Fe.hemisphereLights.value=k.state.hemi,Fe.directionalShadowMatrix.value=k.state.directionalShadowMatrix,Fe.spotLightMatrix.value=k.state.spotLightMatrix,Fe.spotLightMap.value=k.state.spotLightMap,Fe.pointShadowMatrix.value=k.state.pointShadowMatrix),_e.currentProgram=Ve,_e.uniformsList=null,Ve}function Hh(W){if(W.uniformsList===null){const fe=W.currentProgram.getUniforms();W.uniformsList=Zu.seqWithValue(fe.seq,W.uniforms)}return W.uniformsList}function go(W,fe){const Te=x.get(W);Te.outputColorSpace=fe.outputColorSpace,Te.batching=fe.batching,Te.batchingColor=fe.batchingColor,Te.instancing=fe.instancing,Te.instancingColor=fe.instancingColor,Te.instancingMorph=fe.instancingMorph,Te.skinning=fe.skinning,Te.morphTargets=fe.morphTargets,Te.morphNormals=fe.morphNormals,Te.morphColors=fe.morphColors,Te.morphTargetsCount=fe.morphTargetsCount,Te.numClippingPlanes=fe.numClippingPlanes,Te.numIntersection=fe.numClipIntersection,Te.vertexAlphas=fe.vertexAlphas,Te.vertexTangents=fe.vertexTangents,Te.toneMapping=fe.toneMapping}function gf(W,fe,Te,_e,k){fe.isScene!==!0&&(fe=ae),N.resetTextureUnits();const ie=fe.fog,he=_e.isMeshStandardMaterial||_e.isMeshLambertMaterial||_e.isMeshPhongMaterial?fe.environment:null,ce=U===null?E.outputColorSpace:U.isXRRenderTarget===!0?U.texture.colorSpace:Ri,se=_e.isMeshStandardMaterial||_e.isMeshLambertMaterial&&!_e.envMap||_e.isMeshPhongMaterial&&!_e.envMap,Se=X.get(_e.envMap||he,se),He=_e.vertexColors===!0&&!!Te.attributes.color&&Te.attributes.color.itemSize===4,Ve=!!Te.attributes.tangent&&(!!_e.normalMap||_e.anisotropy>0),Fe=!!Te.morphAttributes.position,Je=!!Te.morphAttributes.normal,rt=!!Te.morphAttributes.color;let nt=Xi;_e.toneMapped&&(U===null||U.isXRRenderTarget===!0)&&(nt=E.toneMapping);const at=Te.morphAttributes.position||Te.morphAttributes.normal||Te.morphAttributes.color,mt=at!==void 0?at.length:0,Xe=x.get(_e),Pt=M.state.lights;if(Be===!0&&(Ue===!0||W!==F)){const bt=W===F&&_e.id===C;Ae.setState(_e,W,bt)}let lt=!1;_e.version===Xe.__version?(Xe.needsLights&&Xe.lightsStateVersion!==Pt.state.version||Xe.outputColorSpace!==ce||k.isBatchedMesh&&Xe.batching===!1||!k.isBatchedMesh&&Xe.batching===!0||k.isBatchedMesh&&Xe.batchingColor===!0&&k.colorTexture===null||k.isBatchedMesh&&Xe.batchingColor===!1&&k.colorTexture!==null||k.isInstancedMesh&&Xe.instancing===!1||!k.isInstancedMesh&&Xe.instancing===!0||k.isSkinnedMesh&&Xe.skinning===!1||!k.isSkinnedMesh&&Xe.skinning===!0||k.isInstancedMesh&&Xe.instancingColor===!0&&k.instanceColor===null||k.isInstancedMesh&&Xe.instancingColor===!1&&k.instanceColor!==null||k.isInstancedMesh&&Xe.instancingMorph===!0&&k.morphTexture===null||k.isInstancedMesh&&Xe.instancingMorph===!1&&k.morphTexture!==null||Xe.envMap!==Se||_e.fog===!0&&Xe.fog!==ie||Xe.numClippingPlanes!==void 0&&(Xe.numClippingPlanes!==Ae.numPlanes||Xe.numIntersection!==Ae.numIntersection)||Xe.vertexAlphas!==He||Xe.vertexTangents!==Ve||Xe.morphTargets!==Fe||Xe.morphNormals!==Je||Xe.morphColors!==rt||Xe.toneMapping!==nt||Xe.morphTargetsCount!==mt)&&(lt=!0):(lt=!0,Xe.__version=_e.version);let st=Xe.currentProgram;lt===!0&&(st=mo(_e,fe,k));let Yt=!1,Zi=!1,ji=!1;const kt=st.getUniforms(),Ot=Xe.uniforms;if(ee.useProgram(st.program)&&(Yt=!0,Zi=!0,ji=!0),_e.id!==C&&(C=_e.id,Zi=!0),Yt||F!==W){ee.buffers.depth.getReversed()&&W.reversedDepth!==!0&&(W._reversedDepth=!0,W.updateProjectionMatrix()),kt.setValue(L,"projectionMatrix",W.projectionMatrix),kt.setValue(L,"viewMatrix",W.matrixWorldInverse);const fi=kt.map.cameraPosition;fi!==void 0&&fi.setValue(L,qe.setFromMatrixPosition(W.matrixWorld)),V.logarithmicDepthBuffer&&kt.setValue(L,"logDepthBufFC",2/(Math.log(W.far+1)/Math.LN2)),(_e.isMeshPhongMaterial||_e.isMeshToonMaterial||_e.isMeshLambertMaterial||_e.isMeshBasicMaterial||_e.isMeshStandardMaterial||_e.isShaderMaterial)&&kt.setValue(L,"isOrthographic",W.isOrthographicCamera===!0),F!==W&&(F=W,Zi=!0,ji=!0)}if(Xe.needsLights&&(Pt.state.directionalShadowMap.length>0&&kt.setValue(L,"directionalShadowMap",Pt.state.directionalShadowMap,N),Pt.state.spotShadowMap.length>0&&kt.setValue(L,"spotShadowMap",Pt.state.spotShadowMap,N),Pt.state.pointShadowMap.length>0&&kt.setValue(L,"pointShadowMap",Pt.state.pointShadowMap,N)),k.isSkinnedMesh){kt.setOptional(L,k,"bindMatrix"),kt.setOptional(L,k,"bindMatrixInverse");const bt=k.skeleton;bt&&(bt.boneTexture===null&&bt.computeBoneTexture(),kt.setValue(L,"boneTexture",bt.boneTexture,N))}k.isBatchedMesh&&(kt.setOptional(L,k,"batchingTexture"),kt.setValue(L,"batchingTexture",k._matricesTexture,N),kt.setOptional(L,k,"batchingIdTexture"),kt.setValue(L,"batchingIdTexture",k._indirectTexture,N),kt.setOptional(L,k,"batchingColorTexture"),k._colorsTexture!==null&&kt.setValue(L,"batchingColorTexture",k._colorsTexture,N));const Cn=Te.morphAttributes;if((Cn.position!==void 0||Cn.normal!==void 0||Cn.color!==void 0)&&we.update(k,Te,st),(Zi||Xe.receiveShadow!==k.receiveShadow)&&(Xe.receiveShadow=k.receiveShadow,kt.setValue(L,"receiveShadow",k.receiveShadow)),(_e.isMeshStandardMaterial||_e.isMeshLambertMaterial||_e.isMeshPhongMaterial)&&_e.envMap===null&&fe.environment!==null&&(Ot.envMapIntensity.value=fe.environmentIntensity),Ot.dfgLUT!==void 0&&(Ot.dfgLUT.value=vP()),Zi&&(kt.setValue(L,"toneMappingExposure",E.toneMappingExposure),Xe.needsLights&&Wl(Ot,ji),ie&&_e.fog===!0&&ke.refreshFogUniforms(Ot,ie),ke.refreshMaterialUniforms(Ot,_e,ye,Y,M.state.transmissionRenderTarget[W.id]),Zu.upload(L,Hh(Xe),Ot,N)),_e.isShaderMaterial&&_e.uniformsNeedUpdate===!0&&(Zu.upload(L,Hh(Xe),Ot,N),_e.uniformsNeedUpdate=!1),_e.isSpriteMaterial&&kt.setValue(L,"center",k.center),kt.setValue(L,"modelViewMatrix",k.modelViewMatrix),kt.setValue(L,"normalMatrix",k.normalMatrix),kt.setValue(L,"modelMatrix",k.matrixWorld),_e.isShaderMaterial||_e.isRawShaderMaterial){const bt=_e.uniformsGroups;for(let fi=0,Hi=bt.length;fi<Hi;fi++){const Pi=bt[fi];Re.update(Pi,st),Re.bind(Pi,st)}}return st}function Wl(W,fe){W.ambientLightColor.needsUpdate=fe,W.lightProbe.needsUpdate=fe,W.directionalLights.needsUpdate=fe,W.directionalLightShadows.needsUpdate=fe,W.pointLights.needsUpdate=fe,W.pointLightShadows.needsUpdate=fe,W.spotLights.needsUpdate=fe,W.spotLightShadows.needsUpdate=fe,W.rectAreaLights.needsUpdate=fe,W.hemisphereLights.needsUpdate=fe}function Af(W){return W.isMeshLambertMaterial||W.isMeshToonMaterial||W.isMeshPhongMaterial||W.isMeshStandardMaterial||W.isShadowMaterial||W.isShaderMaterial&&W.lights===!0}this.getActiveCubeFace=function(){return B},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return U},this.setRenderTargetTextures=function(W,fe,Te){const _e=x.get(W);_e.__autoAllocateDepthBuffer=W.resolveDepthBuffer===!1,_e.__autoAllocateDepthBuffer===!1&&(_e.__useRenderToTexture=!1),x.get(W.texture).__webglTexture=fe,x.get(W.depthTexture).__webglTexture=_e.__autoAllocateDepthBuffer?void 0:Te,_e.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(W,fe){const Te=x.get(W);Te.__webglFramebuffer=fe,Te.__useDefaultFramebuffer=fe===void 0};const vf=L.createFramebuffer();this.setRenderTarget=function(W,fe=0,Te=0){U=W,B=fe,R=Te;let _e=null,k=!1,ie=!1;if(W){const ce=x.get(W);if(ce.__useDefaultFramebuffer!==void 0){ee.bindFramebuffer(L.FRAMEBUFFER,ce.__webglFramebuffer),O.copy(W.viewport),H.copy(W.scissor),j=W.scissorTest,ee.viewport(O),ee.scissor(H),ee.setScissorTest(j),C=-1;return}else if(ce.__webglFramebuffer===void 0)N.setupRenderTarget(W);else if(ce.__hasExternalTextures)N.rebindTextures(W,x.get(W.texture).__webglTexture,x.get(W.depthTexture).__webglTexture);else if(W.depthBuffer){const He=W.depthTexture;if(ce.__boundDepthTexture!==He){if(He!==null&&x.has(He)&&(W.width!==He.image.width||W.height!==He.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");N.setupDepthRenderbuffer(W)}}const se=W.texture;(se.isData3DTexture||se.isDataArrayTexture||se.isCompressedArrayTexture)&&(ie=!0);const Se=x.get(W).__webglFramebuffer;W.isWebGLCubeRenderTarget?(Array.isArray(Se[fe])?_e=Se[fe][Te]:_e=Se[fe],k=!0):W.samples>0&&N.useMultisampledRTT(W)===!1?_e=x.get(W).__webglMultisampledFramebuffer:Array.isArray(Se)?_e=Se[Te]:_e=Se,O.copy(W.viewport),H.copy(W.scissor),j=W.scissorTest}else O.copy(J).multiplyScalar(ye).floor(),H.copy(oe).multiplyScalar(ye).floor(),j=ue;if(Te!==0&&(_e=vf),ee.bindFramebuffer(L.FRAMEBUFFER,_e)&&ee.drawBuffers(W,_e),ee.viewport(O),ee.scissor(H),ee.setScissorTest(j),k){const ce=x.get(W.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+fe,ce.__webglTexture,Te)}else if(ie){const ce=fe;for(let se=0;se<W.textures.length;se++){const Se=x.get(W.textures[se]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+se,Se.__webglTexture,Te,ce)}}else if(W!==null&&Te!==0){const ce=x.get(W.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,ce.__webglTexture,Te)}C=-1},this.readRenderTargetPixels=function(W,fe,Te,_e,k,ie,he,ce=0){if(!(W&&W.isWebGLRenderTarget)){ct("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let se=x.get(W).__webglFramebuffer;if(W.isWebGLCubeRenderTarget&&he!==void 0&&(se=se[he]),se){ee.bindFramebuffer(L.FRAMEBUFFER,se);try{const Se=W.textures[ce],He=Se.format,Ve=Se.type;if(W.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+ce),!V.textureFormatReadable(He)){ct("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!V.textureTypeReadable(Ve)){ct("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}fe>=0&&fe<=W.width-_e&&Te>=0&&Te<=W.height-k&&L.readPixels(fe,Te,_e,k,ve.convert(He),ve.convert(Ve),ie)}finally{const Se=U!==null?x.get(U).__webglFramebuffer:null;ee.bindFramebuffer(L.FRAMEBUFFER,Se)}}},this.readRenderTargetPixelsAsync=async function(W,fe,Te,_e,k,ie,he,ce=0){if(!(W&&W.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let se=x.get(W).__webglFramebuffer;if(W.isWebGLCubeRenderTarget&&he!==void 0&&(se=se[he]),se)if(fe>=0&&fe<=W.width-_e&&Te>=0&&Te<=W.height-k){ee.bindFramebuffer(L.FRAMEBUFFER,se);const Se=W.textures[ce],He=Se.format,Ve=Se.type;if(W.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+ce),!V.textureFormatReadable(He))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!V.textureTypeReadable(Ve))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Fe=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,Fe),L.bufferData(L.PIXEL_PACK_BUFFER,ie.byteLength,L.STREAM_READ),L.readPixels(fe,Te,_e,k,ve.convert(He),ve.convert(Ve),0);const Je=U!==null?x.get(U).__webglFramebuffer:null;ee.bindFramebuffer(L.FRAMEBUFFER,Je);const rt=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await yw(L,rt,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,Fe),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,ie),L.deleteBuffer(Fe),L.deleteSync(rt),ie}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(W,fe=null,Te=0){const _e=Math.pow(2,-Te),k=Math.floor(W.image.width*_e),ie=Math.floor(W.image.height*_e),he=fe!==null?fe.x:0,ce=fe!==null?fe.y:0;N.setTexture2D(W,0),L.copyTexSubImage2D(L.TEXTURE_2D,Te,0,0,he,ce,k,ie),ee.unbindTexture()};const wA=L.createFramebuffer(),SA=L.createFramebuffer();this.copyTextureToTexture=function(W,fe,Te=null,_e=null,k=0,ie=0){let he,ce,se,Se,He,Ve,Fe,Je,rt;const nt=W.isCompressedTexture?W.mipmaps[ie]:W.image;if(Te!==null)he=Te.max.x-Te.min.x,ce=Te.max.y-Te.min.y,se=Te.isBox3?Te.max.z-Te.min.z:1,Se=Te.min.x,He=Te.min.y,Ve=Te.isBox3?Te.min.z:0;else{const Ot=Math.pow(2,-k);he=Math.floor(nt.width*Ot),ce=Math.floor(nt.height*Ot),W.isDataArrayTexture?se=nt.depth:W.isData3DTexture?se=Math.floor(nt.depth*Ot):se=1,Se=0,He=0,Ve=0}_e!==null?(Fe=_e.x,Je=_e.y,rt=_e.z):(Fe=0,Je=0,rt=0);const at=ve.convert(fe.format),mt=ve.convert(fe.type);let Xe;fe.isData3DTexture?(N.setTexture3D(fe,0),Xe=L.TEXTURE_3D):fe.isDataArrayTexture||fe.isCompressedArrayTexture?(N.setTexture2DArray(fe,0),Xe=L.TEXTURE_2D_ARRAY):(N.setTexture2D(fe,0),Xe=L.TEXTURE_2D),L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,fe.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,fe.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,fe.unpackAlignment);const Pt=L.getParameter(L.UNPACK_ROW_LENGTH),lt=L.getParameter(L.UNPACK_IMAGE_HEIGHT),st=L.getParameter(L.UNPACK_SKIP_PIXELS),Yt=L.getParameter(L.UNPACK_SKIP_ROWS),Zi=L.getParameter(L.UNPACK_SKIP_IMAGES);L.pixelStorei(L.UNPACK_ROW_LENGTH,nt.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,nt.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Se),L.pixelStorei(L.UNPACK_SKIP_ROWS,He),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Ve);const ji=W.isDataArrayTexture||W.isData3DTexture,kt=fe.isDataArrayTexture||fe.isData3DTexture;if(W.isDepthTexture){const Ot=x.get(W),Cn=x.get(fe),bt=x.get(Ot.__renderTarget),fi=x.get(Cn.__renderTarget);ee.bindFramebuffer(L.READ_FRAMEBUFFER,bt.__webglFramebuffer),ee.bindFramebuffer(L.DRAW_FRAMEBUFFER,fi.__webglFramebuffer);for(let Hi=0;Hi<se;Hi++)ji&&(L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,x.get(W).__webglTexture,k,Ve+Hi),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,x.get(fe).__webglTexture,ie,rt+Hi)),L.blitFramebuffer(Se,He,he,ce,Fe,Je,he,ce,L.DEPTH_BUFFER_BIT,L.NEAREST);ee.bindFramebuffer(L.READ_FRAMEBUFFER,null),ee.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(k!==0||W.isRenderTargetTexture||x.has(W)){const Ot=x.get(W),Cn=x.get(fe);ee.bindFramebuffer(L.READ_FRAMEBUFFER,wA),ee.bindFramebuffer(L.DRAW_FRAMEBUFFER,SA);for(let bt=0;bt<se;bt++)ji?L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Ot.__webglTexture,k,Ve+bt):L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Ot.__webglTexture,k),kt?L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Cn.__webglTexture,ie,rt+bt):L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Cn.__webglTexture,ie),k!==0?L.blitFramebuffer(Se,He,he,ce,Fe,Je,he,ce,L.COLOR_BUFFER_BIT,L.NEAREST):kt?L.copyTexSubImage3D(Xe,ie,Fe,Je,rt+bt,Se,He,he,ce):L.copyTexSubImage2D(Xe,ie,Fe,Je,Se,He,he,ce);ee.bindFramebuffer(L.READ_FRAMEBUFFER,null),ee.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else kt?W.isDataTexture||W.isData3DTexture?L.texSubImage3D(Xe,ie,Fe,Je,rt,he,ce,se,at,mt,nt.data):fe.isCompressedArrayTexture?L.compressedTexSubImage3D(Xe,ie,Fe,Je,rt,he,ce,se,at,nt.data):L.texSubImage3D(Xe,ie,Fe,Je,rt,he,ce,se,at,mt,nt):W.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,ie,Fe,Je,he,ce,at,mt,nt.data):W.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,ie,Fe,Je,nt.width,nt.height,at,nt.data):L.texSubImage2D(L.TEXTURE_2D,ie,Fe,Je,he,ce,at,mt,nt);L.pixelStorei(L.UNPACK_ROW_LENGTH,Pt),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,lt),L.pixelStorei(L.UNPACK_SKIP_PIXELS,st),L.pixelStorei(L.UNPACK_SKIP_ROWS,Yt),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Zi),ie===0&&fe.generateMipmaps&&L.generateMipmap(Xe),ee.unbindTexture()},this.initRenderTarget=function(W){x.get(W).__webglFramebuffer===void 0&&N.setupRenderTarget(W)},this.initTexture=function(W){W.isCubeTexture?N.setTextureCube(W,0):W.isData3DTexture?N.setTexture3D(W,0):W.isDataArrayTexture||W.isCompressedArrayTexture?N.setTexture2DArray(W,0):N.setTexture2D(W,0),ee.unbindTexture()},this.resetState=function(){B=0,R=0,U=null,ee.reset(),me.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Pn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Et._getDrawingBufferColorSpace(e),t.unpackColorSpace=Et._getUnpackColorSpace()}}const bP=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:ra,AddEquation:gn,AddOperation:XA,AdditiveAnimationBlendMode:Cf,AdditiveBlending:Vh,AgXToneMapping:sd,AlphaFormat:wf,AlwaysCompare:ov,AlwaysDepth:Xh,AlwaysStencilFunc:If,AmbientLight:il,AnimationAction:Jb,AnimationClip:el,AnimationLoader:aC,AnimationMixer:BC,AnimationObjectGroup:RC,AnimationUtils:iC,ArcCurve:nb,ArrayCamera:Xb,ArrowHelper:i2,AttachedBindMode:_f,Audio:Yb,AudioAnalyser:xC,AudioContext:Fm,AudioListener:vC,AudioLoader:fC,AxesHelper:d1,BackSide:qi,BasicDepthPacking:ev,BasicShadowMap:PM,BatchedMesh:Qv,BezierInterpolant:Tb,Bone:su,BooleanKeyframeTrack:Ca,Box2:zC,Box3:Ft,Box3Helper:e2,BoxGeometry:ri,BoxHelper:$C,BufferAttribute:St,BufferGeometry:ot,BufferGeometryLoader:Hb,ByteType:Ef,Cache:Ss,Camera:Fu,CameraHelper:JC,CanvasTexture:eb,CapsuleGeometry:vu,CatmullRomCurve3:sb,CineonToneMapping:id,CircleGeometry:bu,ClampToEdgeWrapping:ln,Clock:t1,Color:We,ColorKeyframeTrack:Pm,ColorManagement:Et,Compatibility:mw,CompressedArrayTexture:Jv,CompressedCubeTexture:$v,CompressedTexture:Ko,CompressedTextureLoader:oC,ConeGeometry:Fc,ConstantAlphaFactor:WA,ConstantColorFactor:VA,Controls:qu,CubeCamera:qb,CubeDepthTexture:tb,CubeReflectionMapping:ys,CubeRefractionMapping:gr,CubeTexture:Uc,CubeTextureLoader:lC,CubeUVReflectionMapping:yo,CubicBezierCurve:Am,CubicBezierCurve3:ab,CubicInterpolant:Sb,CullFaceBack:bf,CullFaceFront:RA,CullFaceFrontBack:IM,CullFaceNone:PA,Curve:as,CurvePath:lb,CustomBlending:Qh,CustomToneMapping:nd,CylinderGeometry:Li,Cylindrical:OC,Data3DTexture:xc,DataArrayTexture:Rd,DataTexture:dn,DataTextureLoader:Db,DataUtils:wc,DecrementStencilOp:jM,DecrementWrapStencilOp:XM,DefaultLoadingManager:Rb,DepthFormat:xs,DepthStencilFormat:_s,DepthTexture:Rr,DetachedBindMode:YA,DirectionalLight:Nr,DirectionalLightHelper:ZC,DiscreteInterpolant:Cb,DodecahedronGeometry:yu,DoubleSide:Vt,DstAlphaFactor:Xl,DstColorFactor:Yl,DynamicCopyUsage:cw,DynamicDrawUsage:nw,DynamicReadUsage:aw,EdgesGeometry:ib,EllipseCurve:Oc,EqualCompare:sv,EqualDepth:Kh,EqualStencilFunc:JM,EquirectangularReflectionMapping:bo,EquirectangularRefractionMapping:Zl,Euler:Di,EventDispatcher:is,ExternalTexture:dm,ExtrudeGeometry:Jo,FileLoader:Yi,Float16BufferAttribute:nS,Float32BufferAttribute:tt,FloatType:oi,Fog:Fd,FogExp2:Ud,FramebufferTexture:_S,FrontSide:Gn,Frustum:Yo,FrustumArray:ou,GLBufferAttribute:FC,GLSL1:dw,GLSL3:Pf,GreaterCompare:rv,GreaterDepth:Jh,GreaterEqualCompare:Pd,GreaterEqualDepth:Zh,GreaterEqualStencilFunc:iw,GreaterStencilFunc:ew,GridHelper:YC,Group:Mi,HalfFloatType:Zt,HemisphereLight:Bb,HemisphereLightHelper:XC,IcosahedronGeometry:Tu,ImageBitmapLoader:Qb,ImageLoader:Xc,ImageUtils:gv,IncrementStencilOp:WM,IncrementWrapStencilOp:qM,InstancedBufferAttribute:Pr,InstancedBufferGeometry:zb,InstancedInterleavedBuffer:UC,InstancedMesh:ni,Int16BufferAttribute:tS,Int32BufferAttribute:iS,Int8BufferAttribute:Jw,IntType:od,InterleavedBuffer:Vo,InterleavedBufferAttribute:Vs,Interpolant:Sa,InterpolateBezier:Sf,InterpolateDiscrete:To,InterpolateLinear:Io,InterpolateSmooth:Sd,InterpolationSamplingMode:fw,InterpolationSamplingType:pw,InvertStencilOp:YM,KeepStencilOp:pa,KeyframeTrack:Xn,LOD:Pv,LatheGeometry:Iu,Layers:Bd,LessCompare:nv,LessDepth:Yh,LessEqualCompare:Id,LessEqualDepth:sa,LessEqualStencilFunc:$M,LessStencilFunc:ZM,Light:Lr,LightProbe:Ob,Line:di,Line3:VC,LineBasicMaterial:si,LineCurve:vm,LineCurve3:ob,LineDashedMaterial:Mb,LineLoop:cm,LineSegments:vi,LinearFilter:_t,LinearInterpolant:Im,LinearMipMapLinearFilter:kM,LinearMipMapNearestFilter:LM,LinearMipmapLinearFilter:An,LinearMipmapNearestFilter:_o,LinearSRGBColorSpace:Ri,LinearToneMapping:ed,LinearTransfer:mc,Loader:Qi,LoaderUtils:Ur,LoadingManager:Rm,LoopOnce:KA,LoopPingPong:JA,LoopRepeat:ZA,MOUSE:Tn,Material:Bi,MaterialBlending:RM,MaterialLoader:Ou,MathUtils:Dt,Matrix2:Wm,Matrix3:ft,Matrix4:Ke,MaxEquation:NA,Mesh:Ge,MeshBasicMaterial:Rt,MeshDepthMaterial:wm,MeshDistanceMaterial:Sm,MeshLambertMaterial:Mm,MeshMatcapMaterial:Eb,MeshNormalMaterial:ku,MeshPhongMaterial:xb,MeshPhysicalMaterial:qn,MeshStandardMaterial:Ma,MeshToonMaterial:_b,MinEquation:kA,MirroredRepeatWrapping:xo,MixOperation:qA,MultiplyBlending:xf,MultiplyOperation:Kl,NearestFilter:Ht,NearestMipMapLinearFilter:BM,NearestMipMapNearestFilter:DM,NearestMipmapLinearFilter:aa,NearestMipmapNearestFilter:Jl,NeutralToneMapping:rd,NeverCompare:iv,NeverDepth:qh,NeverStencilFunc:KM,NoBlending:ti,NoColorSpace:ts,NoNormalPacking:zM,NoToneMapping:Xi,NormalAnimationBlendMode:Cd,NormalBlending:na,NormalGAPacking:GM,NormalRGPacking:HM,NotEqualCompare:av,NotEqualDepth:$h,NotEqualStencilFunc:tw,NumberKeyframeTrack:Ta,Object3D:Mt,ObjectLoader:uC,ObjectSpaceNormalMap:tv,OctahedronGeometry:js,OneFactor:UA,OneMinusConstantAlphaFactor:jA,OneMinusConstantColorFactor:QA,OneMinusDstAlphaFactor:zA,OneMinusDstColorFactor:HA,OneMinusSrcAlphaFactor:jh,OneMinusSrcColorFactor:OA,OrthographicCamera:Ki,PCFShadowMap:ql,PCFSoftShadowMap:DA,PMREMGenerator:Kc,Path:Gc,PerspectiveCamera:pi,Plane:li,PlaneGeometry:jn,PlaneHelper:t2,PointLight:km,PointLightHelper:jC,Points:Au,PointsMaterial:fu,PolarGridHelper:KC,PolyhedronGeometry:Dr,PositionalAudio:yC,PropertyBinding:Lt,PropertyMixer:Zb,QuadraticBezierCurve:bm,QuadraticBezierCurve3:ym,Quaternion:Tt,QuaternionKeyframeTrack:Ia,QuaternionLinearInterpolant:Ib,R11_EAC_Format:rc,RED_GREEN_RGTC2_Format:uc,RED_RGTC1_Format:hc,REVISION:Gh,RG11_EAC_Format:oc,RGBADepthPacking:UM,RGBAFormat:hi,RGBAIntegerFormat:dd,RGBA_ASTC_10x10_Format:_d,RGBA_ASTC_10x5_Format:bd,RGBA_ASTC_10x6_Format:yd,RGBA_ASTC_10x8_Format:xd,RGBA_ASTC_12x10_Format:Ed,RGBA_ASTC_12x12_Format:Md,RGBA_ASTC_4x4_Format:yr,RGBA_ASTC_5x4_Format:pd,RGBA_ASTC_5x5_Format:fd,RGBA_ASTC_6x5_Format:md,RGBA_ASTC_6x6_Format:ca,RGBA_ASTC_8x5_Format:gd,RGBA_ASTC_8x6_Format:Ad,RGBA_ASTC_8x8_Format:vd,RGBA_BPTC_Format:ha,RGBA_ETC2_EAC_Format:Co,RGBA_PVRTC_2BPPV1_Format:wo,RGBA_PVRTC_4BPPV1_Format:la,RGBA_S3TC_DXT1_Format:vr,RGBA_S3TC_DXT3_Format:ic,RGBA_S3TC_DXT5_Format:br,RGBDepthPacking:FM,RGBFormat:Mo,RGBIntegerFormat:NM,RGB_BPTC_SIGNED_Format:wd,RGB_BPTC_UNSIGNED_Format:cc,RGB_ETC1_Format:sc,RGB_ETC2_Format:So,RGB_PVRTC_2BPPV1_Format:ud,RGB_PVRTC_4BPPV1_Format:nc,RGB_S3TC_DXT1_Format:oa,RGDepthPacking:OM,RGFormat:Qn,RGIntegerFormat:hd,RawShaderMaterial:Lu,Ray:Ir,Raycaster:Ln,RectAreaLight:Fb,RedFormat:Es,RedIntegerFormat:tc,ReinhardToneMapping:td,RenderTarget:Nf,RenderTarget3D:LC,RepeatWrapping:Ji,ReplaceStencilOp:QM,ReverseSubtractEquation:LA,RingGeometry:Pu,SIGNED_R11_EAC_Format:ac,SIGNED_RED_GREEN_RGTC2_Format:pc,SIGNED_RED_RGTC1_Format:dc,SIGNED_RG11_EAC_Format:lc,SRGBColorSpace:Jt,SRGBTransfer:Ut,Scene:ga,ShaderChunk:yt,ShaderLib:ls,ShaderMaterial:ei,ShadowMaterial:bb,Shape:Ws,ShapeGeometry:qc,ShapePath:u1,ShapeUtils:os,ShortType:Mf,Skeleton:Dc,SkeletonHelper:WC,SkinnedMesh:sm,Source:Er,Sphere:Gi,SphereGeometry:Br,Spherical:rl,SphericalHarmonics3:Nm,SplineCurve:xm,SpotLight:Lm,SpotLightHelper:QC,Sprite:Rc,SpriteMaterial:Vd,SrcAlphaFactor:Wh,SrcAlphaSaturateFactor:GA,SrcColorFactor:FA,StaticCopyUsage:lw,StaticDrawUsage:gc,StaticReadUsage:rw,StereoCamera:mC,StreamCopyUsage:hw,StreamDrawUsage:sw,StreamReadUsage:ow,StringKeyframeTrack:Pa,SubtractEquation:BA,SubtractiveBlending:yf,TOUCH:In,TangentSpaceNormalMap:xr,TetrahedronGeometry:Ru,Texture:ii,TextureLoader:Da,TextureUtils:o2,Timer:Om,TimestampQuery:uw,TorusGeometry:qs,TorusKnotGeometry:Du,Triangle:vn,TriangleFanDrawMode:Td,TriangleStripDrawMode:Tf,TrianglesDrawMode:$A,TubeGeometry:Bu,UVMapping:ad,Uint16BufferAttribute:qf,Uint32BufferAttribute:Xf,Uint8BufferAttribute:$w,Uint8ClampedBufferAttribute:eS,Uniform:Vm,UniformsGroup:NC,UniformsLib:Ze,UniformsUtils:nn,UnsignedByteType:ut,UnsignedInt101111Type:ec,UnsignedInt248Type:Ar,UnsignedInt5999Type:$l,UnsignedIntType:Vn,UnsignedShort4444Type:ld,UnsignedShort5551Type:cd,UnsignedShortType:Eo,VSMShadowMap:vo,Vector2:be,Vector3:T,Vector4:Gt,VectorKeyframeTrack:Ra,VideoFrameTexture:xS,VideoTexture:Zv,WebGL3DRenderTarget:Gw,WebGLArrayRenderTarget:Hw,WebGLCoordinateSystem:Pn,WebGLCubeRenderTarget:eg,WebGLRenderTarget:Ei,WebGLRenderer:$c,WebGLUtils:z1,WebGPUCoordinateSystem:fa,WebXRController:kd,WireframeGeometry:gb,WrapAroundEnding:fc,ZeroCurvatureEnding:da,ZeroFactor:mr,ZeroSlopeEnding:ua,ZeroStencilOp:VM,createCanvasElement:cv,error:ct,getConsoleFunction:bw,log:vc,setConsoleFunction:vw,warn:Ye,warnOnce:bc},Symbol.toStringTag,{value:"Module"}));class yP{engine;scene;constructor(e){this.engine=e,this.scene=new ga;let t=new Mi;t.name="groupEdge",this.scene.add(t)}}class zt{constructor(e,t,i){this.camera=e,this.renderer=t,this.scene=i,this.raycaster=new Ln}raycaster;worldToScreenNormalized(e){const t=e.clone();return t.project(this.camera),new be(t.x,t.y)}worldToScreen(e){const t=new T;return t.copy(e).project(this.camera),t.x=t.x*this.renderer.domElement.clientWidth*.5,t.y=-t.y*this.renderer.domElement.clientHeight*.5,t.z=(t.z+1)*.5,t.x+=this.renderer.domElement.clientWidth*.5,t.y+=this.renderer.domElement.clientHeight*.5,new be(t.x,t.y)}screenToNormalized(e,t){const i=this.renderer.domElement.clientWidth,n=this.renderer.domElement.clientHeight,s=e/i*2-1,a=-(t/n*2-1);return new be(s,a)}screenToWorld(e,t,i){if(!this.scene&&!i)return console.warn("WorldToScreen: 需要提供 scene 或 objects 参数才能进行屏幕坐标转世界坐标"),null;const n=this.screenToNormalized(e,t);this.raycaster.setFromCamera(n,this.camera);const s=i||this.scene.children,a=this.raycaster.intersectObjects(s,!0);return a.length>0?a[0].point:null}screenToWorldWithDepth(e,t,i=0){const n=this.screenToNormalized(e,t);this.raycaster.setFromCamera(n,this.camera);const s=new T;return this.raycaster.ray.at(i,s),s}updateCamera(e){this.camera=e}updateRenderer(e){this.renderer=e}updateScene(e){this.scene=e}}var $u=(r=>(r.PERSPECTIVE="perspective",r.ORTHOGRAPHIC="orthographic",r))($u||{});class zr{static MIN_VISIBLE_HEIGHT=1e-4;static MIN_CAMERA_DISTANCE=1e-4;engine;perspectiveCamera;orthographicCamera;constructor(e){this.engine=e,this.perspectiveCamera=new pi(20,this.engine.container.clientWidth/this.engine.container.clientHeight,.1,1e3),this.perspectiveCamera.position.set(2,2,2),this.perspectiveCamera.lookAt(0,0,0);const t=50,i=this.engine.container.clientWidth/this.engine.container.clientHeight;this.orthographicCamera=new Ki(t*i/-2,t*i/2,t/2,t/-2,.1,1e3)}getCameraAspect(){const e=this.engine.container?.clientWidth??1,t=this.engine.container?.clientHeight??1;return t>0?e/t:1}getPerspectiveVisibleHeight(e,t){const i=Math.max(e.position.distanceTo(t),zr.MIN_CAMERA_DISTANCE),n=Dt.degToRad(e.getEffectiveFOV()*.5);return Math.max(2*i*Math.tan(n),zr.MIN_VISIBLE_HEIGHT)}getOrthographicVisibleHeight(e=this.orthographicCamera){return Math.max((e.top-e.bottom)/e.zoom,zr.MIN_VISIBLE_HEIGHT)}setOrthographicVisibleHeight(e,t=this.orthographicCamera){const i=Math.max(e,zr.MIN_VISIBLE_HEIGHT),n=this.getCameraAspect(),s=i*.5,a=s*n;t.left=-a,t.right=a,t.top=s,t.bottom=-s}getViewDirection(e,t,i){const n=new T().subVectors(e,t);return n.lengthSq()>zr.MIN_CAMERA_DISTANCE?n.normalize():new T(0,0,1).applyQuaternion(i).normalize()}updateComposerCamera(){if(!this.engine.composerModule?.composer)return;const e=this.engine.camera,t=this.engine.composerModule.composer;if(t.passes)for(const i of t.passes)i.camera!==void 0&&(i.camera=e)}applySwitchedCamera(e,t){this.engine.camera=e,this.engine.scene.camera=e,this.engine.controls?.target&&this.engine.controls.target.copy(t),this.engine.controls&&(this.engine.controls.object=e),this.engine.controlModule.orbitControls.object=e,this.engine.controlModule.firstPersonControls.camera=e,e.updateProjectionMatrix?.(),e.updateMatrixWorld(),this.updateComposerCamera(),this.engine.controls?.update&&this.engine.controls.update(),this.engine.worldToScreen=new zt(this.engine.camera,this.engine.renderer,this.engine.scene)}switchCurrentCamera(){this.engine.camera===this.perspectiveCamera?this.switchToOrthographicCamera():this.switchToPerspectiveCamera()}setPerspectiveFov(e,t){const i=this.perspectiveCamera,n=i.fov,s=Math.max(1,Math.min(120,e));if(t?.adjustDistance!==!1&&this.engine.camera===i&&this.engine.controls?.target){const a=this.engine.controls.target.clone(),o=i.position.clone(),l=o.distanceTo(a);if(l>1e-6){const c=Dt.degToRad(n*.5),h=Dt.degToRad(s*.5),d=Math.tan(c)/Math.tan(h),p=l*d,u=new T().subVectors(o,a).normalize();i.position.copy(a).add(u.multiplyScalar(p))}}i.fov=s,i.updateProjectionMatrix()}switchToPerspectiveCamera(){if(!this.engine.controls)return;const e=this.engine.camera;if(!e)return;const t=e.position.clone(),i=this.engine.controls.target.clone(),n=e.quaternion.clone(),s=e.up.clone(),a=this.perspectiveCamera,o=this.getViewDirection(t,i,n),l=e instanceof Ki?this.getOrthographicVisibleHeight(e):this.getPerspectiveVisibleHeight(e,i),c=Dt.degToRad(a.getEffectiveFOV()*.5),h=Math.max(l/(2*Math.tan(c)),zr.MIN_CAMERA_DISTANCE);a.near=e.near,a.far=e.far,a.aspect=this.getCameraAspect(),a.up.copy(s),a.position.copy(i).add(o.multiplyScalar(h)),a.lookAt(i),this.applySwitchedCamera(a,i)}switchToOrthographicCamera(){if(!this.engine.controls)return;const e=this.engine.camera;if(!e)return;e.position.clone();const t=this.engine.controls.target.clone(),i=e.up.clone(),n=this.orthographicCamera,s=e instanceof pi?this.getPerspectiveVisibleHeight(e,t):this.getOrthographicVisibleHeight(e);n.near=e.near,n.far=e.far,n.zoom=1,this.setOrthographicVisibleHeight(s,n),n.up.copy(i),n.lookAt(t),this.applySwitchedCamera(n,t)}getCameraType(){return this.engine.camera===this.perspectiveCamera?"perspective":this.engine.camera===this.orthographicCamera?"orthographic":"perspective"}getCameraPose(){const e=this.engine.camera,t=this.getCameraType(),i={type:t,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z},quaternion:{x:e.quaternion.x,y:e.quaternion.y,z:e.quaternion.z,w:e.quaternion.w}};return this.engine.controls?.target&&(i.target={x:this.engine.controls.target.x,y:this.engine.controls.target.y,z:this.engine.controls.target.z}),t==="orthographic"&&(i.zoom=e.zoom,i.orthographicHeight=this.getOrthographicVisibleHeight(e)),i}restoreCameraPose(e){this.getCameraType()!==e.type&&(e.type==="perspective"?this.switchToPerspectiveCamera():this.switchToOrthographicCamera());const t=this.engine.camera;if(t.position.set(e.position.x,e.position.y,e.position.z),e.quaternion?t.quaternion.set(e.quaternion.x,e.quaternion.y,e.quaternion.z,e.quaternion.w):e.rotation&&t.rotation.set(e.rotation.x,e.rotation.y,e.rotation.z),e.target&&this.engine.controls?.target&&this.engine.controls.target.set(e.target.x,e.target.y,e.target.z),e.type==="orthographic"){const i=t;e.orthographicHeight!==void 0&&this.setOrthographicVisibleHeight(e.orthographicHeight,i),e.zoom!==void 0&&(i.zoom=e.zoom),i.updateProjectionMatrix()}t.updateMatrix(),t.updateMatrixWorld(!0),this.engine.controls?.update&&this.engine.controls.update()}setViewFromOriginAndDirection(e,t,i){const n=new T(t.x,t.y,t.z).normalize(),s=new T(e.x,e.y,e.z);if(i==null||i<=0){const l=this.engine.octreeBox?.getBoundingBox?.();if(l&&l.min&&l.max){const c=new T().subVectors(l.max,l.min);i=Math.max(c.x,c.y,c.z)*1.2}else i=50}const a=s.clone().add(n.clone().negate().multiplyScalar(i)),o=this.engine.camera;o&&(o.position.copy(a),o.lookAt(s),this.engine.controls?.target&&this.engine.controls.target.copy(s),this.engine.controls?.update&&this.engine.controls.update(),o.updateMatrix(),o.updateMatrixWorld(!0))}}class xP{engine;deviceType;constructor(e){this.engine=e,this.deviceType=this.detectDeviceType()}detectDeviceType(){const e=[/Android/i,/webOS/i,/iPhone/i,/iPad/i,/iPod/i,/BlackBerry/i,/Windows Phone/i,/Mobile/i],t=navigator.userAgent||globalThis.opera,i=e.some(c=>c.test(t)),n="ontouchstart"in globalThis||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,s=globalThis.screen.width,a=globalThis.screen.height,o=s<=768||a<=768,l=(globalThis.devicePixelRatio||1)>=2;return i||n&&o||n&&l?"mobile":"PC"}getDeviceType(){return this.deviceType}isMobile(){return this.deviceType==="mobile"}isPC(){return this.deviceType==="PC"}redetectDeviceType(){return this.deviceType=this.detectDeviceType(),this.deviceType}getContainerSize(){return{width:this.engine.container.clientWidth,height:this.engine.container.clientHeight}}}const rg="181",_P=0,H1=1,EP=2,G1=1,V1=2,Ys=3,Hr=0,xn=1,Ks=2,Zs=0,hl=1,Q1=2,W1=3,j1=4,MP=5,Ga=100,wP=101,SP=102,CP=103,TP=104,IP=200,PP=201,RP=202,DP=203,ag=204,og=205,BP=206,LP=207,kP=208,NP=209,UP=210,FP=211,OP=212,zP=213,HP=214,lg=0,cg=1,hg=2,dl=3,dg=4,ug=5,pg=6,fg=7,q1=0,GP=1,VP=2,Gr=0,QP=1,WP=2,jP=3,qP=4,XP=5,YP=6,KP=7,X1=300,ul=301,pl=302,mg=303,gg=304,ep=306,Ag=1e3,Js=1001,vg=1002,kn=1003,ZP=1004,tp=1005,Yn=1006,bg=1007,Va=1008,$s=1009,Y1=1010,K1=1011,eh=1012,yg=1013,Qa=1014,er=1015,fl=1016,xg=1017,_g=1018,th=1020,Z1=35902,J1=35899,$1=1021,ey=1022,cs=1023,ih=1026,nh=1027,ty=1028,Eg=1029,Mg=1030,wg=1031,Sg=1033,ip=33776,np=33777,sp=33778,rp=33779,Cg=35840,Tg=35841,Ig=35842,Pg=35843,Rg=36196,Dg=37492,Bg=37496,Lg=37808,kg=37809,Ng=37810,Ug=37811,Fg=37812,Og=37813,zg=37814,Hg=37815,Gg=37816,Vg=37817,Qg=37818,Wg=37819,jg=37820,qg=37821,Xg=36492,Yg=36494,Kg=36495,Zg=36283,Jg=36284,$g=36285,e0=36286,JP=3200,$P=3201,eR=0,tR=1,Vr="",Nn="srgb",ml="srgb-linear",ap="linear",Qt="srgb",gl=7680,iy=519,iR=512,nR=513,sR=514,ny=515,rR=516,aR=517,oR=518,lR=519,sy=35044,ry="300 es",Is=2e3,op=2001;function ay(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}function lp(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function cR(){const r=lp("canvas");return r.style.display="block",r}const oy={};function ly(...r){const e="THREE."+r.shift();console.log(e,...r)}function At(...r){const e="THREE."+r.shift();console.warn(e,...r)}function yi(...r){const e="THREE."+r.shift();console.error(e,...r)}function sh(...r){const e=r.join(" ");e in oy||(oy[e]=!0,At(...r))}function hR(r,e,t){return new Promise(function(i,n){function s(){switch(r.clientWaitSync(e,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:n();break;case r.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:i()}}setTimeout(s,t)})}class Al{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const n=i[e];if(n!==void 0){const s=n.indexOf(t);s!==-1&&n.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const n=i.slice(0);for(let s=0,a=n.length;s<a;s++)n[s].call(this,e);e.target=null}}}const sn=["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"],t0=Math.PI/180,i0=180/Math.PI;function rh(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(sn[r&255]+sn[r>>8&255]+sn[r>>16&255]+sn[r>>24&255]+"-"+sn[e&255]+sn[e>>8&255]+"-"+sn[e>>16&15|64]+sn[e>>24&255]+"-"+sn[t&63|128]+sn[t>>8&255]+"-"+sn[t>>16&255]+sn[t>>24&255]+sn[i&255]+sn[i>>8&255]+sn[i>>16&255]+sn[i>>24&255]).toLowerCase()}function Bt(r,e,t){return Math.max(e,Math.min(t,r))}function dR(r,e){return(r%e+e)%e}function n0(r,e,t){return(1-t)*r+t*e}function ah(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function _n(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}class Wt{constructor(e=0,t=0){Wt.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,i=this.y,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6],this.y=n[1]*t+n[4]*i+n[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=Bt(this.x,e.x,t.x),this.y=Bt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Bt(this.x,e,t),this.y=Bt(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Bt(i,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 i=this.dot(e)/t;return Math.acos(Bt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,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 i=Math.cos(t),n=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*i-a*n+e.x,this.y=s*n+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class oh{constructor(e=0,t=0,i=0,n=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=n}static slerpFlat(e,t,i,n,s,a,o){let l=i[n+0],c=i[n+1],h=i[n+2],d=i[n+3],p=s[a+0],u=s[a+1],A=s[a+2],m=s[a+3];if(o<=0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d;return}if(o>=1){e[t+0]=p,e[t+1]=u,e[t+2]=A,e[t+3]=m;return}if(d!==m||l!==p||c!==u||h!==A){let g=l*p+c*u+h*A+d*m;g<0&&(p=-p,u=-u,A=-A,m=-m,g=-g);let f=1-o;if(g<.9995){const v=Math.acos(g),b=Math.sin(v);f=Math.sin(f*v)/b,o=Math.sin(o*v)/b,l=l*f+p*o,c=c*f+u*o,h=h*f+A*o,d=d*f+m*o}else{l=l*f+p*o,c=c*f+u*o,h=h*f+A*o,d=d*f+m*o;const v=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=v,c*=v,h*=v,d*=v}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,n,s,a){const o=i[n],l=i[n+1],c=i[n+2],h=i[n+3],d=s[a],p=s[a+1],u=s[a+2],A=s[a+3];return e[t]=o*A+h*d+l*u-c*p,e[t+1]=l*A+h*p+c*d-o*u,e[t+2]=c*A+h*u+o*p-l*d,e[t+3]=h*A-o*d-l*p-c*u,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,i,n){return this._x=e,this._y=t,this._z=i,this._w=n,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 i=e._x,n=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),h=o(n/2),d=o(s/2),p=l(i/2),u=l(n/2),A=l(s/2);switch(a){case"XYZ":this._x=p*h*d+c*u*A,this._y=c*u*d-p*h*A,this._z=c*h*A+p*u*d,this._w=c*h*d-p*u*A;break;case"YXZ":this._x=p*h*d+c*u*A,this._y=c*u*d-p*h*A,this._z=c*h*A-p*u*d,this._w=c*h*d+p*u*A;break;case"ZXY":this._x=p*h*d-c*u*A,this._y=c*u*d+p*h*A,this._z=c*h*A+p*u*d,this._w=c*h*d-p*u*A;break;case"ZYX":this._x=p*h*d-c*u*A,this._y=c*u*d+p*h*A,this._z=c*h*A-p*u*d,this._w=c*h*d+p*u*A;break;case"YZX":this._x=p*h*d+c*u*A,this._y=c*u*d+p*h*A,this._z=c*h*A-p*u*d,this._w=c*h*d-p*u*A;break;case"XZY":this._x=p*h*d-c*u*A,this._y=c*u*d-p*h*A,this._z=c*h*A+p*u*d,this._w=c*h*d+p*u*A;break;default:At("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,n=Math.sin(i);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],n=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],d=t[10],p=i+o+d;if(p>0){const u=.5/Math.sqrt(p+1);this._w=.25/u,this._x=(h-l)*u,this._y=(s-c)*u,this._z=(a-n)*u}else if(i>o&&i>d){const u=2*Math.sqrt(1+i-o-d);this._w=(h-l)/u,this._x=.25*u,this._y=(n+a)/u,this._z=(s+c)/u}else if(o>d){const u=2*Math.sqrt(1+o-i-d);this._w=(s-c)/u,this._x=(n+a)/u,this._y=.25*u,this._z=(l+h)/u}else{const u=2*Math.sqrt(1+d-i-o);this._w=(a-n)/u,this._x=(s+c)/u,this._y=(l+h)/u,this._z=.25*u}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(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=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Bt(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const n=Math.min(1,t/i);return this.slerp(e,n),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 i=e._x,n=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=i*h+a*o+n*c-s*l,this._y=n*h+a*l+s*o-i*c,this._z=s*h+a*c+i*l-n*o,this._w=a*h-i*o-n*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let i=e._x,n=e._y,s=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,n=-n,s=-s,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),h=Math.sin(c);l=Math.sin(l*c)/h,t=Math.sin(t*c)/h,this._x=this._x*l+i*t,this._y=this._y*l+n*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+n*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(n*Math.sin(e),n*Math.cos(e),s*Math.sin(t),s*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 De{constructor(e=0,t=0,i=0){De.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,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(cy.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(cy.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,n=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*n,this.y=s[1]*t+s[4]*i+s[7]*n,this.z=s[2]*t+s[5]*i+s[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,s=e.elements,a=1/(s[3]*t+s[7]*i+s[11]*n+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*n+s[12])*a,this.y=(s[1]*t+s[5]*i+s[9]*n+s[13])*a,this.z=(s[2]*t+s[6]*i+s[10]*n+s[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,n=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*n-o*i),h=2*(o*t-s*n),d=2*(s*i-a*t);return this.x=t+l*c+a*d-o*h,this.y=i+l*h+o*c-s*d,this.z=n+l*d+s*h-a*c,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,i=this.y,n=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*n,this.y=s[1]*t+s[5]*i+s[9]*n,this.z=s[2]*t+s[6]*i+s[10]*n,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=Bt(this.x,e.x,t.x),this.y=Bt(this.y,e.y,t.y),this.z=Bt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Bt(this.x,e,t),this.y=Bt(this.y,e,t),this.z=Bt(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Bt(i,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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,n=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=n*l-s*o,this.y=s*a-i*l,this.z=i*o-n*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return s0.copy(this).projectOnVector(e),this.sub(s0)}reflect(e){return this.sub(s0.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 i=this.dot(e)/t;return Math.acos(Bt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return t*t+i*i+n*n}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,i){const n=Math.sin(t)*e;return this.x=n*Math.sin(i),this.y=Math.cos(t)*e,this.z=n*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,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(),i=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=n,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,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const s0=new De,cy=new oh;class xt{constructor(e,t,i,n,s,a,o,l,c){xt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,n,s,a,o,l,c)}set(e,t,i,n,s,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=n,h[2]=o,h[3]=t,h[4]=s,h[5]=l,h[6]=i,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.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 i=e.elements,n=t.elements,s=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],h=i[4],d=i[7],p=i[2],u=i[5],A=i[8],m=n[0],g=n[3],f=n[6],v=n[1],b=n[4],y=n[7],M=n[2],_=n[5],S=n[8];return s[0]=a*m+o*v+l*M,s[3]=a*g+o*b+l*_,s[6]=a*f+o*y+l*S,s[1]=c*m+h*v+d*M,s[4]=c*g+h*b+d*_,s[7]=c*f+h*y+d*S,s[2]=p*m+u*v+A*M,s[5]=p*g+u*b+A*_,s[8]=p*f+u*y+A*S,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],i=e[1],n=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-i*s*h+i*o*l+n*s*c-n*a*l}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=h*a-o*c,p=o*l-h*s,u=c*s-a*l,A=t*d+i*p+n*u;if(A===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/A;return e[0]=d*m,e[1]=(n*c-h*i)*m,e[2]=(o*i-n*a)*m,e[3]=p*m,e[4]=(h*t-n*l)*m,e[5]=(n*s-o*t)*m,e[6]=u*m,e[7]=(i*l-c*t)*m,e[8]=(a*t-i*s)*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,i,n,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-n*c,n*l,-n*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(r0.makeScale(e,t)),this}rotate(e){return this.premultiply(r0.makeRotation(-e)),this}translate(e,t){return this.premultiply(r0.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),i=Math.sin(e);return this.set(t,-i,0,i,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,i=e.elements;for(let n=0;n<9;n++)if(t[n]!==i[n])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const r0=new xt,hy=new xt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),dy=new xt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function uR(){const r={enabled:!0,workingColorSpace:ml,spaces:{},convert:function(n,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Qt&&(n.r=tr(n.r),n.g=tr(n.g),n.b=tr(n.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(n.applyMatrix3(this.spaces[s].toXYZ),n.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Qt&&(n.r=vl(n.r),n.g=vl(n.g),n.b=vl(n.b))),n},workingToColorSpace:function(n,s){return this.convert(n,this.workingColorSpace,s)},colorSpaceToWorking:function(n,s){return this.convert(n,s,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===Vr?ap:this.spaces[n].transfer},getToneMappingMode:function(n){return this.spaces[n].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(n,s=this.workingColorSpace){return n.fromArray(this.spaces[s].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,s,a){return n.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(n,s){return sh("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(n,s)},toWorkingColorSpace:function(n,s){return sh("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(n,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return r.define({[ml]:{primaries:e,whitePoint:i,transfer:ap,toXYZ:hy,fromXYZ:dy,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Nn},outputColorSpaceConfig:{drawingBufferColorSpace:Nn}},[Nn]:{primaries:e,whitePoint:i,transfer:Qt,toXYZ:hy,fromXYZ:dy,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Nn}}}),r}const Nt=uR();function tr(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function vl(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let bl;class pR{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{bl===void 0&&(bl=lp("canvas")),bl.width=e.width,bl.height=e.height;const n=bl.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),i=bl}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=lp("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const n=i.getImageData(0,0,e.width,e.height),s=n.data;for(let a=0;a<s.length;a++)s[a]=tr(s[a]/255)*255;return i.putImageData(n,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(tr(t[i]/255)*255):t[i]=tr(t[i]);return{data:t,width:e.width,height:e.height}}else return At("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let fR=0;class a0{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:fR++}),this.uuid=rh(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&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 i={uuid:this.uuid,url:""},n=this.data;if(n!==null){let s;if(Array.isArray(n)){s=[];for(let a=0,o=n.length;a<o;a++)n[a].isDataTexture?s.push(o0(n[a].image)):s.push(o0(n[a]))}else s=o0(n);i.url=s}return t||(e.images[this.uuid]=i),i}}function o0(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?pR.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(At("Texture: Unable to serialize Texture."),{})}let mR=0;const l0=new De;class pn extends Al{constructor(e=pn.DEFAULT_IMAGE,t=pn.DEFAULT_MAPPING,i=Js,n=Js,s=Yn,a=Va,o=cs,l=$s,c=pn.DEFAULT_ANISOTROPY,h=Vr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:mR++}),this.uuid=rh(),this.name="",this.source=new a0(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Wt(0,0),this.repeat=new Wt(1,1),this.center=new Wt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new xt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,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(l0).x}get height(){return this.source.getSize(l0).y}get depth(){return this.source.getSize(l0).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 i=e[t];if(i===void 0){At(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){At(`Texture.setValues(): property '${t}' does not exist.`);continue}n&&i&&n.isVector2&&i.isVector2||n&&i&&n.isVector3&&i.isVector3||n&&i&&n.isMatrix3&&i.isMatrix3?n.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={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&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==X1)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ag:e.x=e.x-Math.floor(e.x);break;case Js:e.x=e.x<0?0:1;break;case vg: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 Ag:e.y=e.y-Math.floor(e.y);break;case Js:e.y=e.y<0?0:1;break;case vg: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++}}pn.DEFAULT_IMAGE=null,pn.DEFAULT_MAPPING=X1,pn.DEFAULT_ANISOTROPY=1;class xi{constructor(e=0,t=0,i=0,n=1){xi.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=n}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,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,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,i=this.y,n=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*n+a[12]*s,this.y=a[1]*t+a[5]*i+a[9]*n+a[13]*s,this.z=a[2]*t+a[6]*i+a[10]*n+a[14]*s,this.w=a[3]*t+a[7]*i+a[11]*n+a[15]*s,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,i,n,s;const a=e.elements,o=a[0],l=a[4],c=a[8],h=a[1],d=a[5],p=a[9],u=a[2],A=a[6],m=a[10];if(Math.abs(l-h)<.01&&Math.abs(c-u)<.01&&Math.abs(p-A)<.01){if(Math.abs(l+h)<.1&&Math.abs(c+u)<.1&&Math.abs(p+A)<.1&&Math.abs(o+d+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const f=(o+1)/2,v=(d+1)/2,b=(m+1)/2,y=(l+h)/4,M=(c+u)/4,_=(p+A)/4;return f>v&&f>b?f<.01?(i=0,n=.707106781,s=.707106781):(i=Math.sqrt(f),n=y/i,s=M/i):v>b?v<.01?(i=.707106781,n=0,s=.707106781):(n=Math.sqrt(v),i=y/n,s=_/n):b<.01?(i=.707106781,n=.707106781,s=0):(s=Math.sqrt(b),i=M/s,n=_/s),this.set(i,n,s,t),this}let g=Math.sqrt((A-p)*(A-p)+(c-u)*(c-u)+(h-l)*(h-l));return Math.abs(g)<.001&&(g=1),this.x=(A-p)/g,this.y=(c-u)/g,this.z=(h-l)/g,this.w=Math.acos((o+d+m-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=Bt(this.x,e.x,t.x),this.y=Bt(this.y,e.y,t.y),this.z=Bt(this.z,e.z,t.z),this.w=Bt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Bt(this.x,e,t),this.y=Bt(this.y,e,t),this.z=Bt(this.z,e,t),this.w=Bt(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Bt(i,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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,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 gR extends Al{constructor(e=1,t=1,i={}){super(),i=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},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new xi(0,0,e,t),this.scissorTest=!1,this.viewport=new xi(0,0,e,t);const n={width:e,height:t,depth:i.depth},s=new pn(n);this.textures=[];const a=i.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.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 i=0;i<this.textures.length;i++)this.textures[i].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,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let n=0,s=this.textures.length;n<s;n++)this.textures[n].image.width=e,this.textures[n].image.height=t,this.textures[n].image.depth=i,this.textures[n].isData3DTexture!==!0&&(this.textures[n].isArrayTexture=this.textures[n].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,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const n=Object.assign({},e.textures[t].image);this.textures[t].source=new a0(n)}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 Wa extends gR{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class uy extends pn{constructor(e=null,t=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:n},this.magFilter=kn,this.minFilter=kn,this.wrapR=Js,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class AR extends pn{constructor(e=null,t=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:n},this.magFilter=kn,this.minFilter=kn,this.wrapR=Js,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class lh{constructor(e=new De(1/0,1/0,1/0),t=new De(-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,i=e.length;t<i;t+=3)this.expandByPoint(hs.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(hs.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=hs.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),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 i=e.geometry;if(i!==void 0){const s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,hs):hs.fromBufferAttribute(s,a),hs.applyMatrix4(e.matrixWorld),this.expandByPoint(hs);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),cp.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),cp.copy(i.boundingBox)),cp.applyMatrix4(e.matrixWorld),this.union(cp)}const n=e.children;for(let s=0,a=n.length;s<a;s++)this.expandByObject(n[s],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,hs),hs.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ch),hp.subVectors(this.max,ch),yl.subVectors(e.a,ch),xl.subVectors(e.b,ch),_l.subVectors(e.c,ch),Qr.subVectors(xl,yl),Wr.subVectors(_l,xl),ja.subVectors(yl,_l);let t=[0,-Qr.z,Qr.y,0,-Wr.z,Wr.y,0,-ja.z,ja.y,Qr.z,0,-Qr.x,Wr.z,0,-Wr.x,ja.z,0,-ja.x,-Qr.y,Qr.x,0,-Wr.y,Wr.x,0,-ja.y,ja.x,0];return!c0(t,yl,xl,_l,hp)||(t=[1,0,0,0,1,0,0,0,1],!c0(t,yl,xl,_l,hp))?!1:(dp.crossVectors(Qr,Wr),t=[dp.x,dp.y,dp.z],c0(t,yl,xl,_l,hp))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,hs).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(hs).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:(ir[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ir[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ir[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ir[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ir[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ir[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ir[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ir[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ir),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 ir=[new De,new De,new De,new De,new De,new De,new De,new De],hs=new De,cp=new lh,yl=new De,xl=new De,_l=new De,Qr=new De,Wr=new De,ja=new De,ch=new De,hp=new De,dp=new De,qa=new De;function c0(r,e,t,i,n){for(let s=0,a=r.length-3;s<=a;s+=3){qa.fromArray(r,s);const o=n.x*Math.abs(qa.x)+n.y*Math.abs(qa.y)+n.z*Math.abs(qa.z),l=e.dot(qa),c=t.dot(qa),h=i.dot(qa);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const vR=new lh,hh=new De,h0=new De;class d0{constructor(e=new De,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 i=this.center;t!==void 0?i.copy(t):vR.setFromPoints(e).getCenter(i);let n=0;for(let s=0,a=e.length;s<a;s++)n=Math.max(n,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(n),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 i=this.center.distanceToSquared(e);return t.copy(e),i>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;hh.subVectors(e,this.center);const t=hh.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),n=(i-this.radius)*.5;this.center.addScaledVector(hh,n/i),this.radius+=n}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):(h0.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(hh.copy(e.center).add(h0)),this.expandByPoint(hh.copy(e.center).sub(h0))),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 nr=new De,u0=new De,up=new De,jr=new De,p0=new De,pp=new De,f0=new De;class bR{constructor(e=new De,t=new De(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,nr)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=nr.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(nr.copy(this.origin).addScaledVector(this.direction,t),nr.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){u0.copy(e).add(t).multiplyScalar(.5),up.copy(t).sub(e).normalize(),jr.copy(this.origin).sub(u0);const s=e.distanceTo(t)*.5,a=-this.direction.dot(up),o=jr.dot(this.direction),l=-jr.dot(up),c=jr.lengthSq(),h=Math.abs(1-a*a);let d,p,u,A;if(h>0)if(d=a*l-o,p=a*o-l,A=s*h,d>=0)if(p>=-A)if(p<=A){const m=1/h;d*=m,p*=m,u=d*(d+a*p+2*o)+p*(a*d+p+2*l)+c}else p=s,d=Math.max(0,-(a*p+o)),u=-d*d+p*(p+2*l)+c;else p=-s,d=Math.max(0,-(a*p+o)),u=-d*d+p*(p+2*l)+c;else p<=-A?(d=Math.max(0,-(-a*s+o)),p=d>0?-s:Math.min(Math.max(-s,-l),s),u=-d*d+p*(p+2*l)+c):p<=A?(d=0,p=Math.min(Math.max(-s,-l),s),u=p*(p+2*l)+c):(d=Math.max(0,-(a*s+o)),p=d>0?s:Math.min(Math.max(-s,-l),s),u=-d*d+p*(p+2*l)+c);else p=a>0?-s:s,d=Math.max(0,-(a*p+o)),u=-d*d+p*(p+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),n&&n.copy(u0).addScaledVector(up,p),u}intersectSphere(e,t){nr.subVectors(e.center,this.origin);const i=nr.dot(this.direction),n=nr.dot(nr)-i*i,s=e.radius*e.radius;if(n>s)return null;const a=Math.sqrt(s-n),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,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 i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,n,s,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,p=this.origin;return c>=0?(i=(e.min.x-p.x)*c,n=(e.max.x-p.x)*c):(i=(e.max.x-p.x)*c,n=(e.min.x-p.x)*c),h>=0?(s=(e.min.y-p.y)*h,a=(e.max.y-p.y)*h):(s=(e.max.y-p.y)*h,a=(e.min.y-p.y)*h),i>a||s>n||((s>i||isNaN(i))&&(i=s),(a<n||isNaN(n))&&(n=a),d>=0?(o=(e.min.z-p.z)*d,l=(e.max.z-p.z)*d):(o=(e.max.z-p.z)*d,l=(e.min.z-p.z)*d),i>l||o>n)||((o>i||i!==i)&&(i=o),(l<n||n!==n)&&(n=l),n<0)?null:this.at(i>=0?i:n,t)}intersectsBox(e){return this.intersectBox(e,nr)!==null}intersectTriangle(e,t,i,n,s){p0.subVectors(t,e),pp.subVectors(i,e),f0.crossVectors(p0,pp);let a=this.direction.dot(f0),o;if(a>0){if(n)return null;o=1}else if(a<0)o=-1,a=-a;else return null;jr.subVectors(this.origin,e);const l=o*this.direction.dot(pp.crossVectors(jr,pp));if(l<0)return null;const c=o*this.direction.dot(p0.cross(jr));if(c<0||l+c>a)return null;const h=-o*jr.dot(f0);return h<0?null:this.at(h/a,s)}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 Ui{constructor(e,t,i,n,s,a,o,l,c,h,d,p,u,A,m,g){Ui.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,i,n,s,a,o,l,c,h,d,p,u,A,m,g)}set(e,t,i,n,s,a,o,l,c,h,d,p,u,A,m,g){const f=this.elements;return f[0]=e,f[4]=t,f[8]=i,f[12]=n,f[1]=s,f[5]=a,f[9]=o,f[13]=l,f[2]=c,f[6]=h,f[10]=d,f[14]=p,f[3]=u,f[7]=A,f[11]=m,f[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ui().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[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,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,n=1/El.setFromMatrixColumn(e,0).length(),s=1/El.setFromMatrixColumn(e,1).length(),a=1/El.setFromMatrixColumn(e,2).length();return t[0]=i[0]*n,t[1]=i[1]*n,t[2]=i[2]*n,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,n=e.y,s=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(n),c=Math.sin(n),h=Math.cos(s),d=Math.sin(s);if(e.order==="XYZ"){const p=a*h,u=a*d,A=o*h,m=o*d;t[0]=l*h,t[4]=-l*d,t[8]=c,t[1]=u+A*c,t[5]=p-m*c,t[9]=-o*l,t[2]=m-p*c,t[6]=A+u*c,t[10]=a*l}else if(e.order==="YXZ"){const p=l*h,u=l*d,A=c*h,m=c*d;t[0]=p+m*o,t[4]=A*o-u,t[8]=a*c,t[1]=a*d,t[5]=a*h,t[9]=-o,t[2]=u*o-A,t[6]=m+p*o,t[10]=a*l}else if(e.order==="ZXY"){const p=l*h,u=l*d,A=c*h,m=c*d;t[0]=p-m*o,t[4]=-a*d,t[8]=A+u*o,t[1]=u+A*o,t[5]=a*h,t[9]=m-p*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const p=a*h,u=a*d,A=o*h,m=o*d;t[0]=l*h,t[4]=A*c-u,t[8]=p*c+m,t[1]=l*d,t[5]=m*c+p,t[9]=u*c-A,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const p=a*l,u=a*c,A=o*l,m=o*c;t[0]=l*h,t[4]=m-p*d,t[8]=A*d+u,t[1]=d,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=u*d+A,t[10]=p-m*d}else if(e.order==="XZY"){const p=a*l,u=a*c,A=o*l,m=o*c;t[0]=l*h,t[4]=-d,t[8]=c*h,t[1]=p*d+m,t[5]=a*h,t[9]=u*d-A,t[2]=A*d-u,t[6]=o*h,t[10]=m*d+p}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(yR,e,xR)}lookAt(e,t,i){const n=this.elements;return Un.subVectors(e,t),Un.lengthSq()===0&&(Un.z=1),Un.normalize(),qr.crossVectors(i,Un),qr.lengthSq()===0&&(Math.abs(i.z)===1?Un.x+=1e-4:Un.z+=1e-4,Un.normalize(),qr.crossVectors(i,Un)),qr.normalize(),fp.crossVectors(Un,qr),n[0]=qr.x,n[4]=fp.x,n[8]=Un.x,n[1]=qr.y,n[5]=fp.y,n[9]=Un.y,n[2]=qr.z,n[6]=fp.z,n[10]=Un.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,s=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],h=i[1],d=i[5],p=i[9],u=i[13],A=i[2],m=i[6],g=i[10],f=i[14],v=i[3],b=i[7],y=i[11],M=i[15],_=n[0],S=n[4],w=n[8],E=n[12],I=n[1],B=n[5],R=n[9],U=n[13],C=n[2],F=n[6],O=n[10],H=n[14],j=n[3],G=n[7],re=n[11],q=n[15];return s[0]=a*_+o*I+l*C+c*j,s[4]=a*S+o*B+l*F+c*G,s[8]=a*w+o*R+l*O+c*re,s[12]=a*E+o*U+l*H+c*q,s[1]=h*_+d*I+p*C+u*j,s[5]=h*S+d*B+p*F+u*G,s[9]=h*w+d*R+p*O+u*re,s[13]=h*E+d*U+p*H+u*q,s[2]=A*_+m*I+g*C+f*j,s[6]=A*S+m*B+g*F+f*G,s[10]=A*w+m*R+g*O+f*re,s[14]=A*E+m*U+g*H+f*q,s[3]=v*_+b*I+y*C+M*j,s[7]=v*S+b*B+y*F+M*G,s[11]=v*w+b*R+y*O+M*re,s[15]=v*E+b*U+y*H+M*q,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],i=e[4],n=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],d=e[6],p=e[10],u=e[14],A=e[3],m=e[7],g=e[11],f=e[15];return A*(+s*l*d-n*c*d-s*o*p+i*c*p+n*o*u-i*l*u)+m*(+t*l*u-t*c*p+s*a*p-n*a*u+n*c*h-s*l*h)+g*(+t*c*d-t*o*u-s*a*d+i*a*u+s*o*h-i*c*h)+f*(-n*o*h-t*l*d+t*o*p+n*a*d-i*a*p+i*l*h)}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,i){const n=this.elements;return e.isVector3?(n[12]=e.x,n[13]=e.y,n[14]=e.z):(n[12]=e,n[13]=t,n[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=e[9],p=e[10],u=e[11],A=e[12],m=e[13],g=e[14],f=e[15],v=d*g*c-m*p*c+m*l*u-o*g*u-d*l*f+o*p*f,b=A*p*c-h*g*c-A*l*u+a*g*u+h*l*f-a*p*f,y=h*m*c-A*d*c+A*o*u-a*m*u-h*o*f+a*d*f,M=A*d*l-h*m*l-A*o*p+a*m*p+h*o*g-a*d*g,_=t*v+i*b+n*y+s*M;if(_===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const S=1/_;return e[0]=v*S,e[1]=(m*p*s-d*g*s-m*n*u+i*g*u+d*n*f-i*p*f)*S,e[2]=(o*g*s-m*l*s+m*n*c-i*g*c-o*n*f+i*l*f)*S,e[3]=(d*l*s-o*p*s-d*n*c+i*p*c+o*n*u-i*l*u)*S,e[4]=b*S,e[5]=(h*g*s-A*p*s+A*n*u-t*g*u-h*n*f+t*p*f)*S,e[6]=(A*l*s-a*g*s-A*n*c+t*g*c+a*n*f-t*l*f)*S,e[7]=(a*p*s-h*l*s+h*n*c-t*p*c-a*n*u+t*l*u)*S,e[8]=y*S,e[9]=(A*d*s-h*m*s-A*i*u+t*m*u+h*i*f-t*d*f)*S,e[10]=(a*m*s-A*o*s+A*i*c-t*m*c-a*i*f+t*o*f)*S,e[11]=(h*o*s-a*d*s-h*i*c+t*d*c+a*i*u-t*o*u)*S,e[12]=M*S,e[13]=(h*m*n-A*d*n+A*i*p-t*m*p-h*i*g+t*d*g)*S,e[14]=(A*o*n-a*m*n-A*i*l+t*m*l+a*i*g-t*o*g)*S,e[15]=(a*d*n-h*o*n+h*i*l-t*d*l-a*i*p+t*o*p)*S,this}scale(e){const t=this.elements,i=e.x,n=e.y,s=e.z;return t[0]*=i,t[4]*=n,t[8]*=s,t[1]*=i,t[5]*=n,t[9]*=s,t[2]*=i,t[6]*=n,t[10]*=s,t[3]*=i,t[7]*=n,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,n))}makeTranslation(e,t,i){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,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),n=Math.sin(t),s=1-i,a=e.x,o=e.y,l=e.z,c=s*a,h=s*o;return this.set(c*a+i,c*o-n*l,c*l+n*o,0,c*o+n*l,h*o+i,h*l-n*a,0,c*l-n*o,h*l+n*a,s*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,n,s,a){return this.set(1,i,s,0,e,1,a,0,t,n,1,0,0,0,0,1),this}compose(e,t,i){const n=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,h=a+a,d=o+o,p=s*c,u=s*h,A=s*d,m=a*h,g=a*d,f=o*d,v=l*c,b=l*h,y=l*d,M=i.x,_=i.y,S=i.z;return n[0]=(1-(m+f))*M,n[1]=(u+y)*M,n[2]=(A-b)*M,n[3]=0,n[4]=(u-y)*_,n[5]=(1-(p+f))*_,n[6]=(g+v)*_,n[7]=0,n[8]=(A+b)*S,n[9]=(g-v)*S,n[10]=(1-(p+m))*S,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,this}decompose(e,t,i){const n=this.elements;let s=El.set(n[0],n[1],n[2]).length();const a=El.set(n[4],n[5],n[6]).length(),o=El.set(n[8],n[9],n[10]).length();this.determinant()<0&&(s=-s),e.x=n[12],e.y=n[13],e.z=n[14],ds.copy(this);const l=1/s,c=1/a,h=1/o;return ds.elements[0]*=l,ds.elements[1]*=l,ds.elements[2]*=l,ds.elements[4]*=c,ds.elements[5]*=c,ds.elements[6]*=c,ds.elements[8]*=h,ds.elements[9]*=h,ds.elements[10]*=h,t.setFromRotationMatrix(ds),i.x=s,i.y=a,i.z=o,this}makePerspective(e,t,i,n,s,a,o=Is,l=!1){const c=this.elements,h=2*s/(t-e),d=2*s/(i-n),p=(t+e)/(t-e),u=(i+n)/(i-n);let A,m;if(l)A=s/(a-s),m=a*s/(a-s);else if(o===Is)A=-(a+s)/(a-s),m=-2*a*s/(a-s);else if(o===op)A=-a/(a-s),m=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=p,c[12]=0,c[1]=0,c[5]=d,c[9]=u,c[13]=0,c[2]=0,c[6]=0,c[10]=A,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,n,s,a,o=Is,l=!1){const c=this.elements,h=2/(t-e),d=2/(i-n),p=-(t+e)/(t-e),u=-(i+n)/(i-n);let A,m;if(l)A=1/(a-s),m=a/(a-s);else if(o===Is)A=-2/(a-s),m=-(a+s)/(a-s);else if(o===op)A=-1/(a-s),m=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=p,c[1]=0,c[5]=d,c[9]=0,c[13]=u,c[2]=0,c[6]=0,c[10]=A,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let n=0;n<16;n++)if(t[n]!==i[n])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const El=new De,ds=new Ui,yR=new De(0,0,0),xR=new De(1,1,1),qr=new De,fp=new De,Un=new De,py=new Ui,fy=new oh;class Xa{constructor(e=0,t=0,i=0,n=Xa.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=n}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,i,n=this._order){return this._x=e,this._y=t,this._z=i,this._order=n,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,i=!0){const n=e.elements,s=n[0],a=n[4],o=n[8],l=n[1],c=n[5],h=n[9],d=n[2],p=n[6],u=n[10];switch(t){case"XYZ":this._y=Math.asin(Bt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,u),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(p,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Bt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,u),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(Bt(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-d,u),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Bt(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(p,u),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Bt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(o,u));break;case"XZY":this._z=Math.asin(-Bt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(p,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,u),this._y=0);break;default:At("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return py.makeRotationFromQuaternion(e),this.setFromRotationMatrix(py,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return fy.setFromEuler(this),this.setFromQuaternion(fy,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}}Xa.DEFAULT_ORDER="XYZ";class my{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 _R=0;const gy=new De,Ml=new oh,sr=new Ui,mp=new De,dh=new De,ER=new De,MR=new oh,Ay=new De(1,0,0),vy=new De(0,1,0),by=new De(0,0,1),yy={type:"added"},wR={type:"removed"},wl={type:"childadded",child:null},m0={type:"childremoved",child:null};class Kn extends Al{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:_R++}),this.uuid=rh(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Kn.DEFAULT_UP.clone();const e=new De,t=new Xa,i=new oh,n=new De(1,1,1);function s(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._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:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Ui},normalMatrix:{value:new xt}}),this.matrix=new Ui,this.matrixWorld=new Ui,this.matrixAutoUpdate=Kn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Kn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new my,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 Ml.setFromAxisAngle(e,t),this.quaternion.multiply(Ml),this}rotateOnWorldAxis(e,t){return Ml.setFromAxisAngle(e,t),this.quaternion.premultiply(Ml),this}rotateX(e){return this.rotateOnAxis(Ay,e)}rotateY(e){return this.rotateOnAxis(vy,e)}rotateZ(e){return this.rotateOnAxis(by,e)}translateOnAxis(e,t){return gy.copy(e).applyQuaternion(this.quaternion),this.position.add(gy.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Ay,e)}translateY(e){return this.translateOnAxis(vy,e)}translateZ(e){return this.translateOnAxis(by,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(sr.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?mp.copy(e):mp.set(e,t,i);const n=this.parent;this.updateWorldMatrix(!0,!1),dh.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?sr.lookAt(dh,mp,this.up):sr.lookAt(mp,dh,this.up),this.quaternion.setFromRotationMatrix(sr),n&&(sr.extractRotation(n.matrixWorld),Ml.setFromRotationMatrix(sr),this.quaternion.premultiply(Ml.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(yi("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(yy),wl.child=e,this.dispatchEvent(wl),wl.child=null):yi("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(wR),m0.child=e,this.dispatchEvent(m0),m0.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),sr.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),sr.multiply(e.parent.matrixWorld)),e.applyMatrix4(sr),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(yy),wl.child=e,this.dispatchEvent(wl),wl.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 i=0,n=this.children.length;i<n;i++){const s=this.children[i].getObjectByProperty(e,t);if(s!==void 0)return s}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const n=this.children;for(let s=0,a=n.length;s<a;s++)n[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(dh,e,ER),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(dh,MR,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 i=0,n=t.length;i<n;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].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 i=0,n=t.length;i<n;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.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 n=this.children;for(let s=0,a=n.length;s<a;s++)n[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),n.instanceInfo=this._instanceInfo.map(o=>({...o})),n.availableInstanceIds=this._availableInstanceIds.slice(),n.availableGeometryIds=this._availableGeometryIds.slice(),n.nextIndexStart=this._nextIndexStart,n.nextVertexStart=this._nextVertexStart,n.geometryCount=this._geometryCount,n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.matricesTexture=this._matricesTexture.toJSON(e),n.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(n.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(n.boundingBox=this.boundingBox.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const d=l[c];s(e.shapes,d)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));n.material=o}else n.material=s(e.materials,this.material);if(this.children.length>0){n.children=[];for(let o=0;o<this.children.length;o++)n.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){n.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];n.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),d=a(e.shapes),p=a(e.skeletons),u=a(e.animations),A=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),h.length>0&&(i.images=h),d.length>0&&(i.shapes=d),p.length>0&&(i.skeletons=p),u.length>0&&(i.animations=u),A.length>0&&(i.nodes=A)}return i.object=n,i;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}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 i=0;i<e.children.length;i++){const n=e.children[i];this.add(n.clone())}return this}}Kn.DEFAULT_UP=new De(0,1,0),Kn.DEFAULT_MATRIX_AUTO_UPDATE=!0,Kn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const us=new De,rr=new De,g0=new De,ar=new De,Sl=new De,Cl=new De,xy=new De,A0=new De,v0=new De,b0=new De,y0=new xi,x0=new xi,_0=new xi;class ps{constructor(e=new De,t=new De,i=new De){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,n){n.subVectors(i,t),us.subVectors(e,t),n.cross(us);const s=n.lengthSq();return s>0?n.multiplyScalar(1/Math.sqrt(s)):n.set(0,0,0)}static getBarycoord(e,t,i,n,s){us.subVectors(n,t),rr.subVectors(i,t),g0.subVectors(e,t);const a=us.dot(us),o=us.dot(rr),l=us.dot(g0),c=rr.dot(rr),h=rr.dot(g0),d=a*c-o*o;if(d===0)return s.set(0,0,0),null;const p=1/d,u=(c*l-o*h)*p,A=(a*h-o*l)*p;return s.set(1-u-A,A,u)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,ar)===null?!1:ar.x>=0&&ar.y>=0&&ar.x+ar.y<=1}static getInterpolation(e,t,i,n,s,a,o,l){return this.getBarycoord(e,t,i,n,ar)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,ar.x),l.addScaledVector(a,ar.y),l.addScaledVector(o,ar.z),l)}static getInterpolatedAttribute(e,t,i,n,s,a){return y0.setScalar(0),x0.setScalar(0),_0.setScalar(0),y0.fromBufferAttribute(e,t),x0.fromBufferAttribute(e,i),_0.fromBufferAttribute(e,n),a.setScalar(0),a.addScaledVector(y0,s.x),a.addScaledVector(x0,s.y),a.addScaledVector(_0,s.z),a}static isFrontFacing(e,t,i,n){return us.subVectors(i,t),rr.subVectors(e,t),us.cross(rr).dot(n)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,n){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[n]),this}setFromAttributeAndIndices(e,t,i,n){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,n),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 us.subVectors(this.c,this.b),rr.subVectors(this.a,this.b),us.cross(rr).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ps.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return ps.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,n,s){return ps.getInterpolation(e,this.a,this.b,this.c,t,i,n,s)}containsPoint(e){return ps.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ps.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,n=this.b,s=this.c;let a,o;Sl.subVectors(n,i),Cl.subVectors(s,i),A0.subVectors(e,i);const l=Sl.dot(A0),c=Cl.dot(A0);if(l<=0&&c<=0)return t.copy(i);v0.subVectors(e,n);const h=Sl.dot(v0),d=Cl.dot(v0);if(h>=0&&d<=h)return t.copy(n);const p=l*d-h*c;if(p<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(i).addScaledVector(Sl,a);b0.subVectors(e,s);const u=Sl.dot(b0),A=Cl.dot(b0);if(A>=0&&u<=A)return t.copy(s);const m=u*c-l*A;if(m<=0&&c>=0&&A<=0)return o=c/(c-A),t.copy(i).addScaledVector(Cl,o);const g=h*A-u*d;if(g<=0&&d-h>=0&&u-A>=0)return xy.subVectors(s,n),o=(d-h)/(d-h+(u-A)),t.copy(n).addScaledVector(xy,o);const f=1/(g+m+p);return a=m*f,o=p*f,t.copy(i).addScaledVector(Sl,a).addScaledVector(Cl,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const _y={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},Xr={h:0,s:0,l:0},gp={h:0,s:0,l:0};function E0(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}class jt{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const n=e;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Nn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Nt.colorSpaceToWorking(this,t),this}setRGB(e,t,i,n=Nt.workingColorSpace){return this.r=e,this.g=t,this.b=i,Nt.colorSpaceToWorking(this,n),this}setHSL(e,t,i,n=Nt.workingColorSpace){if(e=dR(e,1),t=Bt(t,0,1),i=Bt(i,0,1),t===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+t):i+t-i*t,a=2*i-s;this.r=E0(a,s,e+1/3),this.g=E0(a,s,e),this.b=E0(a,s,e-1/3)}return Nt.colorSpaceToWorking(this,n),this}setStyle(e,t=Nn){function i(s){s!==void 0&&parseFloat(s)<1&&At("Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=n[1],o=n[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:At("Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=n[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);At("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Nn){const i=_y[e.toLowerCase()];return i!==void 0?this.setHex(i,t):At("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=tr(e.r),this.g=tr(e.g),this.b=tr(e.b),this}copyLinearToSRGB(e){return this.r=vl(e.r),this.g=vl(e.g),this.b=vl(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Nn){return Nt.workingToColorSpace(rn.copy(this),e),Math.round(Bt(rn.r*255,0,255))*65536+Math.round(Bt(rn.g*255,0,255))*256+Math.round(Bt(rn.b*255,0,255))}getHexString(e=Nn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Nt.workingColorSpace){Nt.workingToColorSpace(rn.copy(this),t);const i=rn.r,n=rn.g,s=rn.b,a=Math.max(i,n,s),o=Math.min(i,n,s);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=h<=.5?d/(a+o):d/(2-a-o),a){case i:l=(n-s)/d+(n<s?6:0);break;case n:l=(s-i)/d+2;break;case s:l=(i-n)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Nt.workingColorSpace){return Nt.workingToColorSpace(rn.copy(this),t),e.r=rn.r,e.g=rn.g,e.b=rn.b,e}getStyle(e=Nn){Nt.workingToColorSpace(rn.copy(this),e);const t=rn.r,i=rn.g,n=rn.b;return e!==Nn?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(n*255)})`}offsetHSL(e,t,i){return this.getHSL(Xr),this.setHSL(Xr.h+e,Xr.s+t,Xr.l+i)}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,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(Xr),e.getHSL(gp);const i=n0(Xr.h,gp.h,t),n=n0(Xr.s,gp.s,t),s=n0(Xr.l,gp.l,t);return this.setHSL(i,n,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,n=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*n,this.g=s[1]*t+s[4]*i+s[7]*n,this.b=s[2]*t+s[5]*i+s[8]*n,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 rn=new jt;jt.NAMES=_y;let SR=0;class Ap extends Al{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:SR++}),this.uuid=rh(),this.name="",this.type="Material",this.blending=hl,this.side=Hr,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ag,this.blendDst=og,this.blendEquation=Ga,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new jt(0,0,0),this.blendAlpha=0,this.depthFunc=dl,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=iy,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=gl,this.stencilZFail=gl,this.stencilZPass=gl,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 i=e[t];if(i===void 0){At(`Material: parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){At(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==hl&&(i.blending=this.blending),this.side!==Hr&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==ag&&(i.blendSrc=this.blendSrc),this.blendDst!==og&&(i.blendDst=this.blendDst),this.blendEquation!==Ga&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==dl&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==iy&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==gl&&(i.stencilFail=this.stencilFail),this.stencilZFail!==gl&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==gl&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function n(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=n(e.textures),a=n(e.images);s.length>0&&(i.textures=s),a.length>0&&(i.images=a)}return i}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 i=null;if(t!==null){const n=t.length;i=new Array(n);for(let s=0;s!==n;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,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 Ey extends Ap{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new jt(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 Xa,this.combine=q1,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 Si=new De,vp=new Wt;let CR=0;class Ps{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:CR++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=sy,this.updateRanges=[],this.gpuType=er,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,i){e*=this.itemSize,i*=t.itemSize;for(let n=0,s=this.itemSize;n<s;n++)this.array[e+n]=t.array[i+n];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)vp.fromBufferAttribute(this,t),vp.applyMatrix3(e),this.setXY(t,vp.x,vp.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Si.fromBufferAttribute(this,t),Si.applyMatrix3(e),this.setXYZ(t,Si.x,Si.y,Si.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Si.fromBufferAttribute(this,t),Si.applyMatrix4(e),this.setXYZ(t,Si.x,Si.y,Si.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Si.fromBufferAttribute(this,t),Si.applyNormalMatrix(e),this.setXYZ(t,Si.x,Si.y,Si.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Si.fromBufferAttribute(this,t),Si.transformDirection(e),this.setXYZ(t,Si.x,Si.y,Si.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=ah(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=_n(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=ah(t,this.array)),t}setX(e,t){return this.normalized&&(t=_n(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=ah(t,this.array)),t}setY(e,t){return this.normalized&&(t=_n(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=ah(t,this.array)),t}setZ(e,t){return this.normalized&&(t=_n(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=ah(t,this.array)),t}setW(e,t){return this.normalized&&(t=_n(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=_n(t,this.array),i=_n(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,n){return e*=this.itemSize,this.normalized&&(t=_n(t,this.array),i=_n(i,this.array),n=_n(n,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this}setXYZW(e,t,i,n,s){return e*=this.itemSize,this.normalized&&(t=_n(t,this.array),i=_n(i,this.array),n=_n(n,this.array),s=_n(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this.array[e+3]=s,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!==sy&&(e.usage=this.usage),e}}class My extends Ps{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class wy extends Ps{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class Ya extends Ps{constructor(e,t,i){super(new Float32Array(e),t,i)}}let TR=0;const Zn=new Ui,M0=new Kn,Tl=new De,Fn=new lh,uh=new lh,Wi=new De;class Yr extends Al{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:TR++}),this.uuid=rh(),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(ay(e)?wy:My)(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,i=0){this.groups.push({start:e,count:t,materialIndex:i})}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 i=this.attributes.normal;if(i!==void 0){const s=new xt().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Zn.makeRotationFromQuaternion(e),this.applyMatrix4(Zn),this}rotateX(e){return Zn.makeRotationX(e),this.applyMatrix4(Zn),this}rotateY(e){return Zn.makeRotationY(e),this.applyMatrix4(Zn),this}rotateZ(e){return Zn.makeRotationZ(e),this.applyMatrix4(Zn),this}translate(e,t,i){return Zn.makeTranslation(e,t,i),this.applyMatrix4(Zn),this}scale(e,t,i){return Zn.makeScale(e,t,i),this.applyMatrix4(Zn),this}lookAt(e){return M0.lookAt(e),M0.updateMatrix(),this.applyMatrix4(M0.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Tl).negate(),this.translate(Tl.x,Tl.y,Tl.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let n=0,s=e.length;n<s;n++){const a=e[n];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Ya(i,3))}else{const i=Math.min(e.length,t.count);for(let n=0;n<i;n++){const s=e[n];t.setXYZ(n,s.x,s.y,s.z||0)}e.length>t.count&&At("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 lh);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){yi("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new De(-1/0,-1/0,-1/0),new De(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,n=t.length;i<n;i++){const s=t[i];Fn.setFromBufferAttribute(s),this.morphTargetsRelative?(Wi.addVectors(this.boundingBox.min,Fn.min),this.boundingBox.expandByPoint(Wi),Wi.addVectors(this.boundingBox.max,Fn.max),this.boundingBox.expandByPoint(Wi)):(this.boundingBox.expandByPoint(Fn.min),this.boundingBox.expandByPoint(Fn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&yi('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 d0);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){yi("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new De,1/0);return}if(e){const i=this.boundingSphere.center;if(Fn.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];uh.setFromBufferAttribute(o),this.morphTargetsRelative?(Wi.addVectors(Fn.min,uh.min),Fn.expandByPoint(Wi),Wi.addVectors(Fn.max,uh.max),Fn.expandByPoint(Wi)):(Fn.expandByPoint(uh.min),Fn.expandByPoint(uh.max))}Fn.getCenter(i);let n=0;for(let s=0,a=e.count;s<a;s++)Wi.fromBufferAttribute(e,s),n=Math.max(n,i.distanceToSquared(Wi));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)Wi.fromBufferAttribute(o,c),l&&(Tl.fromBufferAttribute(e,c),Wi.add(Tl)),n=Math.max(n,i.distanceToSquared(Wi))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&yi('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){yi("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,n=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ps(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let w=0;w<i.count;w++)o[w]=new De,l[w]=new De;const c=new De,h=new De,d=new De,p=new Wt,u=new Wt,A=new Wt,m=new De,g=new De;function f(w,E,I){c.fromBufferAttribute(i,w),h.fromBufferAttribute(i,E),d.fromBufferAttribute(i,I),p.fromBufferAttribute(s,w),u.fromBufferAttribute(s,E),A.fromBufferAttribute(s,I),h.sub(c),d.sub(c),u.sub(p),A.sub(p);const B=1/(u.x*A.y-A.x*u.y);isFinite(B)&&(m.copy(h).multiplyScalar(A.y).addScaledVector(d,-u.y).multiplyScalar(B),g.copy(d).multiplyScalar(u.x).addScaledVector(h,-A.x).multiplyScalar(B),o[w].add(m),o[E].add(m),o[I].add(m),l[w].add(g),l[E].add(g),l[I].add(g))}let v=this.groups;v.length===0&&(v=[{start:0,count:e.count}]);for(let w=0,E=v.length;w<E;++w){const I=v[w],B=I.start,R=I.count;for(let U=B,C=B+R;U<C;U+=3)f(e.getX(U+0),e.getX(U+1),e.getX(U+2))}const b=new De,y=new De,M=new De,_=new De;function S(w){M.fromBufferAttribute(n,w),_.copy(M);const E=o[w];b.copy(E),b.sub(M.multiplyScalar(M.dot(E))).normalize(),y.crossVectors(_,E);const I=y.dot(l[w])<0?-1:1;a.setXYZW(w,b.x,b.y,b.z,I)}for(let w=0,E=v.length;w<E;++w){const I=v[w],B=I.start,R=I.count;for(let U=B,C=B+R;U<C;U+=3)S(e.getX(U+0)),S(e.getX(U+1)),S(e.getX(U+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Ps(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let p=0,u=i.count;p<u;p++)i.setXYZ(p,0,0,0);const n=new De,s=new De,a=new De,o=new De,l=new De,c=new De,h=new De,d=new De;if(e)for(let p=0,u=e.count;p<u;p+=3){const A=e.getX(p+0),m=e.getX(p+1),g=e.getX(p+2);n.fromBufferAttribute(t,A),s.fromBufferAttribute(t,m),a.fromBufferAttribute(t,g),h.subVectors(a,s),d.subVectors(n,s),h.cross(d),o.fromBufferAttribute(i,A),l.fromBufferAttribute(i,m),c.fromBufferAttribute(i,g),o.add(h),l.add(h),c.add(h),i.setXYZ(A,o.x,o.y,o.z),i.setXYZ(m,l.x,l.y,l.z),i.setXYZ(g,c.x,c.y,c.z)}else for(let p=0,u=t.count;p<u;p+=3)n.fromBufferAttribute(t,p+0),s.fromBufferAttribute(t,p+1),a.fromBufferAttribute(t,p+2),h.subVectors(a,s),d.subVectors(n,s),h.cross(d),i.setXYZ(p+0,h.x,h.y,h.z),i.setXYZ(p+1,h.x,h.y,h.z),i.setXYZ(p+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Wi.fromBufferAttribute(e,t),Wi.normalize(),e.setXYZ(t,Wi.x,Wi.y,Wi.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,d=o.normalized,p=new c.constructor(l.length*h);let u=0,A=0;for(let m=0,g=l.length;m<g;m++){o.isInterleavedBufferAttribute?u=l[m]*o.data.stride+o.offset:u=l[m]*h;for(let f=0;f<h;f++)p[A++]=c[u++]}return new Ps(p,h,d)}if(this.index===null)return At("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Yr,i=this.index.array,n=this.attributes;for(const o in n){const l=n[o],c=e(l,i);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let h=0,d=c.length;h<d;h++){const p=c[h],u=e(p,i);l.push(u)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.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 l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);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 i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const n={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let d=0,p=c.length;d<p;d++){const u=c[d];h.push(u.toJSON(e.data))}h.length>0&&(n[l]=h,s=!0)}s&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.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 i=e.index;i!==null&&this.setIndex(i.clone());const n=e.attributes;for(const c in n){const h=n[c];this.setAttribute(c,h.clone(t))}const s=e.morphAttributes;for(const c in s){const h=[],d=s[c];for(let p=0,u=d.length;p<u;p++)h.push(d[p].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,h=a.length;c<h;c++){const d=a[c];this.addGroup(d.start,d.count,d.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Sy=new Ui,Ka=new bR,bp=new d0,Cy=new De,yp=new De,xp=new De,_p=new De,w0=new De,Ep=new De,Ty=new De,Mp=new De;class Kr extends Kn{constructor(e=new Yr,t=new Ey){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 e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,s=i.length;n<s;n++){const a=i[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=n}}}}getVertexPosition(e,t){const i=this.geometry,n=i.attributes.position,s=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(n,e);const o=this.morphTargetInfluences;if(s&&o){Ep.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=o[l],d=s[l];h!==0&&(w0.fromBufferAttribute(d,e),a?Ep.addScaledVector(w0,h):Ep.addScaledVector(w0.sub(t),h))}t.add(Ep)}return t}raycast(e,t){const i=this.geometry,n=this.material,s=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),bp.copy(i.boundingSphere),bp.applyMatrix4(s),Ka.copy(e.ray).recast(e.near),!(bp.containsPoint(Ka.origin)===!1&&(Ka.intersectSphere(bp,Cy)===null||Ka.origin.distanceToSquared(Cy)>(e.far-e.near)**2))&&(Sy.copy(s).invert(),Ka.copy(e.ray).applyMatrix4(Sy),!(i.boundingBox!==null&&Ka.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Ka)))}_computeIntersections(e,t,i){let n;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,d=s.attributes.normal,p=s.groups,u=s.drawRange;if(o!==null)if(Array.isArray(a))for(let A=0,m=p.length;A<m;A++){const g=p[A],f=a[g.materialIndex],v=Math.max(g.start,u.start),b=Math.min(o.count,Math.min(g.start+g.count,u.start+u.count));for(let y=v,M=b;y<M;y+=3){const _=o.getX(y),S=o.getX(y+1),w=o.getX(y+2);n=wp(this,f,e,i,c,h,d,_,S,w),n&&(n.faceIndex=Math.floor(y/3),n.face.materialIndex=g.materialIndex,t.push(n))}}else{const A=Math.max(0,u.start),m=Math.min(o.count,u.start+u.count);for(let g=A,f=m;g<f;g+=3){const v=o.getX(g),b=o.getX(g+1),y=o.getX(g+2);n=wp(this,a,e,i,c,h,d,v,b,y),n&&(n.faceIndex=Math.floor(g/3),t.push(n))}}else if(l!==void 0)if(Array.isArray(a))for(let A=0,m=p.length;A<m;A++){const g=p[A],f=a[g.materialIndex],v=Math.max(g.start,u.start),b=Math.min(l.count,Math.min(g.start+g.count,u.start+u.count));for(let y=v,M=b;y<M;y+=3){const _=y,S=y+1,w=y+2;n=wp(this,f,e,i,c,h,d,_,S,w),n&&(n.faceIndex=Math.floor(y/3),n.face.materialIndex=g.materialIndex,t.push(n))}}else{const A=Math.max(0,u.start),m=Math.min(l.count,u.start+u.count);for(let g=A,f=m;g<f;g+=3){const v=g,b=g+1,y=g+2;n=wp(this,a,e,i,c,h,d,v,b,y),n&&(n.faceIndex=Math.floor(g/3),t.push(n))}}}}function IR(r,e,t,i,n,s,a,o){let l;if(e.side===xn?l=i.intersectTriangle(a,s,n,!0,o):l=i.intersectTriangle(n,s,a,e.side===Hr,o),l===null)return null;Mp.copy(o),Mp.applyMatrix4(r.matrixWorld);const c=t.ray.origin.distanceTo(Mp);return c<t.near||c>t.far?null:{distance:c,point:Mp.clone(),object:r}}function wp(r,e,t,i,n,s,a,o,l,c){r.getVertexPosition(o,yp),r.getVertexPosition(l,xp),r.getVertexPosition(c,_p);const h=IR(r,e,t,i,yp,xp,_p,Ty);if(h){const d=new De;ps.getBarycoord(Ty,yp,xp,_p,d),n&&(h.uv=ps.getInterpolatedAttribute(n,o,l,c,d,new Wt)),s&&(h.uv1=ps.getInterpolatedAttribute(s,o,l,c,d,new Wt)),a&&(h.normal=ps.getInterpolatedAttribute(a,o,l,c,d,new De),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const p={a:o,b:l,c,normal:new De,materialIndex:0};ps.getNormal(yp,xp,_p,p.normal),h.face=p,h.barycoord=d}return h}class ph extends Yr{constructor(e=1,t=1,i=1,n=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:n,heightSegments:s,depthSegments:a};const o=this;n=Math.floor(n),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],h=[],d=[];let p=0,u=0;A("z","y","x",-1,-1,i,t,e,a,s,0),A("z","y","x",1,-1,i,t,-e,a,s,1),A("x","z","y",1,1,e,i,t,n,a,2),A("x","z","y",1,-1,e,i,-t,n,a,3),A("x","y","z",1,-1,e,t,i,n,s,4),A("x","y","z",-1,-1,e,t,-i,n,s,5),this.setIndex(l),this.setAttribute("position",new Ya(c,3)),this.setAttribute("normal",new Ya(h,3)),this.setAttribute("uv",new Ya(d,2));function A(m,g,f,v,b,y,M,_,S,w,E){const I=y/S,B=M/w,R=y/2,U=M/2,C=_/2,F=S+1,O=w+1;let H=0,j=0;const G=new De;for(let re=0;re<O;re++){const q=re*B-U;for(let Y=0;Y<F;Y++){const ye=Y*I-R;G[m]=ye*v,G[g]=q*b,G[f]=C,c.push(G.x,G.y,G.z),G[m]=0,G[g]=0,G[f]=_>0?1:-1,h.push(G.x,G.y,G.z),d.push(Y/S),d.push(1-re/w),H+=1}}for(let re=0;re<w;re++)for(let q=0;q<S;q++){const Y=p+q+F*re,ye=p+q+F*(re+1),Me=p+(q+1)+F*(re+1),xe=p+(q+1)+F*re;l.push(Y,ye,xe),l.push(ye,Me,xe),j+=6}o.addGroup(u,j,E),u+=j,p+=H}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ph(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Il(r){const e={};for(const t in r){e[t]={};for(const i in r[t]){const n=r[t][i];n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)?n.isRenderTargetTexture?(At("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=n.clone():Array.isArray(n)?e[t][i]=n.slice():e[t][i]=n}}return e}function fn(r){const e={};for(let t=0;t<r.length;t++){const i=Il(r[t]);for(const n in i)e[n]=i[n]}return e}function PR(r){const e=[];for(let t=0;t<r.length;t++)e.push(r[t].clone());return e}function Iy(r){const e=r.getRenderTarget();return e===null?r.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Nt.workingColorSpace}const RR={clone:Il,merge:fn};var DR=`void main() {
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,BR=`void main() {
|
||
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
||
}`;class or extends Ap{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=DR,this.fragmentShader=BR,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=Il(e.uniforms),this.uniformsGroups=PR(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 n in this.uniforms){const s=this.uniforms[n].value;s&&s.isTexture?t.uniforms[n]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?t.uniforms[n]={type:"c",value:s.getHex()}:s&&s.isVector2?t.uniforms[n]={type:"v2",value:s.toArray()}:s&&s.isVector3?t.uniforms[n]={type:"v3",value:s.toArray()}:s&&s.isVector4?t.uniforms[n]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?t.uniforms[n]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?t.uniforms[n]={type:"m4",value:s.toArray()}:t.uniforms[n]={value:s}}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 i={};for(const n in this.extensions)this.extensions[n]===!0&&(i[n]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class Py extends Kn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ui,this.projectionMatrix=new Ui,this.projectionMatrixInverse=new Ui,this.coordinateSystem=Is,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 Zr=new De,Ry=new Wt,Dy=new Wt;class fs extends Py{constructor(e=50,t=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,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=i0*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(t0*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return i0*2*Math.atan(Math.tan(t0*.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,i){Zr.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Zr.x,Zr.y).multiplyScalar(-e/Zr.z),Zr.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Zr.x,Zr.y).multiplyScalar(-e/Zr.z)}getViewSize(e,t){return this.getViewBounds(e,Ry,Dy),t.subVectors(Dy,Ry)}setViewOffset(e,t,i,n,s,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=i,this.view.offsetY=n,this.view.width=s,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(t0*.5*this.fov)/this.zoom,i=2*t,n=this.aspect*i,s=-.5*n;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*n/l,t-=a.offsetY*i/c,n*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+n,t,t-i,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 Pl=-90,Rl=1;class LR extends Kn{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new fs(Pl,Rl,e,t);n.layers=this.layers,this.add(n);const s=new fs(Pl,Rl,e,t);s.layers=this.layers,this.add(s);const a=new fs(Pl,Rl,e,t);a.layers=this.layers,this.add(a);const o=new fs(Pl,Rl,e,t);o.layers=this.layers,this.add(o);const l=new fs(Pl,Rl,e,t);l.layers=this.layers,this.add(l);const c=new fs(Pl,Rl,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,n,s,a,o,l]=t;for(const c of t)this.remove(c);if(e===Is)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===op)i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:n}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,h]=this.children,d=e.getRenderTarget(),p=e.getActiveCubeFace(),u=e.getActiveMipmapLevel(),A=e.xr.enabled;e.xr.enabled=!1;const m=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,n),e.render(t,s),e.setRenderTarget(i,1,n),e.render(t,a),e.setRenderTarget(i,2,n),e.render(t,o),e.setRenderTarget(i,3,n),e.render(t,l),e.setRenderTarget(i,4,n),e.render(t,c),i.texture.generateMipmaps=m,e.setRenderTarget(i,5,n),e.render(t,h),e.setRenderTarget(d,p,u),e.xr.enabled=A,i.texture.needsPMREMUpdate=!0}}class By extends pn{constructor(e=[],t=ul,i,n,s,a,o,l,c,h){super(e,t,i,n,s,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class kR extends Wa{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},n=[i,i,i,i,i,i];this.texture=new By(n),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 i={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 );
|
||
|
||
}
|
||
`},n=new ph(5,5,5),s=new or({name:"CubemapFromEquirect",uniforms:Il(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:xn,blending:Zs});s.uniforms.tEquirect.value=t;const a=new Kr(n,s),o=t.minFilter;return t.minFilter===Va&&(t.minFilter=Yn),new LR(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,n=!0){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,n);e.setRenderTarget(s)}}let Sp=class extends Kn{constructor(){super(),this.isGroup=!0,this.type="Group"}};const NR={type:"move"};class S0{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Sp,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 Sp,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new De,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new De),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Sp,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new De,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new De),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 i of e.hand.values())this._getHandJoint(t,i)}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,i){let n=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const m of e.hand.values()){const g=t.getJointPose(m,i),f=this._getHandJoint(c,m);g!==null&&(f.matrix.fromArray(g.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=g.radius),f.visible=g!==null}const h=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],p=h.position.distanceTo(d.position),u=.02,A=.005;c.inputState.pinching&&p>u+A?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&p<=u-A&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(n=t.getPose(e.targetRaySpace,i),n===null&&s!==null&&(n=s),n!==null&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,n.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(n.linearVelocity)):o.hasLinearVelocity=!1,n.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(n.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(NR)))}return o!==null&&(o.visible=n!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Sp;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class UR extends pn{constructor(e=null,t=1,i=1,n,s,a,o,l,c=kn,h=kn,d,p){super(null,a,o,l,c,h,n,s,d,p),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const C0=new De,FR=new De,OR=new xt;class Za{constructor(e=new De(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,i,n){return this.normal.set(e,t,i),this.constant=n,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const n=C0.subVectors(i,t).cross(FR.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(n,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 i=e.delta(C0),n=this.normal.dot(i);if(n===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/n;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<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 i=t||OR.getNormalMatrix(e),n=this.coplanarPoint(C0).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(s),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 Ja=new d0,zR=new Wt(.5,.5),Cp=new De;class Ly{constructor(e=new Za,t=new Za,i=new Za,n=new Za,s=new Za,a=new Za){this.planes=[e,t,i,n,s,a]}set(e,t,i,n,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(n),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Is,i=!1){const n=this.planes,s=e.elements,a=s[0],o=s[1],l=s[2],c=s[3],h=s[4],d=s[5],p=s[6],u=s[7],A=s[8],m=s[9],g=s[10],f=s[11],v=s[12],b=s[13],y=s[14],M=s[15];if(n[0].setComponents(c-a,u-h,f-A,M-v).normalize(),n[1].setComponents(c+a,u+h,f+A,M+v).normalize(),n[2].setComponents(c+o,u+d,f+m,M+b).normalize(),n[3].setComponents(c-o,u-d,f-m,M-b).normalize(),i)n[4].setComponents(l,p,g,y).normalize(),n[5].setComponents(c-l,u-p,f-g,M-y).normalize();else if(n[4].setComponents(c-l,u-p,f-g,M-y).normalize(),t===Is)n[5].setComponents(c+l,u+p,f+g,M+y).normalize();else if(t===op)n[5].setComponents(l,p,g,y).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(),Ja.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ja.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ja)}intersectsSprite(e){Ja.center.set(0,0,0);const t=zR.distanceTo(e.center);return Ja.radius=.7071067811865476+t,Ja.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ja)}intersectsSphere(e){const t=this.planes,i=e.center,n=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<n)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const n=t[i];if(Cp.x=n.normal.x>0?e.max.x:e.min.x,Cp.y=n.normal.y>0?e.max.y:e.min.y,Cp.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(Cp)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class ky extends pn{constructor(e,t,i=Qa,n,s,a,o=kn,l=kn,c,h=ih,d=1){if(h!==ih&&h!==nh)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const p={width:e,height:t,depth:d};super(p,n,s,a,o,l,h,i,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new a0(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 Ny extends pn{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Tp extends Yr{constructor(e=1,t=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:n};const s=e/2,a=t/2,o=Math.floor(i),l=Math.floor(n),c=o+1,h=l+1,d=e/o,p=t/l,u=[],A=[],m=[],g=[];for(let f=0;f<h;f++){const v=f*p-a;for(let b=0;b<c;b++){const y=b*d-s;A.push(y,-v,0),m.push(0,0,1),g.push(b/o),g.push(1-f/l)}}for(let f=0;f<l;f++)for(let v=0;v<o;v++){const b=v+c*f,y=v+c*(f+1),M=v+1+c*(f+1),_=v+1+c*f;u.push(b,y,_),u.push(y,M,_)}this.setIndex(u),this.setAttribute("position",new Ya(A,3)),this.setAttribute("normal",new Ya(m,3)),this.setAttribute("uv",new Ya(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Tp(e.width,e.height,e.widthSegments,e.heightSegments)}}class HR extends Ap{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=JP,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 GR extends Ap{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 VR extends Py{constructor(e=-1,t=1,i=1,n=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=s,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,i,n,s,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=i,this.view.offsetY=n,this.view.width=s,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),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let s=i-e,a=i+e,o=n+t,l=n-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,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 QR extends fs{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}function Uy(r,e,t,i){const n=WR(i);switch(t){case $1:return r*e;case ty:return r*e/n.components*n.byteLength;case Eg:return r*e/n.components*n.byteLength;case Mg:return r*e*2/n.components*n.byteLength;case wg:return r*e*2/n.components*n.byteLength;case ey:return r*e*3/n.components*n.byteLength;case cs:return r*e*4/n.components*n.byteLength;case Sg:return r*e*4/n.components*n.byteLength;case ip:case np:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case sp:case rp:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Tg:case Pg:return Math.max(r,16)*Math.max(e,8)/4;case Cg:case Ig:return Math.max(r,8)*Math.max(e,8)/2;case Rg:case Dg:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case Bg:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Lg:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case kg:return Math.floor((r+4)/5)*Math.floor((e+3)/4)*16;case Ng:return Math.floor((r+4)/5)*Math.floor((e+4)/5)*16;case Ug:return Math.floor((r+5)/6)*Math.floor((e+4)/5)*16;case Fg:return Math.floor((r+5)/6)*Math.floor((e+5)/6)*16;case Og:return Math.floor((r+7)/8)*Math.floor((e+4)/5)*16;case zg:return Math.floor((r+7)/8)*Math.floor((e+5)/6)*16;case Hg:return Math.floor((r+7)/8)*Math.floor((e+7)/8)*16;case Gg:return Math.floor((r+9)/10)*Math.floor((e+4)/5)*16;case Vg:return Math.floor((r+9)/10)*Math.floor((e+5)/6)*16;case Qg:return Math.floor((r+9)/10)*Math.floor((e+7)/8)*16;case Wg:return Math.floor((r+9)/10)*Math.floor((e+9)/10)*16;case jg:return Math.floor((r+11)/12)*Math.floor((e+9)/10)*16;case qg:return Math.floor((r+11)/12)*Math.floor((e+11)/12)*16;case Xg:case Yg:case Kg:return Math.ceil(r/4)*Math.ceil(e/4)*16;case Zg:case Jg:return Math.ceil(r/4)*Math.ceil(e/4)*8;case $g:case e0:return Math.ceil(r/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function WR(r){switch(r){case $s:case Y1:return{byteLength:1,components:1};case eh:case K1:case fl:return{byteLength:2,components:1};case xg:case _g:return{byteLength:2,components:4};case Qa:case yg:case er:return{byteLength:4,components:1};case Z1:case J1:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${r}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:rg}})),typeof window<"u"&&(window.__THREE__?At("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=rg);function Fy(){let r=null,e=!1,t=null,i=null;function n(s,a){t(s,a),i=r.requestAnimationFrame(n)}return{start:function(){e!==!0&&t!==null&&(i=r.requestAnimationFrame(n),e=!0)},stop:function(){r.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function jR(r){const e=new WeakMap;function t(o,l){const c=o.array,h=o.usage,d=c.byteLength,p=r.createBuffer();r.bindBuffer(l,p),r.bufferData(l,c,h),o.onUploadCallback();let u;if(c instanceof Float32Array)u=r.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)u=r.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?u=r.HALF_FLOAT:u=r.UNSIGNED_SHORT;else if(c instanceof Int16Array)u=r.SHORT;else if(c instanceof Uint32Array)u=r.UNSIGNED_INT;else if(c instanceof Int32Array)u=r.INT;else if(c instanceof Int8Array)u=r.BYTE;else if(c instanceof Uint8Array)u=r.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)u=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:p,type:u,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,c){const h=l.array,d=l.updateRanges;if(r.bindBuffer(c,o),d.length===0)r.bufferSubData(c,0,h);else{d.sort((u,A)=>u.start-A.start);let p=0;for(let u=1;u<d.length;u++){const A=d[p],m=d[u];m.start<=A.start+A.count+1?A.count=Math.max(A.count,m.start+m.count-A.start):(++p,d[p]=m)}d.length=p+1;for(let u=0,A=d.length;u<A;u++){const m=d[u];r.bufferSubData(c,m.start*h.BYTES_PER_ELEMENT,h,m.start,m.count)}l.clearUpdateRanges()}l.onUploadCallback()}function n(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(r.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=e.get(o);(!h||h.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.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.");i(c.buffer,o,l),c.version=o.version}}return{get:n,remove:s,update:a}}var qR=`#ifdef USE_ALPHAHASH
|
||
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
||
#endif`,XR=`#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`,YR=`#ifdef USE_ALPHAMAP
|
||
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
||
#endif`,KR=`#ifdef USE_ALPHAMAP
|
||
uniform sampler2D alphaMap;
|
||
#endif`,ZR=`#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`,JR=`#ifdef USE_ALPHATEST
|
||
uniform float alphaTest;
|
||
#endif`,$R=`#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`,e4=`#ifdef USE_AOMAP
|
||
uniform sampler2D aoMap;
|
||
uniform float aoMapIntensity;
|
||
#endif`,t4=`#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`,i4=`#ifdef USE_BATCHING
|
||
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
||
#endif`,n4=`vec3 transformed = vec3( position );
|
||
#ifdef USE_ALPHAHASH
|
||
vPosition = vec3( position );
|
||
#endif`,s4=`vec3 objectNormal = vec3( normal );
|
||
#ifdef USE_TANGENT
|
||
vec3 objectTangent = vec3( tangent.xyz );
|
||
#endif`,r4=`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`,a4=`#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`,o4=`#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`,l4=`#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`,c4=`#if NUM_CLIPPING_PLANES > 0
|
||
varying vec3 vClipPosition;
|
||
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
||
#endif`,h4=`#if NUM_CLIPPING_PLANES > 0
|
||
varying vec3 vClipPosition;
|
||
#endif`,d4=`#if NUM_CLIPPING_PLANES > 0
|
||
vClipPosition = - mvPosition.xyz;
|
||
#endif`,u4=`#if defined( USE_COLOR_ALPHA )
|
||
diffuseColor *= vColor;
|
||
#elif defined( USE_COLOR )
|
||
diffuseColor.rgb *= vColor;
|
||
#endif`,p4=`#if defined( USE_COLOR_ALPHA )
|
||
varying vec4 vColor;
|
||
#elif defined( USE_COLOR )
|
||
varying vec3 vColor;
|
||
#endif`,f4=`#if defined( USE_COLOR_ALPHA )
|
||
varying vec4 vColor;
|
||
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
||
varying vec3 vColor;
|
||
#endif`,m4=`#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`,g4=`#define PI 3.141592653589793
|
||
#define PI2 6.283185307179586
|
||
#define PI_HALF 1.5707963267948966
|
||
#define RECIPROCAL_PI 0.3183098861837907
|
||
#define RECIPROCAL_PI2 0.15915494309189535
|
||
#define EPSILON 1e-6
|
||
#ifndef saturate
|
||
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
||
#endif
|
||
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
|
||
float pow2( const in float x ) { return x*x; }
|
||
vec3 pow2( const in vec3 x ) { return x*x; }
|
||
float pow3( const in float x ) { return x*x*x; }
|
||
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
|
||
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
|
||
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
|
||
highp float rand( const in vec2 uv ) {
|
||
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
|
||
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
|
||
return fract( sin( sn ) * c );
|
||
}
|
||
#ifdef HIGH_PRECISION
|
||
float precisionSafeLength( vec3 v ) { return length( v ); }
|
||
#else
|
||
float precisionSafeLength( vec3 v ) {
|
||
float maxComponent = max3( abs( v ) );
|
||
return length( v / maxComponent ) * maxComponent;
|
||
}
|
||
#endif
|
||
struct IncidentLight {
|
||
vec3 color;
|
||
vec3 direction;
|
||
bool visible;
|
||
};
|
||
struct ReflectedLight {
|
||
vec3 directDiffuse;
|
||
vec3 directSpecular;
|
||
vec3 indirectDiffuse;
|
||
vec3 indirectSpecular;
|
||
};
|
||
#ifdef USE_ALPHAHASH
|
||
varying vec3 vPosition;
|
||
#endif
|
||
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
||
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
||
}
|
||
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
|
||
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
|
||
}
|
||
bool isPerspectiveMatrix( mat4 m ) {
|
||
return m[ 2 ][ 3 ] == - 1.0;
|
||
}
|
||
vec2 equirectUv( in vec3 dir ) {
|
||
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
|
||
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
|
||
return vec2( u, v );
|
||
}
|
||
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
|
||
return RECIPROCAL_PI * diffuseColor;
|
||
}
|
||
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
||
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
||
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
||
}
|
||
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
||
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
||
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
||
} // validated`,A4=`#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`,v4=`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`,b4=`#ifdef USE_DISPLACEMENTMAP
|
||
uniform sampler2D displacementMap;
|
||
uniform float displacementScale;
|
||
uniform float displacementBias;
|
||
#endif`,y4=`#ifdef USE_DISPLACEMENTMAP
|
||
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
||
#endif`,x4=`#ifdef USE_EMISSIVEMAP
|
||
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
||
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
||
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
||
#endif
|
||
totalEmissiveRadiance *= emissiveColor.rgb;
|
||
#endif`,_4=`#ifdef USE_EMISSIVEMAP
|
||
uniform sampler2D emissiveMap;
|
||
#endif`,E4="gl_FragColor = linearToOutputTexel( gl_FragColor );",M4=`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 );
|
||
}`,w4=`#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`,S4=`#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`,C4=`#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`,T4=`#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`,I4=`#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`,P4=`#ifdef USE_FOG
|
||
vFogDepth = - mvPosition.z;
|
||
#endif`,R4=`#ifdef USE_FOG
|
||
varying float vFogDepth;
|
||
#endif`,D4=`#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`,B4=`#ifdef USE_FOG
|
||
uniform vec3 fogColor;
|
||
varying float vFogDepth;
|
||
#ifdef FOG_EXP2
|
||
uniform float fogDensity;
|
||
#else
|
||
uniform float fogNear;
|
||
uniform float fogFar;
|
||
#endif
|
||
#endif`,L4=`#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
|
||
}`,k4=`#ifdef USE_LIGHTMAP
|
||
uniform sampler2D lightMap;
|
||
uniform float lightMapIntensity;
|
||
#endif`,N4=`LambertMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;
|
||
material.specularStrength = specularStrength;`,U4=`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`,F4=`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`,O4=`#ifdef USE_ENVMAP
|
||
vec3 getIBLIrradiance( const in vec3 normal ) {
|
||
#ifdef ENVMAP_TYPE_CUBE_UV
|
||
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
||
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
|
||
return PI * envMapColor.rgb * envMapIntensity;
|
||
#else
|
||
return vec3( 0.0 );
|
||
#endif
|
||
}
|
||
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
|
||
#ifdef ENVMAP_TYPE_CUBE_UV
|
||
vec3 reflectVec = reflect( - viewDir, normal );
|
||
reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
|
||
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
|
||
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
|
||
return envMapColor.rgb * envMapIntensity;
|
||
#else
|
||
return vec3( 0.0 );
|
||
#endif
|
||
}
|
||
#ifdef USE_ANISOTROPY
|
||
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
|
||
#ifdef ENVMAP_TYPE_CUBE_UV
|
||
vec3 bentNormal = cross( bitangent, viewDir );
|
||
bentNormal = normalize( cross( bentNormal, bitangent ) );
|
||
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
|
||
return getIBLRadiance( viewDir, bentNormal, roughness );
|
||
#else
|
||
return vec3( 0.0 );
|
||
#endif
|
||
}
|
||
#endif
|
||
#endif`,z4=`ToonMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;`,H4=`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`,G4=`BlinnPhongMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;
|
||
material.specularColor = specular;
|
||
material.specularShininess = shininess;
|
||
material.specularStrength = specularStrength;`,V4=`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`,Q4=`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`,W4=`uniform sampler2D dfgLUT;
|
||
struct PhysicalMaterial {
|
||
vec3 diffuseColor;
|
||
float roughness;
|
||
vec3 specularColor;
|
||
float specularF90;
|
||
float dispersion;
|
||
#ifdef USE_CLEARCOAT
|
||
float clearcoat;
|
||
float clearcoatRoughness;
|
||
vec3 clearcoatF0;
|
||
float clearcoatF90;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE
|
||
float iridescence;
|
||
float iridescenceIOR;
|
||
float iridescenceThickness;
|
||
vec3 iridescenceFresnel;
|
||
vec3 iridescenceF0;
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
vec3 sheenColor;
|
||
float sheenRoughness;
|
||
#endif
|
||
#ifdef IOR
|
||
float ior;
|
||
#endif
|
||
#ifdef USE_TRANSMISSION
|
||
float transmission;
|
||
float transmissionAlpha;
|
||
float thickness;
|
||
float attenuationDistance;
|
||
vec3 attenuationColor;
|
||
#endif
|
||
#ifdef USE_ANISOTROPY
|
||
float anisotropy;
|
||
float alphaT;
|
||
vec3 anisotropyT;
|
||
vec3 anisotropyB;
|
||
#endif
|
||
};
|
||
vec3 clearcoatSpecularDirect = vec3( 0.0 );
|
||
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
|
||
vec3 sheenSpecularDirect = vec3( 0.0 );
|
||
vec3 sheenSpecularIndirect = vec3(0.0 );
|
||
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
|
||
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
|
||
float x2 = x * x;
|
||
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
|
||
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
|
||
}
|
||
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
|
||
float a2 = pow2( alpha );
|
||
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
||
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
|
||
return 0.5 / max( gv + gl, EPSILON );
|
||
}
|
||
float D_GGX( const in float alpha, const in float dotNH ) {
|
||
float a2 = pow2( alpha );
|
||
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
|
||
return RECIPROCAL_PI * a2 / pow2( denom );
|
||
}
|
||
#ifdef USE_ANISOTROPY
|
||
float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
|
||
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
|
||
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
|
||
float v = 0.5 / ( gv + gl );
|
||
return saturate(v);
|
||
}
|
||
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
|
||
float a2 = alphaT * alphaB;
|
||
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
|
||
highp float v2 = dot( v, v );
|
||
float w2 = a2 / v2;
|
||
return RECIPROCAL_PI * a2 * pow2 ( w2 );
|
||
}
|
||
#endif
|
||
#ifdef USE_CLEARCOAT
|
||
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
|
||
vec3 f0 = material.clearcoatF0;
|
||
float f90 = material.clearcoatF90;
|
||
float roughness = material.clearcoatRoughness;
|
||
float alpha = pow2( roughness );
|
||
vec3 halfDir = normalize( lightDir + viewDir );
|
||
float dotNL = saturate( dot( normal, lightDir ) );
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
float dotNH = saturate( dot( normal, halfDir ) );
|
||
float dotVH = saturate( dot( viewDir, halfDir ) );
|
||
vec3 F = F_Schlick( f0, f90, dotVH );
|
||
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
||
float D = D_GGX( alpha, dotNH );
|
||
return F * ( V * D );
|
||
}
|
||
#endif
|
||
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
|
||
vec3 f0 = material.specularColor;
|
||
float f90 = material.specularF90;
|
||
float roughness = material.roughness;
|
||
float alpha = pow2( roughness );
|
||
vec3 halfDir = normalize( lightDir + viewDir );
|
||
float dotNL = saturate( dot( normal, lightDir ) );
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
float dotNH = saturate( dot( normal, halfDir ) );
|
||
float dotVH = saturate( dot( viewDir, halfDir ) );
|
||
vec3 F = F_Schlick( f0, f90, dotVH );
|
||
#ifdef USE_IRIDESCENCE
|
||
F = mix( F, material.iridescenceFresnel, material.iridescence );
|
||
#endif
|
||
#ifdef USE_ANISOTROPY
|
||
float dotTL = dot( material.anisotropyT, lightDir );
|
||
float dotTV = dot( material.anisotropyT, viewDir );
|
||
float dotTH = dot( material.anisotropyT, halfDir );
|
||
float dotBL = dot( material.anisotropyB, lightDir );
|
||
float dotBV = dot( material.anisotropyB, viewDir );
|
||
float dotBH = dot( material.anisotropyB, halfDir );
|
||
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
|
||
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
|
||
#else
|
||
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
||
float D = D_GGX( alpha, dotNH );
|
||
#endif
|
||
return F * ( V * D );
|
||
}
|
||
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
|
||
const float LUT_SIZE = 64.0;
|
||
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
|
||
const float LUT_BIAS = 0.5 / LUT_SIZE;
|
||
float dotNV = saturate( dot( N, V ) );
|
||
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
|
||
uv = uv * LUT_SCALE + LUT_BIAS;
|
||
return uv;
|
||
}
|
||
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
|
||
float l = length( f );
|
||
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
|
||
}
|
||
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
|
||
float x = dot( v1, v2 );
|
||
float y = abs( x );
|
||
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
|
||
float b = 3.4175940 + ( 4.1616724 + y ) * y;
|
||
float v = a / b;
|
||
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
|
||
return cross( v1, v2 ) * theta_sintheta;
|
||
}
|
||
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
|
||
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
|
||
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
|
||
vec3 lightNormal = cross( v1, v2 );
|
||
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
|
||
vec3 T1, T2;
|
||
T1 = normalize( V - N * dot( V, N ) );
|
||
T2 = - cross( N, T1 );
|
||
mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
|
||
vec3 coords[ 4 ];
|
||
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
|
||
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
|
||
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
|
||
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
|
||
coords[ 0 ] = normalize( coords[ 0 ] );
|
||
coords[ 1 ] = normalize( coords[ 1 ] );
|
||
coords[ 2 ] = normalize( coords[ 2 ] );
|
||
coords[ 3 ] = normalize( coords[ 3 ] );
|
||
vec3 vectorFormFactor = vec3( 0.0 );
|
||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
|
||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
|
||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
|
||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
|
||
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
|
||
return vec3( result );
|
||
}
|
||
#if defined( USE_SHEEN )
|
||
float D_Charlie( float roughness, float dotNH ) {
|
||
float alpha = pow2( roughness );
|
||
float invAlpha = 1.0 / alpha;
|
||
float cos2h = dotNH * dotNH;
|
||
float sin2h = max( 1.0 - cos2h, 0.0078125 );
|
||
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
|
||
}
|
||
float V_Neubelt( float dotNV, float dotNL ) {
|
||
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
|
||
}
|
||
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
|
||
vec3 halfDir = normalize( lightDir + viewDir );
|
||
float dotNL = saturate( dot( normal, lightDir ) );
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
float dotNH = saturate( dot( normal, halfDir ) );
|
||
float D = D_Charlie( sheenRoughness, dotNH );
|
||
float V = V_Neubelt( dotNV, dotNL );
|
||
return sheenColor * ( D * V );
|
||
}
|
||
#endif
|
||
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
float r2 = roughness * roughness;
|
||
float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
|
||
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
|
||
float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
|
||
return saturate( DG * RECIPROCAL_PI );
|
||
}
|
||
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
vec2 uv = vec2( roughness, dotNV );
|
||
return texture2D( dfgLUT, uv ).rg;
|
||
}
|
||
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
|
||
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
||
return specularColor * fab.x + specularF90 * fab.y;
|
||
}
|
||
#ifdef USE_IRIDESCENCE
|
||
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
||
#else
|
||
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
||
#endif
|
||
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
||
#ifdef USE_IRIDESCENCE
|
||
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
|
||
#else
|
||
vec3 Fr = specularColor;
|
||
#endif
|
||
vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
|
||
float Ess = fab.x + fab.y;
|
||
float Ems = 1.0 - Ess;
|
||
vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
|
||
singleScatter += FssEss;
|
||
multiScatter += Fms * Ems;
|
||
}
|
||
vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
|
||
vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
|
||
float dotNL = saturate( dot( normal, lightDir ) );
|
||
float dotNV = saturate( dot( normal, viewDir ) );
|
||
vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
|
||
vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
|
||
vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
|
||
vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
|
||
float Ess_V = dfgV.x + dfgV.y;
|
||
float Ess_L = dfgL.x + dfgL.y;
|
||
float Ems_V = 1.0 - Ess_V;
|
||
float Ems_L = 1.0 - Ess_L;
|
||
vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
|
||
vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
|
||
float compensationFactor = Ems_V * Ems_L;
|
||
vec3 multiScatter = Fms * compensationFactor;
|
||
return singleScatter + multiScatter;
|
||
}
|
||
#if NUM_RECT_AREA_LIGHTS > 0
|
||
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||
vec3 normal = geometryNormal;
|
||
vec3 viewDir = geometryViewDir;
|
||
vec3 position = geometryPosition;
|
||
vec3 lightPos = rectAreaLight.position;
|
||
vec3 halfWidth = rectAreaLight.halfWidth;
|
||
vec3 halfHeight = rectAreaLight.halfHeight;
|
||
vec3 lightColor = rectAreaLight.color;
|
||
float roughness = material.roughness;
|
||
vec3 rectCoords[ 4 ];
|
||
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
|
||
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
|
||
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
|
||
vec2 uv = LTC_Uv( normal, viewDir, roughness );
|
||
vec4 t1 = texture2D( ltc_1, uv );
|
||
vec4 t2 = texture2D( ltc_2, uv );
|
||
mat3 mInv = mat3(
|
||
vec3( t1.x, 0, t1.y ),
|
||
vec3( 0, 1, 0 ),
|
||
vec3( t1.z, 0, t1.w )
|
||
);
|
||
vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
|
||
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
|
||
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
|
||
}
|
||
#endif
|
||
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
||
vec3 irradiance = dotNL * directLight.color;
|
||
#ifdef USE_CLEARCOAT
|
||
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
|
||
vec3 ccIrradiance = dotNLcc * directLight.color;
|
||
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
|
||
#endif
|
||
reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
|
||
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
||
}
|
||
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
||
}
|
||
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
|
||
#ifdef USE_CLEARCOAT
|
||
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
||
#endif
|
||
#ifdef USE_SHEEN
|
||
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
||
#endif
|
||
vec3 singleScattering = vec3( 0.0 );
|
||
vec3 multiScattering = vec3( 0.0 );
|
||
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
||
#ifdef USE_IRIDESCENCE
|
||
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
|
||
#else
|
||
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
|
||
#endif
|
||
vec3 totalScattering = singleScattering + multiScattering;
|
||
vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
|
||
reflectedLight.indirectSpecular += radiance * singleScattering;
|
||
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
|
||
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
|
||
}
|
||
#define RE_Direct RE_Direct_Physical
|
||
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
|
||
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
|
||
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
||
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
||
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
||
}`,j4=`
|
||
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`,q4=`#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`,X4=`#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`,Y4=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
||
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
||
#endif`,K4=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
||
uniform float logDepthBufFC;
|
||
varying float vFragDepth;
|
||
varying float vIsPerspective;
|
||
#endif`,Z4=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
||
varying float vFragDepth;
|
||
varying float vIsPerspective;
|
||
#endif`,J4=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
||
vFragDepth = 1.0 + gl_Position.w;
|
||
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
||
#endif`,$4=`#ifdef USE_MAP
|
||
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
||
#ifdef DECODE_VIDEO_TEXTURE
|
||
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
||
#endif
|
||
diffuseColor *= sampledDiffuseColor;
|
||
#endif`,eD=`#ifdef USE_MAP
|
||
uniform sampler2D map;
|
||
#endif`,tD=`#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`,iD=`#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`,nD=`float metalnessFactor = metalness;
|
||
#ifdef USE_METALNESSMAP
|
||
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
||
metalnessFactor *= texelMetalness.b;
|
||
#endif`,sD=`#ifdef USE_METALNESSMAP
|
||
uniform sampler2D metalnessMap;
|
||
#endif`,rD=`#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`,aD=`#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`,oD=`#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`,lD=`#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`,cD=`#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`,hD=`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;`,dD=`#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`,uD=`#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#ifdef USE_TANGENT
|
||
varying vec3 vTangent;
|
||
varying vec3 vBitangent;
|
||
#endif
|
||
#endif`,pD=`#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#ifdef USE_TANGENT
|
||
varying vec3 vTangent;
|
||
varying vec3 vBitangent;
|
||
#endif
|
||
#endif`,fD=`#ifndef FLAT_SHADED
|
||
vNormal = normalize( transformedNormal );
|
||
#ifdef USE_TANGENT
|
||
vTangent = normalize( transformedTangent );
|
||
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
||
#endif
|
||
#endif`,mD=`#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`,gD=`#ifdef USE_CLEARCOAT
|
||
vec3 clearcoatNormal = nonPerturbedNormal;
|
||
#endif`,AD=`#ifdef USE_CLEARCOAT_NORMALMAP
|
||
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
||
clearcoatMapN.xy *= clearcoatNormalScale;
|
||
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
||
#endif`,vD=`#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`,bD=`#ifdef USE_IRIDESCENCEMAP
|
||
uniform sampler2D iridescenceMap;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
uniform sampler2D iridescenceThicknessMap;
|
||
#endif`,yD=`#ifdef OPAQUE
|
||
diffuseColor.a = 1.0;
|
||
#endif
|
||
#ifdef USE_TRANSMISSION
|
||
diffuseColor.a *= material.transmissionAlpha;
|
||
#endif
|
||
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,xD=`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 );
|
||
}`,_D=`#ifdef PREMULTIPLIED_ALPHA
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
#endif`,ED=`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;`,MD=`#ifdef DITHERING
|
||
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
||
#endif`,wD=`#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`,SD=`float roughnessFactor = roughness;
|
||
#ifdef USE_ROUGHNESSMAP
|
||
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
||
roughnessFactor *= texelRoughness.g;
|
||
#endif`,CD=`#ifdef USE_ROUGHNESSMAP
|
||
uniform sampler2D roughnessMap;
|
||
#endif`,TD=`#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`,ID=`#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`,PD=`#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`,RD=`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;
|
||
}`,DD=`#ifdef USE_SKINNING
|
||
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
||
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
||
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
||
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
||
#endif`,BD=`#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`,LD=`#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`,kD=`#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`,ND=`float specularStrength;
|
||
#ifdef USE_SPECULARMAP
|
||
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
||
specularStrength = texelSpecular.r;
|
||
#else
|
||
specularStrength = 1.0;
|
||
#endif`,UD=`#ifdef USE_SPECULARMAP
|
||
uniform sampler2D specularMap;
|
||
#endif`,FD=`#if defined( TONE_MAPPING )
|
||
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
||
#endif`,OD=`#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; }`,zD=`#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`,HD=`#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`,GD=`#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`,VD=`#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`,QD=`#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`,WD=`#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 jD=`varying vec2 vUv;
|
||
uniform mat3 uvTransform;
|
||
void main() {
|
||
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
||
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
||
}`,qD=`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>
|
||
}`,XD=`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
gl_Position.z = gl_Position.w;
|
||
}`,YD=`#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>
|
||
}`,KD=`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
gl_Position.z = gl_Position.w;
|
||
}`,ZD=`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>
|
||
}`,JD=`#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;
|
||
}`,$D=`#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
|
||
}`,eB=`#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;
|
||
}`,tB=`#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 );
|
||
}`,iB=`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
}`,nB=`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>
|
||
}`,sB=`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>
|
||
}`,rB=`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>
|
||
}`,aB=`#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>
|
||
}`,oB=`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>
|
||
}`,lB=`#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>
|
||
}`,cB=`#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>
|
||
}`,hB=`#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;
|
||
}`,dB=`#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>
|
||
}`,uB=`#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
|
||
}`,pB=`#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
|
||
}`,fB=`#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>
|
||
}`,mB=`#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>
|
||
}`,gB=`#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
|
||
}`,AB=`#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>
|
||
}`,vB=`#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>
|
||
}`,bB=`#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>
|
||
}`,yB=`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>
|
||
}`,xB=`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>
|
||
}`,_B=`#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>
|
||
}`,EB=`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>
|
||
}`,MB=`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>
|
||
}`,wB=`uniform vec3 diffuse;
|
||
uniform float opacity;
|
||
#include <common>
|
||
#include <uv_pars_fragment>
|
||
#include <map_pars_fragment>
|
||
#include <alphamap_pars_fragment>
|
||
#include <alphatest_pars_fragment>
|
||
#include <alphahash_pars_fragment>
|
||
#include <fog_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <clipping_planes_pars_fragment>
|
||
void main() {
|
||
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
#include <clipping_planes_fragment>
|
||
vec3 outgoingLight = vec3( 0.0 );
|
||
#include <logdepthbuf_fragment>
|
||
#include <map_fragment>
|
||
#include <alphamap_fragment>
|
||
#include <alphatest_fragment>
|
||
#include <alphahash_fragment>
|
||
outgoingLight = diffuseColor.rgb;
|
||
#include <opaque_fragment>
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
}`,wt={alphahash_fragment:qR,alphahash_pars_fragment:XR,alphamap_fragment:YR,alphamap_pars_fragment:KR,alphatest_fragment:ZR,alphatest_pars_fragment:JR,aomap_fragment:$R,aomap_pars_fragment:e4,batching_pars_vertex:t4,batching_vertex:i4,begin_vertex:n4,beginnormal_vertex:s4,bsdfs:r4,iridescence_fragment:a4,bumpmap_pars_fragment:o4,clipping_planes_fragment:l4,clipping_planes_pars_fragment:c4,clipping_planes_pars_vertex:h4,clipping_planes_vertex:d4,color_fragment:u4,color_pars_fragment:p4,color_pars_vertex:f4,color_vertex:m4,common:g4,cube_uv_reflection_fragment:A4,defaultnormal_vertex:v4,displacementmap_pars_vertex:b4,displacementmap_vertex:y4,emissivemap_fragment:x4,emissivemap_pars_fragment:_4,colorspace_fragment:E4,colorspace_pars_fragment:M4,envmap_fragment:w4,envmap_common_pars_fragment:S4,envmap_pars_fragment:C4,envmap_pars_vertex:T4,envmap_physical_pars_fragment:O4,envmap_vertex:I4,fog_vertex:P4,fog_pars_vertex:R4,fog_fragment:D4,fog_pars_fragment:B4,gradientmap_pars_fragment:L4,lightmap_pars_fragment:k4,lights_lambert_fragment:N4,lights_lambert_pars_fragment:U4,lights_pars_begin:F4,lights_toon_fragment:z4,lights_toon_pars_fragment:H4,lights_phong_fragment:G4,lights_phong_pars_fragment:V4,lights_physical_fragment:Q4,lights_physical_pars_fragment:W4,lights_fragment_begin:j4,lights_fragment_maps:q4,lights_fragment_end:X4,logdepthbuf_fragment:Y4,logdepthbuf_pars_fragment:K4,logdepthbuf_pars_vertex:Z4,logdepthbuf_vertex:J4,map_fragment:$4,map_pars_fragment:eD,map_particle_fragment:tD,map_particle_pars_fragment:iD,metalnessmap_fragment:nD,metalnessmap_pars_fragment:sD,morphinstance_vertex:rD,morphcolor_vertex:aD,morphnormal_vertex:oD,morphtarget_pars_vertex:lD,morphtarget_vertex:cD,normal_fragment_begin:hD,normal_fragment_maps:dD,normal_pars_fragment:uD,normal_pars_vertex:pD,normal_vertex:fD,normalmap_pars_fragment:mD,clearcoat_normal_fragment_begin:gD,clearcoat_normal_fragment_maps:AD,clearcoat_pars_fragment:vD,iridescence_pars_fragment:bD,opaque_fragment:yD,packing:xD,premultiplied_alpha_fragment:_D,project_vertex:ED,dithering_fragment:MD,dithering_pars_fragment:wD,roughnessmap_fragment:SD,roughnessmap_pars_fragment:CD,shadowmap_pars_fragment:TD,shadowmap_pars_vertex:ID,shadowmap_vertex:PD,shadowmask_pars_fragment:RD,skinbase_vertex:DD,skinning_pars_vertex:BD,skinning_vertex:LD,skinnormal_vertex:kD,specularmap_fragment:ND,specularmap_pars_fragment:UD,tonemapping_fragment:FD,tonemapping_pars_fragment:OD,transmission_fragment:zD,transmission_pars_fragment:HD,uv_pars_fragment:GD,uv_pars_vertex:VD,uv_vertex:QD,worldpos_vertex:WD,background_vert:jD,background_frag:qD,backgroundCube_vert:XD,backgroundCube_frag:YD,cube_vert:KD,cube_frag:ZD,depth_vert:JD,depth_frag:$D,distanceRGBA_vert:eB,distanceRGBA_frag:tB,equirect_vert:iB,equirect_frag:nB,linedashed_vert:sB,linedashed_frag:rB,meshbasic_vert:aB,meshbasic_frag:oB,meshlambert_vert:lB,meshlambert_frag:cB,meshmatcap_vert:hB,meshmatcap_frag:dB,meshnormal_vert:uB,meshnormal_frag:pB,meshphong_vert:fB,meshphong_frag:mB,meshphysical_vert:gB,meshphysical_frag:AB,meshtoon_vert:vB,meshtoon_frag:bB,points_vert:yB,points_frag:xB,shadow_vert:_B,shadow_frag:EB,sprite_vert:MB,sprite_frag:wB},$e={common:{diffuse:{value:new jt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new xt},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new xt}},envmap:{envMap:{value:null},envMapRotation:{value:new xt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new xt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new xt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new xt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new xt},normalScale:{value:new Wt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new xt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new xt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new xt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new xt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new jt(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 jt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0},uvTransform:{value:new xt}},sprite:{diffuse:{value:new jt(16777215)},opacity:{value:1},center:{value:new Wt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new xt},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0}}},Rs={basic:{uniforms:fn([$e.common,$e.specularmap,$e.envmap,$e.aomap,$e.lightmap,$e.fog]),vertexShader:wt.meshbasic_vert,fragmentShader:wt.meshbasic_frag},lambert:{uniforms:fn([$e.common,$e.specularmap,$e.envmap,$e.aomap,$e.lightmap,$e.emissivemap,$e.bumpmap,$e.normalmap,$e.displacementmap,$e.fog,$e.lights,{emissive:{value:new jt(0)}}]),vertexShader:wt.meshlambert_vert,fragmentShader:wt.meshlambert_frag},phong:{uniforms:fn([$e.common,$e.specularmap,$e.envmap,$e.aomap,$e.lightmap,$e.emissivemap,$e.bumpmap,$e.normalmap,$e.displacementmap,$e.fog,$e.lights,{emissive:{value:new jt(0)},specular:{value:new jt(1118481)},shininess:{value:30}}]),vertexShader:wt.meshphong_vert,fragmentShader:wt.meshphong_frag},standard:{uniforms:fn([$e.common,$e.envmap,$e.aomap,$e.lightmap,$e.emissivemap,$e.bumpmap,$e.normalmap,$e.displacementmap,$e.roughnessmap,$e.metalnessmap,$e.fog,$e.lights,{emissive:{value:new jt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:wt.meshphysical_vert,fragmentShader:wt.meshphysical_frag},toon:{uniforms:fn([$e.common,$e.aomap,$e.lightmap,$e.emissivemap,$e.bumpmap,$e.normalmap,$e.displacementmap,$e.gradientmap,$e.fog,$e.lights,{emissive:{value:new jt(0)}}]),vertexShader:wt.meshtoon_vert,fragmentShader:wt.meshtoon_frag},matcap:{uniforms:fn([$e.common,$e.bumpmap,$e.normalmap,$e.displacementmap,$e.fog,{matcap:{value:null}}]),vertexShader:wt.meshmatcap_vert,fragmentShader:wt.meshmatcap_frag},points:{uniforms:fn([$e.points,$e.fog]),vertexShader:wt.points_vert,fragmentShader:wt.points_frag},dashed:{uniforms:fn([$e.common,$e.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:wt.linedashed_vert,fragmentShader:wt.linedashed_frag},depth:{uniforms:fn([$e.common,$e.displacementmap]),vertexShader:wt.depth_vert,fragmentShader:wt.depth_frag},normal:{uniforms:fn([$e.common,$e.bumpmap,$e.normalmap,$e.displacementmap,{opacity:{value:1}}]),vertexShader:wt.meshnormal_vert,fragmentShader:wt.meshnormal_frag},sprite:{uniforms:fn([$e.sprite,$e.fog]),vertexShader:wt.sprite_vert,fragmentShader:wt.sprite_frag},background:{uniforms:{uvTransform:{value:new xt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:wt.background_vert,fragmentShader:wt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new xt}},vertexShader:wt.backgroundCube_vert,fragmentShader:wt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:wt.cube_vert,fragmentShader:wt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:wt.equirect_vert,fragmentShader:wt.equirect_frag},distanceRGBA:{uniforms:fn([$e.common,$e.displacementmap,{referencePosition:{value:new De},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:wt.distanceRGBA_vert,fragmentShader:wt.distanceRGBA_frag},shadow:{uniforms:fn([$e.lights,$e.fog,{color:{value:new jt(0)},opacity:{value:1}}]),vertexShader:wt.shadow_vert,fragmentShader:wt.shadow_frag}};Rs.physical={uniforms:fn([Rs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new xt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new xt},clearcoatNormalScale:{value:new Wt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new xt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new xt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new xt},sheen:{value:0},sheenColor:{value:new jt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new xt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new xt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new xt},transmissionSamplerSize:{value:new Wt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new xt},attenuationDistance:{value:0},attenuationColor:{value:new jt(0)},specularColor:{value:new jt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new xt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new xt},anisotropyVector:{value:new Wt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new xt}}]),vertexShader:wt.meshphysical_vert,fragmentShader:wt.meshphysical_frag};const Ip={r:0,b:0,g:0},$a=new Xa,SB=new Ui;function CB(r,e,t,i,n,s,a){const o=new jt(0);let l=s===!0?0:1,c,h,d=null,p=0,u=null;function A(b){let y=b.isScene===!0?b.background:null;return y&&y.isTexture&&(y=(b.backgroundBlurriness>0?t:e).get(y)),y}function m(b){let y=!1;const M=A(b);M===null?f(o,l):M&&M.isColor&&(f(M,1),y=!0);const _=r.xr.getEnvironmentBlendMode();_==="additive"?i.buffers.color.setClear(0,0,0,1,a):_==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,a),(r.autoClear||y)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil))}function g(b,y){const M=A(y);M&&(M.isCubeTexture||M.mapping===ep)?(h===void 0&&(h=new Kr(new ph(1,1,1),new or({name:"BackgroundCubeMaterial",uniforms:Il(Rs.backgroundCube.uniforms),vertexShader:Rs.backgroundCube.vertexShader,fragmentShader:Rs.backgroundCube.fragmentShader,side:xn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(_,S,w){this.matrixWorld.copyPosition(w.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(h)),$a.copy(y.backgroundRotation),$a.x*=-1,$a.y*=-1,$a.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&($a.y*=-1,$a.z*=-1),h.material.uniforms.envMap.value=M,h.material.uniforms.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(SB.makeRotationFromEuler($a)),h.material.toneMapped=Nt.getTransfer(M.colorSpace)!==Qt,(d!==M||p!==M.version||u!==r.toneMapping)&&(h.material.needsUpdate=!0,d=M,p=M.version,u=r.toneMapping),h.layers.enableAll(),b.unshift(h,h.geometry,h.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new Kr(new Tp(2,2),new or({name:"BackgroundMaterial",uniforms:Il(Rs.background.uniforms),vertexShader:Rs.background.vertexShader,fragmentShader:Rs.background.fragmentShader,side:Hr,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=M,c.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,c.material.toneMapped=Nt.getTransfer(M.colorSpace)!==Qt,M.matrixAutoUpdate===!0&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),(d!==M||p!==M.version||u!==r.toneMapping)&&(c.material.needsUpdate=!0,d=M,p=M.version,u=r.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null))}function f(b,y){b.getRGB(Ip,Iy(r)),i.buffers.color.setClear(Ip.r,Ip.g,Ip.b,y,a)}function v(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(b,y=1){o.set(b),l=y,f(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(b){l=b,f(o,l)},render:m,addToRenderList:g,dispose:v}}function TB(r,e){const t=r.getParameter(r.MAX_VERTEX_ATTRIBS),i={},n=p(null);let s=n,a=!1;function o(I,B,R,U,C){let F=!1;const O=d(U,R,B);s!==O&&(s=O,c(s.object)),F=u(I,U,R,C),F&&A(I,U,R,C),C!==null&&e.update(C,r.ELEMENT_ARRAY_BUFFER),(F||a)&&(a=!1,y(I,B,R,U),C!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,e.get(C).buffer))}function l(){return r.createVertexArray()}function c(I){return r.bindVertexArray(I)}function h(I){return r.deleteVertexArray(I)}function d(I,B,R){const U=R.wireframe===!0;let C=i[I.id];C===void 0&&(C={},i[I.id]=C);let F=C[B.id];F===void 0&&(F={},C[B.id]=F);let O=F[U];return O===void 0&&(O=p(l()),F[U]=O),O}function p(I){const B=[],R=[],U=[];for(let C=0;C<t;C++)B[C]=0,R[C]=0,U[C]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:B,enabledAttributes:R,attributeDivisors:U,object:I,attributes:{},index:null}}function u(I,B,R,U){const C=s.attributes,F=B.attributes;let O=0;const H=R.getAttributes();for(const j in H)if(H[j].location>=0){const G=C[j];let re=F[j];if(re===void 0&&(j==="instanceMatrix"&&I.instanceMatrix&&(re=I.instanceMatrix),j==="instanceColor"&&I.instanceColor&&(re=I.instanceColor)),G===void 0||G.attribute!==re||re&&G.data!==re.data)return!0;O++}return s.attributesNum!==O||s.index!==U}function A(I,B,R,U){const C={},F=B.attributes;let O=0;const H=R.getAttributes();for(const j in H)if(H[j].location>=0){let G=F[j];G===void 0&&(j==="instanceMatrix"&&I.instanceMatrix&&(G=I.instanceMatrix),j==="instanceColor"&&I.instanceColor&&(G=I.instanceColor));const re={};re.attribute=G,G&&G.data&&(re.data=G.data),C[j]=re,O++}s.attributes=C,s.attributesNum=O,s.index=U}function m(){const I=s.newAttributes;for(let B=0,R=I.length;B<R;B++)I[B]=0}function g(I){f(I,0)}function f(I,B){const R=s.newAttributes,U=s.enabledAttributes,C=s.attributeDivisors;R[I]=1,U[I]===0&&(r.enableVertexAttribArray(I),U[I]=1),C[I]!==B&&(r.vertexAttribDivisor(I,B),C[I]=B)}function v(){const I=s.newAttributes,B=s.enabledAttributes;for(let R=0,U=B.length;R<U;R++)B[R]!==I[R]&&(r.disableVertexAttribArray(R),B[R]=0)}function b(I,B,R,U,C,F,O){O===!0?r.vertexAttribIPointer(I,B,R,C,F):r.vertexAttribPointer(I,B,R,U,C,F)}function y(I,B,R,U){m();const C=U.attributes,F=R.getAttributes(),O=B.defaultAttributeValues;for(const H in F){const j=F[H];if(j.location>=0){let G=C[H];if(G===void 0&&(H==="instanceMatrix"&&I.instanceMatrix&&(G=I.instanceMatrix),H==="instanceColor"&&I.instanceColor&&(G=I.instanceColor)),G!==void 0){const re=G.normalized,q=G.itemSize,Y=e.get(G);if(Y===void 0)continue;const ye=Y.buffer,Me=Y.type,xe=Y.bytesPerElement,J=Me===r.INT||Me===r.UNSIGNED_INT||G.gpuType===yg;if(G.isInterleavedBufferAttribute){const oe=G.data,ue=oe.stride,Pe=G.offset;if(oe.isInstancedInterleavedBuffer){for(let Be=0;Be<j.locationSize;Be++)f(j.location+Be,oe.meshPerAttribute);I.isInstancedMesh!==!0&&U._maxInstanceCount===void 0&&(U._maxInstanceCount=oe.meshPerAttribute*oe.count)}else for(let Be=0;Be<j.locationSize;Be++)g(j.location+Be);r.bindBuffer(r.ARRAY_BUFFER,ye);for(let Be=0;Be<j.locationSize;Be++)b(j.location+Be,q/j.locationSize,Me,re,ue*xe,(Pe+q/j.locationSize*Be)*xe,J)}else{if(G.isInstancedBufferAttribute){for(let oe=0;oe<j.locationSize;oe++)f(j.location+oe,G.meshPerAttribute);I.isInstancedMesh!==!0&&U._maxInstanceCount===void 0&&(U._maxInstanceCount=G.meshPerAttribute*G.count)}else for(let oe=0;oe<j.locationSize;oe++)g(j.location+oe);r.bindBuffer(r.ARRAY_BUFFER,ye);for(let oe=0;oe<j.locationSize;oe++)b(j.location+oe,q/j.locationSize,Me,re,q*xe,q/j.locationSize*oe*xe,J)}}else if(O!==void 0){const re=O[H];if(re!==void 0)switch(re.length){case 2:r.vertexAttrib2fv(j.location,re);break;case 3:r.vertexAttrib3fv(j.location,re);break;case 4:r.vertexAttrib4fv(j.location,re);break;default:r.vertexAttrib1fv(j.location,re)}}}}v()}function M(){w();for(const I in i){const B=i[I];for(const R in B){const U=B[R];for(const C in U)h(U[C].object),delete U[C];delete B[R]}delete i[I]}}function _(I){if(i[I.id]===void 0)return;const B=i[I.id];for(const R in B){const U=B[R];for(const C in U)h(U[C].object),delete U[C];delete B[R]}delete i[I.id]}function S(I){for(const B in i){const R=i[B];if(R[I.id]===void 0)continue;const U=R[I.id];for(const C in U)h(U[C].object),delete U[C];delete R[I.id]}}function w(){E(),a=!0,s!==n&&(s=n,c(s.object))}function E(){n.geometry=null,n.program=null,n.wireframe=!1}return{setup:o,reset:w,resetDefaultState:E,dispose:M,releaseStatesOfGeometry:_,releaseStatesOfProgram:S,initAttributes:m,enableAttribute:g,disableUnusedAttributes:v}}function IB(r,e,t){let i;function n(c){i=c}function s(c,h){r.drawArrays(i,c,h),t.update(h,i,1)}function a(c,h,d){d!==0&&(r.drawArraysInstanced(i,c,h,d),t.update(h,i,d))}function o(c,h,d){if(d===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,h,0,d);let p=0;for(let u=0;u<d;u++)p+=h[u];t.update(p,i,1)}function l(c,h,d,p){if(d===0)return;const u=e.get("WEBGL_multi_draw");if(u===null)for(let A=0;A<c.length;A++)a(c[A],h[A],p[A]);else{u.multiDrawArraysInstancedWEBGL(i,c,0,h,0,p,0,d);let A=0;for(let m=0;m<d;m++)A+=h[m]*p[m];t.update(A,i,1)}}this.setMode=n,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function PB(r,e,t,i){let n;function s(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const S=e.get("EXT_texture_filter_anisotropic");n=r.getParameter(S.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function a(S){return!(S!==cs&&i.convert(S)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(S){const w=S===fl&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(S!==$s&&i.convert(S)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)&&S!==er&&!w)}function l(S){if(S==="highp"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";S="mediump"}return S==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(At("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const d=t.logarithmicDepthBuffer===!0,p=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),u=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),A=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=r.getParameter(r.MAX_TEXTURE_SIZE),g=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),f=r.getParameter(r.MAX_VERTEX_ATTRIBS),v=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),b=r.getParameter(r.MAX_VARYING_VECTORS),y=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),M=A>0,_=r.getParameter(r.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:p,maxTextures:u,maxVertexTextures:A,maxTextureSize:m,maxCubemapSize:g,maxAttributes:f,maxVertexUniforms:v,maxVaryings:b,maxFragmentUniforms:y,vertexTextures:M,maxSamples:_}}function RB(r){const e=this;let t=null,i=0,n=!1,s=!1;const a=new Za,o=new xt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,p){const u=d.length!==0||p||i!==0||n;return n=p,i=d.length,u},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,p){t=h(d,p,0)},this.setState=function(d,p,u){const A=d.clippingPlanes,m=d.clipIntersection,g=d.clipShadows,f=r.get(d);if(!n||A===null||A.length===0||s&&!g)s?h(null):c();else{const v=s?0:i,b=v*4;let y=f.clippingState||null;l.value=y,y=h(A,p,b,u);for(let M=0;M!==b;++M)y[M]=t[M];f.clippingState=y,this.numIntersection=m?this.numPlanes:0,this.numPlanes+=v}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(d,p,u,A){const m=d!==null?d.length:0;let g=null;if(m!==0){if(g=l.value,A!==!0||g===null){const f=u+m*4,v=p.matrixWorldInverse;o.getNormalMatrix(v),(g===null||g.length<f)&&(g=new Float32Array(f));for(let b=0,y=u;b!==m;++b,y+=4)a.copy(d[b]).applyMatrix4(v,o),a.normal.toArray(g,y),g[y+3]=a.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=m,e.numIntersection=0,g}}function DB(r){let e=new WeakMap;function t(a,o){return o===mg?a.mapping=ul:o===gg&&(a.mapping=pl),a}function i(a){if(a&&a.isTexture){const o=a.mapping;if(o===mg||o===gg)if(e.has(a)){const l=e.get(a).texture;return t(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new kR(l.height);return c.fromEquirectangularTexture(r,a),e.set(a,c),a.addEventListener("dispose",n),t(c.texture,a.mapping)}else return null}}return a}function n(a){const o=a.target;o.removeEventListener("dispose",n);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}const Jr=4,Oy=[.125,.215,.35,.446,.526,.582],eo=20,BB=256,fh=new VR,zy=new jt;let T0=null,I0=0,P0=0,R0=!1;const LB=new De;class Hy{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,n=100,s={}){const{size:a=256,position:o=LB}=s;T0=this._renderer.getRenderTarget(),I0=this._renderer.getActiveCubeFace(),P0=this._renderer.getActiveMipmapLevel(),R0=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,n,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Qy(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Vy(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(T0,I0,P0),this._renderer.xr.enabled=R0,e.scissorTest=!1,Dl(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ul||e.mapping===pl?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),T0=this._renderer.getRenderTarget(),I0=this._renderer.getActiveCubeFace(),P0=this._renderer.getActiveMipmapLevel(),R0=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:Yn,minFilter:Yn,generateMipmaps:!1,type:fl,format:cs,colorSpace:ml,depthBuffer:!1},n=Gy(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Gy(e,t,i);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=kB(s)),this._blurMaterial=UB(s,e,t),this._ggxMaterial=NB(s,e,t)}return n}_compileMaterial(e){const t=new Kr(new Yr,e);this._renderer.compile(t,fh)}_sceneToCubeUV(e,t,i,n,s){const a=new fs(90,1,t,i),o=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],c=this._renderer,h=c.autoClear,d=c.toneMapping;c.getClearColor(zy),c.toneMapping=Gr,c.autoClear=!1,c.state.buffers.depth.getReversed()&&(c.setRenderTarget(n),c.clearDepth(),c.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Kr(new ph,new Ey({name:"PMREM.Background",side:xn,depthWrite:!1,depthTest:!1})));const p=this._backgroundBox,u=p.material;let A=!1;const m=e.background;m?m.isColor&&(u.color.copy(m),e.background=null,A=!0):(u.color.copy(zy),A=!0);for(let g=0;g<6;g++){const f=g%3;f===0?(a.up.set(0,o[g],0),a.position.set(s.x,s.y,s.z),a.lookAt(s.x+l[g],s.y,s.z)):f===1?(a.up.set(0,0,o[g]),a.position.set(s.x,s.y,s.z),a.lookAt(s.x,s.y+l[g],s.z)):(a.up.set(0,o[g],0),a.position.set(s.x,s.y,s.z),a.lookAt(s.x,s.y,s.z+l[g]));const v=this._cubeSize;Dl(n,f*v,g>2?v:0,v,v),c.setRenderTarget(n),A&&c.render(p,a),c.render(e,a)}c.toneMapping=d,c.autoClear=h,e.background=m}_textureToCubeUV(e,t){const i=this._renderer,n=e.mapping===ul||e.mapping===pl;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=Qy()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Vy());const s=n?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;Dl(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,fh)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const n=this._lodMeshes.length;for(let s=1;s<n;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=i}_applyGGXFilter(e,t,i){const n=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[i];o.material=a;const l=a.uniforms,c=i/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),d=Math.sqrt(c*c-h*h),p=.05+c*.95,u=d*p,{_lodMax:A}=this,m=this._sizeLods[i],g=3*m*(i>A-Jr?i-A+Jr:0),f=4*(this._cubeSize-m);l.envMap.value=e.texture,l.roughness.value=u,l.mipInt.value=A-t,Dl(s,g,f,3*m,2*m),n.setRenderTarget(s),n.render(o,fh),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=A-i,Dl(e,g,f,3*m,2*m),n.setRenderTarget(e),n.render(o,fh)}_blur(e,t,i,n,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,n,"latitudinal",s),this._halfBlur(a,e,i,i,n,"longitudinal",s)}_halfBlur(e,t,i,n,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&yi("blur direction must be either latitudinal or longitudinal!");const h=3,d=this._lodMeshes[n];d.material=c;const p=c.uniforms,u=this._sizeLods[i]-1,A=isFinite(s)?Math.PI/(2*u):2*Math.PI/(2*eo-1),m=s/A,g=isFinite(s)?1+Math.floor(h*m):eo;g>eo&&At(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${eo}`);const f=[];let v=0;for(let S=0;S<eo;++S){const w=S/m,E=Math.exp(-w*w/2);f.push(E),S===0?v+=E:S<g&&(v+=2*E)}for(let S=0;S<f.length;S++)f[S]=f[S]/v;p.envMap.value=e.texture,p.samples.value=g,p.weights.value=f,p.latitudinal.value=a==="latitudinal",o&&(p.poleAxis.value=o);const{_lodMax:b}=this;p.dTheta.value=A,p.mipInt.value=b-i;const y=this._sizeLods[n],M=3*y*(n>b-Jr?n-b+Jr:0),_=4*(this._cubeSize-y);Dl(t,M,_,3*y,2*y),l.setRenderTarget(t),l.render(d,fh)}}function kB(r){const e=[],t=[],i=[];let n=r;const s=r-Jr+1+Oy.length;for(let a=0;a<s;a++){const o=Math.pow(2,n);e.push(o);let l=1/o;a>r-Jr?l=Oy[a-r+Jr-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),h=-c,d=1+c,p=[h,h,d,h,d,d,h,h,d,d,h,d],u=6,A=6,m=3,g=2,f=1,v=new Float32Array(m*A*u),b=new Float32Array(g*A*u),y=new Float32Array(f*A*u);for(let _=0;_<u;_++){const S=_%3*2/3-1,w=_>2?0:-1,E=[S,w,0,S+2/3,w,0,S+2/3,w+1,0,S,w,0,S+2/3,w+1,0,S,w+1,0];v.set(E,m*A*_),b.set(p,g*A*_);const I=[_,_,_,_,_,_];y.set(I,f*A*_)}const M=new Yr;M.setAttribute("position",new Ps(v,m)),M.setAttribute("uv",new Ps(b,g)),M.setAttribute("faceIndex",new Ps(y,f)),i.push(new Kr(M,null)),n>Jr&&n--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function Gy(r,e,t){const i=new Wa(r,e,t);return i.texture.mapping=ep,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Dl(r,e,t,i,n){r.viewport.set(e,t,i,n),r.scissor.set(e,t,i,n)}function NB(r,e,t){return new or({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:BB,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Pp(),fragmentShader:`
|
||
|
||
precision highp float;
|
||
precision highp int;
|
||
|
||
varying vec3 vOutputDirection;
|
||
|
||
uniform sampler2D envMap;
|
||
uniform float roughness;
|
||
uniform float mipInt;
|
||
|
||
#define ENVMAP_TYPE_CUBE_UV
|
||
#include <cube_uv_reflection_fragment>
|
||
|
||
#define PI 3.14159265359
|
||
|
||
// Van der Corput radical inverse
|
||
float radicalInverse_VdC(uint bits) {
|
||
bits = (bits << 16u) | (bits >> 16u);
|
||
bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
|
||
bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
|
||
bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
|
||
bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
|
||
return float(bits) * 2.3283064365386963e-10; // / 0x100000000
|
||
}
|
||
|
||
// Hammersley sequence
|
||
vec2 hammersley(uint i, uint N) {
|
||
return vec2(float(i) / float(N), radicalInverse_VdC(i));
|
||
}
|
||
|
||
// GGX VNDF importance sampling (Eric Heitz 2018)
|
||
// "Sampling the GGX Distribution of Visible Normals"
|
||
// https://jcgt.org/published/0007/04/01/
|
||
vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
|
||
float alpha = roughness * roughness;
|
||
|
||
// Section 3.2: Transform view direction to hemisphere configuration
|
||
vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
|
||
|
||
// Section 4.1: Orthonormal basis
|
||
float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
|
||
vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
|
||
vec3 T2 = cross(Vh, T1);
|
||
|
||
// Section 4.2: Parameterization of projected area
|
||
float r = sqrt(Xi.x);
|
||
float phi = 2.0 * PI * Xi.y;
|
||
float t1 = r * cos(phi);
|
||
float t2 = r * sin(phi);
|
||
float s = 0.5 * (1.0 + Vh.z);
|
||
t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
|
||
|
||
// Section 4.3: Reprojection onto hemisphere
|
||
vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
|
||
|
||
// Section 3.4: Transform back to ellipsoid configuration
|
||
return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
|
||
}
|
||
|
||
void main() {
|
||
vec3 N = normalize(vOutputDirection);
|
||
vec3 V = N; // Assume view direction equals normal for pre-filtering
|
||
|
||
vec3 prefilteredColor = vec3(0.0);
|
||
float totalWeight = 0.0;
|
||
|
||
// For very low roughness, just sample the environment directly
|
||
if (roughness < 0.001) {
|
||
gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
|
||
return;
|
||
}
|
||
|
||
// Tangent space basis for VNDF sampling
|
||
vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
|
||
vec3 tangent = normalize(cross(up, N));
|
||
vec3 bitangent = cross(N, tangent);
|
||
|
||
for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
|
||
vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
|
||
|
||
// For PMREM, V = N, so in tangent space V is always (0, 0, 1)
|
||
vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
|
||
|
||
// Transform H back to world space
|
||
vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
|
||
vec3 L = normalize(2.0 * dot(V, H) * H - V);
|
||
|
||
float NdotL = max(dot(N, L), 0.0);
|
||
|
||
if(NdotL > 0.0) {
|
||
// Sample environment at fixed mip level
|
||
// VNDF importance sampling handles the distribution filtering
|
||
vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
|
||
|
||
// Weight by NdotL for the split-sum approximation
|
||
// VNDF PDF naturally accounts for the visible microfacet distribution
|
||
prefilteredColor += sampleColor * NdotL;
|
||
totalWeight += NdotL;
|
||
}
|
||
}
|
||
|
||
if (totalWeight > 0.0) {
|
||
prefilteredColor = prefilteredColor / totalWeight;
|
||
}
|
||
|
||
gl_FragColor = vec4(prefilteredColor, 1.0);
|
||
}
|
||
`,blending:Zs,depthTest:!1,depthWrite:!1})}function UB(r,e,t){const i=new Float32Array(eo),n=new De(0,1,0);return new or({name:"SphericalGaussianBlur",defines:{n:eo,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:n}},vertexShader:Pp(),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:Zs,depthTest:!1,depthWrite:!1})}function Vy(){return new or({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Pp(),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:Zs,depthTest:!1,depthWrite:!1})}function Qy(){return new or({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Pp(),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:Zs,depthTest:!1,depthWrite:!1})}function Pp(){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 FB(r){let e=new WeakMap,t=null;function i(o){if(o&&o.isTexture){const l=o.mapping,c=l===mg||l===gg,h=l===ul||l===pl;if(c||h){let d=e.get(o);const p=d!==void 0?d.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==p)return t===null&&(t=new Hy(r)),d=c?t.fromEquirectangular(o,d):t.fromCubemap(o,d),d.texture.pmremVersion=o.pmremVersion,e.set(o,d),d.texture;if(d!==void 0)return d.texture;{const u=o.image;return c&&u&&u.height>0||h&&u&&n(u)?(t===null&&(t=new Hy(r)),d=c?t.fromEquirectangular(o):t.fromCubemap(o),d.texture.pmremVersion=o.pmremVersion,e.set(o,d),o.addEventListener("dispose",s),d.texture):null}}}return o}function n(o){let l=0;const c=6;for(let h=0;h<c;h++)o[h]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:a}}function OB(r){const e={};function t(i){if(e[i]!==void 0)return e[i];const n=r.getExtension(i);return e[i]=n,n}return{has:function(i){return t(i)!==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(i){const n=t(i);return n===null&&sh("WebGLRenderer: "+i+" extension not supported."),n}}}function zB(r,e,t,i){const n={},s=new WeakMap;function a(d){const p=d.target;p.index!==null&&e.remove(p.index);for(const A in p.attributes)e.remove(p.attributes[A]);p.removeEventListener("dispose",a),delete n[p.id];const u=s.get(p);u&&(e.remove(u),s.delete(p)),i.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,t.memory.geometries--}function o(d,p){return n[p.id]===!0||(p.addEventListener("dispose",a),n[p.id]=!0,t.memory.geometries++),p}function l(d){const p=d.attributes;for(const u in p)e.update(p[u],r.ARRAY_BUFFER)}function c(d){const p=[],u=d.index,A=d.attributes.position;let m=0;if(u!==null){const v=u.array;m=u.version;for(let b=0,y=v.length;b<y;b+=3){const M=v[b+0],_=v[b+1],S=v[b+2];p.push(M,_,_,S,S,M)}}else if(A!==void 0){const v=A.array;m=A.version;for(let b=0,y=v.length/3-1;b<y;b+=3){const M=b+0,_=b+1,S=b+2;p.push(M,_,_,S,S,M)}}else return;const g=new(ay(p)?wy:My)(p,1);g.version=m;const f=s.get(d);f&&e.remove(f),s.set(d,g)}function h(d){const p=s.get(d);if(p){const u=d.index;u!==null&&p.version<u.version&&c(d)}else c(d);return s.get(d)}return{get:o,update:l,getWireframeAttribute:h}}function HB(r,e,t){let i;function n(p){i=p}let s,a;function o(p){s=p.type,a=p.bytesPerElement}function l(p,u){r.drawElements(i,u,s,p*a),t.update(u,i,1)}function c(p,u,A){A!==0&&(r.drawElementsInstanced(i,u,s,p*a,A),t.update(u,i,A))}function h(p,u,A){if(A===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,u,0,s,p,0,A);let m=0;for(let g=0;g<A;g++)m+=u[g];t.update(m,i,1)}function d(p,u,A,m){if(A===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let f=0;f<p.length;f++)c(p[f]/a,u[f],m[f]);else{g.multiDrawElementsInstancedWEBGL(i,u,0,s,p,0,m,0,A);let f=0;for(let v=0;v<A;v++)f+=u[v]*m[v];t.update(f,i,1)}}this.setMode=n,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=d}function GB(r){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,a,o){switch(t.calls++,a){case r.TRIANGLES:t.triangles+=o*(s/3);break;case r.LINES:t.lines+=o*(s/2);break;case r.LINE_STRIP:t.lines+=o*(s-1);break;case r.LINE_LOOP:t.lines+=o*s;break;case r.POINTS:t.points+=o*s;break;default:yi("WebGLInfo: Unknown draw mode:",a);break}}function n(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:n,update:i}}function VB(r,e,t){const i=new WeakMap,n=new xi;function s(a,o,l){const c=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=h!==void 0?h.length:0;let p=i.get(o);if(p===void 0||p.count!==d){let u=function(){w.dispose(),i.delete(o),o.removeEventListener("dispose",u)};p!==void 0&&p.texture.dispose();const A=o.morphAttributes.position!==void 0,m=o.morphAttributes.normal!==void 0,g=o.morphAttributes.color!==void 0,f=o.morphAttributes.position||[],v=o.morphAttributes.normal||[],b=o.morphAttributes.color||[];let y=0;A===!0&&(y=1),m===!0&&(y=2),g===!0&&(y=3);let M=o.attributes.position.count*y,_=1;M>e.maxTextureSize&&(_=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);const S=new Float32Array(M*_*4*d),w=new uy(S,M,_,d);w.type=er,w.needsUpdate=!0;const E=y*4;for(let I=0;I<d;I++){const B=f[I],R=v[I],U=b[I],C=M*_*4*I;for(let F=0;F<B.count;F++){const O=F*E;A===!0&&(n.fromBufferAttribute(B,F),S[C+O+0]=n.x,S[C+O+1]=n.y,S[C+O+2]=n.z,S[C+O+3]=0),m===!0&&(n.fromBufferAttribute(R,F),S[C+O+4]=n.x,S[C+O+5]=n.y,S[C+O+6]=n.z,S[C+O+7]=0),g===!0&&(n.fromBufferAttribute(U,F),S[C+O+8]=n.x,S[C+O+9]=n.y,S[C+O+10]=n.z,S[C+O+11]=U.itemSize===4?n.w:1)}}p={count:d,texture:w,size:new Wt(M,_)},i.set(o,p),o.addEventListener("dispose",u)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(r,"morphTexture",a.morphTexture,t);else{let u=0;for(let m=0;m<c.length;m++)u+=c[m];const A=o.morphTargetsRelative?1:1-u;l.getUniforms().setValue(r,"morphTargetBaseInfluence",A),l.getUniforms().setValue(r,"morphTargetInfluences",c)}l.getUniforms().setValue(r,"morphTargetsTexture",p.texture,t),l.getUniforms().setValue(r,"morphTargetsTextureSize",p.size)}return{update:s}}function QB(r,e,t,i){let n=new WeakMap;function s(l){const c=i.render.frame,h=l.geometry,d=e.get(l,h);if(n.get(d)!==c&&(e.update(d),n.set(d,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),n.get(l)!==c&&(t.update(l.instanceMatrix,r.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,r.ARRAY_BUFFER),n.set(l,c))),l.isSkinnedMesh){const p=l.skeleton;n.get(p)!==c&&(p.update(),n.set(p,c))}return d}function a(){n=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:a}}const Wy=new pn,jy=new ky(1,1),qy=new uy,Xy=new AR,Yy=new By,Ky=[],Zy=[],Jy=new Float32Array(16),$y=new Float32Array(9),ex=new Float32Array(4);function Bl(r,e,t){const i=r[0];if(i<=0||i>0)return r;const n=e*t;let s=Ky[n];if(s===void 0&&(s=new Float32Array(n),Ky[n]=s),e!==0){i.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,r[a].toArray(s,o)}return s}function Fi(r,e){if(r.length!==e.length)return!1;for(let t=0,i=r.length;t<i;t++)if(r[t]!==e[t])return!1;return!0}function Oi(r,e){for(let t=0,i=e.length;t<i;t++)r[t]=e[t]}function Rp(r,e){let t=Zy[e];t===void 0&&(t=new Int32Array(e),Zy[e]=t);for(let i=0;i!==e;++i)t[i]=r.allocateTextureUnit();return t}function WB(r,e){const t=this.cache;t[0]!==e&&(r.uniform1f(this.addr,e),t[0]=e)}function jB(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Fi(t,e))return;r.uniform2fv(this.addr,e),Oi(t,e)}}function qB(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.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)&&(r.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Fi(t,e))return;r.uniform3fv(this.addr,e),Oi(t,e)}}function XB(r,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)&&(r.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(Fi(t,e))return;r.uniform4fv(this.addr,e),Oi(t,e)}}function YB(r,e){const t=this.cache,i=e.elements;if(i===void 0){if(Fi(t,e))return;r.uniformMatrix2fv(this.addr,!1,e),Oi(t,e)}else{if(Fi(t,i))return;ex.set(i),r.uniformMatrix2fv(this.addr,!1,ex),Oi(t,i)}}function KB(r,e){const t=this.cache,i=e.elements;if(i===void 0){if(Fi(t,e))return;r.uniformMatrix3fv(this.addr,!1,e),Oi(t,e)}else{if(Fi(t,i))return;$y.set(i),r.uniformMatrix3fv(this.addr,!1,$y),Oi(t,i)}}function ZB(r,e){const t=this.cache,i=e.elements;if(i===void 0){if(Fi(t,e))return;r.uniformMatrix4fv(this.addr,!1,e),Oi(t,e)}else{if(Fi(t,i))return;Jy.set(i),r.uniformMatrix4fv(this.addr,!1,Jy),Oi(t,i)}}function JB(r,e){const t=this.cache;t[0]!==e&&(r.uniform1i(this.addr,e),t[0]=e)}function $B(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Fi(t,e))return;r.uniform2iv(this.addr,e),Oi(t,e)}}function e5(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Fi(t,e))return;r.uniform3iv(this.addr,e),Oi(t,e)}}function t5(r,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)&&(r.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(Fi(t,e))return;r.uniform4iv(this.addr,e),Oi(t,e)}}function i5(r,e){const t=this.cache;t[0]!==e&&(r.uniform1ui(this.addr,e),t[0]=e)}function n5(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Fi(t,e))return;r.uniform2uiv(this.addr,e),Oi(t,e)}}function s5(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Fi(t,e))return;r.uniform3uiv(this.addr,e),Oi(t,e)}}function r5(r,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)&&(r.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(Fi(t,e))return;r.uniform4uiv(this.addr,e),Oi(t,e)}}function a5(r,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(r.uniform1i(this.addr,n),i[0]=n);let s;this.type===r.SAMPLER_2D_SHADOW?(jy.compareFunction=ny,s=jy):s=Wy,t.setTexture2D(e||s,n)}function o5(r,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(r.uniform1i(this.addr,n),i[0]=n),t.setTexture3D(e||Xy,n)}function l5(r,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(r.uniform1i(this.addr,n),i[0]=n),t.setTextureCube(e||Yy,n)}function c5(r,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(r.uniform1i(this.addr,n),i[0]=n),t.setTexture2DArray(e||qy,n)}function h5(r){switch(r){case 5126:return WB;case 35664:return jB;case 35665:return qB;case 35666:return XB;case 35674:return YB;case 35675:return KB;case 35676:return ZB;case 5124:case 35670:return JB;case 35667:case 35671:return $B;case 35668:case 35672:return e5;case 35669:case 35673:return t5;case 5125:return i5;case 36294:return n5;case 36295:return s5;case 36296:return r5;case 35678:case 36198:case 36298:case 36306:case 35682:return a5;case 35679:case 36299:case 36307:return o5;case 35680:case 36300:case 36308:case 36293:return l5;case 36289:case 36303:case 36311:case 36292:return c5}}function d5(r,e){r.uniform1fv(this.addr,e)}function u5(r,e){const t=Bl(e,this.size,2);r.uniform2fv(this.addr,t)}function p5(r,e){const t=Bl(e,this.size,3);r.uniform3fv(this.addr,t)}function f5(r,e){const t=Bl(e,this.size,4);r.uniform4fv(this.addr,t)}function m5(r,e){const t=Bl(e,this.size,4);r.uniformMatrix2fv(this.addr,!1,t)}function g5(r,e){const t=Bl(e,this.size,9);r.uniformMatrix3fv(this.addr,!1,t)}function A5(r,e){const t=Bl(e,this.size,16);r.uniformMatrix4fv(this.addr,!1,t)}function v5(r,e){r.uniform1iv(this.addr,e)}function b5(r,e){r.uniform2iv(this.addr,e)}function y5(r,e){r.uniform3iv(this.addr,e)}function x5(r,e){r.uniform4iv(this.addr,e)}function _5(r,e){r.uniform1uiv(this.addr,e)}function E5(r,e){r.uniform2uiv(this.addr,e)}function M5(r,e){r.uniform3uiv(this.addr,e)}function w5(r,e){r.uniform4uiv(this.addr,e)}function S5(r,e,t){const i=this.cache,n=e.length,s=Rp(t,n);Fi(i,s)||(r.uniform1iv(this.addr,s),Oi(i,s));for(let a=0;a!==n;++a)t.setTexture2D(e[a]||Wy,s[a])}function C5(r,e,t){const i=this.cache,n=e.length,s=Rp(t,n);Fi(i,s)||(r.uniform1iv(this.addr,s),Oi(i,s));for(let a=0;a!==n;++a)t.setTexture3D(e[a]||Xy,s[a])}function T5(r,e,t){const i=this.cache,n=e.length,s=Rp(t,n);Fi(i,s)||(r.uniform1iv(this.addr,s),Oi(i,s));for(let a=0;a!==n;++a)t.setTextureCube(e[a]||Yy,s[a])}function I5(r,e,t){const i=this.cache,n=e.length,s=Rp(t,n);Fi(i,s)||(r.uniform1iv(this.addr,s),Oi(i,s));for(let a=0;a!==n;++a)t.setTexture2DArray(e[a]||qy,s[a])}function P5(r){switch(r){case 5126:return d5;case 35664:return u5;case 35665:return p5;case 35666:return f5;case 35674:return m5;case 35675:return g5;case 35676:return A5;case 5124:case 35670:return v5;case 35667:case 35671:return b5;case 35668:case 35672:return y5;case 35669:case 35673:return x5;case 5125:return _5;case 36294:return E5;case 36295:return M5;case 36296:return w5;case 35678:case 36198:case 36298:case 36306:case 35682:return S5;case 35679:case 36299:case 36307:return C5;case 35680:case 36300:case 36308:case 36293:return T5;case 36289:case 36303:case 36311:case 36292:return I5}}class R5{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=h5(t.type)}}class D5{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=P5(t.type)}}class B5{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const n=this.seq;for(let s=0,a=n.length;s!==a;++s){const o=n[s];o.setValue(e,t[o.id],i)}}}const D0=/(\w+)(\])?(\[|\.)?/g;function tx(r,e){r.seq.push(e),r.map[e.id]=e}function L5(r,e,t){const i=r.name,n=i.length;for(D0.lastIndex=0;;){const s=D0.exec(i),a=D0.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===n){tx(t,c===void 0?new R5(o,r,e):new D5(o,r,e));break}else{let h=t.map[o];h===void 0&&(h=new B5(o),tx(t,h)),t=h}}}class Dp{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let n=0;n<i;++n){const s=e.getActiveUniform(t,n),a=e.getUniformLocation(t,s.name);L5(s,a,this)}}setValue(e,t,i,n){const s=this.map[t];s!==void 0&&s.setValue(e,i,n)}setOptional(e,t,i){const n=t[i];n!==void 0&&this.setValue(e,i,n)}static upload(e,t,i,n){for(let s=0,a=t.length;s!==a;++s){const o=t[s],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,n)}}static seqWithValue(e,t){const i=[];for(let n=0,s=e.length;n!==s;++n){const a=e[n];a.id in t&&i.push(a)}return i}}function ix(r,e,t){const i=r.createShader(e);return r.shaderSource(i,t),r.compileShader(i),i}const k5=37297;let N5=0;function U5(r,e){const t=r.split(`
|
||
`),i=[],n=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=n;a<s;a++){const o=a+1;i.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return i.join(`
|
||
`)}const nx=new xt;function F5(r){Nt._getMatrix(nx,Nt.workingColorSpace,r);const e=`mat3( ${nx.elements.map(t=>t.toFixed(4))} )`;switch(Nt.getTransfer(r)){case ap:return[e,"LinearTransferOETF"];case Qt:return[e,"sRGBTransferOETF"];default:return At("WebGLProgram: Unsupported color space: ",r),[e,"LinearTransferOETF"]}}function sx(r,e,t){const i=r.getShaderParameter(e,r.COMPILE_STATUS),n=(r.getShaderInfoLog(e)||"").trim();if(i&&n==="")return"";const s=/ERROR: 0:(\d+)/.exec(n);if(s){const a=parseInt(s[1]);return t.toUpperCase()+`
|
||
|
||
`+n+`
|
||
|
||
`+U5(r.getShaderSource(e),a)}else return n}function O5(r,e){const t=F5(e);return[`vec4 ${r}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
||
`)}function z5(r,e){let t;switch(e){case QP:t="Linear";break;case WP:t="Reinhard";break;case jP:t="Cineon";break;case qP:t="ACESFilmic";break;case YP:t="AgX";break;case KP:t="Neutral";break;case XP:t="Custom";break;default:At("WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+r+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Bp=new De;function H5(){Nt.getLuminanceCoefficients(Bp);const r=Bp.x.toFixed(4),e=Bp.y.toFixed(4),t=Bp.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${r}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
||
`)}function G5(r){return[r.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",r.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(mh).join(`
|
||
`)}function V5(r){const e=[];for(const t in r){const i=r[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
|
||
`)}function Q5(r,e){const t={},i=r.getProgramParameter(e,r.ACTIVE_ATTRIBUTES);for(let n=0;n<i;n++){const s=r.getActiveAttrib(e,n),a=s.name;let o=1;s.type===r.FLOAT_MAT2&&(o=2),s.type===r.FLOAT_MAT3&&(o=3),s.type===r.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:r.getAttribLocation(e,a),locationSize:o}}return t}function mh(r){return r!==""}function rx(r,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return r.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 ax(r,e){return r.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const W5=/^[ \t]*#include +<([\w\d./]+)>/gm;function B0(r){return r.replace(W5,q5)}const j5=new Map;function q5(r,e){let t=wt[e];if(t===void 0){const i=j5.get(e);if(i!==void 0)t=wt[i],At('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return B0(t)}const X5=/#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 ox(r){return r.replace(X5,Y5)}function Y5(r,e,t,i){let n="";for(let s=parseInt(e);s<parseInt(t);s++)n+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return n}function lx(r){let e=`precision ${r.precision} float;
|
||
precision ${r.precision} int;
|
||
precision ${r.precision} sampler2D;
|
||
precision ${r.precision} samplerCube;
|
||
precision ${r.precision} sampler3D;
|
||
precision ${r.precision} sampler2DArray;
|
||
precision ${r.precision} sampler2DShadow;
|
||
precision ${r.precision} samplerCubeShadow;
|
||
precision ${r.precision} sampler2DArrayShadow;
|
||
precision ${r.precision} isampler2D;
|
||
precision ${r.precision} isampler3D;
|
||
precision ${r.precision} isamplerCube;
|
||
precision ${r.precision} isampler2DArray;
|
||
precision ${r.precision} usampler2D;
|
||
precision ${r.precision} usampler3D;
|
||
precision ${r.precision} usamplerCube;
|
||
precision ${r.precision} usampler2DArray;
|
||
`;return r.precision==="highp"?e+=`
|
||
#define HIGH_PRECISION`:r.precision==="mediump"?e+=`
|
||
#define MEDIUM_PRECISION`:r.precision==="lowp"&&(e+=`
|
||
#define LOW_PRECISION`),e}function K5(r){let e="SHADOWMAP_TYPE_BASIC";return r.shadowMapType===G1?e="SHADOWMAP_TYPE_PCF":r.shadowMapType===V1?e="SHADOWMAP_TYPE_PCF_SOFT":r.shadowMapType===Ys&&(e="SHADOWMAP_TYPE_VSM"),e}function Z5(r){let e="ENVMAP_TYPE_CUBE";if(r.envMap)switch(r.envMapMode){case ul:case pl:e="ENVMAP_TYPE_CUBE";break;case ep:e="ENVMAP_TYPE_CUBE_UV";break}return e}function J5(r){let e="ENVMAP_MODE_REFLECTION";return r.envMap&&r.envMapMode===pl&&(e="ENVMAP_MODE_REFRACTION"),e}function $5(r){let e="ENVMAP_BLENDING_NONE";if(r.envMap)switch(r.combine){case q1:e="ENVMAP_BLENDING_MULTIPLY";break;case GP:e="ENVMAP_BLENDING_MIX";break;case VP:e="ENVMAP_BLENDING_ADD";break}return e}function eL(r){const e=r.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function tL(r,e,t,i){const n=r.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=K5(t),c=Z5(t),h=J5(t),d=$5(t),p=eL(t),u=G5(t),A=V5(s),m=n.createProgram();let g,f,v=t.glslVersion?"#version "+t.glslVersion+`
|
||
`:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,A].filter(mh).join(`
|
||
`),g.length>0&&(g+=`
|
||
`),f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,A].filter(mh).join(`
|
||
`),f.length>0&&(f+=`
|
||
`)):(g=[lx(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,A,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 "+h:"",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 "+l:"",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(mh).join(`
|
||
`),f=[lx(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,A,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 "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+d:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.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 "+l:"",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!==Gr?"#define TONE_MAPPING":"",t.toneMapping!==Gr?wt.tonemapping_pars_fragment:"",t.toneMapping!==Gr?z5("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",wt.colorspace_pars_fragment,O5("linearToOutputTexel",t.outputColorSpace),H5(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
||
`].filter(mh).join(`
|
||
`)),a=B0(a),a=rx(a,t),a=ax(a,t),o=B0(o),o=rx(o,t),o=ax(o,t),a=ox(a),o=ox(o),t.isRawShaderMaterial!==!0&&(v=`#version 300 es
|
||
`,g=[u,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
||
`)+`
|
||
`+g,f=["#define varying in",t.glslVersion===ry?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===ry?"":"#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(`
|
||
`)+`
|
||
`+f);const b=v+g+a,y=v+f+o,M=ix(n,n.VERTEX_SHADER,b),_=ix(n,n.FRAGMENT_SHADER,y);n.attachShader(m,M),n.attachShader(m,_),t.index0AttributeName!==void 0?n.bindAttribLocation(m,0,t.index0AttributeName):t.morphTargets===!0&&n.bindAttribLocation(m,0,"position"),n.linkProgram(m);function S(B){if(r.debug.checkShaderErrors){const R=n.getProgramInfoLog(m)||"",U=n.getShaderInfoLog(M)||"",C=n.getShaderInfoLog(_)||"",F=R.trim(),O=U.trim(),H=C.trim();let j=!0,G=!0;if(n.getProgramParameter(m,n.LINK_STATUS)===!1)if(j=!1,typeof r.debug.onShaderError=="function")r.debug.onShaderError(n,m,M,_);else{const re=sx(n,M,"vertex"),q=sx(n,_,"fragment");yi("THREE.WebGLProgram: Shader Error "+n.getError()+" - VALIDATE_STATUS "+n.getProgramParameter(m,n.VALIDATE_STATUS)+`
|
||
|
||
Material Name: `+B.name+`
|
||
Material Type: `+B.type+`
|
||
|
||
Program Info Log: `+F+`
|
||
`+re+`
|
||
`+q)}else F!==""?At("WebGLProgram: Program Info Log:",F):(O===""||H==="")&&(G=!1);G&&(B.diagnostics={runnable:j,programLog:F,vertexShader:{log:O,prefix:g},fragmentShader:{log:H,prefix:f}})}n.deleteShader(M),n.deleteShader(_),w=new Dp(n,m),E=Q5(n,m)}let w;this.getUniforms=function(){return w===void 0&&S(this),w};let E;this.getAttributes=function(){return E===void 0&&S(this),E};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=n.getProgramParameter(m,k5)),I},this.destroy=function(){i.releaseStatesOfProgram(this),n.deleteProgram(m),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=N5++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=M,this.fragmentShader=_,this}let iL=0;class nL{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,n=this._getShaderStage(t),s=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return a.has(n)===!1&&(a.add(n),n.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.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 i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new sL(e),t.set(e,i)),i}}class sL{constructor(e){this.id=iL++,this.code=e,this.usedTimes=0}}function rL(r,e,t,i,n,s,a){const o=new my,l=new nL,c=new Set,h=[],d=n.logarithmicDepthBuffer,p=n.vertexTextures;let u=n.precision;const A={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(E){return c.add(E),E===0?"uv":`uv${E}`}function g(E,I,B,R,U){const C=R.fog,F=U.geometry,O=E.isMeshStandardMaterial?R.environment:null,H=(E.isMeshStandardMaterial?t:e).get(E.envMap||O),j=H&&H.mapping===ep?H.image.height:null,G=A[E.type];E.precision!==null&&(u=n.getMaxPrecision(E.precision),u!==E.precision&&At("WebGLProgram.getParameters:",E.precision,"not supported, using",u,"instead."));const re=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,q=re!==void 0?re.length:0;let Y=0;F.morphAttributes.position!==void 0&&(Y=1),F.morphAttributes.normal!==void 0&&(Y=2),F.morphAttributes.color!==void 0&&(Y=3);let ye,Me,xe,J;if(G){const et=Rs[G];ye=et.vertexShader,Me=et.fragmentShader}else ye=E.vertexShader,Me=E.fragmentShader,l.update(E),xe=l.getVertexShaderID(E),J=l.getFragmentShaderID(E);const oe=r.getRenderTarget(),ue=r.state.buffers.depth.getReversed(),Pe=U.isInstancedMesh===!0,Be=U.isBatchedMesh===!0,Ue=!!E.map,it=!!E.matcap,qe=!!H,D=!!E.aoMap,ae=!!E.lightMap,$=!!E.bumpMap,Q=!!E.normalMap,L=!!E.displacementMap,te=!!E.emissiveMap,de=!!E.metalnessMap,V=!!E.roughnessMap,ee=E.anisotropy>0,P=E.clearcoat>0,x=E.dispersion>0,N=E.iridescence>0,X=E.sheen>0,Z=E.transmission>0,K=ee&&!!E.anisotropyMap,Ie=P&&!!E.clearcoatMap,ge=P&&!!E.clearcoatNormalMap,ke=P&&!!E.clearcoatRoughnessMap,Oe=N&&!!E.iridescenceMap,le=N&&!!E.iridescenceThicknessMap,Ae=X&&!!E.sheenColorMap,ze=X&&!!E.sheenRoughnessMap,Ne=!!E.specularMap,we=!!E.specularColorMap,je=!!E.specularIntensityMap,z=Z&&!!E.transmissionMap,ve=Z&&!!E.thicknessMap,me=!!E.gradientMap,Re=!!E.alphaMap,pe=E.alphaTest>0,ne=!!E.alphaHash,Le=!!E.extensions;let Qe=Gr;E.toneMapped&&(oe===null||oe.isXRRenderTarget===!0)&&(Qe=r.toneMapping);const pt={shaderID:G,shaderType:E.type,shaderName:E.name,vertexShader:ye,fragmentShader:Me,defines:E.defines,customVertexShaderID:xe,customFragmentShaderID:J,isRawShaderMaterial:E.isRawShaderMaterial===!0,glslVersion:E.glslVersion,precision:u,batching:Be,batchingColor:Be&&U._colorsTexture!==null,instancing:Pe,instancingColor:Pe&&U.instanceColor!==null,instancingMorph:Pe&&U.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:oe===null?r.outputColorSpace:oe.isXRRenderTarget===!0?oe.texture.colorSpace:ml,alphaToCoverage:!!E.alphaToCoverage,map:Ue,matcap:it,envMap:qe,envMapMode:qe&&H.mapping,envMapCubeUVHeight:j,aoMap:D,lightMap:ae,bumpMap:$,normalMap:Q,displacementMap:p&&L,emissiveMap:te,normalMapObjectSpace:Q&&E.normalMapType===tR,normalMapTangentSpace:Q&&E.normalMapType===eR,metalnessMap:de,roughnessMap:V,anisotropy:ee,anisotropyMap:K,clearcoat:P,clearcoatMap:Ie,clearcoatNormalMap:ge,clearcoatRoughnessMap:ke,dispersion:x,iridescence:N,iridescenceMap:Oe,iridescenceThicknessMap:le,sheen:X,sheenColorMap:Ae,sheenRoughnessMap:ze,specularMap:Ne,specularColorMap:we,specularIntensityMap:je,transmission:Z,transmissionMap:z,thicknessMap:ve,gradientMap:me,opaque:E.transparent===!1&&E.blending===hl&&E.alphaToCoverage===!1,alphaMap:Re,alphaTest:pe,alphaHash:ne,combine:E.combine,mapUv:Ue&&m(E.map.channel),aoMapUv:D&&m(E.aoMap.channel),lightMapUv:ae&&m(E.lightMap.channel),bumpMapUv:$&&m(E.bumpMap.channel),normalMapUv:Q&&m(E.normalMap.channel),displacementMapUv:L&&m(E.displacementMap.channel),emissiveMapUv:te&&m(E.emissiveMap.channel),metalnessMapUv:de&&m(E.metalnessMap.channel),roughnessMapUv:V&&m(E.roughnessMap.channel),anisotropyMapUv:K&&m(E.anisotropyMap.channel),clearcoatMapUv:Ie&&m(E.clearcoatMap.channel),clearcoatNormalMapUv:ge&&m(E.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ke&&m(E.clearcoatRoughnessMap.channel),iridescenceMapUv:Oe&&m(E.iridescenceMap.channel),iridescenceThicknessMapUv:le&&m(E.iridescenceThicknessMap.channel),sheenColorMapUv:Ae&&m(E.sheenColorMap.channel),sheenRoughnessMapUv:ze&&m(E.sheenRoughnessMap.channel),specularMapUv:Ne&&m(E.specularMap.channel),specularColorMapUv:we&&m(E.specularColorMap.channel),specularIntensityMapUv:je&&m(E.specularIntensityMap.channel),transmissionMapUv:z&&m(E.transmissionMap.channel),thicknessMapUv:ve&&m(E.thicknessMap.channel),alphaMapUv:Re&&m(E.alphaMap.channel),vertexTangents:!!F.attributes.tangent&&(Q||ee),vertexColors:E.vertexColors,vertexAlphas:E.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,pointsUvs:U.isPoints===!0&&!!F.attributes.uv&&(Ue||Re),fog:!!C,useFog:E.fog===!0,fogExp2:!!C&&C.isFogExp2,flatShading:E.flatShading===!0&&E.wireframe===!1,sizeAttenuation:E.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:ue,skinning:U.isSkinnedMesh===!0,morphTargets:F.morphAttributes.position!==void 0,morphNormals:F.morphAttributes.normal!==void 0,morphColors:F.morphAttributes.color!==void 0,morphTargetsCount:q,morphTextureStride:Y,numDirLights:I.directional.length,numPointLights:I.point.length,numSpotLights:I.spot.length,numSpotLightMaps:I.spotLightMap.length,numRectAreaLights:I.rectArea.length,numHemiLights:I.hemi.length,numDirLightShadows:I.directionalShadowMap.length,numPointLightShadows:I.pointShadowMap.length,numSpotLightShadows:I.spotShadowMap.length,numSpotLightShadowsWithMaps:I.numSpotLightShadowsWithMaps,numLightProbes:I.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:E.dithering,shadowMapEnabled:r.shadowMap.enabled&&B.length>0,shadowMapType:r.shadowMap.type,toneMapping:Qe,decodeVideoTexture:Ue&&E.map.isVideoTexture===!0&&Nt.getTransfer(E.map.colorSpace)===Qt,decodeVideoTextureEmissive:te&&E.emissiveMap.isVideoTexture===!0&&Nt.getTransfer(E.emissiveMap.colorSpace)===Qt,premultipliedAlpha:E.premultipliedAlpha,doubleSided:E.side===Ks,flipSided:E.side===xn,useDepthPacking:E.depthPacking>=0,depthPacking:E.depthPacking||0,index0AttributeName:E.index0AttributeName,extensionClipCullDistance:Le&&E.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Le&&E.extensions.multiDraw===!0||Be)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:E.customProgramCacheKey()};return pt.vertexUv1s=c.has(1),pt.vertexUv2s=c.has(2),pt.vertexUv3s=c.has(3),c.clear(),pt}function f(E){const I=[];if(E.shaderID?I.push(E.shaderID):(I.push(E.customVertexShaderID),I.push(E.customFragmentShaderID)),E.defines!==void 0)for(const B in E.defines)I.push(B),I.push(E.defines[B]);return E.isRawShaderMaterial===!1&&(v(I,E),b(I,E),I.push(r.outputColorSpace)),I.push(E.customProgramCacheKey),I.join()}function v(E,I){E.push(I.precision),E.push(I.outputColorSpace),E.push(I.envMapMode),E.push(I.envMapCubeUVHeight),E.push(I.mapUv),E.push(I.alphaMapUv),E.push(I.lightMapUv),E.push(I.aoMapUv),E.push(I.bumpMapUv),E.push(I.normalMapUv),E.push(I.displacementMapUv),E.push(I.emissiveMapUv),E.push(I.metalnessMapUv),E.push(I.roughnessMapUv),E.push(I.anisotropyMapUv),E.push(I.clearcoatMapUv),E.push(I.clearcoatNormalMapUv),E.push(I.clearcoatRoughnessMapUv),E.push(I.iridescenceMapUv),E.push(I.iridescenceThicknessMapUv),E.push(I.sheenColorMapUv),E.push(I.sheenRoughnessMapUv),E.push(I.specularMapUv),E.push(I.specularColorMapUv),E.push(I.specularIntensityMapUv),E.push(I.transmissionMapUv),E.push(I.thicknessMapUv),E.push(I.combine),E.push(I.fogExp2),E.push(I.sizeAttenuation),E.push(I.morphTargetsCount),E.push(I.morphAttributeCount),E.push(I.numDirLights),E.push(I.numPointLights),E.push(I.numSpotLights),E.push(I.numSpotLightMaps),E.push(I.numHemiLights),E.push(I.numRectAreaLights),E.push(I.numDirLightShadows),E.push(I.numPointLightShadows),E.push(I.numSpotLightShadows),E.push(I.numSpotLightShadowsWithMaps),E.push(I.numLightProbes),E.push(I.shadowMapType),E.push(I.toneMapping),E.push(I.numClippingPlanes),E.push(I.numClipIntersection),E.push(I.depthPacking)}function b(E,I){o.disableAll(),I.supportsVertexTextures&&o.enable(0),I.instancing&&o.enable(1),I.instancingColor&&o.enable(2),I.instancingMorph&&o.enable(3),I.matcap&&o.enable(4),I.envMap&&o.enable(5),I.normalMapObjectSpace&&o.enable(6),I.normalMapTangentSpace&&o.enable(7),I.clearcoat&&o.enable(8),I.iridescence&&o.enable(9),I.alphaTest&&o.enable(10),I.vertexColors&&o.enable(11),I.vertexAlphas&&o.enable(12),I.vertexUv1s&&o.enable(13),I.vertexUv2s&&o.enable(14),I.vertexUv3s&&o.enable(15),I.vertexTangents&&o.enable(16),I.anisotropy&&o.enable(17),I.alphaHash&&o.enable(18),I.batching&&o.enable(19),I.dispersion&&o.enable(20),I.batchingColor&&o.enable(21),I.gradientMap&&o.enable(22),E.push(o.mask),o.disableAll(),I.fog&&o.enable(0),I.useFog&&o.enable(1),I.flatShading&&o.enable(2),I.logarithmicDepthBuffer&&o.enable(3),I.reversedDepthBuffer&&o.enable(4),I.skinning&&o.enable(5),I.morphTargets&&o.enable(6),I.morphNormals&&o.enable(7),I.morphColors&&o.enable(8),I.premultipliedAlpha&&o.enable(9),I.shadowMapEnabled&&o.enable(10),I.doubleSided&&o.enable(11),I.flipSided&&o.enable(12),I.useDepthPacking&&o.enable(13),I.dithering&&o.enable(14),I.transmission&&o.enable(15),I.sheen&&o.enable(16),I.opaque&&o.enable(17),I.pointsUvs&&o.enable(18),I.decodeVideoTexture&&o.enable(19),I.decodeVideoTextureEmissive&&o.enable(20),I.alphaToCoverage&&o.enable(21),E.push(o.mask)}function y(E){const I=A[E.type];let B;if(I){const R=Rs[I];B=RR.clone(R.uniforms)}else B=E.uniforms;return B}function M(E,I){let B;for(let R=0,U=h.length;R<U;R++){const C=h[R];if(C.cacheKey===I){B=C,++B.usedTimes;break}}return B===void 0&&(B=new tL(r,I,E,s),h.push(B)),B}function _(E){if(--E.usedTimes===0){const I=h.indexOf(E);h[I]=h[h.length-1],h.pop(),E.destroy()}}function S(E){l.remove(E)}function w(){l.dispose()}return{getParameters:g,getProgramCacheKey:f,getUniforms:y,acquireProgram:M,releaseProgram:_,releaseShaderCache:S,programs:h,dispose:w}}function aL(){let r=new WeakMap;function e(a){return r.has(a)}function t(a){let o=r.get(a);return o===void 0&&(o={},r.set(a,o)),o}function i(a){r.delete(a)}function n(a,o,l){r.get(a)[o]=l}function s(){r=new WeakMap}return{has:e,get:t,remove:i,update:n,dispose:s}}function oL(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.z!==e.z?r.z-e.z:r.id-e.id}function cx(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function hx(){const r=[];let e=0;const t=[],i=[],n=[];function s(){e=0,t.length=0,i.length=0,n.length=0}function a(d,p,u,A,m,g){let f=r[e];return f===void 0?(f={id:d.id,object:d,geometry:p,material:u,groupOrder:A,renderOrder:d.renderOrder,z:m,group:g},r[e]=f):(f.id=d.id,f.object=d,f.geometry=p,f.material=u,f.groupOrder=A,f.renderOrder=d.renderOrder,f.z=m,f.group=g),e++,f}function o(d,p,u,A,m,g){const f=a(d,p,u,A,m,g);u.transmission>0?i.push(f):u.transparent===!0?n.push(f):t.push(f)}function l(d,p,u,A,m,g){const f=a(d,p,u,A,m,g);u.transmission>0?i.unshift(f):u.transparent===!0?n.unshift(f):t.unshift(f)}function c(d,p){t.length>1&&t.sort(d||oL),i.length>1&&i.sort(p||cx),n.length>1&&n.sort(p||cx)}function h(){for(let d=e,p=r.length;d<p;d++){const u=r[d];if(u.id===null)break;u.id=null,u.object=null,u.geometry=null,u.material=null,u.group=null}}return{opaque:t,transmissive:i,transparent:n,init:s,push:o,unshift:l,finish:h,sort:c}}function lL(){let r=new WeakMap;function e(i,n){const s=r.get(i);let a;return s===void 0?(a=new hx,r.set(i,[a])):n>=s.length?(a=new hx,s.push(a)):a=s[n],a}function t(){r=new WeakMap}return{get:e,dispose:t}}function cL(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new De,color:new jt};break;case"SpotLight":t={position:new De,direction:new De,color:new jt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new De,color:new jt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new De,skyColor:new jt,groundColor:new jt};break;case"RectAreaLight":t={color:new jt,position:new De,halfWidth:new De,halfHeight:new De};break}return r[e.id]=t,t}}}function hL(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Wt};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Wt};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Wt,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let dL=0;function uL(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function pL(r){const e=new cL,t=hL(),i={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 c=0;c<9;c++)i.probe.push(new De);const n=new De,s=new Ui,a=new Ui;function o(c){let h=0,d=0,p=0;for(let E=0;E<9;E++)i.probe[E].set(0,0,0);let u=0,A=0,m=0,g=0,f=0,v=0,b=0,y=0,M=0,_=0,S=0;c.sort(uL);for(let E=0,I=c.length;E<I;E++){const B=c[E],R=B.color,U=B.intensity,C=B.distance,F=B.shadow&&B.shadow.map?B.shadow.map.texture:null;if(B.isAmbientLight)h+=R.r*U,d+=R.g*U,p+=R.b*U;else if(B.isLightProbe){for(let O=0;O<9;O++)i.probe[O].addScaledVector(B.sh.coefficients[O],U);S++}else if(B.isDirectionalLight){const O=e.get(B);if(O.color.copy(B.color).multiplyScalar(B.intensity),B.castShadow){const H=B.shadow,j=t.get(B);j.shadowIntensity=H.intensity,j.shadowBias=H.bias,j.shadowNormalBias=H.normalBias,j.shadowRadius=H.radius,j.shadowMapSize=H.mapSize,i.directionalShadow[u]=j,i.directionalShadowMap[u]=F,i.directionalShadowMatrix[u]=B.shadow.matrix,v++}i.directional[u]=O,u++}else if(B.isSpotLight){const O=e.get(B);O.position.setFromMatrixPosition(B.matrixWorld),O.color.copy(R).multiplyScalar(U),O.distance=C,O.coneCos=Math.cos(B.angle),O.penumbraCos=Math.cos(B.angle*(1-B.penumbra)),O.decay=B.decay,i.spot[m]=O;const H=B.shadow;if(B.map&&(i.spotLightMap[M]=B.map,M++,H.updateMatrices(B),B.castShadow&&_++),i.spotLightMatrix[m]=H.matrix,B.castShadow){const j=t.get(B);j.shadowIntensity=H.intensity,j.shadowBias=H.bias,j.shadowNormalBias=H.normalBias,j.shadowRadius=H.radius,j.shadowMapSize=H.mapSize,i.spotShadow[m]=j,i.spotShadowMap[m]=F,y++}m++}else if(B.isRectAreaLight){const O=e.get(B);O.color.copy(R).multiplyScalar(U),O.halfWidth.set(B.width*.5,0,0),O.halfHeight.set(0,B.height*.5,0),i.rectArea[g]=O,g++}else if(B.isPointLight){const O=e.get(B);if(O.color.copy(B.color).multiplyScalar(B.intensity),O.distance=B.distance,O.decay=B.decay,B.castShadow){const H=B.shadow,j=t.get(B);j.shadowIntensity=H.intensity,j.shadowBias=H.bias,j.shadowNormalBias=H.normalBias,j.shadowRadius=H.radius,j.shadowMapSize=H.mapSize,j.shadowCameraNear=H.camera.near,j.shadowCameraFar=H.camera.far,i.pointShadow[A]=j,i.pointShadowMap[A]=F,i.pointShadowMatrix[A]=B.shadow.matrix,b++}i.point[A]=O,A++}else if(B.isHemisphereLight){const O=e.get(B);O.skyColor.copy(B.color).multiplyScalar(U),O.groundColor.copy(B.groundColor).multiplyScalar(U),i.hemi[f]=O,f++}}g>0&&(r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=$e.LTC_FLOAT_1,i.rectAreaLTC2=$e.LTC_FLOAT_2):(i.rectAreaLTC1=$e.LTC_HALF_1,i.rectAreaLTC2=$e.LTC_HALF_2)),i.ambient[0]=h,i.ambient[1]=d,i.ambient[2]=p;const w=i.hash;(w.directionalLength!==u||w.pointLength!==A||w.spotLength!==m||w.rectAreaLength!==g||w.hemiLength!==f||w.numDirectionalShadows!==v||w.numPointShadows!==b||w.numSpotShadows!==y||w.numSpotMaps!==M||w.numLightProbes!==S)&&(i.directional.length=u,i.spot.length=m,i.rectArea.length=g,i.point.length=A,i.hemi.length=f,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.pointShadow.length=b,i.pointShadowMap.length=b,i.spotShadow.length=y,i.spotShadowMap.length=y,i.directionalShadowMatrix.length=v,i.pointShadowMatrix.length=b,i.spotLightMatrix.length=y+M-_,i.spotLightMap.length=M,i.numSpotLightShadowsWithMaps=_,i.numLightProbes=S,w.directionalLength=u,w.pointLength=A,w.spotLength=m,w.rectAreaLength=g,w.hemiLength=f,w.numDirectionalShadows=v,w.numPointShadows=b,w.numSpotShadows=y,w.numSpotMaps=M,w.numLightProbes=S,i.version=dL++)}function l(c,h){let d=0,p=0,u=0,A=0,m=0;const g=h.matrixWorldInverse;for(let f=0,v=c.length;f<v;f++){const b=c[f];if(b.isDirectionalLight){const y=i.directional[d];y.direction.setFromMatrixPosition(b.matrixWorld),n.setFromMatrixPosition(b.target.matrixWorld),y.direction.sub(n),y.direction.transformDirection(g),d++}else if(b.isSpotLight){const y=i.spot[u];y.position.setFromMatrixPosition(b.matrixWorld),y.position.applyMatrix4(g),y.direction.setFromMatrixPosition(b.matrixWorld),n.setFromMatrixPosition(b.target.matrixWorld),y.direction.sub(n),y.direction.transformDirection(g),u++}else if(b.isRectAreaLight){const y=i.rectArea[A];y.position.setFromMatrixPosition(b.matrixWorld),y.position.applyMatrix4(g),a.identity(),s.copy(b.matrixWorld),s.premultiply(g),a.extractRotation(s),y.halfWidth.set(b.width*.5,0,0),y.halfHeight.set(0,b.height*.5,0),y.halfWidth.applyMatrix4(a),y.halfHeight.applyMatrix4(a),A++}else if(b.isPointLight){const y=i.point[p];y.position.setFromMatrixPosition(b.matrixWorld),y.position.applyMatrix4(g),p++}else if(b.isHemisphereLight){const y=i.hemi[m];y.direction.setFromMatrixPosition(b.matrixWorld),y.direction.transformDirection(g),m++}}}return{setup:o,setupView:l,state:i}}function dx(r){const e=new pL(r),t=[],i=[];function n(h){c.camera=h,t.length=0,i.length=0}function s(h){t.push(h)}function a(h){i.push(h)}function o(){e.setup(t)}function l(h){e.setupView(t,h)}const c={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:n,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function fL(r){let e=new WeakMap;function t(n,s=0){const a=e.get(n);let o;return a===void 0?(o=new dx(r),e.set(n,[o])):s>=a.length?(o=new dx(r),a.push(o)):o=a[s],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const mL=`void main() {
|
||
gl_Position = vec4( position, 1.0 );
|
||
}`,gL=`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 AL(r,e,t){let i=new Ly;const n=new Wt,s=new Wt,a=new xi,o=new HR({depthPacking:$P}),l=new GR,c={},h=t.maxTextureSize,d={[Hr]:xn,[xn]:Hr,[Ks]:Ks},p=new or({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Wt},radius:{value:4}},vertexShader:mL,fragmentShader:gL}),u=p.clone();u.defines.HORIZONTAL_PASS=1;const A=new Yr;A.setAttribute("position",new Ps(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new Kr(A,p),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=G1;let f=this.type;this.render=function(_,S,w){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||_.length===0)return;const E=r.getRenderTarget(),I=r.getActiveCubeFace(),B=r.getActiveMipmapLevel(),R=r.state;R.setBlending(Zs),R.buffers.depth.getReversed()===!0?R.buffers.color.setClear(0,0,0,0):R.buffers.color.setClear(1,1,1,1),R.buffers.depth.setTest(!0),R.setScissorTest(!1);const U=f!==Ys&&this.type===Ys,C=f===Ys&&this.type!==Ys;for(let F=0,O=_.length;F<O;F++){const H=_[F],j=H.shadow;if(j===void 0){At("WebGLShadowMap:",H,"has no shadow.");continue}if(j.autoUpdate===!1&&j.needsUpdate===!1)continue;n.copy(j.mapSize);const G=j.getFrameExtents();if(n.multiply(G),s.copy(j.mapSize),(n.x>h||n.y>h)&&(n.x>h&&(s.x=Math.floor(h/G.x),n.x=s.x*G.x,j.mapSize.x=s.x),n.y>h&&(s.y=Math.floor(h/G.y),n.y=s.y*G.y,j.mapSize.y=s.y)),j.map===null||U===!0||C===!0){const q=this.type!==Ys?{minFilter:kn,magFilter:kn}:{};j.map!==null&&j.map.dispose(),j.map=new Wa(n.x,n.y,q),j.map.texture.name=H.name+".shadowMap",j.camera.updateProjectionMatrix()}r.setRenderTarget(j.map),r.clear();const re=j.getViewportCount();for(let q=0;q<re;q++){const Y=j.getViewport(q);a.set(s.x*Y.x,s.y*Y.y,s.x*Y.z,s.y*Y.w),R.viewport(a),j.updateMatrices(H,q),i=j.getFrustum(),y(S,w,j.camera,H,this.type)}j.isPointLightShadow!==!0&&this.type===Ys&&v(j,w),j.needsUpdate=!1}f=this.type,g.needsUpdate=!1,r.setRenderTarget(E,I,B)};function v(_,S){const w=e.update(m);p.defines.VSM_SAMPLES!==_.blurSamples&&(p.defines.VSM_SAMPLES=_.blurSamples,u.defines.VSM_SAMPLES=_.blurSamples,p.needsUpdate=!0,u.needsUpdate=!0),_.mapPass===null&&(_.mapPass=new Wa(n.x,n.y)),p.uniforms.shadow_pass.value=_.map.texture,p.uniforms.resolution.value=_.mapSize,p.uniforms.radius.value=_.radius,r.setRenderTarget(_.mapPass),r.clear(),r.renderBufferDirect(S,null,w,p,m,null),u.uniforms.shadow_pass.value=_.mapPass.texture,u.uniforms.resolution.value=_.mapSize,u.uniforms.radius.value=_.radius,r.setRenderTarget(_.map),r.clear(),r.renderBufferDirect(S,null,w,u,m,null)}function b(_,S,w,E){let I=null;const B=w.isPointLight===!0?_.customDistanceMaterial:_.customDepthMaterial;if(B!==void 0)I=B;else if(I=w.isPointLight===!0?l:o,r.localClippingEnabled&&S.clipShadows===!0&&Array.isArray(S.clippingPlanes)&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0||S.map&&S.alphaTest>0||S.alphaToCoverage===!0){const R=I.uuid,U=S.uuid;let C=c[R];C===void 0&&(C={},c[R]=C);let F=C[U];F===void 0&&(F=I.clone(),C[U]=F,S.addEventListener("dispose",M)),I=F}if(I.visible=S.visible,I.wireframe=S.wireframe,E===Ys?I.side=S.shadowSide!==null?S.shadowSide:S.side:I.side=S.shadowSide!==null?S.shadowSide:d[S.side],I.alphaMap=S.alphaMap,I.alphaTest=S.alphaToCoverage===!0?.5:S.alphaTest,I.map=S.map,I.clipShadows=S.clipShadows,I.clippingPlanes=S.clippingPlanes,I.clipIntersection=S.clipIntersection,I.displacementMap=S.displacementMap,I.displacementScale=S.displacementScale,I.displacementBias=S.displacementBias,I.wireframeLinewidth=S.wireframeLinewidth,I.linewidth=S.linewidth,w.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const R=r.properties.get(I);R.light=w}return I}function y(_,S,w,E,I){if(_.visible===!1)return;if(_.layers.test(S.layers)&&(_.isMesh||_.isLine||_.isPoints)&&(_.castShadow||_.receiveShadow&&I===Ys)&&(!_.frustumCulled||i.intersectsObject(_))){_.modelViewMatrix.multiplyMatrices(w.matrixWorldInverse,_.matrixWorld);const R=e.update(_),U=_.material;if(Array.isArray(U)){const C=R.groups;for(let F=0,O=C.length;F<O;F++){const H=C[F],j=U[H.materialIndex];if(j&&j.visible){const G=b(_,j,E,I);_.onBeforeShadow(r,_,S,w,R,G,H),r.renderBufferDirect(w,null,R,G,_,H),_.onAfterShadow(r,_,S,w,R,G,H)}}}else if(U.visible){const C=b(_,U,E,I);_.onBeforeShadow(r,_,S,w,R,C,null),r.renderBufferDirect(w,null,R,C,_,null),_.onAfterShadow(r,_,S,w,R,C,null)}}const B=_.children;for(let R=0,U=B.length;R<U;R++)y(B[R],S,w,E,I)}function M(_){_.target.removeEventListener("dispose",M);for(const S in c){const w=c[S],E=_.target.uuid;E in w&&(w[E].dispose(),delete w[E])}}}const vL={[lg]:cg,[hg]:pg,[dg]:fg,[dl]:ug,[cg]:lg,[pg]:hg,[fg]:dg,[ug]:dl};function bL(r,e){function t(){let z=!1;const ve=new xi;let me=null;const Re=new xi(0,0,0,0);return{setMask:function(pe){me!==pe&&!z&&(r.colorMask(pe,pe,pe,pe),me=pe)},setLocked:function(pe){z=pe},setClear:function(pe,ne,Le,Qe,pt){pt===!0&&(pe*=Qe,ne*=Qe,Le*=Qe),ve.set(pe,ne,Le,Qe),Re.equals(ve)===!1&&(r.clearColor(pe,ne,Le,Qe),Re.copy(ve))},reset:function(){z=!1,me=null,Re.set(-1,0,0,0)}}}function i(){let z=!1,ve=!1,me=null,Re=null,pe=null;return{setReversed:function(ne){if(ve!==ne){const Le=e.get("EXT_clip_control");ne?Le.clipControlEXT(Le.LOWER_LEFT_EXT,Le.ZERO_TO_ONE_EXT):Le.clipControlEXT(Le.LOWER_LEFT_EXT,Le.NEGATIVE_ONE_TO_ONE_EXT),ve=ne;const Qe=pe;pe=null,this.setClear(Qe)}},getReversed:function(){return ve},setTest:function(ne){ne?oe(r.DEPTH_TEST):ue(r.DEPTH_TEST)},setMask:function(ne){me!==ne&&!z&&(r.depthMask(ne),me=ne)},setFunc:function(ne){if(ve&&(ne=vL[ne]),Re!==ne){switch(ne){case lg:r.depthFunc(r.NEVER);break;case cg:r.depthFunc(r.ALWAYS);break;case hg:r.depthFunc(r.LESS);break;case dl:r.depthFunc(r.LEQUAL);break;case dg:r.depthFunc(r.EQUAL);break;case ug:r.depthFunc(r.GEQUAL);break;case pg:r.depthFunc(r.GREATER);break;case fg:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}Re=ne}},setLocked:function(ne){z=ne},setClear:function(ne){pe!==ne&&(ve&&(ne=1-ne),r.clearDepth(ne),pe=ne)},reset:function(){z=!1,me=null,Re=null,pe=null,ve=!1}}}function n(){let z=!1,ve=null,me=null,Re=null,pe=null,ne=null,Le=null,Qe=null,pt=null;return{setTest:function(et){z||(et?oe(r.STENCIL_TEST):ue(r.STENCIL_TEST))},setMask:function(et){ve!==et&&!z&&(r.stencilMask(et),ve=et)},setFunc:function(et,Ti,Ii){(me!==et||Re!==Ti||pe!==Ii)&&(r.stencilFunc(et,Ti,Ii),me=et,Re=Ti,pe=Ii)},setOp:function(et,Ti,Ii){(ne!==et||Le!==Ti||Qe!==Ii)&&(r.stencilOp(et,Ti,Ii),ne=et,Le=Ti,Qe=Ii)},setLocked:function(et){z=et},setClear:function(et){pt!==et&&(r.clearStencil(et),pt=et)},reset:function(){z=!1,ve=null,me=null,Re=null,pe=null,ne=null,Le=null,Qe=null,pt=null}}}const s=new t,a=new i,o=new n,l=new WeakMap,c=new WeakMap;let h={},d={},p=new WeakMap,u=[],A=null,m=!1,g=null,f=null,v=null,b=null,y=null,M=null,_=null,S=new jt(0,0,0),w=0,E=!1,I=null,B=null,R=null,U=null,C=null;const F=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let O=!1,H=0;const j=r.getParameter(r.VERSION);j.indexOf("WebGL")!==-1?(H=parseFloat(/^WebGL (\d)/.exec(j)[1]),O=H>=1):j.indexOf("OpenGL ES")!==-1&&(H=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),O=H>=2);let G=null,re={};const q=r.getParameter(r.SCISSOR_BOX),Y=r.getParameter(r.VIEWPORT),ye=new xi().fromArray(q),Me=new xi().fromArray(Y);function xe(z,ve,me,Re){const pe=new Uint8Array(4),ne=r.createTexture();r.bindTexture(z,ne),r.texParameteri(z,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(z,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let Le=0;Le<me;Le++)z===r.TEXTURE_3D||z===r.TEXTURE_2D_ARRAY?r.texImage3D(ve,0,r.RGBA,1,1,Re,0,r.RGBA,r.UNSIGNED_BYTE,pe):r.texImage2D(ve+Le,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,pe);return ne}const J={};J[r.TEXTURE_2D]=xe(r.TEXTURE_2D,r.TEXTURE_2D,1),J[r.TEXTURE_CUBE_MAP]=xe(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),J[r.TEXTURE_2D_ARRAY]=xe(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),J[r.TEXTURE_3D]=xe(r.TEXTURE_3D,r.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),oe(r.DEPTH_TEST),a.setFunc(dl),$(!1),Q(H1),oe(r.CULL_FACE),D(Zs);function oe(z){h[z]!==!0&&(r.enable(z),h[z]=!0)}function ue(z){h[z]!==!1&&(r.disable(z),h[z]=!1)}function Pe(z,ve){return d[z]!==ve?(r.bindFramebuffer(z,ve),d[z]=ve,z===r.DRAW_FRAMEBUFFER&&(d[r.FRAMEBUFFER]=ve),z===r.FRAMEBUFFER&&(d[r.DRAW_FRAMEBUFFER]=ve),!0):!1}function Be(z,ve){let me=u,Re=!1;if(z){me=p.get(ve),me===void 0&&(me=[],p.set(ve,me));const pe=z.textures;if(me.length!==pe.length||me[0]!==r.COLOR_ATTACHMENT0){for(let ne=0,Le=pe.length;ne<Le;ne++)me[ne]=r.COLOR_ATTACHMENT0+ne;me.length=pe.length,Re=!0}}else me[0]!==r.BACK&&(me[0]=r.BACK,Re=!0);Re&&r.drawBuffers(me)}function Ue(z){return A!==z?(r.useProgram(z),A=z,!0):!1}const it={[Ga]:r.FUNC_ADD,[wP]:r.FUNC_SUBTRACT,[SP]:r.FUNC_REVERSE_SUBTRACT};it[CP]=r.MIN,it[TP]=r.MAX;const qe={[IP]:r.ZERO,[PP]:r.ONE,[RP]:r.SRC_COLOR,[ag]:r.SRC_ALPHA,[UP]:r.SRC_ALPHA_SATURATE,[kP]:r.DST_COLOR,[BP]:r.DST_ALPHA,[DP]:r.ONE_MINUS_SRC_COLOR,[og]:r.ONE_MINUS_SRC_ALPHA,[NP]:r.ONE_MINUS_DST_COLOR,[LP]:r.ONE_MINUS_DST_ALPHA,[FP]:r.CONSTANT_COLOR,[OP]:r.ONE_MINUS_CONSTANT_COLOR,[zP]:r.CONSTANT_ALPHA,[HP]:r.ONE_MINUS_CONSTANT_ALPHA};function D(z,ve,me,Re,pe,ne,Le,Qe,pt,et){if(z===Zs){m===!0&&(ue(r.BLEND),m=!1);return}if(m===!1&&(oe(r.BLEND),m=!0),z!==MP){if(z!==g||et!==E){if((f!==Ga||y!==Ga)&&(r.blendEquation(r.FUNC_ADD),f=Ga,y=Ga),et)switch(z){case hl:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Q1:r.blendFunc(r.ONE,r.ONE);break;case W1:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case j1:r.blendFuncSeparate(r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ZERO,r.ONE);break;default:yi("WebGLState: Invalid blending: ",z);break}else switch(z){case hl:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Q1:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE,r.ONE,r.ONE);break;case W1:yi("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case j1:yi("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:yi("WebGLState: Invalid blending: ",z);break}v=null,b=null,M=null,_=null,S.set(0,0,0),w=0,g=z,E=et}return}pe=pe||ve,ne=ne||me,Le=Le||Re,(ve!==f||pe!==y)&&(r.blendEquationSeparate(it[ve],it[pe]),f=ve,y=pe),(me!==v||Re!==b||ne!==M||Le!==_)&&(r.blendFuncSeparate(qe[me],qe[Re],qe[ne],qe[Le]),v=me,b=Re,M=ne,_=Le),(Qe.equals(S)===!1||pt!==w)&&(r.blendColor(Qe.r,Qe.g,Qe.b,pt),S.copy(Qe),w=pt),g=z,E=!1}function ae(z,ve){z.side===Ks?ue(r.CULL_FACE):oe(r.CULL_FACE);let me=z.side===xn;ve&&(me=!me),$(me),z.blending===hl&&z.transparent===!1?D(Zs):D(z.blending,z.blendEquation,z.blendSrc,z.blendDst,z.blendEquationAlpha,z.blendSrcAlpha,z.blendDstAlpha,z.blendColor,z.blendAlpha,z.premultipliedAlpha),a.setFunc(z.depthFunc),a.setTest(z.depthTest),a.setMask(z.depthWrite),s.setMask(z.colorWrite);const Re=z.stencilWrite;o.setTest(Re),Re&&(o.setMask(z.stencilWriteMask),o.setFunc(z.stencilFunc,z.stencilRef,z.stencilFuncMask),o.setOp(z.stencilFail,z.stencilZFail,z.stencilZPass)),te(z.polygonOffset,z.polygonOffsetFactor,z.polygonOffsetUnits),z.alphaToCoverage===!0?oe(r.SAMPLE_ALPHA_TO_COVERAGE):ue(r.SAMPLE_ALPHA_TO_COVERAGE)}function $(z){I!==z&&(z?r.frontFace(r.CW):r.frontFace(r.CCW),I=z)}function Q(z){z!==_P?(oe(r.CULL_FACE),z!==B&&(z===H1?r.cullFace(r.BACK):z===EP?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):ue(r.CULL_FACE),B=z}function L(z){z!==R&&(O&&r.lineWidth(z),R=z)}function te(z,ve,me){z?(oe(r.POLYGON_OFFSET_FILL),(U!==ve||C!==me)&&(r.polygonOffset(ve,me),U=ve,C=me)):ue(r.POLYGON_OFFSET_FILL)}function de(z){z?oe(r.SCISSOR_TEST):ue(r.SCISSOR_TEST)}function V(z){z===void 0&&(z=r.TEXTURE0+F-1),G!==z&&(r.activeTexture(z),G=z)}function ee(z,ve,me){me===void 0&&(G===null?me=r.TEXTURE0+F-1:me=G);let Re=re[me];Re===void 0&&(Re={type:void 0,texture:void 0},re[me]=Re),(Re.type!==z||Re.texture!==ve)&&(G!==me&&(r.activeTexture(me),G=me),r.bindTexture(z,ve||J[z]),Re.type=z,Re.texture=ve)}function P(){const z=re[G];z!==void 0&&z.type!==void 0&&(r.bindTexture(z.type,null),z.type=void 0,z.texture=void 0)}function x(){try{r.compressedTexImage2D(...arguments)}catch(z){z("WebGLState:",z)}}function N(){try{r.compressedTexImage3D(...arguments)}catch(z){z("WebGLState:",z)}}function X(){try{r.texSubImage2D(...arguments)}catch(z){z("WebGLState:",z)}}function Z(){try{r.texSubImage3D(...arguments)}catch(z){z("WebGLState:",z)}}function K(){try{r.compressedTexSubImage2D(...arguments)}catch(z){z("WebGLState:",z)}}function Ie(){try{r.compressedTexSubImage3D(...arguments)}catch(z){z("WebGLState:",z)}}function ge(){try{r.texStorage2D(...arguments)}catch(z){z("WebGLState:",z)}}function ke(){try{r.texStorage3D(...arguments)}catch(z){z("WebGLState:",z)}}function Oe(){try{r.texImage2D(...arguments)}catch(z){z("WebGLState:",z)}}function le(){try{r.texImage3D(...arguments)}catch(z){z("WebGLState:",z)}}function Ae(z){ye.equals(z)===!1&&(r.scissor(z.x,z.y,z.z,z.w),ye.copy(z))}function ze(z){Me.equals(z)===!1&&(r.viewport(z.x,z.y,z.z,z.w),Me.copy(z))}function Ne(z,ve){let me=c.get(ve);me===void 0&&(me=new WeakMap,c.set(ve,me));let Re=me.get(z);Re===void 0&&(Re=r.getUniformBlockIndex(ve,z.name),me.set(z,Re))}function we(z,ve){const me=c.get(ve).get(z);l.get(ve)!==me&&(r.uniformBlockBinding(ve,me,z.__bindingPointIndex),l.set(ve,me))}function je(){r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SCISSOR_TEST),r.disable(r.STENCIL_TEST),r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.ONE,r.ZERO),r.blendFuncSeparate(r.ONE,r.ZERO,r.ONE,r.ZERO),r.blendColor(0,0,0,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(r.LESS),a.setReversed(!1),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(r.ALWAYS,0,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),r.clearStencil(0),r.cullFace(r.BACK),r.frontFace(r.CCW),r.polygonOffset(0,0),r.activeTexture(r.TEXTURE0),r.bindFramebuffer(r.FRAMEBUFFER,null),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(r.READ_FRAMEBUFFER,null),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),h={},G=null,re={},d={},p=new WeakMap,u=[],A=null,m=!1,g=null,f=null,v=null,b=null,y=null,M=null,_=null,S=new jt(0,0,0),w=0,E=!1,I=null,B=null,R=null,U=null,C=null,ye.set(0,0,r.canvas.width,r.canvas.height),Me.set(0,0,r.canvas.width,r.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:oe,disable:ue,bindFramebuffer:Pe,drawBuffers:Be,useProgram:Ue,setBlending:D,setMaterial:ae,setFlipSided:$,setCullFace:Q,setLineWidth:L,setPolygonOffset:te,setScissorTest:de,activeTexture:V,bindTexture:ee,unbindTexture:P,compressedTexImage2D:x,compressedTexImage3D:N,texImage2D:Oe,texImage3D:le,updateUBOMapping:Ne,uniformBlockBinding:we,texStorage2D:ge,texStorage3D:ke,texSubImage2D:X,texSubImage3D:Z,compressedTexSubImage2D:K,compressedTexSubImage3D:Ie,scissor:Ae,viewport:ze,reset:je}}function yL(r,e,t,i,n,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Wt,h=new WeakMap;let d;const p=new WeakMap;let u=!1;try{u=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function A(P,x){return u?new OffscreenCanvas(P,x):lp("canvas")}function m(P,x,N){let X=1;const Z=ee(P);if((Z.width>N||Z.height>N)&&(X=N/Math.max(Z.width,Z.height)),X<1)if(typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&P instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&P instanceof ImageBitmap||typeof VideoFrame<"u"&&P instanceof VideoFrame){const K=Math.floor(X*Z.width),Ie=Math.floor(X*Z.height);d===void 0&&(d=A(K,Ie));const ge=x?A(K,Ie):d;return ge.width=K,ge.height=Ie,ge.getContext("2d").drawImage(P,0,0,K,Ie),At("WebGLRenderer: Texture has been resized from ("+Z.width+"x"+Z.height+") to ("+K+"x"+Ie+")."),ge}else return"data"in P&&At("WebGLRenderer: Image in DataTexture is too big ("+Z.width+"x"+Z.height+")."),P;return P}function g(P){return P.generateMipmaps}function f(P){r.generateMipmap(P)}function v(P){return P.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:P.isWebGL3DRenderTarget?r.TEXTURE_3D:P.isWebGLArrayRenderTarget||P.isCompressedArrayTexture?r.TEXTURE_2D_ARRAY:r.TEXTURE_2D}function b(P,x,N,X,Z=!1){if(P!==null){if(r[P]!==void 0)return r[P];At("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+P+"'")}let K=x;if(x===r.RED&&(N===r.FLOAT&&(K=r.R32F),N===r.HALF_FLOAT&&(K=r.R16F),N===r.UNSIGNED_BYTE&&(K=r.R8)),x===r.RED_INTEGER&&(N===r.UNSIGNED_BYTE&&(K=r.R8UI),N===r.UNSIGNED_SHORT&&(K=r.R16UI),N===r.UNSIGNED_INT&&(K=r.R32UI),N===r.BYTE&&(K=r.R8I),N===r.SHORT&&(K=r.R16I),N===r.INT&&(K=r.R32I)),x===r.RG&&(N===r.FLOAT&&(K=r.RG32F),N===r.HALF_FLOAT&&(K=r.RG16F),N===r.UNSIGNED_BYTE&&(K=r.RG8)),x===r.RG_INTEGER&&(N===r.UNSIGNED_BYTE&&(K=r.RG8UI),N===r.UNSIGNED_SHORT&&(K=r.RG16UI),N===r.UNSIGNED_INT&&(K=r.RG32UI),N===r.BYTE&&(K=r.RG8I),N===r.SHORT&&(K=r.RG16I),N===r.INT&&(K=r.RG32I)),x===r.RGB_INTEGER&&(N===r.UNSIGNED_BYTE&&(K=r.RGB8UI),N===r.UNSIGNED_SHORT&&(K=r.RGB16UI),N===r.UNSIGNED_INT&&(K=r.RGB32UI),N===r.BYTE&&(K=r.RGB8I),N===r.SHORT&&(K=r.RGB16I),N===r.INT&&(K=r.RGB32I)),x===r.RGBA_INTEGER&&(N===r.UNSIGNED_BYTE&&(K=r.RGBA8UI),N===r.UNSIGNED_SHORT&&(K=r.RGBA16UI),N===r.UNSIGNED_INT&&(K=r.RGBA32UI),N===r.BYTE&&(K=r.RGBA8I),N===r.SHORT&&(K=r.RGBA16I),N===r.INT&&(K=r.RGBA32I)),x===r.RGB&&(N===r.UNSIGNED_INT_5_9_9_9_REV&&(K=r.RGB9_E5),N===r.UNSIGNED_INT_10F_11F_11F_REV&&(K=r.R11F_G11F_B10F)),x===r.RGBA){const Ie=Z?ap:Nt.getTransfer(X);N===r.FLOAT&&(K=r.RGBA32F),N===r.HALF_FLOAT&&(K=r.RGBA16F),N===r.UNSIGNED_BYTE&&(K=Ie===Qt?r.SRGB8_ALPHA8:r.RGBA8),N===r.UNSIGNED_SHORT_4_4_4_4&&(K=r.RGBA4),N===r.UNSIGNED_SHORT_5_5_5_1&&(K=r.RGB5_A1)}return(K===r.R16F||K===r.R32F||K===r.RG16F||K===r.RG32F||K===r.RGBA16F||K===r.RGBA32F)&&e.get("EXT_color_buffer_float"),K}function y(P,x){let N;return P?x===null||x===Qa||x===th?N=r.DEPTH24_STENCIL8:x===er?N=r.DEPTH32F_STENCIL8:x===eh&&(N=r.DEPTH24_STENCIL8,At("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===Qa||x===th?N=r.DEPTH_COMPONENT24:x===er?N=r.DEPTH_COMPONENT32F:x===eh&&(N=r.DEPTH_COMPONENT16),N}function M(P,x){return g(P)===!0||P.isFramebufferTexture&&P.minFilter!==kn&&P.minFilter!==Yn?Math.log2(Math.max(x.width,x.height))+1:P.mipmaps!==void 0&&P.mipmaps.length>0?P.mipmaps.length:P.isCompressedTexture&&Array.isArray(P.image)?x.mipmaps.length:1}function _(P){const x=P.target;x.removeEventListener("dispose",_),w(x),x.isVideoTexture&&h.delete(x)}function S(P){const x=P.target;x.removeEventListener("dispose",S),I(x)}function w(P){const x=i.get(P);if(x.__webglInit===void 0)return;const N=P.source,X=p.get(N);if(X){const Z=X[x.__cacheKey];Z.usedTimes--,Z.usedTimes===0&&E(P),Object.keys(X).length===0&&p.delete(N)}i.remove(P)}function E(P){const x=i.get(P);r.deleteTexture(x.__webglTexture);const N=P.source,X=p.get(N);delete X[x.__cacheKey],a.memory.textures--}function I(P){const x=i.get(P);if(P.depthTexture&&(P.depthTexture.dispose(),i.remove(P.depthTexture)),P.isWebGLCubeRenderTarget)for(let X=0;X<6;X++){if(Array.isArray(x.__webglFramebuffer[X]))for(let Z=0;Z<x.__webglFramebuffer[X].length;Z++)r.deleteFramebuffer(x.__webglFramebuffer[X][Z]);else r.deleteFramebuffer(x.__webglFramebuffer[X]);x.__webglDepthbuffer&&r.deleteRenderbuffer(x.__webglDepthbuffer[X])}else{if(Array.isArray(x.__webglFramebuffer))for(let X=0;X<x.__webglFramebuffer.length;X++)r.deleteFramebuffer(x.__webglFramebuffer[X]);else r.deleteFramebuffer(x.__webglFramebuffer);if(x.__webglDepthbuffer&&r.deleteRenderbuffer(x.__webglDepthbuffer),x.__webglMultisampledFramebuffer&&r.deleteFramebuffer(x.__webglMultisampledFramebuffer),x.__webglColorRenderbuffer)for(let X=0;X<x.__webglColorRenderbuffer.length;X++)x.__webglColorRenderbuffer[X]&&r.deleteRenderbuffer(x.__webglColorRenderbuffer[X]);x.__webglDepthRenderbuffer&&r.deleteRenderbuffer(x.__webglDepthRenderbuffer)}const N=P.textures;for(let X=0,Z=N.length;X<Z;X++){const K=i.get(N[X]);K.__webglTexture&&(r.deleteTexture(K.__webglTexture),a.memory.textures--),i.remove(N[X])}i.remove(P)}let B=0;function R(){B=0}function U(){const P=B;return P>=n.maxTextures&&At("WebGLTextures: Trying to use "+P+" texture units while this GPU supports only "+n.maxTextures),B+=1,P}function C(P){const x=[];return x.push(P.wrapS),x.push(P.wrapT),x.push(P.wrapR||0),x.push(P.magFilter),x.push(P.minFilter),x.push(P.anisotropy),x.push(P.internalFormat),x.push(P.format),x.push(P.type),x.push(P.generateMipmaps),x.push(P.premultiplyAlpha),x.push(P.flipY),x.push(P.unpackAlignment),x.push(P.colorSpace),x.join()}function F(P,x){const N=i.get(P);if(P.isVideoTexture&&de(P),P.isRenderTargetTexture===!1&&P.isExternalTexture!==!0&&P.version>0&&N.__version!==P.version){const X=P.image;if(X===null)At("WebGLRenderer: Texture marked for update but no image data found.");else if(X.complete===!1)At("WebGLRenderer: Texture marked for update but image is incomplete");else{J(N,P,x);return}}else P.isExternalTexture&&(N.__webglTexture=P.sourceTexture?P.sourceTexture:null);t.bindTexture(r.TEXTURE_2D,N.__webglTexture,r.TEXTURE0+x)}function O(P,x){const N=i.get(P);if(P.isRenderTargetTexture===!1&&P.version>0&&N.__version!==P.version){J(N,P,x);return}else P.isExternalTexture&&(N.__webglTexture=P.sourceTexture?P.sourceTexture:null);t.bindTexture(r.TEXTURE_2D_ARRAY,N.__webglTexture,r.TEXTURE0+x)}function H(P,x){const N=i.get(P);if(P.isRenderTargetTexture===!1&&P.version>0&&N.__version!==P.version){J(N,P,x);return}t.bindTexture(r.TEXTURE_3D,N.__webglTexture,r.TEXTURE0+x)}function j(P,x){const N=i.get(P);if(P.version>0&&N.__version!==P.version){oe(N,P,x);return}t.bindTexture(r.TEXTURE_CUBE_MAP,N.__webglTexture,r.TEXTURE0+x)}const G={[Ag]:r.REPEAT,[Js]:r.CLAMP_TO_EDGE,[vg]:r.MIRRORED_REPEAT},re={[kn]:r.NEAREST,[ZP]:r.NEAREST_MIPMAP_NEAREST,[tp]:r.NEAREST_MIPMAP_LINEAR,[Yn]:r.LINEAR,[bg]:r.LINEAR_MIPMAP_NEAREST,[Va]:r.LINEAR_MIPMAP_LINEAR},q={[iR]:r.NEVER,[lR]:r.ALWAYS,[nR]:r.LESS,[ny]:r.LEQUAL,[sR]:r.EQUAL,[oR]:r.GEQUAL,[rR]:r.GREATER,[aR]:r.NOTEQUAL};function Y(P,x){if(x.type===er&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===Yn||x.magFilter===bg||x.magFilter===tp||x.magFilter===Va||x.minFilter===Yn||x.minFilter===bg||x.minFilter===tp||x.minFilter===Va)&&At("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),r.texParameteri(P,r.TEXTURE_WRAP_S,G[x.wrapS]),r.texParameteri(P,r.TEXTURE_WRAP_T,G[x.wrapT]),(P===r.TEXTURE_3D||P===r.TEXTURE_2D_ARRAY)&&r.texParameteri(P,r.TEXTURE_WRAP_R,G[x.wrapR]),r.texParameteri(P,r.TEXTURE_MAG_FILTER,re[x.magFilter]),r.texParameteri(P,r.TEXTURE_MIN_FILTER,re[x.minFilter]),x.compareFunction&&(r.texParameteri(P,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(P,r.TEXTURE_COMPARE_FUNC,q[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===kn||x.minFilter!==tp&&x.minFilter!==Va||x.type===er&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||i.get(x).__currentAnisotropy){const N=e.get("EXT_texture_filter_anisotropic");r.texParameterf(P,N.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,n.getMaxAnisotropy())),i.get(x).__currentAnisotropy=x.anisotropy}}}function ye(P,x){let N=!1;P.__webglInit===void 0&&(P.__webglInit=!0,x.addEventListener("dispose",_));const X=x.source;let Z=p.get(X);Z===void 0&&(Z={},p.set(X,Z));const K=C(x);if(K!==P.__cacheKey){Z[K]===void 0&&(Z[K]={texture:r.createTexture(),usedTimes:0},a.memory.textures++,N=!0),Z[K].usedTimes++;const Ie=Z[P.__cacheKey];Ie!==void 0&&(Z[P.__cacheKey].usedTimes--,Ie.usedTimes===0&&E(x)),P.__cacheKey=K,P.__webglTexture=Z[K].texture}return N}function Me(P,x,N){return Math.floor(Math.floor(P/N)/x)}function xe(P,x,N,X){const Z=P.updateRanges;if(Z.length===0)t.texSubImage2D(r.TEXTURE_2D,0,0,0,x.width,x.height,N,X,x.data);else{Z.sort((Oe,le)=>Oe.start-le.start);let K=0;for(let Oe=1;Oe<Z.length;Oe++){const le=Z[K],Ae=Z[Oe],ze=le.start+le.count,Ne=Me(Ae.start,x.width,4),we=Me(le.start,x.width,4);Ae.start<=ze+1&&Ne===we&&Me(Ae.start+Ae.count-1,x.width,4)===Ne?le.count=Math.max(le.count,Ae.start+Ae.count-le.start):(++K,Z[K]=Ae)}Z.length=K+1;const Ie=r.getParameter(r.UNPACK_ROW_LENGTH),ge=r.getParameter(r.UNPACK_SKIP_PIXELS),ke=r.getParameter(r.UNPACK_SKIP_ROWS);r.pixelStorei(r.UNPACK_ROW_LENGTH,x.width);for(let Oe=0,le=Z.length;Oe<le;Oe++){const Ae=Z[Oe],ze=Math.floor(Ae.start/4),Ne=Math.ceil(Ae.count/4),we=ze%x.width,je=Math.floor(ze/x.width),z=Ne;r.pixelStorei(r.UNPACK_SKIP_PIXELS,we),r.pixelStorei(r.UNPACK_SKIP_ROWS,je),t.texSubImage2D(r.TEXTURE_2D,0,we,je,z,1,N,X,x.data)}P.clearUpdateRanges(),r.pixelStorei(r.UNPACK_ROW_LENGTH,Ie),r.pixelStorei(r.UNPACK_SKIP_PIXELS,ge),r.pixelStorei(r.UNPACK_SKIP_ROWS,ke)}}function J(P,x,N){let X=r.TEXTURE_2D;(x.isDataArrayTexture||x.isCompressedArrayTexture)&&(X=r.TEXTURE_2D_ARRAY),x.isData3DTexture&&(X=r.TEXTURE_3D);const Z=ye(P,x),K=x.source;t.bindTexture(X,P.__webglTexture,r.TEXTURE0+N);const Ie=i.get(K);if(K.version!==Ie.__version||Z===!0){t.activeTexture(r.TEXTURE0+N);const ge=Nt.getPrimaries(Nt.workingColorSpace),ke=x.colorSpace===Vr?null:Nt.getPrimaries(x.colorSpace),Oe=x.colorSpace===Vr||ge===ke?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,x.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,x.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,Oe);let le=m(x.image,!1,n.maxTextureSize);le=V(x,le);const Ae=s.convert(x.format,x.colorSpace),ze=s.convert(x.type);let Ne=b(x.internalFormat,Ae,ze,x.colorSpace,x.isVideoTexture);Y(X,x);let we;const je=x.mipmaps,z=x.isVideoTexture!==!0,ve=Ie.__version===void 0||Z===!0,me=K.dataReady,Re=M(x,le);if(x.isDepthTexture)Ne=y(x.format===nh,x.type),ve&&(z?t.texStorage2D(r.TEXTURE_2D,1,Ne,le.width,le.height):t.texImage2D(r.TEXTURE_2D,0,Ne,le.width,le.height,0,Ae,ze,null));else if(x.isDataTexture)if(je.length>0){z&&ve&&t.texStorage2D(r.TEXTURE_2D,Re,Ne,je[0].width,je[0].height);for(let pe=0,ne=je.length;pe<ne;pe++)we=je[pe],z?me&&t.texSubImage2D(r.TEXTURE_2D,pe,0,0,we.width,we.height,Ae,ze,we.data):t.texImage2D(r.TEXTURE_2D,pe,Ne,we.width,we.height,0,Ae,ze,we.data);x.generateMipmaps=!1}else z?(ve&&t.texStorage2D(r.TEXTURE_2D,Re,Ne,le.width,le.height),me&&xe(x,le,Ae,ze)):t.texImage2D(r.TEXTURE_2D,0,Ne,le.width,le.height,0,Ae,ze,le.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){z&&ve&&t.texStorage3D(r.TEXTURE_2D_ARRAY,Re,Ne,je[0].width,je[0].height,le.depth);for(let pe=0,ne=je.length;pe<ne;pe++)if(we=je[pe],x.format!==cs)if(Ae!==null)if(z){if(me)if(x.layerUpdates.size>0){const Le=Uy(we.width,we.height,x.format,x.type);for(const Qe of x.layerUpdates){const pt=we.data.subarray(Qe*Le/we.data.BYTES_PER_ELEMENT,(Qe+1)*Le/we.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,pe,0,0,Qe,we.width,we.height,1,Ae,pt)}x.clearLayerUpdates()}else t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,pe,0,0,0,we.width,we.height,le.depth,Ae,we.data)}else t.compressedTexImage3D(r.TEXTURE_2D_ARRAY,pe,Ne,we.width,we.height,le.depth,0,we.data,0,0);else At("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else z?me&&t.texSubImage3D(r.TEXTURE_2D_ARRAY,pe,0,0,0,we.width,we.height,le.depth,Ae,ze,we.data):t.texImage3D(r.TEXTURE_2D_ARRAY,pe,Ne,we.width,we.height,le.depth,0,Ae,ze,we.data)}else{z&&ve&&t.texStorage2D(r.TEXTURE_2D,Re,Ne,je[0].width,je[0].height);for(let pe=0,ne=je.length;pe<ne;pe++)we=je[pe],x.format!==cs?Ae!==null?z?me&&t.compressedTexSubImage2D(r.TEXTURE_2D,pe,0,0,we.width,we.height,Ae,we.data):t.compressedTexImage2D(r.TEXTURE_2D,pe,Ne,we.width,we.height,0,we.data):At("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):z?me&&t.texSubImage2D(r.TEXTURE_2D,pe,0,0,we.width,we.height,Ae,ze,we.data):t.texImage2D(r.TEXTURE_2D,pe,Ne,we.width,we.height,0,Ae,ze,we.data)}else if(x.isDataArrayTexture)if(z){if(ve&&t.texStorage3D(r.TEXTURE_2D_ARRAY,Re,Ne,le.width,le.height,le.depth),me)if(x.layerUpdates.size>0){const pe=Uy(le.width,le.height,x.format,x.type);for(const ne of x.layerUpdates){const Le=le.data.subarray(ne*pe/le.data.BYTES_PER_ELEMENT,(ne+1)*pe/le.data.BYTES_PER_ELEMENT);t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,ne,le.width,le.height,1,Ae,ze,Le)}x.clearLayerUpdates()}else t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,le.width,le.height,le.depth,Ae,ze,le.data)}else t.texImage3D(r.TEXTURE_2D_ARRAY,0,Ne,le.width,le.height,le.depth,0,Ae,ze,le.data);else if(x.isData3DTexture)z?(ve&&t.texStorage3D(r.TEXTURE_3D,Re,Ne,le.width,le.height,le.depth),me&&t.texSubImage3D(r.TEXTURE_3D,0,0,0,0,le.width,le.height,le.depth,Ae,ze,le.data)):t.texImage3D(r.TEXTURE_3D,0,Ne,le.width,le.height,le.depth,0,Ae,ze,le.data);else if(x.isFramebufferTexture){if(ve)if(z)t.texStorage2D(r.TEXTURE_2D,Re,Ne,le.width,le.height);else{let pe=le.width,ne=le.height;for(let Le=0;Le<Re;Le++)t.texImage2D(r.TEXTURE_2D,Le,Ne,pe,ne,0,Ae,ze,null),pe>>=1,ne>>=1}}else if(je.length>0){if(z&&ve){const pe=ee(je[0]);t.texStorage2D(r.TEXTURE_2D,Re,Ne,pe.width,pe.height)}for(let pe=0,ne=je.length;pe<ne;pe++)we=je[pe],z?me&&t.texSubImage2D(r.TEXTURE_2D,pe,0,0,Ae,ze,we):t.texImage2D(r.TEXTURE_2D,pe,Ne,Ae,ze,we);x.generateMipmaps=!1}else if(z){if(ve){const pe=ee(le);t.texStorage2D(r.TEXTURE_2D,Re,Ne,pe.width,pe.height)}me&&t.texSubImage2D(r.TEXTURE_2D,0,0,0,Ae,ze,le)}else t.texImage2D(r.TEXTURE_2D,0,Ne,Ae,ze,le);g(x)&&f(X),Ie.__version=K.version,x.onUpdate&&x.onUpdate(x)}P.__version=x.version}function oe(P,x,N){if(x.image.length!==6)return;const X=ye(P,x),Z=x.source;t.bindTexture(r.TEXTURE_CUBE_MAP,P.__webglTexture,r.TEXTURE0+N);const K=i.get(Z);if(Z.version!==K.__version||X===!0){t.activeTexture(r.TEXTURE0+N);const Ie=Nt.getPrimaries(Nt.workingColorSpace),ge=x.colorSpace===Vr?null:Nt.getPrimaries(x.colorSpace),ke=x.colorSpace===Vr||Ie===ge?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,x.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,x.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,ke);const Oe=x.isCompressedTexture||x.image[0].isCompressedTexture,le=x.image[0]&&x.image[0].isDataTexture,Ae=[];for(let ne=0;ne<6;ne++)!Oe&&!le?Ae[ne]=m(x.image[ne],!0,n.maxCubemapSize):Ae[ne]=le?x.image[ne].image:x.image[ne],Ae[ne]=V(x,Ae[ne]);const ze=Ae[0],Ne=s.convert(x.format,x.colorSpace),we=s.convert(x.type),je=b(x.internalFormat,Ne,we,x.colorSpace),z=x.isVideoTexture!==!0,ve=K.__version===void 0||X===!0,me=Z.dataReady;let Re=M(x,ze);Y(r.TEXTURE_CUBE_MAP,x);let pe;if(Oe){z&&ve&&t.texStorage2D(r.TEXTURE_CUBE_MAP,Re,je,ze.width,ze.height);for(let ne=0;ne<6;ne++){pe=Ae[ne].mipmaps;for(let Le=0;Le<pe.length;Le++){const Qe=pe[Le];x.format!==cs?Ne!==null?z?me&&t.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Le,0,0,Qe.width,Qe.height,Ne,Qe.data):t.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Le,je,Qe.width,Qe.height,0,Qe.data):At("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):z?me&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Le,0,0,Qe.width,Qe.height,Ne,we,Qe.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Le,je,Qe.width,Qe.height,0,Ne,we,Qe.data)}}}else{if(pe=x.mipmaps,z&&ve){pe.length>0&&Re++;const ne=ee(Ae[0]);t.texStorage2D(r.TEXTURE_CUBE_MAP,Re,je,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(le){z?me&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Ae[ne].width,Ae[ne].height,Ne,we,Ae[ne].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,je,Ae[ne].width,Ae[ne].height,0,Ne,we,Ae[ne].data);for(let Le=0;Le<pe.length;Le++){const Qe=pe[Le].image[ne].image;z?me&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Le+1,0,0,Qe.width,Qe.height,Ne,we,Qe.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Le+1,je,Qe.width,Qe.height,0,Ne,we,Qe.data)}}else{z?me&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Ne,we,Ae[ne]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,je,Ne,we,Ae[ne]);for(let Le=0;Le<pe.length;Le++){const Qe=pe[Le];z?me&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Le+1,0,0,Ne,we,Qe.image[ne]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ne,Le+1,je,Ne,we,Qe.image[ne])}}}g(x)&&f(r.TEXTURE_CUBE_MAP),K.__version=Z.version,x.onUpdate&&x.onUpdate(x)}P.__version=x.version}function ue(P,x,N,X,Z,K){const Ie=s.convert(N.format,N.colorSpace),ge=s.convert(N.type),ke=b(N.internalFormat,Ie,ge,N.colorSpace),Oe=i.get(x),le=i.get(N);if(le.__renderTarget=x,!Oe.__hasExternalTextures){const Ae=Math.max(1,x.width>>K),ze=Math.max(1,x.height>>K);Z===r.TEXTURE_3D||Z===r.TEXTURE_2D_ARRAY?t.texImage3D(Z,K,ke,Ae,ze,x.depth,0,Ie,ge,null):t.texImage2D(Z,K,ke,Ae,ze,0,Ie,ge,null)}t.bindFramebuffer(r.FRAMEBUFFER,P),te(x)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,X,Z,le.__webglTexture,0,L(x)):(Z===r.TEXTURE_2D||Z>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&Z<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,X,Z,le.__webglTexture,K),t.bindFramebuffer(r.FRAMEBUFFER,null)}function Pe(P,x,N){if(r.bindRenderbuffer(r.RENDERBUFFER,P),x.depthBuffer){const X=x.depthTexture,Z=X&&X.isDepthTexture?X.type:null,K=y(x.stencilBuffer,Z),Ie=x.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,ge=L(x);te(x)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,ge,K,x.width,x.height):N?r.renderbufferStorageMultisample(r.RENDERBUFFER,ge,K,x.width,x.height):r.renderbufferStorage(r.RENDERBUFFER,K,x.width,x.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,Ie,r.RENDERBUFFER,P)}else{const X=x.textures;for(let Z=0;Z<X.length;Z++){const K=X[Z],Ie=s.convert(K.format,K.colorSpace),ge=s.convert(K.type),ke=b(K.internalFormat,Ie,ge,K.colorSpace),Oe=L(x);N&&te(x)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,Oe,ke,x.width,x.height):te(x)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Oe,ke,x.width,x.height):r.renderbufferStorage(r.RENDERBUFFER,ke,x.width,x.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function Be(P,x){if(x&&x.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(r.FRAMEBUFFER,P),!(x.depthTexture&&x.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const N=i.get(x.depthTexture);N.__renderTarget=x,(!N.__webglTexture||x.depthTexture.image.width!==x.width||x.depthTexture.image.height!==x.height)&&(x.depthTexture.image.width=x.width,x.depthTexture.image.height=x.height,x.depthTexture.needsUpdate=!0),F(x.depthTexture,0);const X=N.__webglTexture,Z=L(x);if(x.depthTexture.format===ih)te(x)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,X,0,Z):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,X,0);else if(x.depthTexture.format===nh)te(x)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,X,0,Z):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,X,0);else throw new Error("Unknown depthTexture format")}function Ue(P){const x=i.get(P),N=P.isWebGLCubeRenderTarget===!0;if(x.__boundDepthTexture!==P.depthTexture){const X=P.depthTexture;if(x.__depthDisposeCallback&&x.__depthDisposeCallback(),X){const Z=()=>{delete x.__boundDepthTexture,delete x.__depthDisposeCallback,X.removeEventListener("dispose",Z)};X.addEventListener("dispose",Z),x.__depthDisposeCallback=Z}x.__boundDepthTexture=X}if(P.depthTexture&&!x.__autoAllocateDepthBuffer){if(N)throw new Error("target.depthTexture not supported in Cube render targets");const X=P.texture.mipmaps;X&&X.length>0?Be(x.__webglFramebuffer[0],P):Be(x.__webglFramebuffer,P)}else if(N){x.__webglDepthbuffer=[];for(let X=0;X<6;X++)if(t.bindFramebuffer(r.FRAMEBUFFER,x.__webglFramebuffer[X]),x.__webglDepthbuffer[X]===void 0)x.__webglDepthbuffer[X]=r.createRenderbuffer(),Pe(x.__webglDepthbuffer[X],P,!1);else{const Z=P.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,K=x.__webglDepthbuffer[X];r.bindRenderbuffer(r.RENDERBUFFER,K),r.framebufferRenderbuffer(r.FRAMEBUFFER,Z,r.RENDERBUFFER,K)}}else{const X=P.texture.mipmaps;if(X&&X.length>0?t.bindFramebuffer(r.FRAMEBUFFER,x.__webglFramebuffer[0]):t.bindFramebuffer(r.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=r.createRenderbuffer(),Pe(x.__webglDepthbuffer,P,!1);else{const Z=P.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,K=x.__webglDepthbuffer;r.bindRenderbuffer(r.RENDERBUFFER,K),r.framebufferRenderbuffer(r.FRAMEBUFFER,Z,r.RENDERBUFFER,K)}}t.bindFramebuffer(r.FRAMEBUFFER,null)}function it(P,x,N){const X=i.get(P);x!==void 0&&ue(X.__webglFramebuffer,P,P.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),N!==void 0&&Ue(P)}function qe(P){const x=P.texture,N=i.get(P),X=i.get(x);P.addEventListener("dispose",S);const Z=P.textures,K=P.isWebGLCubeRenderTarget===!0,Ie=Z.length>1;if(Ie||(X.__webglTexture===void 0&&(X.__webglTexture=r.createTexture()),X.__version=x.version,a.memory.textures++),K){N.__webglFramebuffer=[];for(let ge=0;ge<6;ge++)if(x.mipmaps&&x.mipmaps.length>0){N.__webglFramebuffer[ge]=[];for(let ke=0;ke<x.mipmaps.length;ke++)N.__webglFramebuffer[ge][ke]=r.createFramebuffer()}else N.__webglFramebuffer[ge]=r.createFramebuffer()}else{if(x.mipmaps&&x.mipmaps.length>0){N.__webglFramebuffer=[];for(let ge=0;ge<x.mipmaps.length;ge++)N.__webglFramebuffer[ge]=r.createFramebuffer()}else N.__webglFramebuffer=r.createFramebuffer();if(Ie)for(let ge=0,ke=Z.length;ge<ke;ge++){const Oe=i.get(Z[ge]);Oe.__webglTexture===void 0&&(Oe.__webglTexture=r.createTexture(),a.memory.textures++)}if(P.samples>0&&te(P)===!1){N.__webglMultisampledFramebuffer=r.createFramebuffer(),N.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,N.__webglMultisampledFramebuffer);for(let ge=0;ge<Z.length;ge++){const ke=Z[ge];N.__webglColorRenderbuffer[ge]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,N.__webglColorRenderbuffer[ge]);const Oe=s.convert(ke.format,ke.colorSpace),le=s.convert(ke.type),Ae=b(ke.internalFormat,Oe,le,ke.colorSpace,P.isXRRenderTarget===!0),ze=L(P);r.renderbufferStorageMultisample(r.RENDERBUFFER,ze,Ae,P.width,P.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+ge,r.RENDERBUFFER,N.__webglColorRenderbuffer[ge])}r.bindRenderbuffer(r.RENDERBUFFER,null),P.depthBuffer&&(N.__webglDepthRenderbuffer=r.createRenderbuffer(),Pe(N.__webglDepthRenderbuffer,P,!0)),t.bindFramebuffer(r.FRAMEBUFFER,null)}}if(K){t.bindTexture(r.TEXTURE_CUBE_MAP,X.__webglTexture),Y(r.TEXTURE_CUBE_MAP,x);for(let ge=0;ge<6;ge++)if(x.mipmaps&&x.mipmaps.length>0)for(let ke=0;ke<x.mipmaps.length;ke++)ue(N.__webglFramebuffer[ge][ke],P,x,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+ge,ke);else ue(N.__webglFramebuffer[ge],P,x,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+ge,0);g(x)&&f(r.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Ie){for(let ge=0,ke=Z.length;ge<ke;ge++){const Oe=Z[ge],le=i.get(Oe);let Ae=r.TEXTURE_2D;(P.isWebGL3DRenderTarget||P.isWebGLArrayRenderTarget)&&(Ae=P.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),t.bindTexture(Ae,le.__webglTexture),Y(Ae,Oe),ue(N.__webglFramebuffer,P,Oe,r.COLOR_ATTACHMENT0+ge,Ae,0),g(Oe)&&f(Ae)}t.unbindTexture()}else{let ge=r.TEXTURE_2D;if((P.isWebGL3DRenderTarget||P.isWebGLArrayRenderTarget)&&(ge=P.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),t.bindTexture(ge,X.__webglTexture),Y(ge,x),x.mipmaps&&x.mipmaps.length>0)for(let ke=0;ke<x.mipmaps.length;ke++)ue(N.__webglFramebuffer[ke],P,x,r.COLOR_ATTACHMENT0,ge,ke);else ue(N.__webglFramebuffer,P,x,r.COLOR_ATTACHMENT0,ge,0);g(x)&&f(ge),t.unbindTexture()}P.depthBuffer&&Ue(P)}function D(P){const x=P.textures;for(let N=0,X=x.length;N<X;N++){const Z=x[N];if(g(Z)){const K=v(P),Ie=i.get(Z).__webglTexture;t.bindTexture(K,Ie),f(K),t.unbindTexture()}}}const ae=[],$=[];function Q(P){if(P.samples>0){if(te(P)===!1){const x=P.textures,N=P.width,X=P.height;let Z=r.COLOR_BUFFER_BIT;const K=P.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Ie=i.get(P),ge=x.length>1;if(ge)for(let Oe=0;Oe<x.length;Oe++)t.bindFramebuffer(r.FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Oe,r.RENDERBUFFER,null),t.bindFramebuffer(r.FRAMEBUFFER,Ie.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Oe,r.TEXTURE_2D,null,0);t.bindFramebuffer(r.READ_FRAMEBUFFER,Ie.__webglMultisampledFramebuffer);const ke=P.texture.mipmaps;ke&&ke.length>0?t.bindFramebuffer(r.DRAW_FRAMEBUFFER,Ie.__webglFramebuffer[0]):t.bindFramebuffer(r.DRAW_FRAMEBUFFER,Ie.__webglFramebuffer);for(let Oe=0;Oe<x.length;Oe++){if(P.resolveDepthBuffer&&(P.depthBuffer&&(Z|=r.DEPTH_BUFFER_BIT),P.stencilBuffer&&P.resolveStencilBuffer&&(Z|=r.STENCIL_BUFFER_BIT)),ge){r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,Ie.__webglColorRenderbuffer[Oe]);const le=i.get(x[Oe]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,le,0)}r.blitFramebuffer(0,0,N,X,0,0,N,X,Z,r.NEAREST),l===!0&&(ae.length=0,$.length=0,ae.push(r.COLOR_ATTACHMENT0+Oe),P.depthBuffer&&P.resolveDepthBuffer===!1&&(ae.push(K),$.push(K),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,$)),r.invalidateFramebuffer(r.READ_FRAMEBUFFER,ae))}if(t.bindFramebuffer(r.READ_FRAMEBUFFER,null),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),ge)for(let Oe=0;Oe<x.length;Oe++){t.bindFramebuffer(r.FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Oe,r.RENDERBUFFER,Ie.__webglColorRenderbuffer[Oe]);const le=i.get(x[Oe]).__webglTexture;t.bindFramebuffer(r.FRAMEBUFFER,Ie.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Oe,r.TEXTURE_2D,le,0)}t.bindFramebuffer(r.DRAW_FRAMEBUFFER,Ie.__webglMultisampledFramebuffer)}else if(P.depthBuffer&&P.resolveDepthBuffer===!1&&l){const x=P.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[x])}}}function L(P){return Math.min(n.maxSamples,P.samples)}function te(P){const x=i.get(P);return P.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function de(P){const x=a.render.frame;h.get(P)!==x&&(h.set(P,x),P.update())}function V(P,x){const N=P.colorSpace,X=P.format,Z=P.type;return P.isCompressedTexture===!0||P.isVideoTexture===!0||N!==ml&&N!==Vr&&(Nt.getTransfer(N)===Qt?(X!==cs||Z!==$s)&&At("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):yi("WebGLTextures: Unsupported texture color space:",N)),x}function ee(P){return typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement?(c.width=P.naturalWidth||P.width,c.height=P.naturalHeight||P.height):typeof VideoFrame<"u"&&P instanceof VideoFrame?(c.width=P.displayWidth,c.height=P.displayHeight):(c.width=P.width,c.height=P.height),c}this.allocateTextureUnit=U,this.resetTextureUnits=R,this.setTexture2D=F,this.setTexture2DArray=O,this.setTexture3D=H,this.setTextureCube=j,this.rebindTextures=it,this.setupRenderTarget=qe,this.updateRenderTargetMipmap=D,this.updateMultisampleRenderTarget=Q,this.setupDepthRenderbuffer=Ue,this.setupFrameBufferTexture=ue,this.useMultisampledRTT=te}function xL(r,e){function t(i,n=Vr){let s;const a=Nt.getTransfer(n);if(i===$s)return r.UNSIGNED_BYTE;if(i===xg)return r.UNSIGNED_SHORT_4_4_4_4;if(i===_g)return r.UNSIGNED_SHORT_5_5_5_1;if(i===Z1)return r.UNSIGNED_INT_5_9_9_9_REV;if(i===J1)return r.UNSIGNED_INT_10F_11F_11F_REV;if(i===Y1)return r.BYTE;if(i===K1)return r.SHORT;if(i===eh)return r.UNSIGNED_SHORT;if(i===yg)return r.INT;if(i===Qa)return r.UNSIGNED_INT;if(i===er)return r.FLOAT;if(i===fl)return r.HALF_FLOAT;if(i===$1)return r.ALPHA;if(i===ey)return r.RGB;if(i===cs)return r.RGBA;if(i===ih)return r.DEPTH_COMPONENT;if(i===nh)return r.DEPTH_STENCIL;if(i===ty)return r.RED;if(i===Eg)return r.RED_INTEGER;if(i===Mg)return r.RG;if(i===wg)return r.RG_INTEGER;if(i===Sg)return r.RGBA_INTEGER;if(i===ip||i===np||i===sp||i===rp)if(a===Qt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===ip)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===np)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===sp)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===rp)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===ip)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===np)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===sp)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===rp)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Cg||i===Tg||i===Ig||i===Pg)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Cg)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Tg)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ig)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Pg)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Rg||i===Dg||i===Bg)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Rg||i===Dg)return a===Qt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Bg)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===Lg||i===kg||i===Ng||i===Ug||i===Fg||i===Og||i===zg||i===Hg||i===Gg||i===Vg||i===Qg||i===Wg||i===jg||i===qg)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Lg)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===kg)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Ng)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Ug)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Fg)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Og)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===zg)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Hg)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Gg)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Vg)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Qg)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Wg)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===jg)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===qg)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Xg||i===Yg||i===Kg)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===Xg)return a===Qt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Yg)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Kg)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Zg||i===Jg||i===$g||i===e0)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===Zg)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Jg)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===$g)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===e0)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===th?r.UNSIGNED_INT_24_8:r[i]!==void 0?r[i]:null}return{convert:t}}const _L=`
|
||
void main() {
|
||
|
||
gl_Position = vec4( position, 1.0 );
|
||
|
||
}`,EL=`
|
||
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 ML{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new Ny(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new or({vertexShader:_L,fragmentShader:EL,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Kr(new Tp(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class wL extends Al{constructor(e,t){super();const i=this;let n=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,d=null,p=null,u=null,A=null;const m=typeof XRWebGLBinding<"u",g=new ML,f={},v=t.getContextAttributes();let b=null,y=null;const M=[],_=[],S=new Wt;let w=null;const E=new fs;E.viewport=new xi;const I=new fs;I.viewport=new xi;const B=[E,I],R=new QR;let U=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(J){let oe=M[J];return oe===void 0&&(oe=new S0,M[J]=oe),oe.getTargetRaySpace()},this.getControllerGrip=function(J){let oe=M[J];return oe===void 0&&(oe=new S0,M[J]=oe),oe.getGripSpace()},this.getHand=function(J){let oe=M[J];return oe===void 0&&(oe=new S0,M[J]=oe),oe.getHandSpace()};function F(J){const oe=_.indexOf(J.inputSource);if(oe===-1)return;const ue=M[oe];ue!==void 0&&(ue.update(J.inputSource,J.frame,c||a),ue.dispatchEvent({type:J.type,data:J.inputSource}))}function O(){n.removeEventListener("select",F),n.removeEventListener("selectstart",F),n.removeEventListener("selectend",F),n.removeEventListener("squeeze",F),n.removeEventListener("squeezestart",F),n.removeEventListener("squeezeend",F),n.removeEventListener("end",O),n.removeEventListener("inputsourceschange",H);for(let J=0;J<M.length;J++){const oe=_[J];oe!==null&&(_[J]=null,M[J].disconnect(oe))}U=null,C=null,g.reset();for(const J in f)delete f[J];e.setRenderTarget(b),u=null,p=null,d=null,n=null,y=null,xe.stop(),i.isPresenting=!1,e.setPixelRatio(w),e.setSize(S.width,S.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(J){s=J,i.isPresenting===!0&&At("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(J){o=J,i.isPresenting===!0&&At("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(J){c=J},this.getBaseLayer=function(){return p!==null?p:u},this.getBinding=function(){return d===null&&m&&(d=new XRWebGLBinding(n,t)),d},this.getFrame=function(){return A},this.getSession=function(){return n},this.setSession=async function(J){if(n=J,n!==null){if(b=e.getRenderTarget(),n.addEventListener("select",F),n.addEventListener("selectstart",F),n.addEventListener("selectend",F),n.addEventListener("squeeze",F),n.addEventListener("squeezestart",F),n.addEventListener("squeezeend",F),n.addEventListener("end",O),n.addEventListener("inputsourceschange",H),v.xrCompatible!==!0&&await t.makeXRCompatible(),w=e.getPixelRatio(),e.getSize(S),m&&"createProjectionLayer"in XRWebGLBinding.prototype){let oe=null,ue=null,Pe=null;v.depth&&(Pe=v.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,oe=v.stencil?nh:ih,ue=v.stencil?th:Qa);const Be={colorFormat:t.RGBA8,depthFormat:Pe,scaleFactor:s};d=this.getBinding(),p=d.createProjectionLayer(Be),n.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),y=new Wa(p.textureWidth,p.textureHeight,{format:cs,type:$s,depthTexture:new ky(p.textureWidth,p.textureHeight,ue,void 0,void 0,void 0,void 0,void 0,void 0,oe),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}else{const oe={antialias:v.antialias,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:s};u=new XRWebGLLayer(n,t,oe),n.updateRenderState({baseLayer:u}),e.setPixelRatio(1),e.setSize(u.framebufferWidth,u.framebufferHeight,!1),y=new Wa(u.framebufferWidth,u.framebufferHeight,{format:cs,type:$s,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await n.requestReferenceSpace(o),xe.setContext(n),xe.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function H(J){for(let oe=0;oe<J.removed.length;oe++){const ue=J.removed[oe],Pe=_.indexOf(ue);Pe>=0&&(_[Pe]=null,M[Pe].disconnect(ue))}for(let oe=0;oe<J.added.length;oe++){const ue=J.added[oe];let Pe=_.indexOf(ue);if(Pe===-1){for(let Ue=0;Ue<M.length;Ue++)if(Ue>=_.length){_.push(ue),Pe=Ue;break}else if(_[Ue]===null){_[Ue]=ue,Pe=Ue;break}if(Pe===-1)break}const Be=M[Pe];Be&&Be.connect(ue)}}const j=new De,G=new De;function re(J,oe,ue){j.setFromMatrixPosition(oe.matrixWorld),G.setFromMatrixPosition(ue.matrixWorld);const Pe=j.distanceTo(G),Be=oe.projectionMatrix.elements,Ue=ue.projectionMatrix.elements,it=Be[14]/(Be[10]-1),qe=Be[14]/(Be[10]+1),D=(Be[9]+1)/Be[5],ae=(Be[9]-1)/Be[5],$=(Be[8]-1)/Be[0],Q=(Ue[8]+1)/Ue[0],L=it*$,te=it*Q,de=Pe/(-$+Q),V=de*-$;if(oe.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(V),J.translateZ(de),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert(),Be[10]===-1)J.projectionMatrix.copy(oe.projectionMatrix),J.projectionMatrixInverse.copy(oe.projectionMatrixInverse);else{const ee=it+de,P=qe+de,x=L-V,N=te+(Pe-V),X=D*qe/P*ee,Z=ae*qe/P*ee;J.projectionMatrix.makePerspective(x,N,X,Z,ee,P),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}}function q(J,oe){oe===null?J.matrixWorld.copy(J.matrix):J.matrixWorld.multiplyMatrices(oe.matrixWorld,J.matrix),J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(n===null)return;let oe=J.near,ue=J.far;g.texture!==null&&(g.depthNear>0&&(oe=g.depthNear),g.depthFar>0&&(ue=g.depthFar)),R.near=I.near=E.near=oe,R.far=I.far=E.far=ue,(U!==R.near||C!==R.far)&&(n.updateRenderState({depthNear:R.near,depthFar:R.far}),U=R.near,C=R.far),R.layers.mask=J.layers.mask|6,E.layers.mask=R.layers.mask&3,I.layers.mask=R.layers.mask&5;const Pe=J.parent,Be=R.cameras;q(R,Pe);for(let Ue=0;Ue<Be.length;Ue++)q(Be[Ue],Pe);Be.length===2?re(R,E,I):R.projectionMatrix.copy(E.projectionMatrix),Y(J,R,Pe)};function Y(J,oe,ue){ue===null?J.matrix.copy(oe.matrixWorld):(J.matrix.copy(ue.matrixWorld),J.matrix.invert(),J.matrix.multiply(oe.matrixWorld)),J.matrix.decompose(J.position,J.quaternion,J.scale),J.updateMatrixWorld(!0),J.projectionMatrix.copy(oe.projectionMatrix),J.projectionMatrixInverse.copy(oe.projectionMatrixInverse),J.isPerspectiveCamera&&(J.fov=i0*2*Math.atan(1/J.projectionMatrix.elements[5]),J.zoom=1)}this.getCamera=function(){return R},this.getFoveation=function(){if(!(p===null&&u===null))return l},this.setFoveation=function(J){l=J,p!==null&&(p.fixedFoveation=J),u!==null&&u.fixedFoveation!==void 0&&(u.fixedFoveation=J)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(R)},this.getCameraTexture=function(J){return f[J]};let ye=null;function Me(J,oe){if(h=oe.getViewerPose(c||a),A=oe,h!==null){const ue=h.views;u!==null&&(e.setRenderTargetFramebuffer(y,u.framebuffer),e.setRenderTarget(y));let Pe=!1;ue.length!==R.cameras.length&&(R.cameras.length=0,Pe=!0);for(let Ue=0;Ue<ue.length;Ue++){const it=ue[Ue];let qe=null;if(u!==null)qe=u.getViewport(it);else{const ae=d.getViewSubImage(p,it);qe=ae.viewport,Ue===0&&(e.setRenderTargetTextures(y,ae.colorTexture,ae.depthStencilTexture),e.setRenderTarget(y))}let D=B[Ue];D===void 0&&(D=new fs,D.layers.enable(Ue),D.viewport=new xi,B[Ue]=D),D.matrix.fromArray(it.transform.matrix),D.matrix.decompose(D.position,D.quaternion,D.scale),D.projectionMatrix.fromArray(it.projectionMatrix),D.projectionMatrixInverse.copy(D.projectionMatrix).invert(),D.viewport.set(qe.x,qe.y,qe.width,qe.height),Ue===0&&(R.matrix.copy(D.matrix),R.matrix.decompose(R.position,R.quaternion,R.scale)),Pe===!0&&R.cameras.push(D)}const Be=n.enabledFeatures;if(Be&&Be.includes("depth-sensing")&&n.depthUsage=="gpu-optimized"&&m){d=i.getBinding();const Ue=d.getDepthInformation(ue[0]);Ue&&Ue.isValid&&Ue.texture&&g.init(Ue,n.renderState)}if(Be&&Be.includes("camera-access")&&m){e.state.unbindTexture(),d=i.getBinding();for(let Ue=0;Ue<ue.length;Ue++){const it=ue[Ue].camera;if(it){let qe=f[it];qe||(qe=new Ny,f[it]=qe);const D=d.getCameraImage(it);qe.sourceTexture=D}}}}for(let ue=0;ue<M.length;ue++){const Pe=_[ue],Be=M[ue];Pe!==null&&Be!==void 0&&Be.update(Pe,oe,c||a)}ye&&ye(J,oe),oe.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:oe}),A=null}const xe=new Fy;xe.setAnimationLoop(Me),this.setAnimationLoop=function(J){ye=J},this.dispose=function(){}}}const to=new Xa,SL=new Ui;function CL(r,e){function t(g,f){g.matrixAutoUpdate===!0&&g.updateMatrix(),f.value.copy(g.matrix)}function i(g,f){f.color.getRGB(g.fogColor.value,Iy(r)),f.isFog?(g.fogNear.value=f.near,g.fogFar.value=f.far):f.isFogExp2&&(g.fogDensity.value=f.density)}function n(g,f,v,b,y){f.isMeshBasicMaterial||f.isMeshLambertMaterial?s(g,f):f.isMeshToonMaterial?(s(g,f),d(g,f)):f.isMeshPhongMaterial?(s(g,f),h(g,f)):f.isMeshStandardMaterial?(s(g,f),p(g,f),f.isMeshPhysicalMaterial&&u(g,f,y)):f.isMeshMatcapMaterial?(s(g,f),A(g,f)):f.isMeshDepthMaterial?s(g,f):f.isMeshDistanceMaterial?(s(g,f),m(g,f)):f.isMeshNormalMaterial?s(g,f):f.isLineBasicMaterial?(a(g,f),f.isLineDashedMaterial&&o(g,f)):f.isPointsMaterial?l(g,f,v,b):f.isSpriteMaterial?c(g,f):f.isShadowMaterial?(g.color.value.copy(f.color),g.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function s(g,f){g.opacity.value=f.opacity,f.color&&g.diffuse.value.copy(f.color),f.emissive&&g.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(g.map.value=f.map,t(f.map,g.mapTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,t(f.alphaMap,g.alphaMapTransform)),f.bumpMap&&(g.bumpMap.value=f.bumpMap,t(f.bumpMap,g.bumpMapTransform),g.bumpScale.value=f.bumpScale,f.side===xn&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,t(f.normalMap,g.normalMapTransform),g.normalScale.value.copy(f.normalScale),f.side===xn&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,t(f.displacementMap,g.displacementMapTransform),g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias),f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,g.emissiveMapTransform)),f.specularMap&&(g.specularMap.value=f.specularMap,t(f.specularMap,g.specularMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest);const v=e.get(f),b=v.envMap,y=v.envMapRotation;b&&(g.envMap.value=b,to.copy(y),to.x*=-1,to.y*=-1,to.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(to.y*=-1,to.z*=-1),g.envMapRotation.value.setFromMatrix4(SL.makeRotationFromEuler(to)),g.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=f.reflectivity,g.ior.value=f.ior,g.refractionRatio.value=f.refractionRatio),f.lightMap&&(g.lightMap.value=f.lightMap,g.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,g.lightMapTransform)),f.aoMap&&(g.aoMap.value=f.aoMap,g.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,g.aoMapTransform))}function a(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,f.map&&(g.map.value=f.map,t(f.map,g.mapTransform))}function o(g,f){g.dashSize.value=f.dashSize,g.totalSize.value=f.dashSize+f.gapSize,g.scale.value=f.scale}function l(g,f,v,b){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.size.value=f.size*v,g.scale.value=b*.5,f.map&&(g.map.value=f.map,t(f.map,g.uvTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,t(f.alphaMap,g.alphaMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest)}function c(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.rotation.value=f.rotation,f.map&&(g.map.value=f.map,t(f.map,g.mapTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,t(f.alphaMap,g.alphaMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest)}function h(g,f){g.specular.value.copy(f.specular),g.shininess.value=Math.max(f.shininess,1e-4)}function d(g,f){f.gradientMap&&(g.gradientMap.value=f.gradientMap)}function p(g,f){g.metalness.value=f.metalness,f.metalnessMap&&(g.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,g.metalnessMapTransform)),g.roughness.value=f.roughness,f.roughnessMap&&(g.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,g.roughnessMapTransform)),f.envMap&&(g.envMapIntensity.value=f.envMapIntensity)}function u(g,f,v){g.ior.value=f.ior,f.sheen>0&&(g.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),g.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(g.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,g.sheenColorMapTransform)),f.sheenRoughnessMap&&(g.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,g.sheenRoughnessMapTransform))),f.clearcoat>0&&(g.clearcoat.value=f.clearcoat,g.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(g.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,g.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(g.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===xn&&g.clearcoatNormalScale.value.negate())),f.dispersion>0&&(g.dispersion.value=f.dispersion),f.iridescence>0&&(g.iridescence.value=f.iridescence,g.iridescenceIOR.value=f.iridescenceIOR,g.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(g.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,g.iridescenceMapTransform)),f.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),f.transmission>0&&(g.transmission.value=f.transmission,g.transmissionSamplerMap.value=v.texture,g.transmissionSamplerSize.value.set(v.width,v.height),f.transmissionMap&&(g.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,g.transmissionMapTransform)),g.thickness.value=f.thickness,f.thicknessMap&&(g.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=f.attenuationDistance,g.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(g.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(g.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=f.specularIntensity,g.specularColor.value.copy(f.specularColor),f.specularColorMap&&(g.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,g.specularColorMapTransform)),f.specularIntensityMap&&(g.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,g.specularIntensityMapTransform))}function A(g,f){f.matcap&&(g.matcap.value=f.matcap)}function m(g,f){const v=e.get(f).light;g.referencePosition.value.setFromMatrixPosition(v.matrixWorld),g.nearDistance.value=v.shadow.camera.near,g.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function TL(r,e,t,i){let n={},s={},a=[];const o=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function l(v,b){const y=b.program;i.uniformBlockBinding(v,y)}function c(v,b){let y=n[v.id];y===void 0&&(A(v),y=h(v),n[v.id]=y,v.addEventListener("dispose",g));const M=b.program;i.updateUBOMapping(v,M);const _=e.render.frame;s[v.id]!==_&&(p(v),s[v.id]=_)}function h(v){const b=d();v.__bindingPointIndex=b;const y=r.createBuffer(),M=v.__size,_=v.usage;return r.bindBuffer(r.UNIFORM_BUFFER,y),r.bufferData(r.UNIFORM_BUFFER,M,_),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,b,y),y}function d(){for(let v=0;v<o;v++)if(a.indexOf(v)===-1)return a.push(v),v;return yi("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(v){const b=n[v.id],y=v.uniforms,M=v.__cache;r.bindBuffer(r.UNIFORM_BUFFER,b);for(let _=0,S=y.length;_<S;_++){const w=Array.isArray(y[_])?y[_]:[y[_]];for(let E=0,I=w.length;E<I;E++){const B=w[E];if(u(B,_,E,M)===!0){const R=B.__offset,U=Array.isArray(B.value)?B.value:[B.value];let C=0;for(let F=0;F<U.length;F++){const O=U[F],H=m(O);typeof O=="number"||typeof O=="boolean"?(B.__data[0]=O,r.bufferSubData(r.UNIFORM_BUFFER,R+C,B.__data)):O.isMatrix3?(B.__data[0]=O.elements[0],B.__data[1]=O.elements[1],B.__data[2]=O.elements[2],B.__data[3]=0,B.__data[4]=O.elements[3],B.__data[5]=O.elements[4],B.__data[6]=O.elements[5],B.__data[7]=0,B.__data[8]=O.elements[6],B.__data[9]=O.elements[7],B.__data[10]=O.elements[8],B.__data[11]=0):(O.toArray(B.__data,C),C+=H.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,R,B.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function u(v,b,y,M){const _=v.value,S=b+"_"+y;if(M[S]===void 0)return typeof _=="number"||typeof _=="boolean"?M[S]=_:M[S]=_.clone(),!0;{const w=M[S];if(typeof _=="number"||typeof _=="boolean"){if(w!==_)return M[S]=_,!0}else if(w.equals(_)===!1)return w.copy(_),!0}return!1}function A(v){const b=v.uniforms;let y=0;const M=16;for(let S=0,w=b.length;S<w;S++){const E=Array.isArray(b[S])?b[S]:[b[S]];for(let I=0,B=E.length;I<B;I++){const R=E[I],U=Array.isArray(R.value)?R.value:[R.value];for(let C=0,F=U.length;C<F;C++){const O=U[C],H=m(O),j=y%M,G=j%H.boundary,re=j+G;y+=G,re!==0&&M-re<H.storage&&(y+=M-re),R.__data=new Float32Array(H.storage/Float32Array.BYTES_PER_ELEMENT),R.__offset=y,y+=H.storage}}}const _=y%M;return _>0&&(y+=M-_),v.__size=y,v.__cache={},this}function m(v){const b={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(b.boundary=4,b.storage=4):v.isVector2?(b.boundary=8,b.storage=8):v.isVector3||v.isColor?(b.boundary=16,b.storage=12):v.isVector4?(b.boundary=16,b.storage=16):v.isMatrix3?(b.boundary=48,b.storage=48):v.isMatrix4?(b.boundary=64,b.storage=64):v.isTexture?At("WebGLRenderer: Texture samplers can not be part of an uniforms group."):At("WebGLRenderer: Unsupported uniform value type.",v),b}function g(v){const b=v.target;b.removeEventListener("dispose",g);const y=a.indexOf(b.__bindingPointIndex);a.splice(y,1),r.deleteBuffer(n[b.id]),delete n[b.id],delete s[b.id]}function f(){for(const v in n)r.deleteBuffer(n[v]);a=[],n={},s={}}return{bind:l,update:c,dispose:f}}const IL=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let lr=null;function PL(){return lr===null&&(lr=new UR(IL,32,32,Mg,fl),lr.minFilter=Yn,lr.magFilter=Yn,lr.wrapS=Js,lr.wrapT=Js,lr.generateMipmaps=!1,lr.needsUpdate=!0),lr}class RL{constructor(e={}){const{canvas:t=cR(),context:i=null,depth:n=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:p=!1}=e;this.isWebGLRenderer=!0;let u;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");u=i.getContextAttributes().alpha}else u=a;const A=new Set([Sg,wg,Eg]),m=new Set([$s,Qa,eh,th,xg,_g]),g=new Uint32Array(4),f=new Int32Array(4);let v=null,b=null;const y=[],M=[];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=Gr,this.toneMappingExposure=1,this.transmissionResolutionScale=.25,this.interactionCullingEnabled=!1,this.interactionActive=!1,this.interactionRenderScene=null,this.interactionFrameBudgetMs=4,this.interactionSkipShadows=!1;const _=this;let S=!1;this._outputColorSpace=Nn;let w=0,E=0,I=null,B=-1,R=null;const U=new xi,C=new xi;let F=null;const O=new jt(0);let H=0,j=t.width,G=t.height,re=1,q=null,Y=null;const ye=new xi(0,0,j,G),Me=new xi(0,0,j,G);let xe=!1;const J=new Ly;let oe=!1,ue=!1;const Pe=new Ui,Be=new De,Ue=new xi,it={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let qe=!1,D=null;const ae=[];function $(k){ae.push(D);const ie=Number.isFinite(_.interactionFrameBudgetMs)?_.interactionFrameBudgetMs:0,he=_.interactionRenderScene===null||k===_.interactionRenderScene;_.interactionCullingEnabled===!0&&_.interactionActive===!0&&he===!0&&ie>0?D={startTime:performance.now(),budgetMs:ie,aborted:!1}:D=null}function Q(k){const ie=Number.isFinite(_.interactionFrameBudgetMs)?_.interactionFrameBudgetMs:0,he=_.interactionRenderScene===null||k===_.interactionRenderScene;return _.interactionCullingEnabled===!0&&_.interactionActive===!0&&he===!0&&ie>0}function L(){D=ae.pop()??null}function te(){return D===null?!1:D.aborted===!0?!0:performance.now()-D.startTime<D.budgetMs?!1:(D.aborted=!0,!0)}function de(){return I===null?re:1}let V=i;function ee(k,ie){return t.getContext(k,ie)}try{const k={alpha:!0,depth:n,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${rg}`),t.addEventListener("webglcontextlost",Ti,!1),t.addEventListener("webglcontextrestored",Ii,!1),t.addEventListener("webglcontextcreationerror",Nh,!1),V===null){const ie="webgl2";if(V=ee(ie,k),V===null)throw ee(ie)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(k){throw k("WebGLRenderer: "+k.message),k}let P,x,N,X,Z,K,Ie,ge,ke,Oe,le,Ae,ze,Ne,we,je,z,ve,me,Re,pe,ne,Le,Qe;function pt(){P=new OB(V),P.init(),ne=new xL(V,P),x=new PB(V,P,e,ne),N=new bL(V,P),x.reversedDepthBuffer&&p&&N.buffers.depth.setReversed(!0),X=new GB(V),Z=new aL,K=new yL(V,P,N,Z,x,ne,X),Ie=new DB(_),ge=new FB(_),ke=new jR(V),Le=new TB(V,ke),Oe=new zB(V,ke,X,Le),le=new QB(V,Oe,ke,X),me=new VB(V,x,K),je=new RB(Z),Ae=new rL(_,Ie,ge,P,x,Le,je),ze=new CL(_,Z),Ne=new lL,we=new fL(P),ve=new CB(_,Ie,ge,N,le,u,l),z=new AL(_,le,x),Qe=new TL(V,X,x,N),Re=new IB(V,P,X),pe=new HB(V,P,X),X.programs=Ae.programs,_.capabilities=x,_.extensions=P,_.properties=Z,_.renderLists=Ne,_.shadowMap=z,_.state=N,_.info=X}pt();const et=new wL(_,V);this.xr=et,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){const k=P.get("WEBGL_lose_context");k&&k.loseContext()},this.forceContextRestore=function(){const k=P.get("WEBGL_lose_context");k&&k.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(k){k!==void 0&&(re=k,this.setSize(j,G,!1))},this.getSize=function(k){return k.set(j,G)},this.setSize=function(k,ie,he=!0){if(et.isPresenting){At("WebGLRenderer: Can't change size while VR device is presenting.");return}j=k,G=ie,t.width=Math.floor(k*re),t.height=Math.floor(ie*re),he===!0&&(t.style.width=k+"px",t.style.height=ie+"px"),this.setViewport(0,0,k,ie)},this.getDrawingBufferSize=function(k){return k.set(j*re,G*re).floor()},this.setDrawingBufferSize=function(k,ie,he){j=k,G=ie,re=he,t.width=Math.floor(k*he),t.height=Math.floor(ie*he),this.setViewport(0,0,k,ie)},this.getCurrentViewport=function(k){return k.copy(U)},this.getViewport=function(k){return k.copy(ye)},this.setViewport=function(k,ie,he,ce){k.isVector4?ye.set(k.x,k.y,k.z,k.w):ye.set(k,ie,he,ce),N.viewport(U.copy(ye).multiplyScalar(re).round())},this.getScissor=function(k){return k.copy(Me)},this.setScissor=function(k,ie,he,ce){k.isVector4?Me.set(k.x,k.y,k.z,k.w):Me.set(k,ie,he,ce),N.scissor(C.copy(Me).multiplyScalar(re).round())},this.getScissorTest=function(){return xe},this.setScissorTest=function(k){N.setScissorTest(xe=k)},this.setOpaqueSort=function(k){q=k},this.setTransparentSort=function(k){Y=k},this.getClearColor=function(k){return k.copy(ve.getClearColor())},this.setClearColor=function(){ve.setClearColor(...arguments)},this.getClearAlpha=function(){return ve.getClearAlpha()},this.setClearAlpha=function(){ve.setClearAlpha(...arguments)},this.clear=function(k=!0,ie=!0,he=!0){let ce=0;if(k){let se=!1;if(I!==null){const Se=I.texture.format;se=A.has(Se)}if(se){const Se=I.texture.type,He=m.has(Se),Ve=ve.getClearColor(),Fe=ve.getClearAlpha(),Je=Ve.r,rt=Ve.g,nt=Ve.b;He?(g[0]=Je,g[1]=rt,g[2]=nt,g[3]=Fe,V.clearBufferuiv(V.COLOR,0,g)):(f[0]=Je,f[1]=rt,f[2]=nt,f[3]=Fe,V.clearBufferiv(V.COLOR,0,f))}else ce|=V.COLOR_BUFFER_BIT}ie&&(ce|=V.DEPTH_BUFFER_BIT),he&&(ce|=V.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),V.clear(ce)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Ti,!1),t.removeEventListener("webglcontextrestored",Ii,!1),t.removeEventListener("webglcontextcreationerror",Nh,!1),ve.dispose(),Ne.dispose(),we.dispose(),Z.dispose(),Ie.dispose(),ge.dispose(),le.dispose(),Le.dispose(),Qe.dispose(),Ae.dispose(),et.dispose(),et.removeEventListener("sessionstart",Oh),et.removeEventListener("sessionend",zh),es.stop()};function Ti(k){k.preventDefault(),ly("WebGLRenderer: Context Lost."),S=!0}function Ii(){ly("WebGLRenderer: Context Restored."),S=!1;const k=X.autoReset,ie=z.enabled,he=z.autoUpdate,ce=z.needsUpdate,se=z.type;pt(),X.autoReset=k,z.enabled=ie,z.autoUpdate=he,z.needsUpdate=ce,z.type=se}function Nh(k){yi("WebGLRenderer: A WebGL context could not be created. Reason: ",k.statusMessage)}function Vl(k){const ie=k.target;ie.removeEventListener("dispose",Vl),MA(ie)}function MA(k){mf(k),Z.remove(k)}function mf(k){const ie=Z.get(k).programs;ie!==void 0&&(ie.forEach(function(he){Ae.releaseProgram(he)}),k.isShaderMaterial&&Ae.releaseShaderCache(k))}this.renderBufferDirect=function(k,ie,he,ce,se,Se){ie===null&&(ie=it);const He=se.isMesh&&se.matrixWorld.determinant()<0,Ve=wA(k,ie,he,ce,se);N.setMaterial(ce,He);let Fe=he.index,Je=1;if(ce.wireframe===!0){if(Fe=Oe.getWireframeAttribute(he),Fe===void 0)return;Je=2}const rt=he.drawRange,nt=he.attributes.position;let at=rt.start*Je,mt=(rt.start+rt.count)*Je;Se!==null&&(at=Math.max(at,Se.start*Je),mt=Math.min(mt,(Se.start+Se.count)*Je)),Fe!==null?(at=Math.max(at,0),mt=Math.min(mt,Fe.count)):nt!=null&&(at=Math.max(at,0),mt=Math.min(mt,nt.count));const Xe=mt-at;if(Xe<0||Xe===1/0)return;Le.setup(se,ce,Ve,he,Fe);let Pt,lt=Re;if(Fe!==null&&(Pt=ke.get(Fe),lt=pe,lt.setIndex(Pt)),se.isMesh)ce.wireframe===!0?(N.setLineWidth(ce.wireframeLinewidth*de()),lt.setMode(V.LINES)):lt.setMode(V.TRIANGLES);else if(se.isLine){let st=ce.linewidth;st===void 0&&(st=1),N.setLineWidth(st*de()),se.isLineSegments?lt.setMode(V.LINES):se.isLineLoop?lt.setMode(V.LINE_LOOP):lt.setMode(V.LINE_STRIP)}else se.isPoints?lt.setMode(V.POINTS):se.isSprite&<.setMode(V.TRIANGLES);if(se.isBatchedMesh)if(se._multiDrawInstances!==null)sh("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),lt.renderMultiDrawInstances(se._multiDrawStarts,se._multiDrawCounts,se._multiDrawCount,se._multiDrawInstances);else if(P.get("WEBGL_multi_draw"))lt.renderMultiDraw(se._multiDrawStarts,se._multiDrawCounts,se._multiDrawCount);else{const st=se._multiDrawStarts,Yt=se._multiDrawCounts,Zi=se._multiDrawCount,ji=Fe?ke.get(Fe).bytesPerElement:1,kt=Z.get(ce).currentProgram.getUniforms();for(let Ot=0;Ot<Zi;Ot++)kt.setValue(V,"_gl_DrawID",Ot),lt.render(st[Ot]/ji,Yt[Ot])}else if(se.isInstancedMesh)lt.renderInstances(at,Xe,se.count);else if(he.isInstancedBufferGeometry){const st=he._maxInstanceCount!==void 0?he._maxInstanceCount:1/0,Yt=Math.min(he.instanceCount,st);lt.renderInstances(at,Xe,Yt)}else lt.render(at,Xe)};function Uh(k,ie,he){k.transparent===!0&&k.side===Ks&&k.forceSinglePass===!1?(k.side=xn,k.needsUpdate=!0,Wl(k,ie,he),k.side=Hr,k.needsUpdate=!0,Wl(k,ie,he),k.side=Ks):Wl(k,ie,he)}this.compile=function(k,ie,he=null){he===null&&(he=k),b=we.get(he),b.init(ie),M.push(b),he.traverseVisible(function(se){se.isLight&&se.layers.test(ie.layers)&&(b.pushLight(se),se.castShadow&&b.pushShadow(se))}),k!==he&&k.traverseVisible(function(se){se.isLight&&se.layers.test(ie.layers)&&(b.pushLight(se),se.castShadow&&b.pushShadow(se))}),b.setupLights();const ce=new Set;return k.traverse(function(se){if(!(se.isMesh||se.isPoints||se.isLine||se.isSprite))return;const Se=se.material;if(Se)if(Array.isArray(Se))for(let He=0;He<Se.length;He++){const Ve=Se[He];Uh(Ve,he,se),ce.add(Ve)}else Uh(Se,he,se),ce.add(Se)}),b=M.pop(),ce},this.compileAsync=function(k,ie,he=null){const ce=this.compile(k,ie,he);return new Promise(se=>{function Se(){if(ce.forEach(function(He){Z.get(He).currentProgram.isReady()&&ce.delete(He)}),ce.size===0){se(k);return}setTimeout(Se,10)}P.get("KHR_parallel_shader_compile")!==null?Se():setTimeout(Se,10)})};let As=null;function Fh(k){As&&As(k)}function Oh(){es.stop()}function zh(){es.start()}const es=new Fy;es.setAnimationLoop(Fh),typeof self<"u"&&es.setContext(self),this.setAnimationLoop=function(k){As=k,et.setAnimationLoop(k),k===null?es.stop():es.start()},et.addEventListener("sessionstart",Oh),et.addEventListener("sessionend",zh),this.render=function(k,ie){if(ie!==void 0&&ie.isCamera!==!0){yi("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(S!==!0){k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),ie.parent===null&&ie.matrixWorldAutoUpdate===!0&&ie.updateMatrixWorld(),et.enabled===!0&&et.isPresenting===!0&&(et.cameraAutoUpdate===!0&&et.updateCamera(ie),ie=et.getCamera()),k.isScene===!0&&k.onBeforeRender(_,k,ie,I),b=we.get(k,M.length),b.init(ie),M.push(b),Pe.multiplyMatrices(ie.projectionMatrix,ie.matrixWorldInverse),J.setFromProjectionMatrix(Pe,Is,ie.reversedDepth),ue=this.localClippingEnabled,oe=je.init(this.clippingPlanes,ue),v=Ne.get(k,y.length),v.init(),y.push(v),$(k);try{if(et.enabled===!0&&et.isPresenting===!0){const Se=_.xr.getDepthSensingMesh();Se!==null&&Ql(Se,ie,-1/0,_.sortObjects)}Ql(k,ie,0,_.sortObjects),v.finish(),_.sortObjects===!0&&v.sort(q,Y),qe=et.enabled===!1||et.isPresenting===!1||et.hasDepthSensing()===!1,qe&&ve.addToRenderList(v,k),this.info.render.frame++,oe===!0&&je.beginShadows();const he=b.state.shadowsArray;(_.interactionSkipShadows!==!0||Q(k)===!1)&&z.render(he,k,ie),oe===!0&&je.endShadows(),this.info.autoReset===!0&&this.info.reset();const ce=v.opaque,se=v.transmissive;if(b.setupLights(),ie.isArrayCamera){const Se=ie.cameras;if(se.length>0)for(let He=0,Ve=Se.length;He<Ve;He++){const Fe=Se[He];Hh(ce,se,k,Fe)}qe&&ve.render(k);for(let He=0,Ve=Se.length;He<Ve;He++){const Fe=Se[He];mo(v,k,Fe,Fe.viewport)}}else se.length>0&&Hh(ce,se,k,ie),qe&&ve.render(k),mo(v,k,ie)}finally{L()}I!==null&&E===0&&(K.updateMultisampleRenderTarget(I),K.updateRenderTargetMipmap(I)),k.isScene===!0&&k.onAfterRender(_,k,ie),Le.resetDefaultState(),B=-1,R=null,M.pop(),M.length>0?(b=M[M.length-1],oe===!0&&je.setGlobalState(_.clippingPlanes,b.state.camera)):b=null,y.pop(),y.length>0?v=y[y.length-1]:v=null}};function Ql(k,ie,he,ce){if(te()===!0||k.visible===!1)return;if(k.layers.test(ie.layers)){if(k.isGroup)he=k.renderOrder;else if(k.isLOD)k.autoUpdate===!0&&k.update(ie);else if(k.isLight)b.pushLight(k),k.castShadow&&b.pushShadow(k);else if(k.isSprite){if(!k.frustumCulled||J.intersectsSprite(k)){ce&&Ue.setFromMatrixPosition(k.matrixWorld).applyMatrix4(Pe);const Se=le.update(k),He=k.material;He.visible&&v.push(k,Se,He,he,Ue.z,null)}}else if((k.isMesh||k.isLine||k.isPoints)&&(!k.frustumCulled||J.intersectsObject(k))){const Se=le.update(k),He=k.material;if(ce&&(k.boundingSphere!==void 0?(k.boundingSphere===null&&k.computeBoundingSphere(),Ue.copy(k.boundingSphere.center)):(Se.boundingSphere===null&&Se.computeBoundingSphere(),Ue.copy(Se.boundingSphere.center)),Ue.applyMatrix4(k.matrixWorld).applyMatrix4(Pe)),Array.isArray(He)){const Ve=Se.groups;for(let Fe=0,Je=Ve.length;Fe<Je;Fe++){const rt=Ve[Fe],nt=He[rt.materialIndex];nt&&nt.visible&&v.push(k,Se,nt,he,Ue.z,rt)}}else He.visible&&v.push(k,Se,He,he,Ue.z,null)}}const se=k.children;for(let Se=0,He=se.length;Se<He;Se++)Ql(se[Se],ie,he,ce)}function mo(k,ie,he,ce){const{opaque:se,transmissive:Se,transparent:He}=k;b.setupLightsView(he),oe===!0&&je.setGlobalState(_.clippingPlanes,he),ce&&N.viewport(U.copy(ce)),se.length>0&&go(se,ie,he),Se.length>0&&go(Se,ie,he),He.length>0&&go(He,ie,he),N.buffers.depth.setTest(!0),N.buffers.depth.setMask(!0),N.buffers.color.setMask(!0),N.setPolygonOffset(!1)}function Hh(k,ie,he,ce){if((he.isScene===!0?he.overrideMaterial:null)!==null)return;b.state.transmissionRenderTarget[ce.id]===void 0&&(b.state.transmissionRenderTarget[ce.id]=new Wa(1,1,{generateMipmaps:!0,type:P.has("EXT_color_buffer_half_float")||P.has("EXT_color_buffer_float")?fl:$s,minFilter:Va,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Nt.workingColorSpace}));const se=b.state.transmissionRenderTarget[ce.id],Se=ce.viewport||U;se.setSize(Se.z*_.transmissionResolutionScale,Se.w*_.transmissionResolutionScale);const He=_.getRenderTarget(),Ve=_.getActiveCubeFace(),Fe=_.getActiveMipmapLevel();_.setRenderTarget(se),_.getClearColor(O),H=_.getClearAlpha(),H<1&&_.setClearColor(16777215,.5),_.clear(),qe&&ve.render(he);const Je=_.toneMapping;_.toneMapping=Gr;const rt=ce.viewport;if(ce.viewport!==void 0&&(ce.viewport=void 0),b.setupLightsView(ce),oe===!0&&je.setGlobalState(_.clippingPlanes,ce),go(k,he,ce),K.updateMultisampleRenderTarget(se),K.updateRenderTargetMipmap(se),P.has("WEBGL_multisampled_render_to_texture")===!1){let nt=!1;for(let at=0,mt=ie.length;at<mt;at++){const Xe=ie[at],{object:Pt,geometry:lt,material:st,group:Yt}=Xe;if(st.side===Ks&&Pt.layers.test(ce.layers)){const Zi=st.side;st.side=xn,st.needsUpdate=!0,gf(Pt,he,ce,lt,st,Yt),st.side=Zi,st.needsUpdate=!0,nt=!0}}nt===!0&&(K.updateMultisampleRenderTarget(se),K.updateRenderTargetMipmap(se))}_.setRenderTarget(He,Ve,Fe),_.setClearColor(O,H),rt!==void 0&&(ce.viewport=rt),_.toneMapping=Je}function go(k,ie,he){const ce=ie.isScene===!0?ie.overrideMaterial:null;for(let se=0,Se=k.length;se<Se;se++){if(te()===!0)return;const He=k[se],{object:Ve,geometry:Fe,group:Je}=He;let rt=He.material;rt.allowOverride===!0&&ce!==null&&(rt=ce),Ve.layers.test(he.layers)&&gf(Ve,ie,he,Fe,rt,Je)}}function gf(k,ie,he,ce,se,Se){k.onBeforeRender(_,ie,he,ce,se,Se),k.modelViewMatrix.multiplyMatrices(he.matrixWorldInverse,k.matrixWorld),k.normalMatrix.getNormalMatrix(k.modelViewMatrix),se.onBeforeRender(_,ie,he,ce,k,Se),se.transparent===!0&&se.side===Ks&&se.forceSinglePass===!1?(se.side=xn,se.needsUpdate=!0,_.renderBufferDirect(he,ie,ce,se,k,Se),se.side=Hr,se.needsUpdate=!0,_.renderBufferDirect(he,ie,ce,se,k,Se),se.side=Ks):_.renderBufferDirect(he,ie,ce,se,k,Se),k.onAfterRender(_,ie,he,ce,se,Se)}function Wl(k,ie,he){ie.isScene!==!0&&(ie=it);const ce=Z.get(k),se=b?.state.lights,Se=b?.state.shadowsArray,He=se.state.version,Ve=Ae.getParameters(k,se.state,Se,ie,he),Fe=Ae.getProgramCacheKey(Ve);let Je=ce.programs;ce.environment=k.isMeshStandardMaterial?ie.environment:null,ce.fog=ie.fog,ce.envMap=(k.isMeshStandardMaterial?ge:Ie).get(k.envMap||ce.environment),ce.envMapRotation=ce.environment!==null&&k.envMap===null?ie.environmentRotation:k.envMapRotation,Je===void 0&&(k.addEventListener("dispose",Vl),Je=new Map,ce.programs=Je);let rt=Je.get(Fe);if(rt!==void 0){if(ce.currentProgram===rt&&ce.lightsStateVersion===He)return vf(k,Ve),rt}else Ve.uniforms=Ae.getUniforms(k),k.onBeforeCompile(Ve,_),rt=Ae.acquireProgram(Ve,Fe),Je.set(Fe,rt),ce.uniforms=Ve.uniforms;const nt=ce.uniforms;return(!k.isShaderMaterial&&!k.isRawShaderMaterial||k.clipping===!0)&&(nt.clippingPlanes=je.uniform),vf(k,Ve),ce.needsLights=W(k),ce.lightsStateVersion=He,ce.needsLights&&(nt.ambientLightColor.value=se.state.ambient,nt.lightProbe.value=se.state.probe,nt.directionalLights.value=se.state.directional,nt.directionalLightShadows.value=se.state.directionalShadow,nt.spotLights.value=se.state.spot,nt.spotLightShadows.value=se.state.spotShadow,nt.rectAreaLights.value=se.state.rectArea,nt.ltc_1.value=se.state.rectAreaLTC1,nt.ltc_2.value=se.state.rectAreaLTC2,nt.pointLights.value=se.state.point,nt.pointLightShadows.value=se.state.pointShadow,nt.hemisphereLights.value=se.state.hemi,nt.directionalShadowMap.value=se.state.directionalShadowMap,nt.directionalShadowMatrix.value=se.state.directionalShadowMatrix,nt.spotShadowMap.value=se.state.spotShadowMap,nt.spotLightMatrix.value=se.state.spotLightMatrix,nt.spotLightMap.value=se.state.spotLightMap,nt.pointShadowMap.value=se.state.pointShadowMap,nt.pointShadowMatrix.value=se.state.pointShadowMatrix),ce.currentProgram=rt,ce.uniformsList=null,rt}function Af(k){if(k.uniformsList===null){const ie=k.currentProgram.getUniforms();k.uniformsList=Dp.seqWithValue(ie.seq,k.uniforms)}return k.uniformsList}function vf(k,ie){const he=Z.get(k);he.outputColorSpace=ie.outputColorSpace,he.batching=ie.batching,he.batchingColor=ie.batchingColor,he.instancing=ie.instancing,he.instancingColor=ie.instancingColor,he.instancingMorph=ie.instancingMorph,he.skinning=ie.skinning,he.morphTargets=ie.morphTargets,he.morphNormals=ie.morphNormals,he.morphColors=ie.morphColors,he.morphTargetsCount=ie.morphTargetsCount,he.numClippingPlanes=ie.numClippingPlanes,he.numIntersection=ie.numClipIntersection,he.vertexAlphas=ie.vertexAlphas,he.vertexTangents=ie.vertexTangents,he.toneMapping=ie.toneMapping}function wA(k,ie,he,ce,se){ie.isScene!==!0&&(ie=it),K.resetTextureUnits();const Se=ie.fog,He=ce.isMeshStandardMaterial?ie.environment:null,Ve=I===null?_.outputColorSpace:I.isXRRenderTarget===!0?I.texture.colorSpace:ml,Fe=(ce.isMeshStandardMaterial?ge:Ie).get(ce.envMap||He),Je=ce.vertexColors===!0&&!!he.attributes.color&&he.attributes.color.itemSize===4,rt=!!he.attributes.tangent&&(!!ce.normalMap||ce.anisotropy>0),nt=!!he.morphAttributes.position,at=!!he.morphAttributes.normal,mt=!!he.morphAttributes.color;let Xe=Gr;ce.toneMapped&&(I===null||I.isXRRenderTarget===!0)&&(Xe=_.toneMapping);const Pt=he.morphAttributes.position||he.morphAttributes.normal||he.morphAttributes.color,lt=Pt!==void 0?Pt.length:0,st=Z.get(ce),Yt=b?.state.lights;if(oe===!0&&(ue===!0||k!==R)){const Pi=k===R&&ce.id===B;je.setState(ce,k,Pi)}let Zi=!1;ce.version===st.__version?(st.needsLights&&st.lightsStateVersion!==Yt.state.version||st.outputColorSpace!==Ve||se.isBatchedMesh&&st.batching===!1||!se.isBatchedMesh&&st.batching===!0||se.isBatchedMesh&&st.batchingColor===!0&&se.colorTexture===null||se.isBatchedMesh&&st.batchingColor===!1&&se.colorTexture!==null||se.isInstancedMesh&&st.instancing===!1||!se.isInstancedMesh&&st.instancing===!0||se.isSkinnedMesh&&st.skinning===!1||!se.isSkinnedMesh&&st.skinning===!0||se.isInstancedMesh&&st.instancingColor===!0&&se.instanceColor===null||se.isInstancedMesh&&st.instancingColor===!1&&se.instanceColor!==null||se.isInstancedMesh&&st.instancingMorph===!0&&se.morphTexture===null||se.isInstancedMesh&&st.instancingMorph===!1&&se.morphTexture!==null||st.envMap!==Fe||ce.fog===!0&&st.fog!==Se||st.numClippingPlanes!==void 0&&(st.numClippingPlanes!==je.numPlanes||st.numIntersection!==je.numIntersection)||st.vertexAlphas!==Je||st.vertexTangents!==rt||st.morphTargets!==nt||st.morphNormals!==at||st.morphColors!==mt||st.toneMapping!==Xe||st.morphTargetsCount!==lt)&&(Zi=!0):(Zi=!0,st.__version=ce.version);let ji=st.currentProgram;Zi===!0&&(ji=Wl(ce,ie,se));let kt=!1,Ot=!1,Cn=!1;const bt=ji.getUniforms(),fi=st.uniforms;if(N.useProgram(ji.program)&&(kt=!0,Ot=!0,Cn=!0),ce.id!==B&&(B=ce.id,Ot=!0),kt||R!==k){N.buffers.depth.getReversed()&&k.reversedDepth!==!0&&(k._reversedDepth=!0,k.updateProjectionMatrix()),bt.setValue(V,"projectionMatrix",k.projectionMatrix),bt.setValue(V,"viewMatrix",k.matrixWorldInverse);const Pi=bt.map.cameraPosition;Pi!==void 0&&Pi.setValue(V,Be.setFromMatrixPosition(k.matrixWorld)),x.logarithmicDepthBuffer&&bt.setValue(V,"logDepthBufFC",2/(Math.log(k.far+1)/Math.LN2)),(ce.isMeshPhongMaterial||ce.isMeshToonMaterial||ce.isMeshLambertMaterial||ce.isMeshBasicMaterial||ce.isMeshStandardMaterial||ce.isShaderMaterial)&&bt.setValue(V,"isOrthographic",k.isOrthographicCamera===!0),R!==k&&(R=k,Ot=!0,Cn=!0)}if(se.isSkinnedMesh){bt.setOptional(V,se,"bindMatrix"),bt.setOptional(V,se,"bindMatrixInverse");const Pi=se.skeleton;Pi&&(Pi.boneTexture===null&&Pi.computeBoneTexture(),bt.setValue(V,"boneTexture",Pi.boneTexture,K))}se.isBatchedMesh&&(bt.setOptional(V,se,"batchingTexture"),bt.setValue(V,"batchingTexture",se._matricesTexture,K),bt.setOptional(V,se,"batchingIdTexture"),bt.setValue(V,"batchingIdTexture",se._indirectTexture,K),bt.setOptional(V,se,"batchingColorTexture"),se._colorsTexture!==null&&bt.setValue(V,"batchingColorTexture",se._colorsTexture,K));const Hi=he.morphAttributes;if((Hi.position!==void 0||Hi.normal!==void 0||Hi.color!==void 0)&&me.update(se,he,ji),(Ot||st.receiveShadow!==se.receiveShadow)&&(st.receiveShadow=se.receiveShadow,bt.setValue(V,"receiveShadow",se.receiveShadow)),ce.isMeshGouraudMaterial&&ce.envMap!==null&&(fi.envMap.value=Fe,fi.flipEnvMap.value=Fe.isCubeTexture&&Fe.isRenderTargetTexture===!1?-1:1),ce.isMeshStandardMaterial&&ce.envMap===null&&ie.environment!==null&&(fi.envMapIntensity.value=ie.environmentIntensity),fi.dfgLUT!==void 0&&(fi.dfgLUT.value=PL()),Ot&&(bt.setValue(V,"toneMappingExposure",_.toneMappingExposure),st.needsLights&&SA(fi,Cn),Se&&ce.fog===!0&&ze.refreshFogUniforms(fi,Se),ze.refreshMaterialUniforms(fi,ce,re,G,b.state.transmissionRenderTarget[k.id]),Dp.upload(V,Af(st),fi,K)),ce.isShaderMaterial&&ce.uniformsNeedUpdate===!0&&(Dp.upload(V,Af(st),fi,K),ce.uniformsNeedUpdate=!1),ce.isSpriteMaterial&&bt.setValue(V,"center",se.center),bt.setValue(V,"modelViewMatrix",se.modelViewMatrix),bt.setValue(V,"normalMatrix",se.normalMatrix),bt.setValue(V,"modelMatrix",se.matrixWorld),ce.isShaderMaterial||ce.isRawShaderMaterial){const Pi=ce.uniformsGroups;for(let vs=0,CA=Pi.length;vs<CA;vs++){const Ao=Pi[vs];Qe.update(Ao,ji),Qe.bind(Ao,ji)}}return ji}function SA(k,ie){k.ambientLightColor.needsUpdate=ie,k.lightProbe.needsUpdate=ie,k.directionalLights.needsUpdate=ie,k.directionalLightShadows.needsUpdate=ie,k.pointLights.needsUpdate=ie,k.pointLightShadows.needsUpdate=ie,k.spotLights.needsUpdate=ie,k.spotLightShadows.needsUpdate=ie,k.rectAreaLights.needsUpdate=ie,k.hemisphereLights.needsUpdate=ie}function W(k){return k.isMeshLambertMaterial||k.isMeshToonMaterial||k.isMeshPhongMaterial||k.isMeshStandardMaterial||k.isShadowMaterial||k.isShaderMaterial&&k.lights===!0}this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return E},this.getRenderTarget=function(){return I},this.setRenderTargetTextures=function(k,ie,he){const ce=Z.get(k);ce.__autoAllocateDepthBuffer=k.resolveDepthBuffer===!1,ce.__autoAllocateDepthBuffer===!1&&(ce.__useRenderToTexture=!1),Z.get(k.texture).__webglTexture=ie,Z.get(k.depthTexture).__webglTexture=ce.__autoAllocateDepthBuffer?void 0:he,ce.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(k,ie){const he=Z.get(k);he.__webglFramebuffer=ie,he.__useDefaultFramebuffer=ie===void 0};const fe=V.createFramebuffer();this.setRenderTarget=function(k,ie=0,he=0){I=k,w=ie,E=he;let ce=!0,se=null,Se=!1,He=!1;if(k){const Ve=Z.get(k);if(Ve.__useDefaultFramebuffer!==void 0)N.bindFramebuffer(V.FRAMEBUFFER,null),ce=!1;else if(Ve.__webglFramebuffer===void 0)K.setupRenderTarget(k);else if(Ve.__hasExternalTextures)K.rebindTextures(k,Z.get(k.texture).__webglTexture,Z.get(k.depthTexture).__webglTexture);else if(k.depthBuffer){const rt=k.depthTexture;if(Ve.__boundDepthTexture!==rt){if(rt!==null&&Z.has(rt)&&(k.width!==rt.image.width||k.height!==rt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");K.setupDepthRenderbuffer(k)}}const Fe=k.texture;(Fe.isData3DTexture||Fe.isDataArrayTexture||Fe.isCompressedArrayTexture)&&(He=!0);const Je=Z.get(k).__webglFramebuffer;k.isWebGLCubeRenderTarget?(Array.isArray(Je[ie])?se=Je[ie][he]:se=Je[ie],Se=!0):k.samples>0&&K.useMultisampledRTT(k)===!1?se=Z.get(k).__webglMultisampledFramebuffer:Array.isArray(Je)?se=Je[he]:se=Je,U.copy(k.viewport),C.copy(k.scissor),F=k.scissorTest}else U.copy(ye).multiplyScalar(re).floor(),C.copy(Me).multiplyScalar(re).floor(),F=xe;if(he!==0&&(se=fe),N.bindFramebuffer(V.FRAMEBUFFER,se)&&ce&&N.drawBuffers(k,se),N.viewport(U),N.scissor(C),N.setScissorTest(F),Se){const Ve=Z.get(k.texture);V.framebufferTexture2D(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_CUBE_MAP_POSITIVE_X+ie,Ve.__webglTexture,he)}else if(He){const Ve=ie;for(let Fe=0;Fe<k.textures.length;Fe++){const Je=Z.get(k.textures[Fe]);V.framebufferTextureLayer(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0+Fe,Je.__webglTexture,he,Ve)}}else if(k!==null&&he!==0){const Ve=Z.get(k.texture);V.framebufferTexture2D(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_2D,Ve.__webglTexture,he)}B=-1},this.readRenderTargetPixels=function(k,ie,he,ce,se,Se,He,Ve=0){if(!(k&&k.isWebGLRenderTarget)){yi("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Fe=Z.get(k).__webglFramebuffer;if(k.isWebGLCubeRenderTarget&&He!==void 0&&(Fe=Fe[He]),Fe){N.bindFramebuffer(V.FRAMEBUFFER,Fe);try{const Je=k.textures[Ve],rt=Je.format,nt=Je.type;if(!x.textureFormatReadable(rt)){yi("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!x.textureTypeReadable(nt)){yi("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ie>=0&&ie<=k.width-ce&&he>=0&&he<=k.height-se&&(k.textures.length>1&&V.readBuffer(V.COLOR_ATTACHMENT0+Ve),V.readPixels(ie,he,ce,se,ne.convert(rt),ne.convert(nt),Se))}finally{const Je=I!==null?Z.get(I).__webglFramebuffer:null;N.bindFramebuffer(V.FRAMEBUFFER,Je)}}},this.readRenderTargetPixelsAsync=async function(k,ie,he,ce,se,Se,He,Ve=0){if(!(k&&k.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Fe=Z.get(k).__webglFramebuffer;if(k.isWebGLCubeRenderTarget&&He!==void 0&&(Fe=Fe[He]),Fe)if(ie>=0&&ie<=k.width-ce&&he>=0&&he<=k.height-se){N.bindFramebuffer(V.FRAMEBUFFER,Fe);const Je=k.textures[Ve],rt=Je.format,nt=Je.type;if(!x.textureFormatReadable(rt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!x.textureTypeReadable(nt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const at=V.createBuffer();V.bindBuffer(V.PIXEL_PACK_BUFFER,at),V.bufferData(V.PIXEL_PACK_BUFFER,Se.byteLength,V.STREAM_READ),k.textures.length>1&&V.readBuffer(V.COLOR_ATTACHMENT0+Ve),V.readPixels(ie,he,ce,se,ne.convert(rt),ne.convert(nt),0);const mt=I!==null?Z.get(I).__webglFramebuffer:null;N.bindFramebuffer(V.FRAMEBUFFER,mt);const Xe=V.fenceSync(V.SYNC_GPU_COMMANDS_COMPLETE,0);return V.flush(),await hR(V,Xe,4),V.bindBuffer(V.PIXEL_PACK_BUFFER,at),V.getBufferSubData(V.PIXEL_PACK_BUFFER,0,Se),V.deleteBuffer(at),V.deleteSync(Xe),Se}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(k,ie=null,he=0){const ce=Math.pow(2,-he),se=Math.floor(k.image.width*ce),Se=Math.floor(k.image.height*ce),He=ie!==null?ie.x:0,Ve=ie!==null?ie.y:0;K.setTexture2D(k,0),V.copyTexSubImage2D(V.TEXTURE_2D,he,0,0,He,Ve,se,Se),N.unbindTexture()};const Te=V.createFramebuffer(),_e=V.createFramebuffer();this.copyTextureToTexture=function(k,ie,he=null,ce=null,se=0,Se=null){Se===null&&(se!==0?(sh("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Se=se,se=0):Se=0);let He,Ve,Fe,Je,rt,nt,at,mt,Xe;const Pt=k.isCompressedTexture?k.mipmaps[Se]:k.image;if(he!==null)He=he.max.x-he.min.x,Ve=he.max.y-he.min.y,Fe=he.isBox3?he.max.z-he.min.z:1,Je=he.min.x,rt=he.min.y,nt=he.isBox3?he.min.z:0;else{const Hi=Math.pow(2,-se);He=Math.floor(Pt.width*Hi),Ve=Math.floor(Pt.height*Hi),k.isDataArrayTexture?Fe=Pt.depth:k.isData3DTexture?Fe=Math.floor(Pt.depth*Hi):Fe=1,Je=0,rt=0,nt=0}ce!==null?(at=ce.x,mt=ce.y,Xe=ce.z):(at=0,mt=0,Xe=0);const lt=ne.convert(ie.format),st=ne.convert(ie.type);let Yt;ie.isData3DTexture?(K.setTexture3D(ie,0),Yt=V.TEXTURE_3D):ie.isDataArrayTexture||ie.isCompressedArrayTexture?(K.setTexture2DArray(ie,0),Yt=V.TEXTURE_2D_ARRAY):(K.setTexture2D(ie,0),Yt=V.TEXTURE_2D),V.pixelStorei(V.UNPACK_FLIP_Y_WEBGL,ie.flipY),V.pixelStorei(V.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ie.premultiplyAlpha),V.pixelStorei(V.UNPACK_ALIGNMENT,ie.unpackAlignment);const Zi=V.getParameter(V.UNPACK_ROW_LENGTH),ji=V.getParameter(V.UNPACK_IMAGE_HEIGHT),kt=V.getParameter(V.UNPACK_SKIP_PIXELS),Ot=V.getParameter(V.UNPACK_SKIP_ROWS),Cn=V.getParameter(V.UNPACK_SKIP_IMAGES);V.pixelStorei(V.UNPACK_ROW_LENGTH,Pt.width),V.pixelStorei(V.UNPACK_IMAGE_HEIGHT,Pt.height),V.pixelStorei(V.UNPACK_SKIP_PIXELS,Je),V.pixelStorei(V.UNPACK_SKIP_ROWS,rt),V.pixelStorei(V.UNPACK_SKIP_IMAGES,nt);const bt=k.isDataArrayTexture||k.isData3DTexture,fi=ie.isDataArrayTexture||ie.isData3DTexture;if(k.isDepthTexture){const Hi=Z.get(k),Pi=Z.get(ie),vs=Z.get(Hi.__renderTarget),CA=Z.get(Pi.__renderTarget);N.bindFramebuffer(V.READ_FRAMEBUFFER,vs.__webglFramebuffer),N.bindFramebuffer(V.DRAW_FRAMEBUFFER,CA.__webglFramebuffer);for(let Ao=0;Ao<Fe;Ao++)bt&&(V.framebufferTextureLayer(V.READ_FRAMEBUFFER,V.COLOR_ATTACHMENT0,Z.get(k).__webglTexture,se,nt+Ao),V.framebufferTextureLayer(V.DRAW_FRAMEBUFFER,V.COLOR_ATTACHMENT0,Z.get(ie).__webglTexture,Se,Xe+Ao)),V.blitFramebuffer(Je,rt,He,Ve,at,mt,He,Ve,V.DEPTH_BUFFER_BIT,V.NEAREST);N.bindFramebuffer(V.READ_FRAMEBUFFER,null),N.bindFramebuffer(V.DRAW_FRAMEBUFFER,null)}else if(se!==0||k.isRenderTargetTexture||Z.has(k)){const Hi=Z.get(k),Pi=Z.get(ie);N.bindFramebuffer(V.READ_FRAMEBUFFER,Te),N.bindFramebuffer(V.DRAW_FRAMEBUFFER,_e);for(let vs=0;vs<Fe;vs++)bt?V.framebufferTextureLayer(V.READ_FRAMEBUFFER,V.COLOR_ATTACHMENT0,Hi.__webglTexture,se,nt+vs):V.framebufferTexture2D(V.READ_FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_2D,Hi.__webglTexture,se),fi?V.framebufferTextureLayer(V.DRAW_FRAMEBUFFER,V.COLOR_ATTACHMENT0,Pi.__webglTexture,Se,Xe+vs):V.framebufferTexture2D(V.DRAW_FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_2D,Pi.__webglTexture,Se),se!==0?V.blitFramebuffer(Je,rt,He,Ve,at,mt,He,Ve,V.COLOR_BUFFER_BIT,V.NEAREST):fi?V.copyTexSubImage3D(Yt,Se,at,mt,Xe+vs,Je,rt,He,Ve):V.copyTexSubImage2D(Yt,Se,at,mt,Je,rt,He,Ve);N.bindFramebuffer(V.READ_FRAMEBUFFER,null),N.bindFramebuffer(V.DRAW_FRAMEBUFFER,null)}else fi?k.isDataTexture||k.isData3DTexture?V.texSubImage3D(Yt,Se,at,mt,Xe,He,Ve,Fe,lt,st,Pt.data):ie.isCompressedArrayTexture?V.compressedTexSubImage3D(Yt,Se,at,mt,Xe,He,Ve,Fe,lt,Pt.data):V.texSubImage3D(Yt,Se,at,mt,Xe,He,Ve,Fe,lt,st,Pt):k.isDataTexture?V.texSubImage2D(V.TEXTURE_2D,Se,at,mt,He,Ve,lt,st,Pt.data):k.isCompressedTexture?V.compressedTexSubImage2D(V.TEXTURE_2D,Se,at,mt,Pt.width,Pt.height,lt,Pt.data):V.texSubImage2D(V.TEXTURE_2D,Se,at,mt,He,Ve,lt,st,Pt);V.pixelStorei(V.UNPACK_ROW_LENGTH,Zi),V.pixelStorei(V.UNPACK_IMAGE_HEIGHT,ji),V.pixelStorei(V.UNPACK_SKIP_PIXELS,kt),V.pixelStorei(V.UNPACK_SKIP_ROWS,Ot),V.pixelStorei(V.UNPACK_SKIP_IMAGES,Cn),Se===0&&ie.generateMipmaps&&V.generateMipmap(Yt),N.unbindTexture()},this.initRenderTarget=function(k){Z.get(k).__webglFramebuffer===void 0&&K.setupRenderTarget(k)},this.initTexture=function(k){k.isCubeTexture?K.setTextureCube(k,0):k.isData3DTexture?K.setTexture3D(k,0):k.isDataArrayTexture||k.isCompressedArrayTexture?K.setTexture2DArray(k,0):K.setTexture2D(k,0),N.unbindTexture()},this.resetState=function(){w=0,E=0,I=null,N.reset(),Le.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Is}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Nt._getDrawingBufferColorSpace(e),t.unpackColorSpace=Nt._getUnpackColorSpace()}}class DL{engine;renderer;constructor(e){this.engine=e,this.renderer=null}createRenderer(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize();return this.renderer=new RL({alpha:!0,premultipliedAlpha:!1,stencil:!0}),this.renderer.setClearColor(0,0),this.renderer.setSize(e,t),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=V1,this.renderer.localClippingEnabled=!0,this.renderer.outputColorSpace=Nn,this.engine.container.appendChild(this.renderer.domElement),this.renderer}disposeRenderer(){this.renderer?.dispose()}}const ux={type:"change"},L0={type:"start"},px={type:"end"},Lp=new Ir,fx=new li,BL=Math.cos(70*Dt.DEG2RAD),Ci=new T,LL=new T,kL=new T,NL=new T(0,1,0),UL=new T(1,0,0),FL=new T(0,0,1),En=.25*Math.PI,qt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},kp=1e-6;let OL=class extends qu{constructor(r,e,t=null){super(e,t),this.engine=r,this.state=qt.NONE,this.target=new T,this.cursor=new T,this.origin=new T(0,0,0),this.showOriginIcon=!0,this.originPosition={x:0,y:0},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.polarSafetyAngle=Dt.degToRad(5),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:Tn.ROTATE,MIDDLE:Tn.DOLLY,RIGHT:Tn.PAN},this.touches={ONE:In.ROTATE,TWO:In.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new T,this._lastQuaternion=new Tt,this._lastTargetPosition=new T,this._quat=new Tt().setFromUnitVectors(e.up,new T(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new rl,this._sphericalDelta=new rl,this._scale=1,this._panOffset=new T,this._rotateStart=new be,this._rotateEnd=new be,this._rotateDelta=new be,this._panStart=new be,this._panEnd=new be,this._panDelta=new be,this._dollyStart=new be,this._dollyEnd=new be,this._dollyDelta=new be,this._dollyDirection=new T,this._mouse=new be,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=HL.bind(this),this._onPointerDown=zL.bind(this),this._onPointerUp=GL.bind(this),this._onContextMenu=YL.bind(this),this._onMouseWheel=WL.bind(this),this._onKeyDown=jL.bind(this),this._onTouchStart=qL.bind(this),this._onTouchMove=XL.bind(this),this._onMouseDown=VL.bind(this),this._onMouseMove=QL.bind(this),this._interceptControlDown=KL.bind(this),this._interceptControlUp=ZL.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(r){super.connect(r),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(r){r.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=r}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(ux),this.update(),this.state=qt.NONE}update(r=null){this.engine&&this.engine.interactionManager&&this.engine.interactionManager.origin&&this.origin.copy(this.engine.interactionManager.origin);const e=this.object.position;Ci.copy(e).sub(this.target),Ci.applyQuaternion(this._quat),this._spherical.setFromVector3(Ci),this.autoRotate&&this.state===qt.NONE&&this._rotateLeft(this._getAutoRotationAngle(r)),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 t=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(t)&&isFinite(i)&&(t<-Math.PI?t+=En:t>Math.PI&&(t-=En),i<-Math.PI?i+=En:i>Math.PI&&(i-=En),t<=i?this._spherical.theta=Math.max(t,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(t+i)/2?Math.max(t,this._spherical.theta):Math.min(i,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 n=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),n=s!=this._spherical.radius}if(Ci.setFromSpherical(this._spherical),Ci.applyQuaternion(this._quatInverse),this.engine&&this.engine.deviceType==="PC"){const s=new T;if(s.copy(this.origin).sub(this.target),s.lengthSq()>1e-4&&(this._sphericalDelta.theta!==0||this._sphericalDelta.phi!==0)){const a=this.enableDamping?this.dampingFactor*3:1,o=NL,l=LL;this.object.getWorldDirection(l);const c=Math.abs(l.y)>.999?UL:o,h=kL;h.crossVectors(l,c),h.lengthSq()<kp&&h.crossVectors(l,FL),h.normalize();const d=new T().copy(this.object.position).sub(this.origin);d.applyAxisAngle(o,Math.PI*this._sphericalDelta.theta*a),d.applyAxisAngle(h,Math.PI*this._sphericalDelta.phi*a),e.copy(this.origin).add(d);const p=new T().copy(this.target).sub(this.origin);p.applyAxisAngle(o,Math.PI*this._sphericalDelta.theta*a),p.applyAxisAngle(h,Math.PI*this._sphericalDelta.phi*a),this.target.copy(this.origin).add(p)}else if(this._panOffset.lengthSq()===0&&this._sphericalDelta.phi===0&&this._sphericalDelta.theta===0){if(this._scale!==1){const a=new T;this.object.getWorldDirection(a);const o=this._spherical.radius*.05*(this._scale-1);e.add(a.multiplyScalar(o))}}else e.copy(this.target).add(Ci);this.object.lookAt(this.target)}else e.copy(this.target).add(Ci),this.object.lookAt(this.target);if(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 s=null;if(this.object.isPerspectiveCamera){const a=Ci.length();s=this._clampDistance(a*this._scale);const o=a-s;this.object.position.addScaledVector(this._dollyDirection,o),this.object.updateMatrixWorld(),n=!!o}else if(this.object.isOrthographicCamera){const a=new T(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),n=o!==this.object.zoom;const l=new T(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(a),this.object.updateMatrixWorld(),s=Ci.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;s!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position):(Lp.origin.copy(this.object.position),Lp.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Lp.direction))<BL?this.object.lookAt(this.target):(fx.setFromNormalAndCoplanarPoint(this.object.up,this.target),Lp.intersectPlane(fx,this.target))))}else if(this.object.isOrthographicCamera){const s=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom&&(this.object.updateProjectionMatrix(),n=!0)}return this._scale=1,this._performCursorZoom=!1,n||this._lastPosition.distanceToSquared(this.object.position)>kp||8*(1-this._lastQuaternion.dot(this.object.quaternion))>kp||this._lastTargetPosition.distanceToSquared(this.target)>kp?(this.dispatchEvent(ux),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(r){return r!==null?En/60*this.autoRotateSpeed*r:En/60/60*this.autoRotateSpeed}_getZoomScale(r){const e=Math.abs(r*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(r){this._sphericalDelta.theta-=r}_rotateUp(r){this._sphericalDelta.phi-=r}_panLeft(r,e){Ci.setFromMatrixColumn(e,0),Ci.multiplyScalar(-r),this._panOffset.add(Ci)}_panUp(r,e){this.screenSpacePanning===!0?Ci.setFromMatrixColumn(e,1):(Ci.setFromMatrixColumn(e,0),Ci.crossVectors(this.object.up,Ci)),Ci.multiplyScalar(r),this._panOffset.add(Ci)}_pan(r,e){const t=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Ci.copy(i).sub(this.target);let n=Ci.length();n*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*r*n/t.clientHeight,this.object.matrix),this._panUp(2*e*n/t.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(r*(this.object.right-this.object.left)/this.object.zoom/t.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/t.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(r){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=r:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(r){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=r:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(r,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const t=this.domElement.getBoundingClientRect(),i=r-t.left,n=e-t.top,s=t.width,a=t.height;this._mouse.x=i/s*2-1,this._mouse.y=-(n/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(r){return Math.max(this.minDistance,Math.min(this.maxDistance,r))}_handleMouseDownRotate(r){this._rotateStart.set(r.clientX,r.clientY)}_handleMouseDownDolly(r){this._updateZoomParameters(r.clientX,r.clientX),this._dollyStart.set(r.clientX,r.clientY)}_handleMouseDownPan(r){this._panStart.set(r.clientX,r.clientY)}_handleMouseMoveRotate(r){this._rotateEnd.set(r.clientX,r.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(En*this._rotateDelta.x/e.clientHeight),this._rotateUp(En*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(r){this._dollyEnd.set(r.clientX,r.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(r){this._panEnd.set(r.clientX,r.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(r){this._updateZoomParameters(r.clientX,r.clientY);let e;if(this.object.isOrthographicCamera)r.deltaY<0?this._dollyIn(this._getZoomScale(r.deltaY)):r.deltaY!==0&&this._dollyOut(this._getZoomScale(r.deltaY));else{const t=Math.abs(r.deltaY*.01);e=Math.pow(1.15,this.zoomSpeed*t),r.deltaY>0?this._scale/=e:r.deltaY!==0&&(this._scale*=e)}this.update()}_handleKeyDown(r){let e=!1;switch(r.code){case this.keys.UP:r.ctrlKey||r.metaKey||r.shiftKey?this.enableRotate&&this._rotateUp(En*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:r.ctrlKey||r.metaKey||r.shiftKey?this.enableRotate&&this._rotateUp(-En*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:r.ctrlKey||r.metaKey||r.shiftKey?this.enableRotate&&this._rotateLeft(En*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:r.ctrlKey||r.metaKey||r.shiftKey?this.enableRotate&&this._rotateLeft(-En*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(r.preventDefault(),this.update())}_handleTouchStartRotate(r){if(this._pointers.length===1)this._rotateStart.set(r.pageX,r.pageY);else{const e=this._getSecondPointerPosition(r),t=.5*(r.pageX+e.x),i=.5*(r.pageY+e.y);this._rotateStart.set(t,i)}}_handleTouchStartPan(r){if(this._pointers.length===1)this._panStart.set(r.pageX,r.pageY);else{const e=this._getSecondPointerPosition(r),t=.5*(r.pageX+e.x),i=.5*(r.pageY+e.y);this._panStart.set(t,i)}}_handleTouchStartDolly(r){const e=this._getSecondPointerPosition(r),t=r.pageX-e.x,i=r.pageY-e.y,n=Math.sqrt(t*t+i*i);this._dollyStart.set(0,n)}_handleTouchStartDollyPan(r){this.enableZoom&&this._handleTouchStartDolly(r),this.enablePan&&this._handleTouchStartPan(r)}_handleTouchStartDollyRotate(r){this.enableZoom&&this._handleTouchStartDolly(r),this.enableRotate&&this._handleTouchStartRotate(r)}_handleTouchMoveRotate(r){if(this._pointers.length==1)this._rotateEnd.set(r.pageX,r.pageY);else{const t=this._getSecondPointerPosition(r),i=.5*(r.pageX+t.x),n=.5*(r.pageY+t.y);this._rotateEnd.set(i,n)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(En*this._rotateDelta.x/e.clientHeight),this._rotateUp(En*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(r){if(this._pointers.length===1)this._panEnd.set(r.pageX,r.pageY);else{const e=this._getSecondPointerPosition(r),t=.5*(r.pageX+e.x),i=.5*(r.pageY+e.y);this._panEnd.set(t,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(r){const e=this._getSecondPointerPosition(r),t=r.pageX-e.x,i=r.pageY-e.y,n=Math.sqrt(t*t+i*i);this._dollyEnd.set(0,n),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 s=(r.pageX+e.x)*.5,a=(r.pageY+e.y)*.5;this._updateZoomParameters(s,a)}_handleTouchMoveDollyPan(r){this.enableZoom&&this._handleTouchMoveDolly(r),this.enablePan&&this._handleTouchMovePan(r)}_handleTouchMoveDollyRotate(r){this.enableZoom&&this._handleTouchMoveDolly(r),this.enableRotate&&this._handleTouchMoveRotate(r)}_addPointer(r){this._pointers.push(r.pointerId)}_removePointer(r){delete this._pointerPositions[r.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==r.pointerId){this._pointers.splice(e,1);return}}_isTrackingPointer(r){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==r.pointerId)return!0;return!1}_trackPointer(r){let e=this._pointerPositions[r.pointerId];e===void 0&&(e=new be,this._pointerPositions[r.pointerId]=e),e.set(r.pageX,r.pageY)}_getSecondPointerPosition(r){const e=r.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(r){const e=r.deltaMode,t={clientX:r.clientX,clientY:r.clientY,deltaY:r.deltaY};switch(e){case 1:t.deltaY*=16;break;case 2:t.deltaY*=100;break}return r.ctrlKey&&!this._controlActive&&(t.deltaY*=10),t}};function zL(r){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(r.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(r)&&(this._addPointer(r),r.pointerType==="touch"?this._onTouchStart(r):this._onMouseDown(r)))}function HL(r){this.enabled!==!1&&(r.pointerType==="touch"?this._onTouchMove(r):this._onMouseMove(r))}function GL(r){switch(this._removePointer(r),this._pointers.length){case 0:this.domElement.releasePointerCapture(r.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(px),this.state=qt.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 VL(r){if(this.showOriginIcon&&this.engine&&this.engine.ToolUntils){const t=this.engine.scene?.camera||this.object;this.originPosition=this.engine.ToolUntils.WorldPointToScreenPoint(this.origin.clone(),t),console.log("Origin position:",this.originPosition,"Origin:",this.origin)}let e;switch(r.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 Tn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(r),this.state=qt.DOLLY;break;case Tn.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=qt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=qt.ROTATE}break;case Tn.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=qt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=qt.PAN}break;default:this.state=qt.NONE}this.state!==qt.NONE&&this.dispatchEvent(L0)}function QL(r){switch(this.state){case qt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(r);break;case qt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(r);break;case qt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(r);break}}function WL(r){this.enabled===!1||this.enableZoom===!1||this.state!==qt.NONE||(r.preventDefault(),this.dispatchEvent(L0),this._handleMouseWheel(this._customWheelEvent(r)),this.dispatchEvent(px))}function jL(r){this.enabled!==!1&&this._handleKeyDown(r)}function qL(r){switch(this._trackPointer(r),this._pointers.length){case 1:switch(this.touches.ONE){case In.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(r),this.state=qt.TOUCH_ROTATE;break;case In.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(r),this.state=qt.TOUCH_PAN;break;default:this.state=qt.NONE}break;case 2:switch(this.touches.TWO){case In.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(r),this.state=qt.TOUCH_DOLLY_PAN;break;case In.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(r),this.state=qt.TOUCH_DOLLY_ROTATE;break;default:this.state=qt.NONE}break;default:this.state=qt.NONE}this.state!==qt.NONE&&this.dispatchEvent(L0)}function XL(r){switch(this._trackPointer(r),this.state){case qt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(r),this.update();break;case qt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(r),this.update();break;case qt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(r),this.update();break;case qt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(r),this.update();break;default:this.state=qt.NONE}}function YL(r){this.enabled!==!1&&r.preventDefault()}function KL(r){r.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function ZL(r){r.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class mx{constructor(e,t,i,n){this._Engine=e,this.camera=t,this.domElement=i,this._isEnabled=!1,this._rayOriginOffset=new T(0,-1,0),this._camerLocalDirection=new T,this._tmpVector=new T,this._rayCaster=new Ln,this._fallingTime=0,this._isMouseInElement=!1,this._euler=new Di(0,0,0,"YZX"),this._prevMouseX=0,this._prevMouseY=0,this.applyGravity=!1,this.gravityMinHeight=!0,this.applyCollision=!0,this.positionEasing=!0,this.lookflag=1,this.lookSpeed=.001,this.moveSpeed=.02,this.playerHeight=1.4,this.maxRotateX=3,this.g=9.8,this.bindmousedown=this._Engine&&this._Engine.deviceType!=="PC"?this.onTouchStart.bind(this):this.onMouseDown.bind(this),this.bindmouseup=this._Engine&&this._Engine.deviceType!=="PC"?this.onTouchEnd.bind(this):this.onMouseUp.bind(this),this.bindmousemove=this._Engine&&this._Engine.deviceType!=="PC"?this.onTouchMove.bind(this):this.onMouseMove.bind(this),this.bindonKeyDown=this.onKeyDown.bind(this),this.bindonKeyUp=this.onKeyUp.bind(this),this.bindMousewheel=this.onMousewheel.bind(this),this.bindMouseEnter=this.onMouseEnter.bind(this),this.bindMouseLeave=this.onMouseLeave.bind(this),this.needMousewheel=!1,this.moveWheelRun=!0,this.moveWheelStop=!1,this.wheelClock,this.keydown=!1,this.GetEngine=()=>e}set colliders(e){this._rayCastObjects=e}set enabled(e){this._isEnabled!==e&&(this._isEnabled=e,this._euler.setFromQuaternion(this.camera.quaternion),e?this.addEvents():this.removeEvents())}get enabled(){return this._isEnabled}addEvents(){const e=this._Engine?.DeviceType,t=e==="PC"||!e;console.log("[FirstPersonCameraControl] addEvents - DeviceType:",e,"isPC:",t),t?(console.log("[FirstPersonCameraControl] 添加鼠标事件监听器 - mousedown, mouseup"),this.domElement.addEventListener("mousedown",this.bindmousedown,!1),this.domElement.addEventListener("mouseup",this.bindmouseup,!1)):(console.log("[FirstPersonCameraControl] 添加触摸事件监听器"),this.domElement.addEventListener("touchstart",this.bindmousedown,!1),this.domElement.addEventListener("touchend",this.bindmouseup,!1)),this.domElement.addEventListener("mouseenter",this.bindMouseEnter,!1),this.domElement.addEventListener("mouseleave",this.bindMouseLeave,!1),window.addEventListener("keydown",this.bindonKeyDown,!1),window.addEventListener("keyup",this.bindonKeyUp,!1),this.needMousewheel&&(document.addEventListener&&document.addEventListener("DOMMouseScroll",this.bindMousewheel,!1),window.addEventListener("mousewheel",this.bindMousewheel,!1))}removeEvents(){this._Engine&&this._Engine.deviceType!=="PC"?(this.domElement.removeEventListener("touchstart",this.bindmousedown),this.domElement.removeEventListener("touchend",this.bindmouseup),this.domElement.removeEventListener("touchmove",this.bindmousemove)):(this.domElement.removeEventListener("mousedown",this.bindmousedown),this.domElement.removeEventListener("mouseup",this.bindmouseup),this.domElement.removeEventListener("mousemove",this.bindmousemove)),this.domElement.removeEventListener("mouseenter",this.bindMouseEnter),this.domElement.removeEventListener("mouseleave",this.bindMouseLeave),window.removeEventListener("keydown",this.bindonKeyDown),window.removeEventListener("keyup",this.bindonKeyUp),this.needMousewheel&&(document.addEventListener&&document.removeEventListener("DOMMouseScroll",this.bindMousewheel),window.removeEventListener("mousewheel",this.bindMousewheel))}onMouseEnter(e){this._isMouseInElement=!0}onMouseLeave(e){this._isMouseInElement=!1}onMousewheel(e){debugger;let t;switch(e.wheelDelta?(e.wheelDelta>0&&(t="up"),e.wheelDelta<0&&(t="down")):e.detail&&(e.detail<0&&(t="up"),e.detail>0&&(t="down")),t){case"up":this._camerLocalDirection.z=1;break;case"down":this._camerLocalDirection.z=-1;break}this.moveWheelRun==!0?(this.moveWheelRun=!1,this.moveWheelStop=!0,this.wheelClock=setTimeout(()=>{this.moveWheelStop==!0&&(this.moveWheelStop=!1,this.moveWheelRun=!0,this._camerLocalDirection.z=0)},200)):(clearTimeout(this.wheelClock),this.wheelClock=setTimeout(()=>{this.moveWheelStop==!0&&(this.moveWheelStop=!1,this.moveWheelRun=!0,this._camerLocalDirection.z=0)},150))}onMouseDown(e){console.log("[FirstPersonCameraControl] onMouseDown 被调用",e),this.domElement.addEventListener("mousemove",this.bindmousemove,!1),this._prevMouseX=e.screenX,this._prevMouseY=e.screenY}onMouseMove(e){if(this._isEnabled==!1)return;let t=this._prevMouseX?e.screenX-this._prevMouseX:0,i=this._prevMouseY?e.screenY-this._prevMouseY:0,n=this._euler.x-i*this.lookflag*this.lookSpeed;n>=0?n<this.maxRotateX?this._euler.x=n:this._euler.x=this.maxRotateX:n>-this.maxRotateX?this._euler.x=n:this._euler.x=-this.maxRotateX,this._euler.y-=t*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler),this._prevMouseX=e.screenX,this._prevMouseY=e.screenY;let s=this.GetEngine();s.movefirst=!0;var a=new CustomEvent("bimengine:camerachange",{detail:""});window.dispatchEvent(a)}onMouseUp(e){let t=this.GetEngine();t.movefirst=!1,this.domElement.removeEventListener("mousemove",this.bindmousemove)}onTouchStart(e){this.domElement.addEventListener("touchmove",this.bindmousemove,!1),this._prevMouseX=e.targetTouches[0].clientX,this._prevMouseY=e.targetTouches[0].clientY}onTouchMove(e){if(this._isEnabled==!1)return;let t=this._prevMouseX?e.targetTouches[0].clientX-this._prevMouseX:0,i=this._prevMouseY?e.targetTouches[0].clientY-this._prevMouseY:0,n=this._euler.x-i*this.lookflag*this.lookSpeed;n>=0?n<this.maxRotateX?this._euler.x=n:this._euler.x=this.maxRotateX:n>-this.maxRotateX?this._euler.x=n:this._euler.x=-this.maxRotateX,this._euler.y-=t*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler),this._prevMouseX=e.targetTouches[0].clientX,this._prevMouseY=e.targetTouches[0].clientY;let s=this.GetEngine();s.movefirst=!0;var a=new CustomEvent("bimengine:camerachange",{detail:""});window.dispatchEvent(a)}onTouchEnd(e){let t=this.GetEngine();t.movefirst=!1,this.domElement.removeEventListener("touchmove",this.bindmousemove)}onKeyDown(e){if(!this._isMouseInElement)return;var t=new CustomEvent("bimengine:camerachange",{detail:""});let i=this.GetEngine();switch(i.movefirst=!0,window.dispatchEvent(t),e.keyCode){case 38:this.rotateY(-1);break;case 81:this.keydown=!0,this._camerLocalDirection.y=1;break;case 69:this._camerLocalDirection.y=-1;break;case 87:this._camerLocalDirection.z=1;break;case 37:this.rotateX(-1);break;case 65:this._camerLocalDirection.x=-1;break;case 40:this.rotateY(1);break;case 83:this._camerLocalDirection.z=-1;break;case 39:this.rotateX(1);break;case 68:this._camerLocalDirection.x=1;break}}onKeyUp(e){if(!this._isMouseInElement)return;let t=this.GetEngine();switch(t.movefirst=!1,e.keyCode){case 38:case 87:this._camerLocalDirection.z=0;break;case 37:case 65:this._camerLocalDirection.x=0;break;case 40:case 83:this._camerLocalDirection.z=0;break;case 39:case 68:this._camerLocalDirection.x=0;break;case 81:case 69:this.keydown=!1,this._camerLocalDirection.y=0;break}}rotateX(e){this._euler.y-=e*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler)}rotateY(e){let t=this._euler.x-e*this.lookflag*.5*this.lookSpeed;t>=0?t<this.maxRotateX?this._euler.x=t:this._euler.x=this.maxRotateX:t>-this.maxRotateX?this._euler.x=t:this._euler.x=-this.maxRotateX,this.camera.quaternion.setFromEuler(this._euler)}update(){this.keydown||this.gravityTest(),this.collisionTest()}gravityTest(){if(this.applyGravity){let e=!0;this._fallingTime+=.01,this._tmpVector.set(0,-1,0);const t=this.hitTest();if(t){const i=t.point.add(new T(0,this.playerHeight,0));if(this.positionEasing){if(i.y>=this.camera.position.y||i.y-this.camera.position.y<.2){this.setCameraHeight(this.camera.position.y+(i.y-this.camera.position.y)*.08),this._fallingTime=0,e=!1;return}}else t.distance<this.playerHeight&&(this.setCameraHeight(i.y),this._fallingTime=0,e=!1)}e&&this.setCameraHeight(this.camera.position.y-this.g*Math.pow(this._fallingTime,2))}else this.setCameraHeight(this.camera.position.y)}collisionTest(){this._camerLocalDirection.x!==0&&this.collisionTestX(),this._camerLocalDirection.z!==0&&this.collisionTestZ(),this._camerLocalDirection.y!==0&&this.collisionTestY()}collisionTestX(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector.multiplyScalar(this._camerLocalDirection.x),this.applyCollision){const t=this.hitTest();if(t&&t.distance<.3)return}this.camera.position.addScaledVector(this._tmpVector,this.moveSpeed)}collisionTestZ(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector.crossVectors(this.camera.up,this._tmpVector),this._tmpVector.multiplyScalar(this._camerLocalDirection.z),this.applyCollision){const t=this.hitTest();if(t&&t.distance<.3)return}this.camera.position.addScaledVector(this._tmpVector,this.moveSpeed)}collisionTestY(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector=new T(0,1,0),this._tmpVector.multiplyScalar(this._camerLocalDirection.y),this.applyCollision){const i=this.hitTest();if(i&&i.distance<.3)return}let t=this.camera.position.clone().addScaledVector(this._tmpVector,this.moveSpeed);this.setCameraHeight(t.y)}setCameraHeight(e){let t=this.getMinHeight();this.gravityMinHeight&&t!==void 0&&e<t?this.camera.position.y=t:this.camera.position.y=e}getMinHeight(){let e,t=this.GetEngine(),i=t.ToolUntils?t.ToolUntils.GetBoundingBox(t):null;return t&&i&&(e=i.min.y),e}hitTest(){const e=this.camera.position.clone().add(this._rayOriginOffset);this._rayCaster.ray.origin=e,this._rayCaster.ray.direction=this._tmpVector;let t=this.GetEngine();var i=t.scene.ground;i&&i.material.type;let n={},s=t.handelBehaved.handle_catch(this._rayCaster,n);if(s==null)return null;let a=s.object.name,o=s.object.url,l=t.models.find(c=>c.url==o);if(l!=null){let c=l.nodesMap.get(a);if(c.infos!=null&&c.infos.length!=0&&c.infos[0].name&&c.infos[0].name.includes("门"))return null}return s}}function k0(r){const e={self:null,options:null,mouseDownTime:0,mouseDownPosition:null,lastClickTime:0};e.handle_catch=function(m,g){return A(m,g,!0)},e.init=function(m,g){e.self!=null&&e.self.disActive!=null&&e.self.type!=m.type&&e.self.disActive(),e.self=m,g==null&&(g={showCatch:!1}),e.options=g},e.render=function(){e.self&&e.self.render!=null&&e.self.render()},e.active=function(){r.renderer.domElement.addEventListener("mousedown",o),r.renderer.domElement.addEventListener("mouseup",c),r.renderer.domElement.addEventListener("mousemove",l),r.renderer.domElement.addEventListener("touchstart",d,{passive:!1}),r.renderer.domElement.addEventListener("touchend",u,{passive:!1}),r.renderer.domElement.addEventListener("touchmove",p,{passive:!1}),window.addEventListener("keydown",t),window.addEventListener("keyup",i)},e.disActive=function(){r.renderer.domElement.removeEventListener("mousedown",o),r.renderer.domElement.removeEventListener("mouseup",c),r.renderer.domElement.removeEventListener("mousemove",l),r.renderer.domElement.removeEventListener("touchstart",d),r.renderer.domElement.removeEventListener("touchend",u),r.renderer.domElement.removeEventListener("touchmove",p),window.removeEventListener("keydown",t),window.removeEventListener("keyup",i)};function t(m){(m.keyCode===8||m.keyCode===46)&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),m.keyCode===27&&e.self&&e.self.handelKeyEscDown!=null&&e.self.handelKeyEscDown(),m.keyCode===13&&e.self&&e.self.handelKeyEnterDown!=null&&e.self.handelKeyEnterDown(),m.keyCode===32&&e.self&&e.self.handelKeySpaceDown!=null&&e.self.handelKeySpaceDown(),m.key==="Control"&&e.self&&e.self.handelKeyCtrlDown!=null&&e.self.handelKeyCtrlDown(),m.key==="Delete"&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),m.key==="Shift"&&e.self&&e.self.handelKeyShiftDown!=null&&e.self.handelKeyShiftDown(),m.key==="Meta"&&e.self&&e.self.handelKeyMetaDown!=null&&e.self.handelKeyMetaDown()}function i(m){m.key==="Alt"&&e.self&&e.self.handelKeyAltUp!=null&&e.self.handelKeyAltUp(),m.key==="Tab"&&e.self&&e.self.handelKeyTabUp!=null&&e.self.handelKeyTabUp(),m.key==="Control"&&e.self&&e.self.handelKeyCtrlUp!=null&&e.self.handelKeyCtrlUp(),m.key==="Shift"&&e.self&&e.self.handelKeyShiftUp!=null&&e.self.handelKeyShiftUp(),m.key==="Meta"&&e.self&&e.self.handelKeyMetaUp!=null&&e.self.handelKeyMetaUp(),m.key==="Command"&&e.self&&e.self.handelKeyCommandUp!=null&&e.self.handelKeyCommandUp(),m.key==="Windows"&&e.self&&e.self.handelKeyWindowsUp!=null&&e.self.handelKeyWindowsUp()}function n(m){const g=new be,f=r.renderer.domElement.clientWidth,v=r.renderer.domElement.clientHeight;return g.x=m.offsetX/f*2-1,g.y=-(m.offsetY/v)*2+1,g}function s(m){const g=new Ln,f=n(m);return g.setFromCamera(f,r.camera),g}function a(m,g=!1,f=!1){const v=s(m);if(m.raycaster=v,g){const b=A(v,m,f);m.catch=b}}function o(m){m.button===0&&(e.mouseDownTime=Date.now(),e.mouseDownPosition=new T(m.offsetX,m.offsetY,0),e.self&&e.self.handleMouseDown!=null&&(a(m,!0,!0),m.catch!=null&&(r.engineStatus.highlightModels==null||r.engineStatus.highlightModels.length==0)&&r.controlModule.orbitControls.origin.set(m.catch.point.x,m.catch.point.y,m.catch.point.z),e.self.handleMouseDown(m)))}function l(m){e.self&&e.self.handleMouseMove!=null&&((r.engineStatus.isFree||r.engineStatus.isForceFree)&&a(m,!0,!0),e.self.handleMouseMove(m))}function c(m){if(m.button!==0)return;const g=Date.now(),f=g-e.mouseDownTime,v=new T(m.offsetX,m.offsetY,0);e.self&&e.self.handleMouseUp!=null&&(a(m,!1),e.self.handleMouseUp(m));const b=v.distanceTo(e.mouseDownPosition);if((f<100||b==0)&&e.self&&e.self.handleMouseClick!=null){a(m,!0,!0);const y=g-e.lastClickTime;console.log(y),y<200?e.self.handleMouseDoubleClick!=null&&e.self.handleMouseDoubleClick(m):e.self.handleMouseClick!=null&&e.self.handleMouseClick(m),e.lastClickTime=Date.now()}}function h(m){const g=m.touches[0]||m.changedTouches[0];if(!g)return null;const f=r.renderer.domElement.getBoundingClientRect(),v=g.clientX-f.left,b=g.clientY-f.top;return{offsetX:v,offsetY:b,button:0,clientX:g.clientX,clientY:g.clientY,preventDefault:()=>m.preventDefault(),stopPropagation:()=>m.stopPropagation(),originalEvent:m}}function d(m){if(m.preventDefault(),m.touches.length!==1)return;const g=h(m);g&&o(g)}function p(m){if(m.preventDefault(),m.touches.length!==1)return;const g=h(m);g&&l(g)}function u(m){m.preventDefault();const g=h(m);g&&c(g)}function A(m,g,f=!1){if(!r.engineStatus.isFree&&f==!1){r.hoverHighLight.clearHighlight();return}console.log("catch"),r.catchSvg.innerHTML="";let v=r.octreeBox.rayInterationModel(m,f);v=r.clipping?.filterIntersectionsByClipping(v)??v;let b=m.intersectObjects(r.scene.children.filter(O=>O instanceof ni),!0);if(b=r.clipping?.filterIntersectionsByClipping(b)??b,b.length>0&&(v.length==0||b[0].distance<v[0].distance)){let O=b[0].object;if(O.ids!=null&&O.ids.length!=0){let H=O.ids[b[0].instanceId],j={object:{url:O.url,id:H,name:H,isInstance:!0},face:b[0].face,distance:b[0].distance,point:b[0].point,instanceId:b[0].instanceId,matrix:O.matrixs[b[0].instanceId]};v.splice(0,0,j)}}if(v.length===0)return;let y=v[0].object.url,M=v[0].object.name,_=r.modelEdge.getModelEdge(y,M);_||(_=[0,0,[]]);let S=[];_[2].forEach(O=>{O[0]!=null&&O[1]!=null&&S.push({X:O[0].X*.5+O[1].X*.5,Y:O[0].Y*.5+O[1].Y*.5,Z:O[0].Z*.5+O[1].Z*.5})});let w=[..._[2].map(O=>O[0]),...S],E="face",I=[],B=[],R=10;if(w.forEach(O=>{if(O!=null){let H=new T(O.X,O.Z,-O.Y);if(r.clipping&&!r.clipping.isPointInClippingRange(H))return;let j=new zt(r.camera,r.renderer,r.scene).worldToScreen(H),G=Math.sqrt(Math.pow(j.x-g.offsetX,2)+Math.pow(j.y-g.offsetY,2));G<R&&(R=G,I.push({point:H,distance:G,pointxy:j}))}}),I.length>0?(I.sort((O,H)=>O.distance-H.distance),E="point"):(_[2].forEach(O=>{if(O[0]!=null&&O[1]!=null){let H=new T(O[0].X,O[0].Z,-O[0].Y),j=new T(O[1].X,O[1].Z,-O[1].Y),G=new zt(r.camera,r.renderer,r.scene).worldToScreen(H),re=new zt(r.camera,r.renderer,r.scene).worldToScreen(j),q=U(new be(g.offsetX,g.offsetY),G,re);if(q<R){let Y=C(new be(g.offsetX,g.offsetY),G,re),ye=F(Y,H,j);if(r.clipping&&!r.clipping.isPointInClippingRange(ye))return;B.push({distance:q,point:ye,pointxy:new zt(r.camera,r.renderer,r.scene).worldToScreen(ye),start:G,end:re})}}}),B.length>0&&(B.sort((O,H)=>O.distance-H.distance),E="line")),E=="point"&&e.options.showCatch){const O=new zt(r.camera,r.renderer,r.scene).worldToScreen(I[0].point);r.catchSvg.innerHTML="";const H=O.x+r.reactBoundingClientRect.left,j=O.y+r.reactBoundingClientRect.top;console.log(H,j);const G=document.createElementNS("http://www.w3.org/2000/svg","polygon");G.setAttribute("class","catchPoint"),G.setAttribute("points",`${H},${j-8} ${H-7},${j+4} ${H+7},${j+4}`),G.setAttribute("stroke","rgb(8, 223, 215)"),G.setAttribute("fill","transparent"),r.catchSvg.appendChild(G),v[0].point=I[0].point}else if(E=="line"&&e.options.showCatch){const O=new zt(r.camera,r.renderer,r.scene).worldToScreen(B[0].point),H=B[0].start,j=B[0].end;r.catchSvg.innerHTML="";const G=document.createElementNS("http://www.w3.org/2000/svg","line");G.setAttribute("class","catchLine"),G.setAttribute("x1",(H.x+r.reactBoundingClientRect.left).toString()),G.setAttribute("y1",(H.y+r.reactBoundingClientRect.top).toString()),G.setAttribute("x2",(j.x+r.reactBoundingClientRect.left).toString()),G.setAttribute("y2",(j.y+r.reactBoundingClientRect.top).toString()),G.setAttribute("stroke","rgb(8, 223, 215)"),G.setAttribute("stroke-width","2"),r.catchSvg.appendChild(G);const re=O.x+r.reactBoundingClientRect.left,q=O.y+r.reactBoundingClientRect.top,Y=document.createElementNS("http://www.w3.org/2000/svg","polygon");Y.setAttribute("class","catchPoint"),Y.setAttribute("points",`${re},${q-8} ${re-7},${q+4} ${re+7},${q+4}`),Y.setAttribute("stroke","rgb(8, 223, 215)"),Y.setAttribute("fill","transparent"),r.catchSvg.appendChild(Y),v[0].point=B[0].point}else if(E=="face"&&e.options.showCatch){let O=v[0].point.clone(),H=v[0].normal||(v[0].face?v[0].face.normal:null);const j=(H?H.clone():new T(0,0,1)).normalize(),G=Math.abs(j.y)<.9?new T(0,1,0):new T(1,0,0),re=new T().crossVectors(j,G).normalize(),q=new T().crossVectors(j,re).normalize(),Y=.2,ye=[new T().copy(re).add(q).multiplyScalar(Y),new T().copy(re).sub(q).multiplyScalar(Y),new T().copy(re).multiplyScalar(-1).sub(q).multiplyScalar(Y),new T().copy(re).multiplyScalar(-1).add(q).multiplyScalar(Y)].map(xe=>new T().copy(O).add(xe)).map(xe=>new zt(r.camera,r.renderer,r.scene).worldToScreen(xe));r.catchSvg.innerHTML="";const Me=document.createElementNS("http://www.w3.org/2000/svg","polygon");Me.setAttribute("class","catchFace"),Me.setAttribute("points",ye.map(xe=>`${xe.x+r.reactBoundingClientRect.left},${xe.y+r.reactBoundingClientRect.top}`).join(" ")),Me.setAttribute("fill","rgba(1, 238, 255, 0.2)"),Me.setAttribute("stroke","rgb(0, 255, 247)"),Me.setAttribute("stroke-width","1"),r.catchSvg.appendChild(Me)}return v[0];function U(O,H,j){const G=new be().subVectors(j,H),re=G.lengthSq();if(re<1e-10)return O.distanceTo(H);const q=new be().subVectors(O,H),Y=Dt.clamp(q.dot(G)/re,0,1),ye=new be().copy(G).multiplyScalar(Y).add(H);return O.distanceTo(ye)}function C(O,H,j){const G=new be().subVectors(j,H),re=G.lengthSq();if(re<1e-10)return 0;const q=new be().subVectors(O,H);return Dt.clamp(q.dot(G)/re,0,1)}function F(O,H,j){const G=Dt.clamp(O,0,1);return new T().lerpVectors(H,j,G)}}return e}class JL{engine;orbitControls;firstPersonControls;isActive=!0;originDiv=null;handelBehaved;isDragging=!1;isDown=!1;containerOffset={left:0,top:0};constructor(e){this.engine=e,this.init(),this.handelBehaved=k0(this.engine),this.handelBehaved.init(this,null),this.handelBehaved.active()}init(){this.orbitControls=new OL(this.engine,this.engine.camera,this.engine.renderer.domElement),this.orbitControls.showOriginIcon=!0,this.firstPersonControls=new mx(this.engine,this.engine.camera,this.engine.renderer.domElement);const e=document.createElement("div");this.originDiv=e,e.className="originDiv",e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.width="30px",e.style.height="30px",e.style.borderRadius="50%",e.style.pointerEvents="none",e.style.backgroundImage="url(/assets/svg/rotate-orbit.svg)",this.engine.container.appendChild(this.originDiv)}active(){this.isActive=!0,this.orbitControls.enabled=!0}disActive(){this.isActive=!1,this.orbitControls.enabled=!1}setMoveSpeed(e){this.firstPersonControls.moveSpeed=e*.1}getMoveSpeed(){return this.firstPersonControls.moveSpeed*10}setApplyCollision(e){this.firstPersonControls.applyCollision=e}getApplyCollision(){return this.firstPersonControls.applyCollision}setApplyGravity(e){this.firstPersonControls.applyGravity=e}getApplyGravity(){return this.firstPersonControls.applyGravity}toggleMinMap(){this.engine.minMap.toggle()}switchFirstPersonMode(){this.engine.cameraModule.switchToPerspectiveCamera(),this.firstPersonControls=new mx(this.engine,this.engine.camera,this.engine.renderer.domElement,[]),this.orbitControls.enabled=!1,this.firstPersonControls.enabled=!0,this.firstPersonControls.isActive=!0,this.engine.worldToScreen=new zt(this.engine.camera,this.engine.renderer,this.engine.scene)}switchDefaultMode(){this.firstPersonControls&&(this.firstPersonControls.enabled=!1),this.orbitControls.enabled=!0,this.engine.worldToScreen=new zt(this.engine.camera,this.engine.renderer,this.engine.scene)}handleMouseUp(e){this.isDragging=!1,this.isDown=!1}handleMouseMove(e){this.isDown?this.isDragging=!0:this.isDragging=!1}handleMouseDown(e){this.isDown=!0}handleMouseClick(e){this.isDragging=!1,this.isDown=!1}update(){if(this.firstPersonControls.enabled&&this.firstPersonControls.update(),this.orbitControls.enabled){const e=this.engine.controlModule.orbitControls.origin,t=this.engine.worldToScreen.worldToScreen(e);this.originDiv&&this.isDragging?(this.originDiv.style.left=t.x-15+this.engine.reactBoundingClientRect.left+"px",this.originDiv.style.top=t.y-15+this.engine.reactBoundingClientRect.top+"px",this.originDiv.style.display="block"):this.originDiv&&(this.originDiv.style.display="none")}}}const io={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 no{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 $L=new Ki(-1,1,1,-1,0,1);class e8 extends ot{constructor(){super(),this.setAttribute("position",new tt([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new tt([0,2,0,0,2,0],2))}}const t8=new e8;class Np{constructor(e){this._mesh=new Ge(t8,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,$L)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class Up extends no{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof ei?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=nn.clone(e.uniforms),this.material=new ei({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 Np(this.material)}render(e,t,i){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=i.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 gx extends no{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,i){const n=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0);let a,o;this.inverse?(a=0,o=1):(a=1,o=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(n.REPLACE,n.REPLACE,n.REPLACE),s.buffers.stencil.setFunc(n.ALWAYS,a,4294967295),s.buffers.stencil.setClear(o),s.buffers.stencil.setLocked(!0),e.setRenderTarget(i),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(n.EQUAL,1,4294967295),s.buffers.stencil.setOp(n.KEEP,n.KEEP,n.KEEP),s.buffers.stencil.setLocked(!0)}}class i8 extends no{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class n8{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const i=e.getSize(new be);this._width=i.width,this._height=i.height,t=new Ei(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Zt}),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 Up(io),this.copyPass.material.blending=ti,this.timer=new Om}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){this.timer.update(),e===void 0&&(e=this.timer.getDelta());const t=this.renderer.getRenderTarget();let i=!1;for(let n=0,s=this.passes.length;n<s;n++){const a=this.passes[n];if(a.enabled!==!1){if(a.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(n),a.render(this.renderer,this.writeBuffer,this.readBuffer,e,i),a.needsSwap){if(i){const o=this.renderer.getContext(),l=this.renderer.state.buffers.stencil;l.setFunc(o.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),l.setFunc(o.EQUAL,1,4294967295)}this.swapBuffers()}gx!==void 0&&(a instanceof gx?i=!0:a instanceof i8&&(i=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new be);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 i=this._width*this._pixelRatio,n=this._height*this._pixelRatio;this.renderTarget1.setSize(i,n),this.renderTarget2.setSize(i,n);for(let s=0;s<this.passes.length;s++)this.passes[s].setSize(i,n)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class s8 extends no{constructor(e,t,i=null,n=null,s=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=i,this.clearColor=n,this.clearAlpha=s,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.isRenderPass=!0,this._oldClearColor=new We}render(e,t,i){const n=e.autoClear;e.autoClear=!1;let s,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&&(s=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:i),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(s),this.overrideMaterial!==null&&(this.scene.overrideMaterial=a),e.autoClear=n}}const Fp={defines:{PERSPECTIVE_CAMERA:1,SAMPLES:16,NORMAL_VECTOR_TYPE:1,DEPTH_SWIZZLING:"x",SCREEN_SPACE_RADIUS:0,SCREEN_SPACE_RADIUS_SCALE:100,SCENE_CLIP_BOX:0},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new be},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new Ke},cameraProjectionMatrixInverse:{value:new Ke},cameraWorldMatrix:{value:new Ke},radius:{value:.25},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},scale:{value:1},sceneBoxMin:{value:new T(-1,-1,-1)},sceneBoxMax:{value:new T(1,1,1)}},vertexShader:`
|
||
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,fragmentShader:`
|
||
varying vec2 vUv;
|
||
uniform highp sampler2D tNormal;
|
||
uniform highp sampler2D tDepth;
|
||
uniform sampler2D tNoise;
|
||
uniform vec2 resolution;
|
||
uniform float cameraNear;
|
||
uniform float cameraFar;
|
||
uniform mat4 cameraProjectionMatrix;
|
||
uniform mat4 cameraProjectionMatrixInverse;
|
||
uniform mat4 cameraWorldMatrix;
|
||
uniform float radius;
|
||
uniform float distanceExponent;
|
||
uniform float thickness;
|
||
uniform float distanceFallOff;
|
||
uniform float scale;
|
||
#if SCENE_CLIP_BOX == 1
|
||
uniform vec3 sceneBoxMin;
|
||
uniform vec3 sceneBoxMax;
|
||
#endif
|
||
|
||
#include <common>
|
||
#include <packing>
|
||
|
||
#ifndef FRAGMENT_OUTPUT
|
||
#define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)
|
||
#endif
|
||
|
||
vec3 getViewPosition( const in vec2 screenPosition, const in float depth ) {
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
vec4 clipSpacePosition = vec4( vec2( screenPosition ) * 2.0 - 1.0, depth, 1.0 );
|
||
#else
|
||
vec4 clipSpacePosition = vec4( vec3( screenPosition, depth ) * 2.0 - 1.0, 1.0 );
|
||
#endif
|
||
vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;
|
||
return viewSpacePosition.xyz / viewSpacePosition.w;
|
||
}
|
||
|
||
float getDepth(const vec2 uv) {
|
||
return textureLod(tDepth, uv.xy, 0.0).DEPTH_SWIZZLING;
|
||
}
|
||
|
||
float fetchDepth(const ivec2 uv) {
|
||
return texelFetch(tDepth, uv.xy, 0).DEPTH_SWIZZLING;
|
||
}
|
||
|
||
float getViewZ(const in float depth) {
|
||
#if PERSPECTIVE_CAMERA == 1
|
||
return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);
|
||
#else
|
||
return orthographicDepthToViewZ(depth, cameraNear, cameraFar);
|
||
#endif
|
||
}
|
||
|
||
vec3 computeNormalFromDepth(const vec2 uv) {
|
||
vec2 size = vec2(textureSize(tDepth, 0));
|
||
ivec2 p = ivec2(uv * size);
|
||
float c0 = fetchDepth(p);
|
||
float l2 = fetchDepth(p - ivec2(2, 0));
|
||
float l1 = fetchDepth(p - ivec2(1, 0));
|
||
float r1 = fetchDepth(p + ivec2(1, 0));
|
||
float r2 = fetchDepth(p + ivec2(2, 0));
|
||
float b2 = fetchDepth(p - ivec2(0, 2));
|
||
float b1 = fetchDepth(p - ivec2(0, 1));
|
||
float t1 = fetchDepth(p + ivec2(0, 1));
|
||
float t2 = fetchDepth(p + ivec2(0, 2));
|
||
float dl = abs((2.0 * l1 - l2) - c0);
|
||
float dr = abs((2.0 * r1 - r2) - c0);
|
||
float db = abs((2.0 * b1 - b2) - c0);
|
||
float dt = abs((2.0 * t1 - t2) - c0);
|
||
vec3 ce = getViewPosition(uv, c0).xyz;
|
||
vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;
|
||
vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;
|
||
return normalize(cross(dpdx, dpdy));
|
||
}
|
||
|
||
vec3 getViewNormal(const vec2 uv) {
|
||
#if NORMAL_VECTOR_TYPE == 2
|
||
return normalize(textureLod(tNormal, uv, 0.).rgb);
|
||
#elif NORMAL_VECTOR_TYPE == 1
|
||
return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);
|
||
#else
|
||
return computeNormalFromDepth(uv);
|
||
#endif
|
||
}
|
||
|
||
vec3 getSceneUvAndDepth(vec3 sampleViewPos) {
|
||
vec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);
|
||
vec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;
|
||
float sampleSceneDepth = getDepth(sampleUv);
|
||
return vec3(sampleUv, sampleSceneDepth);
|
||
}
|
||
|
||
void main() {
|
||
float depth = getDepth(vUv.xy);
|
||
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
if (depth <= 0.0) {
|
||
discard;
|
||
return;
|
||
}
|
||
#else
|
||
if (depth >= 1.0) {
|
||
discard;
|
||
return;
|
||
}
|
||
#endif
|
||
|
||
vec3 viewPos = getViewPosition(vUv, depth);
|
||
vec3 viewNormal = getViewNormal(vUv);
|
||
|
||
float radiusToUse = radius;
|
||
float distanceFalloffToUse = thickness;
|
||
#if SCREEN_SPACE_RADIUS == 1
|
||
float radiusScale = getViewPosition(vec2(0.5 + float(SCREEN_SPACE_RADIUS_SCALE) / resolution.x, 0.0), depth).x;
|
||
radiusToUse *= radiusScale;
|
||
distanceFalloffToUse *= radiusScale;
|
||
#endif
|
||
|
||
#if SCENE_CLIP_BOX == 1
|
||
vec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;
|
||
float boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));
|
||
if (boxDistance > radiusToUse) {
|
||
discard;
|
||
return;
|
||
}
|
||
#endif
|
||
|
||
vec2 noiseResolution = vec2(textureSize(tNoise, 0));
|
||
vec2 noiseUv = vUv * resolution / noiseResolution;
|
||
vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);
|
||
vec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;
|
||
vec3 tangent = normalize(vec3(randomVec.xy, 0.));
|
||
vec3 bitangent = vec3(-tangent.y, tangent.x, 0.);
|
||
mat3 kernelMatrix = mat3(tangent, bitangent, vec3(0., 0., 1.));
|
||
|
||
const int DIRECTIONS = SAMPLES < 30 ? 3 : 5;
|
||
const int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;
|
||
float ao = 0.0;
|
||
for (int i = 0; i < DIRECTIONS; ++i) {
|
||
|
||
float angle = float(i) / float(DIRECTIONS) * PI;
|
||
vec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w);
|
||
sampleDir.xyz = normalize(kernelMatrix * sampleDir.xyz);
|
||
|
||
vec3 viewDir = normalize(-viewPos.xyz);
|
||
vec3 sliceBitangent = normalize(cross(sampleDir.xyz, viewDir));
|
||
vec3 sliceTangent = cross(sliceBitangent, viewDir);
|
||
vec3 normalInSlice = normalize(viewNormal - sliceBitangent * dot(viewNormal, sliceBitangent));
|
||
|
||
vec3 tangentToNormalInSlice = cross(normalInSlice, sliceBitangent);
|
||
vec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice), dot(viewDir, -tangentToNormalInSlice));
|
||
|
||
for (int j = 0; j < STEPS; ++j) {
|
||
vec3 sampleViewOffset = sampleDir.xyz * radiusToUse * sampleDir.w * pow(float(j + 1) / float(STEPS), distanceExponent);
|
||
|
||
vec3 sampleSceneUvDepth = getSceneUvAndDepth(viewPos + sampleViewOffset);
|
||
vec3 sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);
|
||
vec3 viewDelta = sampleSceneViewPos - viewPos;
|
||
if (abs(viewDelta.z) < thickness) {
|
||
float sampleCosHorizon = dot(viewDir, normalize(viewDelta));
|
||
cosHorizons.x += max(0., (sampleCosHorizon - cosHorizons.x) * mix(1., 2. / float(j + 2), distanceFallOff));
|
||
}
|
||
|
||
sampleSceneUvDepth = getSceneUvAndDepth(viewPos - sampleViewOffset);
|
||
sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);
|
||
viewDelta = sampleSceneViewPos - viewPos;
|
||
if (abs(viewDelta.z) < thickness) {
|
||
float sampleCosHorizon = dot(viewDir, normalize(viewDelta));
|
||
cosHorizons.y += max(0., (sampleCosHorizon - cosHorizons.y) * mix(1., 2. / float(j + 2), distanceFallOff));
|
||
}
|
||
}
|
||
|
||
vec2 sinHorizons = sqrt(1. - cosHorizons * cosHorizons);
|
||
float nx = dot(normalInSlice, sliceTangent);
|
||
float ny = dot(normalInSlice, viewDir);
|
||
float nxb = 1. / 2. * (acos(cosHorizons.y) - acos(cosHorizons.x) + sinHorizons.x * cosHorizons.x - sinHorizons.y * cosHorizons.y);
|
||
float nyb = 1. / 2. * (2. - cosHorizons.x * cosHorizons.x - cosHorizons.y * cosHorizons.y);
|
||
float occlusion = nx * nxb + ny * nyb;
|
||
ao += occlusion;
|
||
}
|
||
|
||
ao = clamp(ao / float(DIRECTIONS), 0., 1.);
|
||
#if SCENE_CLIP_BOX == 1
|
||
ao = mix(ao, 1., smoothstep(0., radiusToUse, boxDistance));
|
||
#endif
|
||
ao = pow(ao, scale);
|
||
|
||
gl_FragColor = FRAGMENT_OUTPUT;
|
||
}`},Op={defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:`
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,fragmentShader:`
|
||
uniform sampler2D tDepth;
|
||
uniform float cameraNear;
|
||
uniform float cameraFar;
|
||
varying vec2 vUv;
|
||
|
||
#include <packing>
|
||
|
||
float getLinearDepth( const in vec2 screenPosition ) {
|
||
#if PERSPECTIVE_CAMERA == 1
|
||
float fragCoordZ = texture2D( tDepth, screenPosition ).x;
|
||
float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );
|
||
return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );
|
||
#else
|
||
return texture2D( tDepth, screenPosition ).x;
|
||
#endif
|
||
}
|
||
|
||
void main() {
|
||
float depth = getLinearDepth( vUv );
|
||
gl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );
|
||
|
||
}`},N0={uniforms:{tDiffuse:{value:null},intensity:{value:1}},vertexShader:`
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,fragmentShader:`
|
||
uniform float intensity;
|
||
uniform sampler2D tDiffuse;
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
vec4 texel = texture2D( tDiffuse, vUv );
|
||
gl_FragColor = vec4(mix(vec3(1.), texel.rgb, intensity), texel.a);
|
||
}`};function r8(r=5){const e=Math.floor(r)%2===0?Math.floor(r)+1:Math.floor(r),t=a8(e),i=t.length,n=new Uint8Array(i*4);for(let a=0;a<i;++a){const o=t[a],l=2*Math.PI*o/i,c=new T(Math.cos(l),Math.sin(l),0).normalize();n[a*4]=(c.x*.5+.5)*255,n[a*4+1]=(c.y*.5+.5)*255,n[a*4+2]=127,n[a*4+3]=255}const s=new dn(n,e,e);return s.wrapS=Ji,s.wrapT=Ji,s.needsUpdate=!0,s}function a8(r){const e=Math.floor(r)%2===0?Math.floor(r)+1:Math.floor(r),t=e*e,i=Array(t).fill(0);let n=Math.floor(e/2),s=e-1;for(let a=1;a<=t;){if(n===-1&&s===e?(s=e-2,n=0):(s===e&&(s=0),n<0&&(n=e-1)),i[n*e+s]!==0){s-=2,n++;continue}else i[n*e+s]=a++;s++,n--}return i}const zp={defines:{SAMPLES:16,SAMPLE_VECTORS:Ax(16,2,1),NORMAL_VECTOR_TYPE:1,DEPTH_VALUE_SOURCE:0},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new be},cameraProjectionMatrixInverse:{value:new Ke},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:4},index:{value:0}},vertexShader:`
|
||
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,fragmentShader:`
|
||
|
||
varying vec2 vUv;
|
||
|
||
uniform sampler2D tDiffuse;
|
||
uniform sampler2D tNormal;
|
||
uniform sampler2D tDepth;
|
||
uniform sampler2D tNoise;
|
||
uniform vec2 resolution;
|
||
uniform mat4 cameraProjectionMatrixInverse;
|
||
uniform float lumaPhi;
|
||
uniform float depthPhi;
|
||
uniform float normalPhi;
|
||
uniform float radius;
|
||
uniform int index;
|
||
|
||
#include <common>
|
||
#include <packing>
|
||
|
||
#ifndef SAMPLE_LUMINANCE
|
||
#define SAMPLE_LUMINANCE dot(vec3(0.2125, 0.7154, 0.0721), a)
|
||
#endif
|
||
|
||
#ifndef FRAGMENT_OUTPUT
|
||
#define FRAGMENT_OUTPUT vec4(denoised, 1.)
|
||
#endif
|
||
|
||
float getLuminance(const in vec3 a) {
|
||
return SAMPLE_LUMINANCE;
|
||
}
|
||
|
||
const vec3 poissonDisk[SAMPLES] = SAMPLE_VECTORS;
|
||
|
||
vec3 getViewPosition( const in vec2 screenPosition, const in float depth ) {
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
vec4 clipSpacePosition = vec4( vec2( screenPosition ) * 2.0 - 1.0, depth, 1.0 );
|
||
#else
|
||
vec4 clipSpacePosition = vec4( vec3( screenPosition, depth ) * 2.0 - 1.0, 1.0 );
|
||
#endif
|
||
vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;
|
||
return viewSpacePosition.xyz / viewSpacePosition.w;
|
||
}
|
||
|
||
float getDepth(const vec2 uv) {
|
||
#if DEPTH_VALUE_SOURCE == 1
|
||
return textureLod(tDepth, uv.xy, 0.0).a;
|
||
#else
|
||
return textureLod(tDepth, uv.xy, 0.0).r;
|
||
#endif
|
||
}
|
||
|
||
float fetchDepth(const ivec2 uv) {
|
||
#if DEPTH_VALUE_SOURCE == 1
|
||
return texelFetch(tDepth, uv.xy, 0).a;
|
||
#else
|
||
return texelFetch(tDepth, uv.xy, 0).r;
|
||
#endif
|
||
}
|
||
|
||
vec3 computeNormalFromDepth(const vec2 uv) {
|
||
vec2 size = vec2(textureSize(tDepth, 0));
|
||
ivec2 p = ivec2(uv * size);
|
||
float c0 = fetchDepth(p);
|
||
float l2 = fetchDepth(p - ivec2(2, 0));
|
||
float l1 = fetchDepth(p - ivec2(1, 0));
|
||
float r1 = fetchDepth(p + ivec2(1, 0));
|
||
float r2 = fetchDepth(p + ivec2(2, 0));
|
||
float b2 = fetchDepth(p - ivec2(0, 2));
|
||
float b1 = fetchDepth(p - ivec2(0, 1));
|
||
float t1 = fetchDepth(p + ivec2(0, 1));
|
||
float t2 = fetchDepth(p + ivec2(0, 2));
|
||
float dl = abs((2.0 * l1 - l2) - c0);
|
||
float dr = abs((2.0 * r1 - r2) - c0);
|
||
float db = abs((2.0 * b1 - b2) - c0);
|
||
float dt = abs((2.0 * t1 - t2) - c0);
|
||
vec3 ce = getViewPosition(uv, c0).xyz;
|
||
vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz
|
||
: -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;
|
||
vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz
|
||
: -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;
|
||
return normalize(cross(dpdx, dpdy));
|
||
}
|
||
|
||
vec3 getViewNormal(const vec2 uv) {
|
||
#if NORMAL_VECTOR_TYPE == 2
|
||
return normalize(textureLod(tNormal, uv, 0.).rgb);
|
||
#elif NORMAL_VECTOR_TYPE == 1
|
||
return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);
|
||
#else
|
||
return computeNormalFromDepth(uv);
|
||
#endif
|
||
}
|
||
|
||
void denoiseSample(in vec3 center, in vec3 viewNormal, in vec3 viewPos, in vec2 sampleUv, inout vec3 denoised, inout float totalWeight) {
|
||
vec4 sampleTexel = textureLod(tDiffuse, sampleUv, 0.0);
|
||
float sampleDepth = getDepth(sampleUv);
|
||
vec3 sampleNormal = getViewNormal(sampleUv);
|
||
vec3 neighborColor = sampleTexel.rgb;
|
||
vec3 viewPosSample = getViewPosition(sampleUv, sampleDepth);
|
||
|
||
float normalDiff = dot(viewNormal, sampleNormal);
|
||
float normalSimilarity = pow(max(normalDiff, 0.), normalPhi);
|
||
float lumaDiff = abs(getLuminance(neighborColor) - getLuminance(center));
|
||
float lumaSimilarity = max(1.0 - lumaDiff / lumaPhi, 0.0);
|
||
float depthDiff = abs(dot(viewPos - viewPosSample, viewNormal));
|
||
float depthSimilarity = max(1. - depthDiff / depthPhi, 0.);
|
||
float w = lumaSimilarity * depthSimilarity * normalSimilarity;
|
||
|
||
denoised += w * neighborColor;
|
||
totalWeight += w;
|
||
}
|
||
|
||
void main() {
|
||
float depth = getDepth(vUv.xy);
|
||
vec3 viewNormal = getViewNormal(vUv);
|
||
if (depth == 1. || dot(viewNormal, viewNormal) == 0.) {
|
||
discard;
|
||
return;
|
||
}
|
||
vec4 texel = textureLod(tDiffuse, vUv, 0.0);
|
||
vec3 center = texel.rgb;
|
||
vec3 viewPos = getViewPosition(vUv, depth);
|
||
|
||
vec2 noiseResolution = vec2(textureSize(tNoise, 0));
|
||
vec2 noiseUv = vUv * resolution / noiseResolution;
|
||
vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);
|
||
vec2 noiseVec = vec2(sin(noiseTexel[index % 4] * 2. * PI), cos(noiseTexel[index % 4] * 2. * PI));
|
||
mat2 rotationMatrix = mat2(noiseVec.x, -noiseVec.y, noiseVec.x, noiseVec.y);
|
||
|
||
float totalWeight = 1.0;
|
||
vec3 denoised = texel.rgb;
|
||
for (int i = 0; i < SAMPLES; i++) {
|
||
vec3 sampleDir = poissonDisk[i];
|
||
vec2 offset = rotationMatrix * (sampleDir.xy * (1. + sampleDir.z * (radius - 1.)) / resolution);
|
||
vec2 sampleUv = vUv + offset;
|
||
denoiseSample(center, viewNormal, viewPos, sampleUv, denoised, totalWeight);
|
||
}
|
||
|
||
if (totalWeight > 0.) {
|
||
denoised /= totalWeight;
|
||
}
|
||
gl_FragColor = FRAGMENT_OUTPUT;
|
||
}`};function Ax(r,e,t){const i=o8(r,e,t);let n="vec3[SAMPLES](";for(let s=0;s<r;s++){const a=i[s];n+=`vec3(${a.x}, ${a.y}, ${a.z})${s<r-1?",":")"}`}return n}function o8(r,e,t){const i=[];for(let n=0;n<r;n++){const s=2*Math.PI*e*n/r,a=Math.pow(n/(r-1),t);i.push(new T(Math.cos(s),Math.sin(s),a))}return i}class vx{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(e.random()*256);this.perm=[];for(let t=0;t<512;t++)this.perm[t]=this.p[t&255];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}noise(e,t){let i,n,s;const a=.5*(Math.sqrt(3)-1),o=(e+t)*a,l=Math.floor(e+o),c=Math.floor(t+o),h=(3-Math.sqrt(3))/6,d=(l+c)*h,p=l-d,u=c-d,A=e-p,m=t-u;let g,f;A>m?(g=1,f=0):(g=0,f=1);const v=A-g+h,b=m-f+h,y=A-1+2*h,M=m-1+2*h,_=l&255,S=c&255,w=this.perm[_+this.perm[S]]%12,E=this.perm[_+g+this.perm[S+f]]%12,I=this.perm[_+1+this.perm[S+1]]%12;let B=.5-A*A-m*m;B<0?i=0:(B*=B,i=B*B*this._dot(this.grad3[w],A,m));let R=.5-v*v-b*b;R<0?n=0:(R*=R,n=R*R*this._dot(this.grad3[E],v,b));let U=.5-y*y-M*M;return U<0?s=0:(U*=U,s=U*U*this._dot(this.grad3[I],y,M)),70*(i+n+s)}noise3d(e,t,i){let n,s,a,o;const l=(e+t+i)*.3333333333333333,c=Math.floor(e+l),h=Math.floor(t+l),d=Math.floor(i+l),p=1/6,u=(c+h+d)*p,A=c-u,m=h-u,g=d-u,f=e-A,v=t-m,b=i-g;let y,M,_,S,w,E;f>=v?v>=b?(y=1,M=0,_=0,S=1,w=1,E=0):f>=b?(y=1,M=0,_=0,S=1,w=0,E=1):(y=0,M=0,_=1,S=1,w=0,E=1):v<b?(y=0,M=0,_=1,S=0,w=1,E=1):f<b?(y=0,M=1,_=0,S=0,w=1,E=1):(y=0,M=1,_=0,S=1,w=1,E=0);const I=f-y+p,B=v-M+p,R=b-_+p,U=f-S+2*p,C=v-w+2*p,F=b-E+2*p,O=f-1+3*p,H=v-1+3*p,j=b-1+3*p,G=c&255,re=h&255,q=d&255,Y=this.perm[G+this.perm[re+this.perm[q]]]%12,ye=this.perm[G+y+this.perm[re+M+this.perm[q+_]]]%12,Me=this.perm[G+S+this.perm[re+w+this.perm[q+E]]]%12,xe=this.perm[G+1+this.perm[re+1+this.perm[q+1]]]%12;let J=.6-f*f-v*v-b*b;J<0?n=0:(J*=J,n=J*J*this._dot3(this.grad3[Y],f,v,b));let oe=.6-I*I-B*B-R*R;oe<0?s=0:(oe*=oe,s=oe*oe*this._dot3(this.grad3[ye],I,B,R));let ue=.6-U*U-C*C-F*F;ue<0?a=0:(ue*=ue,a=ue*ue*this._dot3(this.grad3[Me],U,C,F));let Pe=.6-O*O-H*H-j*j;return Pe<0?o=0:(Pe*=Pe,o=Pe*Pe*this._dot3(this.grad3[xe],O,H,j)),32*(n+s+a+o)}noise4d(e,t,i,n){const s=this.grad4,a=this.simplex,o=this.perm,l=(Math.sqrt(5)-1)/4,c=(5-Math.sqrt(5))/20;let h,d,p,u,A;const m=(e+t+i+n)*l,g=Math.floor(e+m),f=Math.floor(t+m),v=Math.floor(i+m),b=Math.floor(n+m),y=(g+f+v+b)*c,M=g-y,_=f-y,S=v-y,w=b-y,E=e-M,I=t-_,B=i-S,R=n-w,U=E>I?32:0,C=E>B?16:0,F=I>B?8:0,O=E>R?4:0,H=I>R?2:0,j=B>R?1:0,G=U+C+F+O+H+j,re=a[G][0]>=3?1:0,q=a[G][1]>=3?1:0,Y=a[G][2]>=3?1:0,ye=a[G][3]>=3?1:0,Me=a[G][0]>=2?1:0,xe=a[G][1]>=2?1:0,J=a[G][2]>=2?1:0,oe=a[G][3]>=2?1:0,ue=a[G][0]>=1?1:0,Pe=a[G][1]>=1?1:0,Be=a[G][2]>=1?1:0,Ue=a[G][3]>=1?1:0,it=E-re+c,qe=I-q+c,D=B-Y+c,ae=R-ye+c,$=E-Me+2*c,Q=I-xe+2*c,L=B-J+2*c,te=R-oe+2*c,de=E-ue+3*c,V=I-Pe+3*c,ee=B-Be+3*c,P=R-Ue+3*c,x=E-1+4*c,N=I-1+4*c,X=B-1+4*c,Z=R-1+4*c,K=g&255,Ie=f&255,ge=v&255,ke=b&255,Oe=o[K+o[Ie+o[ge+o[ke]]]]%32,le=o[K+re+o[Ie+q+o[ge+Y+o[ke+ye]]]]%32,Ae=o[K+Me+o[Ie+xe+o[ge+J+o[ke+oe]]]]%32,ze=o[K+ue+o[Ie+Pe+o[ge+Be+o[ke+Ue]]]]%32,Ne=o[K+1+o[Ie+1+o[ge+1+o[ke+1]]]]%32;let we=.6-E*E-I*I-B*B-R*R;we<0?h=0:(we*=we,h=we*we*this._dot4(s[Oe],E,I,B,R));let je=.6-it*it-qe*qe-D*D-ae*ae;je<0?d=0:(je*=je,d=je*je*this._dot4(s[le],it,qe,D,ae));let z=.6-$*$-Q*Q-L*L-te*te;z<0?p=0:(z*=z,p=z*z*this._dot4(s[Ae],$,Q,L,te));let ve=.6-de*de-V*V-ee*ee-P*P;ve<0?u=0:(ve*=ve,u=ve*ve*this._dot4(s[ze],de,V,ee,P));let me=.6-x*x-N*N-X*X-Z*Z;return me<0?A=0:(me*=me,A=me*me*this._dot4(s[Ne],x,N,X,Z)),27*(h+d+p+u+A)}_dot(e,t,i){return e[0]*t+e[1]*i}_dot3(e,t,i,n){return e[0]*t+e[1]*i+e[2]*n}_dot4(e,t,i,n,s){return e[0]*t+e[1]*i+e[2]*n+e[3]*s}}class ms extends no{constructor(e,t,i=512,n=512,s,a,o){super(),this.width=i,this.height=n,this.clear=!0,this.camera=t,this.scene=e,this.output=0,this._renderGBuffer=!0,this._visibilityCache=[],this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=r8(),this.pdNoiseTexture=this._generateNoise(),this.gtaoRenderTarget=new Ei(this.width,this.height,{type:Zt}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new ei({defines:Object.assign({},Fp.defines),uniforms:nn.clone(Fp.uniforms),vertexShader:Fp.vertexShader,fragmentShader:Fp.fragmentShader,blending:ti,depthTest:!1,depthWrite:!1}),this.gtaoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.gtaoMaterial.uniforms.tNoise.value=this.gtaoNoiseTexture,this.gtaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.normalMaterial=new ku,this.normalMaterial.blending=ti,this.pdMaterial=new ei({defines:Object.assign({},zp.defines),uniforms:nn.clone(zp.uniforms),vertexShader:zp.vertexShader,fragmentShader:zp.fragmentShader,depthTest:!1,depthWrite:!1}),this.pdMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.pdMaterial.uniforms.tNoise.value=this.pdNoiseTexture,this.pdMaterial.uniforms.resolution.value.set(this.width,this.height),this.pdMaterial.uniforms.lumaPhi.value=10,this.pdMaterial.uniforms.depthPhi.value=2,this.pdMaterial.uniforms.normalPhi.value=3,this.pdMaterial.uniforms.radius.value=8,this.depthRenderMaterial=new ei({defines:Object.assign({},Op.defines),uniforms:nn.clone(Op.uniforms),vertexShader:Op.vertexShader,fragmentShader:Op.fragmentShader,blending:ti}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new ei({uniforms:nn.clone(io.uniforms),vertexShader:io.vertexShader,fragmentShader:io.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:Yl,blendDst:mr,blendEquation:gn,blendSrcAlpha:Xl,blendDstAlpha:mr,blendEquationAlpha:gn}),this.blendMaterial=new ei({uniforms:nn.clone(N0.uniforms),vertexShader:N0.vertexShader,fragmentShader:N0.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:Qh,blendSrc:Yl,blendDst:mr,blendEquation:gn,blendSrcAlpha:Xl,blendDstAlpha:mr,blendEquationAlpha:gn}),this._fsQuad=new Np(null),this._originalClearColor=new We,this.setGBuffer(s?s.depthTexture:void 0,s?s.normalTexture:void 0),a!==void 0&&this.updateGtaoMaterial(a),o!==void 0&&this.updatePdMaterial(o)}setSize(e,t){this.width=e,this.height=t,this.gtaoRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.pdRenderTarget.setSize(e,t),this.gtaoMaterial.uniforms.resolution.value.set(e,t),this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.pdMaterial.uniforms.resolution.value.set(e,t),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse)}dispose(){this.gtaoNoiseTexture.dispose(),this.pdNoiseTexture.dispose(),this.normalRenderTarget.dispose(),this.gtaoRenderTarget.dispose(),this.pdRenderTarget.dispose(),this.normalMaterial.dispose(),this.pdMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this._fsQuad.dispose()}get gtaoMap(){return this.pdRenderTarget.texture}setGBuffer(e,t){e!==void 0?(this.depthTexture=e,this.normalTexture=t,this._renderGBuffer=!1):(this.depthTexture=new Rr,this.depthTexture.format=_s,this.depthTexture.type=Ar,this.normalRenderTarget=new Ei(this.width,this.height,{minFilter:Ht,magFilter:Ht,type:Zt,depthTexture:this.depthTexture}),this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0);const i=this.normalTexture?1:0,n=this.depthTexture===this.normalTexture?"w":"x";this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=i,this.gtaoMaterial.defines.DEPTH_SWIZZLING=n,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=i,this.pdMaterial.defines.DEPTH_SWIZZLING=n,this.pdMaterial.uniforms.tNormal.value=this.normalTexture,this.pdMaterial.uniforms.tDepth.value=this.depthTexture,this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture}setSceneClipBox(e){e?(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX!==1,this.gtaoMaterial.defines.SCENE_CLIP_BOX=1,this.gtaoMaterial.uniforms.sceneBoxMin.value.copy(e.min),this.gtaoMaterial.uniforms.sceneBoxMax.value.copy(e.max)):(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX===0,this.gtaoMaterial.defines.SCENE_CLIP_BOX=0)}updateGtaoMaterial(e){e.radius!==void 0&&(this.gtaoMaterial.uniforms.radius.value=e.radius),e.distanceExponent!==void 0&&(this.gtaoMaterial.uniforms.distanceExponent.value=e.distanceExponent),e.thickness!==void 0&&(this.gtaoMaterial.uniforms.thickness.value=e.thickness),e.distanceFallOff!==void 0&&(this.gtaoMaterial.uniforms.distanceFallOff.value=e.distanceFallOff,this.gtaoMaterial.needsUpdate=!0),e.scale!==void 0&&(this.gtaoMaterial.uniforms.scale.value=e.scale),e.samples!==void 0&&e.samples!==this.gtaoMaterial.defines.SAMPLES&&(this.gtaoMaterial.defines.SAMPLES=e.samples,this.gtaoMaterial.needsUpdate=!0),e.screenSpaceRadius!==void 0&&(e.screenSpaceRadius?1:0)!==this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS&&(this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS=e.screenSpaceRadius?1:0,this.gtaoMaterial.needsUpdate=!0)}updatePdMaterial(e){let t=!1;e.lumaPhi!==void 0&&(this.pdMaterial.uniforms.lumaPhi.value=e.lumaPhi),e.depthPhi!==void 0&&(this.pdMaterial.uniforms.depthPhi.value=e.depthPhi),e.normalPhi!==void 0&&(this.pdMaterial.uniforms.normalPhi.value=e.normalPhi),e.radius!==void 0&&e.radius!==this.radius&&(this.pdMaterial.uniforms.radius.value=e.radius),e.radiusExponent!==void 0&&e.radiusExponent!==this.pdRadiusExponent&&(this.pdRadiusExponent=e.radiusExponent,t=!0),e.rings!==void 0&&e.rings!==this.pdRings&&(this.pdRings=e.rings,t=!0),e.samples!==void 0&&e.samples!==this.pdSamples&&(this.pdSamples=e.samples,t=!0),t&&(this.pdMaterial.defines.SAMPLES=this.pdSamples,this.pdMaterial.defines.SAMPLE_VECTORS=Ax(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(e,t,i){switch(this._renderGBuffer&&(this._overrideVisibility(),this._renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this._restoreVisibility()),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld),this._renderPass(e,this.gtaoMaterial,this.gtaoRenderTarget,16777215,1),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this._renderPass(e,this.pdMaterial,this.pdRenderTarget,16777215,1),this.output){case ms.OUTPUT.Off:break;case ms.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=i.texture,this.copyMaterial.blending=ti,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case ms.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=ti,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case ms.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=ti,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case ms.OUTPUT.Depth:this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this._renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:t);break;case ms.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=ti,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case ms.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=i.texture,this.copyMaterial.blending=ti,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this._renderPass(e,this.blendMaterial,this.renderToScreen?null:t);break;default:console.warn("THREE.GTAOPass: Unknown output type.")}}_renderPass(e,t,i,n,s){e.getClearColor(this._originalClearColor);const a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(i),e.autoClear=!1,n!=null&&(e.setClearColor(n),e.setClearAlpha(s||0),e.clear()),this._fsQuad.material=t,this._fsQuad.render(e),e.autoClear=o,e.setClearColor(this._originalClearColor),e.setClearAlpha(a)}_renderOverride(e,t,i,n,s){e.getClearColor(this._originalClearColor);const a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(i),e.autoClear=!1,n=t.clearColor||n,s=t.clearAlpha||s,n!=null&&(e.setClearColor(n),e.setClearAlpha(s||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=o,e.setClearColor(this._originalClearColor),e.setClearAlpha(a)}_overrideVisibility(){const e=this.scene,t=this._visibilityCache;e.traverse(function(i){(i.isPoints||i.isLine||i.isLine2)&&i.visible&&(i.visible=!1,t.push(i))})}_restoreVisibility(){const e=this._visibilityCache;for(let t=0;t<e.length;t++)e[t].visible=!0;e.length=0}_generateNoise(e=64){const t=new vx,i=e*e*4,n=new Uint8Array(i);for(let a=0;a<e;a++)for(let o=0;o<e;o++){const l=a,c=o;n[(a*e+o)*4]=(t.noise(l,c)*.5+.5)*255,n[(a*e+o)*4+1]=(t.noise(l+e,c)*.5+.5)*255,n[(a*e+o)*4+2]=(t.noise(l,c+e)*.5+.5)*255,n[(a*e+o)*4+3]=(t.noise(l+e,c+e)*.5+.5)*255}const s=new dn(n,e,e,hi,ut);return s.wrapS=Ji,s.wrapT=Ji,s.needsUpdate=!0,s}}ms.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};const Hp={defines:{PERSPECTIVE_CAMERA:1,KERNEL_SIZE:32},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},kernel:{value:null},cameraNear:{value:null},cameraFar:{value:null},resolution:{value:new be},cameraProjectionMatrix:{value:new Ke},cameraInverseProjectionMatrix:{value:new Ke},kernelRadius:{value:8},minDistance:{value:.005},maxDistance:{value:.05}},vertexShader:`
|
||
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
|
||
vUv = uv;
|
||
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
|
||
}`,fragmentShader:`
|
||
uniform highp sampler2D tNormal;
|
||
uniform highp sampler2D tDepth;
|
||
uniform sampler2D tNoise;
|
||
|
||
uniform vec3 kernel[ KERNEL_SIZE ];
|
||
|
||
uniform vec2 resolution;
|
||
|
||
uniform float cameraNear;
|
||
uniform float cameraFar;
|
||
uniform mat4 cameraProjectionMatrix;
|
||
uniform mat4 cameraInverseProjectionMatrix;
|
||
|
||
uniform float kernelRadius;
|
||
uniform float minDistance; // avoid artifacts caused by neighbour fragments with minimal depth difference
|
||
uniform float maxDistance; // avoid the influence of fragments which are too far away
|
||
|
||
varying vec2 vUv;
|
||
|
||
#include <packing>
|
||
|
||
#ifdef USE_REVERSED_DEPTH_BUFFER
|
||
|
||
const float depthThreshold = 0.0;
|
||
|
||
#else
|
||
|
||
const float depthThreshold = 1.0;
|
||
|
||
#endif
|
||
|
||
float getDepth( const in vec2 screenPosition ) {
|
||
|
||
return texture2D( tDepth, screenPosition ).x;
|
||
|
||
}
|
||
|
||
float getLinearDepth( const in vec2 screenPosition ) {
|
||
|
||
#if PERSPECTIVE_CAMERA == 1
|
||
|
||
float fragCoordZ = texture2D( tDepth, screenPosition ).x;
|
||
float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );
|
||
return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );
|
||
|
||
#else
|
||
|
||
return texture2D( tDepth, screenPosition ).x;
|
||
|
||
#endif
|
||
|
||
}
|
||
|
||
float getViewZ( const in float depth ) {
|
||
|
||
#if PERSPECTIVE_CAMERA == 1
|
||
|
||
return perspectiveDepthToViewZ( depth, cameraNear, cameraFar );
|
||
|
||
#else
|
||
|
||
return orthographicDepthToViewZ( depth, cameraNear, cameraFar );
|
||
|
||
#endif
|
||
|
||
}
|
||
|
||
vec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {
|
||
|
||
float clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];
|
||
|
||
vec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );
|
||
|
||
clipPosition *= clipW; // unprojection.
|
||
|
||
return ( cameraInverseProjectionMatrix * clipPosition ).xyz;
|
||
|
||
}
|
||
|
||
vec3 getViewNormal( const in vec2 screenPosition ) {
|
||
|
||
return unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );
|
||
|
||
}
|
||
|
||
void main() {
|
||
|
||
float depth = getDepth( vUv );
|
||
|
||
if ( depth == depthThreshold ) {
|
||
|
||
gl_FragColor = vec4( 1.0 ); // don't influence background
|
||
|
||
} else {
|
||
|
||
float viewZ = getViewZ( depth );
|
||
|
||
vec3 viewPosition = getViewPosition( vUv, depth, viewZ );
|
||
vec3 viewNormal = getViewNormal( vUv );
|
||
|
||
vec2 noiseScale = vec2( resolution.x / 4.0, resolution.y / 4.0 );
|
||
vec3 random = vec3( texture2D( tNoise, vUv * noiseScale ).r );
|
||
|
||
// compute matrix used to reorient a kernel vector
|
||
|
||
vec3 tangent = normalize( random - viewNormal * dot( random, viewNormal ) );
|
||
vec3 bitangent = cross( viewNormal, tangent );
|
||
mat3 kernelMatrix = mat3( tangent, bitangent, viewNormal );
|
||
|
||
float occlusion = 0.0;
|
||
|
||
for ( int i = 0; i < KERNEL_SIZE; i ++ ) {
|
||
|
||
vec3 sampleVector = kernelMatrix * kernel[ i ]; // reorient sample vector in view space
|
||
vec3 samplePoint = viewPosition + ( sampleVector * kernelRadius ); // calculate sample point
|
||
|
||
vec4 samplePointNDC = cameraProjectionMatrix * vec4( samplePoint, 1.0 ); // project point and calculate NDC
|
||
samplePointNDC /= samplePointNDC.w;
|
||
|
||
vec2 samplePointUv = samplePointNDC.xy * 0.5 + 0.5; // compute uv coordinates
|
||
|
||
float realDepth = getLinearDepth( samplePointUv ); // get linear depth from depth texture
|
||
float sampleDepth = viewZToOrthographicDepth( samplePoint.z, cameraNear, cameraFar ); // compute linear depth of the sample view Z value
|
||
float delta = sampleDepth - realDepth;
|
||
|
||
if ( delta > minDistance && delta < maxDistance ) { // if fragment is before sample point, increase occlusion
|
||
|
||
occlusion += 1.0;
|
||
|
||
}
|
||
|
||
}
|
||
|
||
occlusion = clamp( occlusion / float( KERNEL_SIZE ), 0.0, 1.0 );
|
||
|
||
gl_FragColor = vec4( vec3( 1.0 - occlusion ), 1.0 );
|
||
|
||
}
|
||
|
||
}`},Gp={defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:`varying vec2 vUv;
|
||
|
||
void main() {
|
||
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
|
||
}`,fragmentShader:`uniform sampler2D tDepth;
|
||
|
||
uniform float cameraNear;
|
||
uniform float cameraFar;
|
||
|
||
varying vec2 vUv;
|
||
|
||
#include <packing>
|
||
|
||
float getLinearDepth( const in vec2 screenPosition ) {
|
||
|
||
#if PERSPECTIVE_CAMERA == 1
|
||
|
||
float fragCoordZ = texture2D( tDepth, screenPosition ).x;
|
||
float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );
|
||
return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );
|
||
|
||
#else
|
||
|
||
return texture2D( tDepth, screenPosition ).x;
|
||
|
||
#endif
|
||
|
||
}
|
||
|
||
void main() {
|
||
|
||
float depth = getLinearDepth( vUv );
|
||
gl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );
|
||
|
||
}`},Vp={uniforms:{tDiffuse:{value:null},resolution:{value:new be}},vertexShader:`varying vec2 vUv;
|
||
|
||
void main() {
|
||
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
|
||
}`,fragmentShader:`uniform sampler2D tDiffuse;
|
||
|
||
uniform vec2 resolution;
|
||
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
|
||
vec2 texelSize = ( 1.0 / resolution );
|
||
float result = 0.0;
|
||
|
||
for ( int i = - 2; i <= 2; i ++ ) {
|
||
|
||
for ( int j = - 2; j <= 2; j ++ ) {
|
||
|
||
vec2 offset = ( vec2( float( i ), float( j ) ) ) * texelSize;
|
||
result += texture2D( tDiffuse, vUv + offset ).r;
|
||
|
||
}
|
||
|
||
}
|
||
|
||
gl_FragColor = vec4( vec3( result / ( 5.0 * 5.0 ) ), 1.0 );
|
||
|
||
}`};class cr extends no{constructor(e,t,i=512,n=512,s=32){super(),this.width=i,this.height=n,this.clear=!0,this.needsSwap=!1,this.camera=t,this.scene=e,this.kernelRadius=8,this.kernel=[],this.noiseTexture=null,this.output=0,this.minDistance=.005,this.maxDistance=.1,this._visibilityCache=[],this._generateSampleKernel(s),this._generateRandomKernelRotations();const a=new Rr;a.format=_s,a.type=Ar,this.normalRenderTarget=new Ei(this.width,this.height,{minFilter:Ht,magFilter:Ht,type:Zt,depthTexture:a}),this.ssaoRenderTarget=new Ei(this.width,this.height,{type:Zt}),this.blurRenderTarget=this.ssaoRenderTarget.clone(),this.ssaoMaterial=new ei({defines:Object.assign({},Hp.defines),uniforms:nn.clone(Hp.uniforms),vertexShader:Hp.vertexShader,fragmentShader:Hp.fragmentShader,blending:ti}),this.ssaoMaterial.defines.KERNEL_SIZE=s,this.ssaoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.ssaoMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture,this.ssaoMaterial.uniforms.tNoise.value=this.noiseTexture,this.ssaoMaterial.uniforms.kernel.value=this.kernel,this.ssaoMaterial.uniforms.cameraNear.value=this.camera.near,this.ssaoMaterial.uniforms.cameraFar.value=this.camera.far,this.ssaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.ssaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssaoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.normalMaterial=new ku,this.normalMaterial.blending=ti,this.blurMaterial=new ei({defines:Object.assign({},Vp.defines),uniforms:nn.clone(Vp.uniforms),vertexShader:Vp.vertexShader,fragmentShader:Vp.fragmentShader}),this.blurMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.depthRenderMaterial=new ei({defines:Object.assign({},Gp.defines),uniforms:nn.clone(Gp.uniforms),vertexShader:Gp.vertexShader,fragmentShader:Gp.fragmentShader,blending:ti}),this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture,this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new ei({uniforms:nn.clone(io.uniforms),vertexShader:io.vertexShader,fragmentShader:io.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:Yl,blendDst:mr,blendEquation:gn,blendSrcAlpha:Xl,blendDstAlpha:mr,blendEquationAlpha:gn}),this._fsQuad=new Np(null),this._originalClearColor=new We}dispose(){this.normalRenderTarget.dispose(),this.ssaoRenderTarget.dispose(),this.blurRenderTarget.dispose(),this.normalMaterial.dispose(),this.blurMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this._fsQuad.dispose()}render(e,t,i){switch(this._overrideVisibility(),this._renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this._restoreVisibility(),this.ssaoMaterial.uniforms.kernelRadius.value=this.kernelRadius,this.ssaoMaterial.uniforms.minDistance.value=this.minDistance,this.ssaoMaterial.uniforms.maxDistance.value=this.maxDistance,this._renderPass(e,this.ssaoMaterial,this.ssaoRenderTarget),this._renderPass(e,this.blurMaterial,this.blurRenderTarget),this.output){case cr.OUTPUT.SSAO:this.copyMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.copyMaterial.blending=ti,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:i);break;case cr.OUTPUT.Blur:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=ti,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:i);break;case cr.OUTPUT.Depth:this._renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:i);break;case cr.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=ti,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:i);break;case cr.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=Qh,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:i);break;default:console.warn("THREE.SSAOPass: Unknown output type.")}}setSize(e,t){this.width=e,this.height=t,this.ssaoRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.blurRenderTarget.setSize(e,t),this.ssaoMaterial.uniforms.resolution.value.set(e,t),this.ssaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssaoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.blurMaterial.uniforms.resolution.value.set(e,t)}_renderPass(e,t,i,n,s){e.getClearColor(this._originalClearColor);const a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(i),e.autoClear=!1,n!=null&&(e.setClearColor(n),e.setClearAlpha(s||0),e.clear()),this._fsQuad.material=t,this._fsQuad.render(e),e.autoClear=o,e.setClearColor(this._originalClearColor),e.setClearAlpha(a)}_renderOverride(e,t,i,n,s){e.getClearColor(this._originalClearColor);const a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(i),e.autoClear=!1,n=t.clearColor||n,s=t.clearAlpha||s,n!=null&&(e.setClearColor(n),e.setClearAlpha(s||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=o,e.setClearColor(this._originalClearColor),e.setClearAlpha(a)}_generateSampleKernel(e){const t=this.kernel;for(let i=0;i<e;i++){const n=new T;n.x=Math.random()*2-1,n.y=Math.random()*2-1,n.z=Math.random(),n.normalize();let s=i/e;s=Dt.lerp(.1,1,s*s),n.multiplyScalar(s),t.push(n)}}_generateRandomKernelRotations(){const e=new vx,t=16,i=new Float32Array(t);for(let n=0;n<t;n++){const s=Math.random()*2-1,a=Math.random()*2-1,o=0;i[n]=e.noise3d(s,a,o)}this.noiseTexture=new dn(i,4,4,Es,oi),this.noiseTexture.wrapS=Ji,this.noiseTexture.wrapT=Ji,this.noiseTexture.needsUpdate=!0}_overrideVisibility(){const e=this.scene,t=this._visibilityCache;e.traverse(function(i){(i.isPoints||i.isLine||i.isLine2)&&i.visible&&(i.visible=!1,t.push(i))})}_restoreVisibility(){const e=this._visibilityCache;for(let t=0;t<e.length;t++)e[t].visible=!0;e.length=0}}cr.OUTPUT={Default:0,SSAO:1,Blur:2,Depth:3,Normal:4};const Qp={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
|
||
precision highp float;
|
||
|
||
uniform mat4 modelViewMatrix;
|
||
uniform mat4 projectionMatrix;
|
||
|
||
attribute vec3 position;
|
||
attribute vec2 uv;
|
||
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
|
||
}`,fragmentShader:`
|
||
|
||
precision highp float;
|
||
|
||
uniform sampler2D tDiffuse;
|
||
|
||
#include <tonemapping_pars_fragment>
|
||
#include <colorspace_pars_fragment>
|
||
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
|
||
gl_FragColor = texture2D( tDiffuse, vUv );
|
||
|
||
// tone mapping
|
||
|
||
#ifdef LINEAR_TONE_MAPPING
|
||
|
||
gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
|
||
|
||
#elif defined( REINHARD_TONE_MAPPING )
|
||
|
||
gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
|
||
|
||
#elif defined( CINEON_TONE_MAPPING )
|
||
|
||
gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
|
||
|
||
#elif defined( ACES_FILMIC_TONE_MAPPING )
|
||
|
||
gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
|
||
|
||
#elif defined( AGX_TONE_MAPPING )
|
||
|
||
gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
|
||
|
||
#elif defined( NEUTRAL_TONE_MAPPING )
|
||
|
||
gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
|
||
|
||
#elif defined( CUSTOM_TONE_MAPPING )
|
||
|
||
gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
|
||
|
||
#endif
|
||
|
||
// color space
|
||
|
||
#ifdef SRGB_TRANSFER
|
||
|
||
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
||
|
||
#endif
|
||
|
||
}`};class l8 extends no{constructor(){super(),this.isOutputPass=!0,this.uniforms=nn.clone(Qp.uniforms),this.material=new Lu({name:Qp.name,uniforms:this.uniforms,vertexShader:Qp.vertexShader,fragmentShader:Qp.fragmentShader}),this._fsQuad=new Np(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,i){this.uniforms.tDiffuse.value=i.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},Et.getTransfer(this._outputColorSpace)===Ut&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===ed?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===td?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===id?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===ra?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===sd?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===rd?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===nd&&(this.material.defines.CUSTOM_TONE_MAPPING=""),this.material.needsUpdate=!0),this.renderToScreen===!0?(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()}}const c8={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new be(1/1024,1/512)}},vertexShader:`
|
||
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
|
||
}`,fragmentShader:`
|
||
|
||
uniform sampler2D tDiffuse;
|
||
uniform vec2 resolution;
|
||
varying vec2 vUv;
|
||
|
||
#define EDGE_STEP_COUNT 6
|
||
#define EDGE_GUESS 8.0
|
||
#define EDGE_STEPS 1.0, 1.5, 2.0, 2.0, 2.0, 4.0
|
||
const float edgeSteps[EDGE_STEP_COUNT] = float[EDGE_STEP_COUNT]( EDGE_STEPS );
|
||
|
||
float _ContrastThreshold = 0.0312;
|
||
float _RelativeThreshold = 0.063;
|
||
float _SubpixelBlending = 1.0;
|
||
|
||
vec4 Sample( sampler2D tex2D, vec2 uv ) {
|
||
|
||
return texture( tex2D, uv );
|
||
|
||
}
|
||
|
||
float SampleLuminance( sampler2D tex2D, vec2 uv ) {
|
||
|
||
return dot( Sample( tex2D, uv ).rgb, vec3( 0.3, 0.59, 0.11 ) );
|
||
|
||
}
|
||
|
||
float SampleLuminance( sampler2D tex2D, vec2 texSize, vec2 uv, float uOffset, float vOffset ) {
|
||
|
||
uv += texSize * vec2(uOffset, vOffset);
|
||
return SampleLuminance(tex2D, uv);
|
||
|
||
}
|
||
|
||
struct LuminanceData {
|
||
|
||
float m, n, e, s, w;
|
||
float ne, nw, se, sw;
|
||
float highest, lowest, contrast;
|
||
|
||
};
|
||
|
||
LuminanceData SampleLuminanceNeighborhood( sampler2D tex2D, vec2 texSize, vec2 uv ) {
|
||
|
||
LuminanceData l;
|
||
l.m = SampleLuminance( tex2D, uv );
|
||
l.n = SampleLuminance( tex2D, texSize, uv, 0.0, 1.0 );
|
||
l.e = SampleLuminance( tex2D, texSize, uv, 1.0, 0.0 );
|
||
l.s = SampleLuminance( tex2D, texSize, uv, 0.0, -1.0 );
|
||
l.w = SampleLuminance( tex2D, texSize, uv, -1.0, 0.0 );
|
||
|
||
l.ne = SampleLuminance( tex2D, texSize, uv, 1.0, 1.0 );
|
||
l.nw = SampleLuminance( tex2D, texSize, uv, -1.0, 1.0 );
|
||
l.se = SampleLuminance( tex2D, texSize, uv, 1.0, -1.0 );
|
||
l.sw = SampleLuminance( tex2D, texSize, uv, -1.0, -1.0 );
|
||
|
||
l.highest = max( max( max( max( l.n, l.e ), l.s ), l.w ), l.m );
|
||
l.lowest = min( min( min( min( l.n, l.e ), l.s ), l.w ), l.m );
|
||
l.contrast = l.highest - l.lowest;
|
||
return l;
|
||
|
||
}
|
||
|
||
bool ShouldSkipPixel( LuminanceData l ) {
|
||
|
||
float threshold = max( _ContrastThreshold, _RelativeThreshold * l.highest );
|
||
return l.contrast < threshold;
|
||
|
||
}
|
||
|
||
float DeterminePixelBlendFactor( LuminanceData l ) {
|
||
|
||
float f = 2.0 * ( l.n + l.e + l.s + l.w );
|
||
f += l.ne + l.nw + l.se + l.sw;
|
||
f *= 1.0 / 12.0;
|
||
f = abs( f - l.m );
|
||
f = clamp( f / l.contrast, 0.0, 1.0 );
|
||
|
||
float blendFactor = smoothstep( 0.0, 1.0, f );
|
||
return blendFactor * blendFactor * _SubpixelBlending;
|
||
|
||
}
|
||
|
||
struct EdgeData {
|
||
|
||
bool isHorizontal;
|
||
float pixelStep;
|
||
float oppositeLuminance, gradient;
|
||
|
||
};
|
||
|
||
EdgeData DetermineEdge( vec2 texSize, LuminanceData l ) {
|
||
|
||
EdgeData e;
|
||
float horizontal =
|
||
abs( l.n + l.s - 2.0 * l.m ) * 2.0 +
|
||
abs( l.ne + l.se - 2.0 * l.e ) +
|
||
abs( l.nw + l.sw - 2.0 * l.w );
|
||
float vertical =
|
||
abs( l.e + l.w - 2.0 * l.m ) * 2.0 +
|
||
abs( l.ne + l.nw - 2.0 * l.n ) +
|
||
abs( l.se + l.sw - 2.0 * l.s );
|
||
e.isHorizontal = horizontal >= vertical;
|
||
|
||
float pLuminance = e.isHorizontal ? l.n : l.e;
|
||
float nLuminance = e.isHorizontal ? l.s : l.w;
|
||
float pGradient = abs( pLuminance - l.m );
|
||
float nGradient = abs( nLuminance - l.m );
|
||
|
||
e.pixelStep = e.isHorizontal ? texSize.y : texSize.x;
|
||
|
||
if (pGradient < nGradient) {
|
||
|
||
e.pixelStep = -e.pixelStep;
|
||
e.oppositeLuminance = nLuminance;
|
||
e.gradient = nGradient;
|
||
|
||
} else {
|
||
|
||
e.oppositeLuminance = pLuminance;
|
||
e.gradient = pGradient;
|
||
|
||
}
|
||
|
||
return e;
|
||
|
||
}
|
||
|
||
float DetermineEdgeBlendFactor( sampler2D tex2D, vec2 texSize, LuminanceData l, EdgeData e, vec2 uv ) {
|
||
|
||
vec2 uvEdge = uv;
|
||
vec2 edgeStep;
|
||
if (e.isHorizontal) {
|
||
|
||
uvEdge.y += e.pixelStep * 0.5;
|
||
edgeStep = vec2( texSize.x, 0.0 );
|
||
|
||
} else {
|
||
|
||
uvEdge.x += e.pixelStep * 0.5;
|
||
edgeStep = vec2( 0.0, texSize.y );
|
||
|
||
}
|
||
|
||
float edgeLuminance = ( l.m + e.oppositeLuminance ) * 0.5;
|
||
float gradientThreshold = e.gradient * 0.25;
|
||
|
||
vec2 puv = uvEdge + edgeStep * edgeSteps[0];
|
||
float pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;
|
||
bool pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;
|
||
|
||
for ( int i = 1; i < EDGE_STEP_COUNT && !pAtEnd; i++ ) {
|
||
|
||
puv += edgeStep * edgeSteps[i];
|
||
pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;
|
||
pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;
|
||
|
||
}
|
||
|
||
if ( !pAtEnd ) {
|
||
|
||
puv += edgeStep * EDGE_GUESS;
|
||
|
||
}
|
||
|
||
vec2 nuv = uvEdge - edgeStep * edgeSteps[0];
|
||
float nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;
|
||
bool nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;
|
||
|
||
for ( int i = 1; i < EDGE_STEP_COUNT && !nAtEnd; i++ ) {
|
||
|
||
nuv -= edgeStep * edgeSteps[i];
|
||
nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;
|
||
nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;
|
||
|
||
}
|
||
|
||
if ( !nAtEnd ) {
|
||
|
||
nuv -= edgeStep * EDGE_GUESS;
|
||
|
||
}
|
||
|
||
float pDistance, nDistance;
|
||
if ( e.isHorizontal ) {
|
||
|
||
pDistance = puv.x - uv.x;
|
||
nDistance = uv.x - nuv.x;
|
||
|
||
} else {
|
||
|
||
pDistance = puv.y - uv.y;
|
||
nDistance = uv.y - nuv.y;
|
||
|
||
}
|
||
|
||
float shortestDistance;
|
||
bool deltaSign;
|
||
if ( pDistance <= nDistance ) {
|
||
|
||
shortestDistance = pDistance;
|
||
deltaSign = pLuminanceDelta >= 0.0;
|
||
|
||
} else {
|
||
|
||
shortestDistance = nDistance;
|
||
deltaSign = nLuminanceDelta >= 0.0;
|
||
|
||
}
|
||
|
||
if ( deltaSign == ( l.m - edgeLuminance >= 0.0 ) ) {
|
||
|
||
return 0.0;
|
||
|
||
}
|
||
|
||
return 0.5 - shortestDistance / ( pDistance + nDistance );
|
||
|
||
}
|
||
|
||
vec4 ApplyFXAA( sampler2D tex2D, vec2 texSize, vec2 uv ) {
|
||
|
||
LuminanceData luminance = SampleLuminanceNeighborhood( tex2D, texSize, uv );
|
||
if ( ShouldSkipPixel( luminance ) ) {
|
||
|
||
return Sample( tex2D, uv );
|
||
|
||
}
|
||
|
||
float pixelBlend = DeterminePixelBlendFactor( luminance );
|
||
EdgeData edge = DetermineEdge( texSize, luminance );
|
||
float edgeBlend = DetermineEdgeBlendFactor( tex2D, texSize, luminance, edge, uv );
|
||
float finalBlend = max( pixelBlend, edgeBlend );
|
||
|
||
if (edge.isHorizontal) {
|
||
|
||
uv.y += edge.pixelStep * finalBlend;
|
||
|
||
} else {
|
||
|
||
uv.x += edge.pixelStep * finalBlend;
|
||
|
||
}
|
||
|
||
return Sample( tex2D, uv );
|
||
|
||
}
|
||
|
||
void main() {
|
||
|
||
gl_FragColor = ApplyFXAA( tDiffuse, resolution.xy, vUv );
|
||
|
||
}`},h8={uniforms:{tDiffuse:{value:null},saturation:{value:1.2},contrast:{value:1.2}},vertexShader:`
|
||
varying vec2 vUv;
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
||
}
|
||
`,fragmentShader:`
|
||
uniform sampler2D tDiffuse;
|
||
uniform float saturation;
|
||
uniform float contrast;
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
vec4 color = texture2D(tDiffuse, vUv);
|
||
|
||
// 转换为灰度值用于饱和度调整
|
||
float gray = dot(color.rgb, vec3(0.299, 0.587, 0.114));
|
||
|
||
// 混合原始颜色和灰度值来调整饱和度
|
||
color.rgb = mix(vec3(gray), color.rgb, saturation);
|
||
|
||
// 调整对比度
|
||
color.rgb = (color.rgb - 0.5) * contrast + 0.5;
|
||
|
||
gl_FragColor = color;
|
||
}
|
||
`};class d8{engine;composer;saturationPass;ssaoPass;gtaoPass;outputPass;fxaaPass;constructor(e){this.engine=e}applyClippingToAmbientOcclusionPass(e){const t=Array.isArray(this.engine.sectionPlane)?this.engine.sectionPlane:null,i=e?.normalMaterial;i&&(i.clippingPlanes=t,i.needsUpdate=!0)}syncAmbientOcclusionClipping(){this.applyClippingToAmbientOcclusionPass(this.gtaoPass),this.applyClippingToAmbientOcclusionPass(this.ssaoPass)}resize(e,t){if(e===void 0||t===void 0){const s=this.engine.deviceModule.getContainerSize();e=e??s.width,t=t??s.height}if(!e||!t||!this.composer)return;const i=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1;this.composer.setPixelRatio(i),this.composer.setSize(e,t);const n=this.composer.passes.find(s=>s instanceof Up&&s.material.uniforms.resolution);n&&(n.material.uniforms.resolution.value.x=1/(e*i),n.material.uniforms.resolution.value.y=1/(t*i))}init(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize(),i=this.engine.scene,n=this.engine.camera,s=this.engine.renderer,a=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1,o=new Ei(e,t,{minFilter:_t,magFilter:_t,format:hi,samples:4});this.composer=new n8(s,o),this.composer.setPixelRatio(a),this.composer.setSize(e,t);const l=new s8(i,n);this.composer.addPass(l),this.gtaoPass=new ms(i,n,e,t),this.gtaoPass.output=ms.OUTPUT.Default,this.gtaoPass.blendIntensity=.3,this.gtaoPass.enabled=!1,this.gtaoPass.updateGtaoMaterial&&this.gtaoPass.updateGtaoMaterial({enabled:!0,radius:.3,thickness:1,distanceExponent:1,distanceFallOff:1,scale:3,samples:16,resolutionScale:.45,useTemporalFiltering:!1,screenSpaceRadius:!1}),this.applyClippingToAmbientOcclusionPass(this.gtaoPass),this.composer.addPass(this.gtaoPass),this.ssaoPass=new cr(i,n,e,t),this.ssaoPass.kernelRadius=8,this.ssaoPass.minDistance=.005,this.ssaoPass.maxDistance=.1,this.ssaoPass.output=cr.OUTPUT.Default,this.ssaoPass.enabled=!1,this.applyClippingToAmbientOcclusionPass(this.ssaoPass),this.composer.addPass(this.ssaoPass),this.saturationPass=new Up(h8),this.saturationPass.uniforms.saturation.value=1.3,this.saturationPass.uniforms.contrast.value=1.1,this.saturationPass.enabled=!1,this.composer.addPass(this.saturationPass),this.outputPass=new l8,this.outputPass.enabled=!1,this.composer.addPass(this.outputPass),this.fxaaPass=new Up(c8),this.fxaaPass.material.uniforms.resolution.value.x=1/(e*a),this.fxaaPass.material.uniforms.resolution.value.y=1/(t*a),this.fxaaPass.enabled=!1,this.composer.addPass(this.fxaaPass)}}var Wp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function bx(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function jp(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var yx={exports:{}},xx;function u8(){return xx||(xx=1,(function(r,e){(function(t){r.exports=t()})(function(){return(function t(i,n,s){function a(c,h){if(!n[c]){if(!i[c]){var d=typeof jp=="function"&&jp;if(!h&&d)return d(c,!0);if(o)return o(c,!0);var p=new Error("Cannot find module '"+c+"'");throw p.code="MODULE_NOT_FOUND",p}var u=n[c]={exports:{}};i[c][0].call(u.exports,function(A){var m=i[c][1][A];return a(m||A)},u,u.exports,t,i,n,s)}return n[c].exports}for(var o=typeof jp=="function"&&jp,l=0;l<s.length;l++)a(s[l]);return a})({1:[function(t,i,n){var s=t("./utils"),a=t("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.encode=function(l){for(var c,h,d,p,u,A,m,g=[],f=0,v=l.length,b=v,y=s.getTypeOf(l)!=="string";f<l.length;)b=v-f,d=y?(c=l[f++],h=f<v?l[f++]:0,f<v?l[f++]:0):(c=l.charCodeAt(f++),h=f<v?l.charCodeAt(f++):0,f<v?l.charCodeAt(f++):0),p=c>>2,u=(3&c)<<4|h>>4,A=1<b?(15&h)<<2|d>>6:64,m=2<b?63&d:64,g.push(o.charAt(p)+o.charAt(u)+o.charAt(A)+o.charAt(m));return g.join("")},n.decode=function(l){var c,h,d,p,u,A,m=0,g=0,f="data:";if(l.substr(0,f.length)===f)throw new Error("Invalid base64 input, it looks like a data url.");var v,b=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===o.charAt(64)&&b--,l.charAt(l.length-2)===o.charAt(64)&&b--,b%1!=0)throw new Error("Invalid base64 input, bad content length.");for(v=a.uint8array?new Uint8Array(0|b):new Array(0|b);m<l.length;)c=o.indexOf(l.charAt(m++))<<2|(p=o.indexOf(l.charAt(m++)))>>4,h=(15&p)<<4|(u=o.indexOf(l.charAt(m++)))>>2,d=(3&u)<<6|(A=o.indexOf(l.charAt(m++))),v[g++]=c,u!==64&&(v[g++]=h),A!==64&&(v[g++]=d);return v}},{"./support":30,"./utils":32}],2:[function(t,i,n){var s=t("./external"),a=t("./stream/DataWorker"),o=t("./stream/Crc32Probe"),l=t("./stream/DataLengthProbe");function c(h,d,p,u,A){this.compressedSize=h,this.uncompressedSize=d,this.crc32=p,this.compression=u,this.compressedContent=A}c.prototype={getContentWorker:function(){var h=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),d=this;return h.on("end",function(){if(this.streamInfo.data_length!==d.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),h},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(h,d,p){return h.pipe(new o).pipe(new l("uncompressedSize")).pipe(d.compressWorker(p)).pipe(new l("compressedSize")).withStreamInfo("compression",d)},i.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,i,n){var s=t("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},n.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,i,n){var s=t("./utils"),a=(function(){for(var o,l=[],c=0;c<256;c++){o=c;for(var h=0;h<8;h++)o=1&o?3988292384^o>>>1:o>>>1;l[c]=o}return l})();i.exports=function(o,l){return o!==void 0&&o.length?s.getTypeOf(o)!=="string"?(function(c,h,d,p){var u=a,A=p+d;c^=-1;for(var m=p;m<A;m++)c=c>>>8^u[255&(c^h[m])];return-1^c})(0|l,o,o.length,0):(function(c,h,d,p){var u=a,A=p+d;c^=-1;for(var m=p;m<A;m++)c=c>>>8^u[255&(c^h.charCodeAt(m))];return-1^c})(0|l,o,o.length,0):0}},{"./utils":32}],5:[function(t,i,n){n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(t,i,n){var s=null;s=typeof Promise<"u"?Promise:t("lie"),i.exports={Promise:s}},{lie:37}],7:[function(t,i,n){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=t("pako"),o=t("./utils"),l=t("./stream/GenericWorker"),c=s?"uint8array":"array";function h(d,p){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=p,this.meta={}}n.magic="\b\0",o.inherits(h,l),h.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(c,d.data),!1)},h.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},h.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},h.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var d=this;this._pako.onData=function(p){d.push({data:p,meta:d.meta})}},n.compressWorker=function(d){return new h("Deflate",d)},n.uncompressWorker=function(){return new h("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,i,n){function s(u,A){var m,g="";for(m=0;m<A;m++)g+=String.fromCharCode(255&u),u>>>=8;return g}function a(u,A,m,g,f,v){var b,y,M=u.file,_=u.compression,S=v!==c.utf8encode,w=o.transformTo("string",v(M.name)),E=o.transformTo("string",c.utf8encode(M.name)),I=M.comment,B=o.transformTo("string",v(I)),R=o.transformTo("string",c.utf8encode(I)),U=E.length!==M.name.length,C=R.length!==I.length,F="",O="",H="",j=M.dir,G=M.date,re={crc32:0,compressedSize:0,uncompressedSize:0};A&&!m||(re.crc32=u.crc32,re.compressedSize=u.compressedSize,re.uncompressedSize=u.uncompressedSize);var q=0;A&&(q|=8),S||!U&&!C||(q|=2048);var Y=0,ye=0;j&&(Y|=16),f==="UNIX"?(ye=798,Y|=(function(xe,J){var oe=xe;return xe||(oe=J?16893:33204),(65535&oe)<<16})(M.unixPermissions,j)):(ye=20,Y|=(function(xe){return 63&(xe||0)})(M.dosPermissions)),b=G.getUTCHours(),b<<=6,b|=G.getUTCMinutes(),b<<=5,b|=G.getUTCSeconds()/2,y=G.getUTCFullYear()-1980,y<<=4,y|=G.getUTCMonth()+1,y<<=5,y|=G.getUTCDate(),U&&(O=s(1,1)+s(h(w),4)+E,F+="up"+s(O.length,2)+O),C&&(H=s(1,1)+s(h(B),4)+R,F+="uc"+s(H.length,2)+H);var Me="";return Me+=`
|
||
\0`,Me+=s(q,2),Me+=_.magic,Me+=s(b,2),Me+=s(y,2),Me+=s(re.crc32,4),Me+=s(re.compressedSize,4),Me+=s(re.uncompressedSize,4),Me+=s(w.length,2),Me+=s(F.length,2),{fileRecord:d.LOCAL_FILE_HEADER+Me+w+F,dirRecord:d.CENTRAL_FILE_HEADER+s(ye,2)+Me+s(B.length,2)+"\0\0\0\0"+s(Y,4)+s(g,4)+w+F+B}}var o=t("../utils"),l=t("../stream/GenericWorker"),c=t("../utf8"),h=t("../crc32"),d=t("../signature");function p(u,A,m,g){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=A,this.zipPlatform=m,this.encodeFileName=g,this.streamFiles=u,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(p,l),p.prototype.push=function(u){var A=u.meta.percent||0,m=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(u):(this.bytesWritten+=u.data.length,l.prototype.push.call(this,{data:u.data,meta:{currentFile:this.currentFile,percent:m?(A+100*(m-g-1))/m:100}}))},p.prototype.openedSource=function(u){this.currentSourceOffset=this.bytesWritten,this.currentFile=u.file.name;var A=this.streamFiles&&!u.file.dir;if(A){var m=a(u,A,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(u){this.accumulate=!1;var A=this.streamFiles&&!u.file.dir,m=a(u,A,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),A)this.push({data:(function(g){return d.DATA_DESCRIPTOR+s(g.crc32,4)+s(g.compressedSize,4)+s(g.uncompressedSize,4)})(u),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var u=this.bytesWritten,A=0;A<this.dirRecords.length;A++)this.push({data:this.dirRecords[A],meta:{percent:100}});var m=this.bytesWritten-u,g=(function(f,v,b,y,M){var _=o.transformTo("string",M(y));return d.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(f,2)+s(f,2)+s(v,4)+s(b,4)+s(_.length,2)+_})(this.dirRecords.length,m,u,this.zipComment,this.encodeFileName);this.push({data:g,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(u){this._sources.push(u);var A=this;return u.on("data",function(m){A.processChunk(m)}),u.on("end",function(){A.closedSource(A.previous.streamInfo),A._sources.length?A.prepareNextSource():A.end()}),u.on("error",function(m){A.error(m)}),this},p.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},p.prototype.error=function(u){var A=this._sources;if(!l.prototype.error.call(this,u))return!1;for(var m=0;m<A.length;m++)try{A[m].error(u)}catch{}return!0},p.prototype.lock=function(){l.prototype.lock.call(this);for(var u=this._sources,A=0;A<u.length;A++)u[A].lock()},i.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,i,n){var s=t("../compressions"),a=t("./ZipFileWorker");n.generateWorker=function(o,l,c){var h=new a(l.streamFiles,c,l.platform,l.encodeFileName),d=0;try{o.forEach(function(p,u){d++;var A=(function(v,b){var y=v||b,M=s[y];if(!M)throw new Error(y+" is not a valid compression method !");return M})(u.options.compression,l.compression),m=u.options.compressionOptions||l.compressionOptions||{},g=u.dir,f=u.date;u._compressWorker(A,m).withStreamInfo("file",{name:p,dir:g,date:f,comment:u.comment||"",unixPermissions:u.unixPermissions,dosPermissions:u.dosPermissions}).pipe(h)}),h.entriesCount=d}catch(p){h.error(p)}return h}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(t,i,n){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new s;for(var o in this)typeof this[o]!="function"&&(a[o]=this[o]);return a}}(s.prototype=t("./object")).loadAsync=t("./load"),s.support=t("./support"),s.defaults=t("./defaults"),s.version="3.10.1",s.loadAsync=function(a,o){return new s().loadAsync(a,o)},s.external=t("./external"),i.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(t,i,n){var s=t("./utils"),a=t("./external"),o=t("./utf8"),l=t("./zipEntries"),c=t("./stream/Crc32Probe"),h=t("./nodejsUtils");function d(p){return new a.Promise(function(u,A){var m=p.decompressed.getContentWorker().pipe(new c);m.on("error",function(g){A(g)}).on("end",function(){m.streamInfo.crc32!==p.decompressed.crc32?A(new Error("Corrupted zip : CRC32 mismatch")):u()}).resume()})}i.exports=function(p,u){var A=this;return u=s.extend(u||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),h.isNode&&h.isStream(p)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",p,!0,u.optimizedBinaryString,u.base64).then(function(m){var g=new l(u);return g.load(m),g}).then(function(m){var g=[a.Promise.resolve(m)],f=m.files;if(u.checkCRC32)for(var v=0;v<f.length;v++)g.push(d(f[v]));return a.Promise.all(g)}).then(function(m){for(var g=m.shift(),f=g.files,v=0;v<f.length;v++){var b=f[v],y=b.fileNameStr,M=s.resolve(b.fileNameStr);A.file(M,b.decompressed,{binary:!0,optimizedBinaryString:!0,date:b.date,dir:b.dir,comment:b.fileCommentStr.length?b.fileCommentStr:null,unixPermissions:b.unixPermissions,dosPermissions:b.dosPermissions,createFolders:u.createFolders}),b.dir||(A.file(M).unsafeOriginalName=y)}return g.zipComment.length&&(A.comment=g.zipComment),A})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,i,n){var s=t("../utils"),a=t("../stream/GenericWorker");function o(l,c){a.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}s.inherits(o,a),o.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(h){c.push({data:h,meta:{percent:0}})}).on("error",function(h){c.isPaused?this.generatedError=h:c.error(h)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},o.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(t,i,n){var s=t("readable-stream").Readable;function a(o,l,c){s.call(this,l),this._helper=o;var h=this;o.on("data",function(d,p){h.push(d)||h._helper.pause(),c&&c(p)}).on("error",function(d){h.emit("error",d)}).on("end",function(){h.push(null)})}t("../utils").inherits(a,s),a.prototype._read=function(){this._helper.resume()},i.exports=a},{"../utils":32,"readable-stream":16}],14:[function(t,i,n){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,a);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,a)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var a=new Buffer(s);return a.fill(0),a},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(t,i,n){function s(M,_,S){var w,E=o.getTypeOf(_),I=o.extend(S||{},h);I.date=I.date||new Date,I.compression!==null&&(I.compression=I.compression.toUpperCase()),typeof I.unixPermissions=="string"&&(I.unixPermissions=parseInt(I.unixPermissions,8)),I.unixPermissions&&16384&I.unixPermissions&&(I.dir=!0),I.dosPermissions&&16&I.dosPermissions&&(I.dir=!0),I.dir&&(M=f(M)),I.createFolders&&(w=g(M))&&v.call(this,w,!0);var B=E==="string"&&I.binary===!1&&I.base64===!1;S&&S.binary!==void 0||(I.binary=!B),(_ instanceof d&&_.uncompressedSize===0||I.dir||!_||_.length===0)&&(I.base64=!1,I.binary=!0,_="",I.compression="STORE",E="string");var R=null;R=_ instanceof d||_ instanceof l?_:A.isNode&&A.isStream(_)?new m(M,_):o.prepareContent(M,_,I.binary,I.optimizedBinaryString,I.base64);var U=new p(M,R,I);this.files[M]=U}var a=t("./utf8"),o=t("./utils"),l=t("./stream/GenericWorker"),c=t("./stream/StreamHelper"),h=t("./defaults"),d=t("./compressedObject"),p=t("./zipObject"),u=t("./generate"),A=t("./nodejsUtils"),m=t("./nodejs/NodejsStreamInputAdapter"),g=function(M){M.slice(-1)==="/"&&(M=M.substring(0,M.length-1));var _=M.lastIndexOf("/");return 0<_?M.substring(0,_):""},f=function(M){return M.slice(-1)!=="/"&&(M+="/"),M},v=function(M,_){return _=_!==void 0?_:h.createFolders,M=f(M),this.files[M]||s.call(this,M,null,{dir:!0,createFolders:_}),this.files[M]};function b(M){return Object.prototype.toString.call(M)==="[object RegExp]"}var y={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(M){var _,S,w;for(_ in this.files)w=this.files[_],(S=_.slice(this.root.length,_.length))&&_.slice(0,this.root.length)===this.root&&M(S,w)},filter:function(M){var _=[];return this.forEach(function(S,w){M(S,w)&&_.push(w)}),_},file:function(M,_,S){if(arguments.length!==1)return M=this.root+M,s.call(this,M,_,S),this;if(b(M)){var w=M;return this.filter(function(I,B){return!B.dir&&w.test(I)})}var E=this.files[this.root+M];return E&&!E.dir?E:null},folder:function(M){if(!M)return this;if(b(M))return this.filter(function(E,I){return I.dir&&M.test(E)});var _=this.root+M,S=v.call(this,_),w=this.clone();return w.root=S.name,w},remove:function(M){M=this.root+M;var _=this.files[M];if(_||(M.slice(-1)!=="/"&&(M+="/"),_=this.files[M]),_&&!_.dir)delete this.files[M];else for(var S=this.filter(function(E,I){return I.name.slice(0,M.length)===M}),w=0;w<S.length;w++)delete this.files[S[w].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(M){var _,S={};try{if((S=o.extend(M||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=S.type.toLowerCase(),S.compression=S.compression.toUpperCase(),S.type==="binarystring"&&(S.type="string"),!S.type)throw new Error("No output type specified.");o.checkSupport(S.type),S.platform!=="darwin"&&S.platform!=="freebsd"&&S.platform!=="linux"&&S.platform!=="sunos"||(S.platform="UNIX"),S.platform==="win32"&&(S.platform="DOS");var w=S.comment||this.comment||"";_=u.generateWorker(this,S,w)}catch(E){(_=new l("error")).error(E)}return new c(_,S.type||"string",S.mimeType)},generateAsync:function(M,_){return this.generateInternalStream(M).accumulate(_)},generateNodeStream:function(M,_){return(M=M||{}).type||(M.type="nodebuffer"),this.generateInternalStream(M).toNodejsStream(_)}};i.exports=y},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(t,i,n){i.exports=t("stream")},{stream:void 0}],17:[function(t,i,n){var s=t("./DataReader");function a(o){s.call(this,o);for(var l=0;l<this.data.length;l++)o[l]=255&o[l]}t("../utils").inherits(a,s),a.prototype.byteAt=function(o){return this.data[this.zero+o]},a.prototype.lastIndexOfSignature=function(o){for(var l=o.charCodeAt(0),c=o.charCodeAt(1),h=o.charCodeAt(2),d=o.charCodeAt(3),p=this.length-4;0<=p;--p)if(this.data[p]===l&&this.data[p+1]===c&&this.data[p+2]===h&&this.data[p+3]===d)return p-this.zero;return-1},a.prototype.readAndCheckSignature=function(o){var l=o.charCodeAt(0),c=o.charCodeAt(1),h=o.charCodeAt(2),d=o.charCodeAt(3),p=this.readData(4);return l===p[0]&&c===p[1]&&h===p[2]&&d===p[3]},a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=a},{"../utils":32,"./DataReader":18}],18:[function(t,i,n){var s=t("../utils");function a(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(o){this.checkIndex(this.index+o)},checkIndex:function(o){if(this.length<this.zero+o||o<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+o+"). Corrupted zip ?")},setIndex:function(o){this.checkIndex(o),this.index=o},skip:function(o){this.setIndex(this.index+o)},byteAt:function(){},readInt:function(o){var l,c=0;for(this.checkOffset(o),l=this.index+o-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=o,c},readString:function(o){return s.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},i.exports=a},{"../utils":32}],19:[function(t,i,n){var s=t("./Uint8ArrayReader");function a(o){s.call(this,o)}t("../utils").inherits(a,s),a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,i,n){var s=t("./DataReader");function a(o){s.call(this,o)}t("../utils").inherits(a,s),a.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},a.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},a.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=a},{"../utils":32,"./DataReader":18}],21:[function(t,i,n){var s=t("./ArrayReader");function a(o){s.call(this,o)}t("../utils").inherits(a,s),a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(t,i,n){var s=t("../utils"),a=t("../support"),o=t("./ArrayReader"),l=t("./StringReader"),c=t("./NodeBufferReader"),h=t("./Uint8ArrayReader");i.exports=function(d){var p=s.getTypeOf(d);return s.checkSupport(p),p!=="string"||a.uint8array?p==="nodebuffer"?new c(d):a.uint8array?new h(s.transformTo("uint8array",d)):new o(s.transformTo("array",d)):new l(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,i,n){n.LOCAL_FILE_HEADER="PK",n.CENTRAL_FILE_HEADER="PK",n.CENTRAL_DIRECTORY_END="PK",n.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",n.ZIP64_CENTRAL_DIRECTORY_END="PK",n.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,i,n){var s=t("./GenericWorker"),a=t("../utils");function o(l){s.call(this,"ConvertWorker to "+l),this.destType=l}a.inherits(o,s),o.prototype.processChunk=function(l){this.push({data:a.transformTo(this.destType,l.data),meta:l.meta})},i.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(t,i,n){var s=t("./GenericWorker"),a=t("../crc32");function o(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(o,s),o.prototype.processChunk=function(l){this.streamInfo.crc32=a(l.data,this.streamInfo.crc32||0),this.push(l)},i.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,i,n){var s=t("../utils"),a=t("./GenericWorker");function o(l){a.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(o,a),o.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}a.prototype.processChunk.call(this,l)},i.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(t,i,n){var s=t("../utils"),a=t("./GenericWorker");function o(l){a.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(h){c.dataIsReady=!0,c.data=h,c.max=h&&h.length||0,c.type=s.getTypeOf(h),c.isPaused||c._tickAndRepeat()},function(h){c.error(h)})}s.inherits(o,a),o.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(t,i,n){function s(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,o){return this._listeners[a].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,o){if(this._listeners[a])for(var l=0;l<this._listeners[a].length;l++)this._listeners[a][l].call(this,o)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var o=this;return a.on("data",function(l){o.processChunk(l)}),a.on("end",function(){o.end()}),a.on("error",function(l){o.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,o){return this.extraStreamInfo[a]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},i.exports=s},{}],29:[function(t,i,n){var s=t("../utils"),a=t("./ConvertWorker"),o=t("./GenericWorker"),l=t("../base64"),c=t("../support"),h=t("../external"),d=null;if(c.nodestream)try{d=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(A,m){return new h.Promise(function(g,f){var v=[],b=A._internalType,y=A._outputType,M=A._mimeType;A.on("data",function(_,S){v.push(_),m&&m(S)}).on("error",function(_){v=[],f(_)}).on("end",function(){try{var _=(function(S,w,E){switch(S){case"blob":return s.newBlob(s.transformTo("arraybuffer",w),E);case"base64":return l.encode(w);default:return s.transformTo(S,w)}})(y,(function(S,w){var E,I=0,B=null,R=0;for(E=0;E<w.length;E++)R+=w[E].length;switch(S){case"string":return w.join("");case"array":return Array.prototype.concat.apply([],w);case"uint8array":for(B=new Uint8Array(R),E=0;E<w.length;E++)B.set(w[E],I),I+=w[E].length;return B;case"nodebuffer":return Buffer.concat(w);default:throw new Error("concat : unsupported type '"+S+"'")}})(b,v),M);g(_)}catch(S){f(S)}v=[]}).resume()})}function u(A,m,g){var f=m;switch(m){case"blob":case"arraybuffer":f="uint8array";break;case"base64":f="string"}try{this._internalType=f,this._outputType=m,this._mimeType=g,s.checkSupport(f),this._worker=A.pipe(new a(f)),A.lock()}catch(v){this._worker=new o("error"),this._worker.error(v)}}u.prototype={accumulate:function(A){return p(this,A)},on:function(A,m){var g=this;return A==="data"?this._worker.on(A,function(f){m.call(g,f.data,f.meta)}):this._worker.on(A,function(){s.delay(m,arguments,g)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(A){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new d(this,{objectMode:this._outputType!=="nodebuffer"},A)}},i.exports=u},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(t,i,n){if(n.base64=!0,n.array=!0,n.string=!0,n.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",n.nodebuffer=typeof Buffer<"u",n.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")n.blob=!1;else{var s=new ArrayBuffer(0);try{n.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(s),n.blob=a.getBlob("application/zip").size===0}catch{n.blob=!1}}}try{n.nodestream=!!t("readable-stream").Readable}catch{n.nodestream=!1}},{"readable-stream":16}],31:[function(t,i,n){for(var s=t("./utils"),a=t("./support"),o=t("./nodejsUtils"),l=t("./stream/GenericWorker"),c=new Array(256),h=0;h<256;h++)c[h]=252<=h?6:248<=h?5:240<=h?4:224<=h?3:192<=h?2:1;c[254]=c[254]=1;function d(){l.call(this,"utf-8 decode"),this.leftOver=null}function p(){l.call(this,"utf-8 encode")}n.utf8encode=function(u){return a.nodebuffer?o.newBufferFrom(u,"utf-8"):(function(A){var m,g,f,v,b,y=A.length,M=0;for(v=0;v<y;v++)(64512&(g=A.charCodeAt(v)))==55296&&v+1<y&&(64512&(f=A.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(f-56320),v++),M+=g<128?1:g<2048?2:g<65536?3:4;for(m=a.uint8array?new Uint8Array(M):new Array(M),v=b=0;b<M;v++)(64512&(g=A.charCodeAt(v)))==55296&&v+1<y&&(64512&(f=A.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(f-56320),v++),g<128?m[b++]=g:(g<2048?m[b++]=192|g>>>6:(g<65536?m[b++]=224|g>>>12:(m[b++]=240|g>>>18,m[b++]=128|g>>>12&63),m[b++]=128|g>>>6&63),m[b++]=128|63&g);return m})(u)},n.utf8decode=function(u){return a.nodebuffer?s.transformTo("nodebuffer",u).toString("utf-8"):(function(A){var m,g,f,v,b=A.length,y=new Array(2*b);for(m=g=0;m<b;)if((f=A[m++])<128)y[g++]=f;else if(4<(v=c[f]))y[g++]=65533,m+=v-1;else{for(f&=v===2?31:v===3?15:7;1<v&&m<b;)f=f<<6|63&A[m++],v--;1<v?y[g++]=65533:f<65536?y[g++]=f:(f-=65536,y[g++]=55296|f>>10&1023,y[g++]=56320|1023&f)}return y.length!==g&&(y.subarray?y=y.subarray(0,g):y.length=g),s.applyFromCharCode(y)})(u=s.transformTo(a.uint8array?"uint8array":"array",u))},s.inherits(d,l),d.prototype.processChunk=function(u){var A=s.transformTo(a.uint8array?"uint8array":"array",u.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var m=A;(A=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),A.set(m,this.leftOver.length)}else A=this.leftOver.concat(A);this.leftOver=null}var g=(function(v,b){var y;for((b=b||v.length)>v.length&&(b=v.length),y=b-1;0<=y&&(192&v[y])==128;)y--;return y<0||y===0?b:y+c[v[y]]>b?y:b})(A),f=A;g!==A.length&&(a.uint8array?(f=A.subarray(0,g),this.leftOver=A.subarray(g,A.length)):(f=A.slice(0,g),this.leftOver=A.slice(g,A.length))),this.push({data:n.utf8decode(f),meta:u.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=d,s.inherits(p,l),p.prototype.processChunk=function(u){this.push({data:n.utf8encode(u.data),meta:u.meta})},n.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,i,n){var s=t("./support"),a=t("./base64"),o=t("./nodejsUtils"),l=t("./external");function c(m){return m}function h(m,g){for(var f=0;f<m.length;++f)g[f]=255&m.charCodeAt(f);return g}t("setimmediate"),n.newBlob=function(m,g){n.checkSupport("blob");try{return new Blob([m],{type:g})}catch{try{var f=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return f.append(m),f.getBlob(g)}catch{throw new Error("Bug : can't construct the Blob.")}}};var d={stringifyByChunk:function(m,g,f){var v=[],b=0,y=m.length;if(y<=f)return String.fromCharCode.apply(null,m);for(;b<y;)g==="array"||g==="nodebuffer"?v.push(String.fromCharCode.apply(null,m.slice(b,Math.min(b+f,y)))):v.push(String.fromCharCode.apply(null,m.subarray(b,Math.min(b+f,y)))),b+=f;return v.join("")},stringifyByChar:function(m){for(var g="",f=0;f<m.length;f++)g+=String.fromCharCode(m[f]);return g},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}})()}};function p(m){var g=65536,f=n.getTypeOf(m),v=!0;if(f==="uint8array"?v=d.applyCanBeUsed.uint8array:f==="nodebuffer"&&(v=d.applyCanBeUsed.nodebuffer),v)for(;1<g;)try{return d.stringifyByChunk(m,f,g)}catch{g=Math.floor(g/2)}return d.stringifyByChar(m)}function u(m,g){for(var f=0;f<m.length;f++)g[f]=m[f];return g}n.applyFromCharCode=p;var A={};A.string={string:c,array:function(m){return h(m,new Array(m.length))},arraybuffer:function(m){return A.string.uint8array(m).buffer},uint8array:function(m){return h(m,new Uint8Array(m.length))},nodebuffer:function(m){return h(m,o.allocBuffer(m.length))}},A.array={string:p,array:c,arraybuffer:function(m){return new Uint8Array(m).buffer},uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return o.newBufferFrom(m)}},A.arraybuffer={string:function(m){return p(new Uint8Array(m))},array:function(m){return u(new Uint8Array(m),new Array(m.byteLength))},arraybuffer:c,uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return o.newBufferFrom(new Uint8Array(m))}},A.uint8array={string:p,array:function(m){return u(m,new Array(m.length))},arraybuffer:function(m){return m.buffer},uint8array:c,nodebuffer:function(m){return o.newBufferFrom(m)}},A.nodebuffer={string:p,array:function(m){return u(m,new Array(m.length))},arraybuffer:function(m){return A.nodebuffer.uint8array(m).buffer},uint8array:function(m){return u(m,new Uint8Array(m.length))},nodebuffer:c},n.transformTo=function(m,g){if(g=g||"",!m)return g;n.checkSupport(m);var f=n.getTypeOf(g);return A[f][m](g)},n.resolve=function(m){for(var g=m.split("/"),f=[],v=0;v<g.length;v++){var b=g[v];b==="."||b===""&&v!==0&&v!==g.length-1||(b===".."?f.pop():f.push(b))}return f.join("/")},n.getTypeOf=function(m){return typeof m=="string"?"string":Object.prototype.toString.call(m)==="[object Array]"?"array":s.nodebuffer&&o.isBuffer(m)?"nodebuffer":s.uint8array&&m instanceof Uint8Array?"uint8array":s.arraybuffer&&m instanceof ArrayBuffer?"arraybuffer":void 0},n.checkSupport=function(m){if(!s[m.toLowerCase()])throw new Error(m+" is not supported by this platform")},n.MAX_VALUE_16BITS=65535,n.MAX_VALUE_32BITS=-1,n.pretty=function(m){var g,f,v="";for(f=0;f<(m||"").length;f++)v+="\\x"+((g=m.charCodeAt(f))<16?"0":"")+g.toString(16).toUpperCase();return v},n.delay=function(m,g,f){setImmediate(function(){m.apply(f||null,g||[])})},n.inherits=function(m,g){function f(){}f.prototype=g.prototype,m.prototype=new f},n.extend=function(){var m,g,f={};for(m=0;m<arguments.length;m++)for(g in arguments[m])Object.prototype.hasOwnProperty.call(arguments[m],g)&&f[g]===void 0&&(f[g]=arguments[m][g]);return f},n.prepareContent=function(m,g,f,v,b){return l.Promise.resolve(g).then(function(y){return s.blob&&(y instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(y))!==-1)&&typeof FileReader<"u"?new l.Promise(function(M,_){var S=new FileReader;S.onload=function(w){M(w.target.result)},S.onerror=function(w){_(w.target.error)},S.readAsArrayBuffer(y)}):y}).then(function(y){var M=n.getTypeOf(y);return M?(M==="arraybuffer"?y=n.transformTo("uint8array",y):M==="string"&&(b?y=a.decode(y):f&&v!==!0&&(y=(function(_){return h(_,s.uint8array?new Uint8Array(_.length):new Array(_.length))})(y))),y):l.Promise.reject(new Error("Can't read the data of '"+m+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(t,i,n){var s=t("./reader/readerFor"),a=t("./utils"),o=t("./signature"),l=t("./zipEntry"),c=t("./support");function h(d){this.files=[],this.loadOptions=d}h.prototype={checkSignature:function(d){if(!this.reader.readAndCheckSignature(d)){this.reader.index-=4;var p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(p)+", expected "+a.pretty(d)+")")}},isSignature:function(d,p){var u=this.reader.index;this.reader.setIndex(d);var A=this.reader.readString(4)===p;return this.reader.setIndex(u),A},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var d=this.reader.readData(this.zipCommentLength),p=c.uint8array?"uint8array":"array",u=a.transformTo(p,d);this.zipComment=this.loadOptions.decodeFileName(u)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var d,p,u,A=this.zip64EndOfCentralSize-44;0<A;)d=this.reader.readInt(2),p=this.reader.readInt(4),u=this.reader.readData(p),this.zip64ExtensibleData[d]={id:d,length:p,value:u}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var d,p;for(d=0;d<this.files.length;d++)p=this.files[d],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var d;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(d=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(d);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var d=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(d<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(d);var p=d;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(d=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(d),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var u=this.centralDirOffset+this.centralDirSize;this.zip64&&(u+=20,u+=12+this.zip64EndOfCentralSize);var A=p-u;if(0<A)this.isSignature(p,o.CENTRAL_FILE_HEADER)||(this.reader.zero=A);else if(A<0)throw new Error("Corrupted zip: missing "+Math.abs(A)+" bytes.")},prepareReader:function(d){this.reader=s(d)},load:function(d){this.prepareReader(d),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=h},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(t,i,n){var s=t("./reader/readerFor"),a=t("./utils"),o=t("./compressedObject"),l=t("./crc32"),c=t("./utf8"),h=t("./compressions"),d=t("./support");function p(u,A){this.options=u,this.loadOptions=A}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(u){var A,m;if(u.skip(22),this.fileNameLength=u.readInt(2),m=u.readInt(2),this.fileName=u.readData(this.fileNameLength),u.skip(m),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((A=(function(g){for(var f in h)if(Object.prototype.hasOwnProperty.call(h,f)&&h[f].magic===g)return h[f];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,A,u.readData(this.compressedSize))},readCentralPart:function(u){this.versionMadeBy=u.readInt(2),u.skip(2),this.bitFlag=u.readInt(2),this.compressionMethod=u.readString(2),this.date=u.readDate(),this.crc32=u.readInt(4),this.compressedSize=u.readInt(4),this.uncompressedSize=u.readInt(4);var A=u.readInt(2);if(this.extraFieldsLength=u.readInt(2),this.fileCommentLength=u.readInt(2),this.diskNumberStart=u.readInt(2),this.internalFileAttributes=u.readInt(2),this.externalFileAttributes=u.readInt(4),this.localHeaderOffset=u.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");u.skip(A),this.readExtraFields(u),this.parseZIP64ExtraField(u),this.fileComment=u.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var u=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),u==0&&(this.dosPermissions=63&this.externalFileAttributes),u==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var u=s(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=u.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=u.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=u.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=u.readInt(4))}},readExtraFields:function(u){var A,m,g,f=u.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});u.index+4<f;)A=u.readInt(2),m=u.readInt(2),g=u.readData(m),this.extraFields[A]={id:A,length:m,value:g};u.setIndex(f)},handleUTF8:function(){var u=d.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var A=this.findExtraFieldUnicodePath();if(A!==null)this.fileNameStr=A;else{var m=a.transformTo(u,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(m)}var g=this.findExtraFieldUnicodeComment();if(g!==null)this.fileCommentStr=g;else{var f=a.transformTo(u,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(f)}}},findExtraFieldUnicodePath:function(){var u=this.extraFields[28789];if(u){var A=s(u.value);return A.readInt(1)!==1||l(this.fileName)!==A.readInt(4)?null:c.utf8decode(A.readData(u.length-5))}return null},findExtraFieldUnicodeComment:function(){var u=this.extraFields[25461];if(u){var A=s(u.value);return A.readInt(1)!==1||l(this.fileComment)!==A.readInt(4)?null:c.utf8decode(A.readData(u.length-5))}return null}},i.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(t,i,n){function s(A,m,g){this.name=A,this.dir=g.dir,this.date=g.date,this.comment=g.comment,this.unixPermissions=g.unixPermissions,this.dosPermissions=g.dosPermissions,this._data=m,this._dataBinary=g.binary,this.options={compression:g.compression,compressionOptions:g.compressionOptions}}var a=t("./stream/StreamHelper"),o=t("./stream/DataWorker"),l=t("./utf8"),c=t("./compressedObject"),h=t("./stream/GenericWorker");s.prototype={internalStream:function(A){var m=null,g="string";try{if(!A)throw new Error("No output type specified.");var f=(g=A.toLowerCase())==="string"||g==="text";g!=="binarystring"&&g!=="text"||(g="string"),m=this._decompressWorker();var v=!this._dataBinary;v&&!f&&(m=m.pipe(new l.Utf8EncodeWorker)),!v&&f&&(m=m.pipe(new l.Utf8DecodeWorker))}catch(b){(m=new h("error")).error(b)}return new a(m,g,"")},async:function(A,m){return this.internalStream(A).accumulate(m)},nodeStream:function(A,m){return this.internalStream(A||"nodebuffer").toNodejsStream(m)},_compressWorker:function(A,m){if(this._data instanceof c&&this._data.compression.magic===A.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(g,A,m)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof h?this._data:new o(this._data)}};for(var d=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},u=0;u<d.length;u++)s.prototype[d[u]]=p;i.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,i,n){(function(s){var a,o,l=s.MutationObserver||s.WebKitMutationObserver;if(l){var c=0,h=new l(A),d=s.document.createTextNode("");h.observe(d,{characterData:!0}),a=function(){d.data=c=++c%2}}else if(s.setImmediate||s.MessageChannel===void 0)a="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var m=s.document.createElement("script");m.onreadystatechange=function(){A(),m.onreadystatechange=null,m.parentNode.removeChild(m),m=null},s.document.documentElement.appendChild(m)}:function(){setTimeout(A,0)};else{var p=new s.MessageChannel;p.port1.onmessage=A,a=function(){p.port2.postMessage(0)}}var u=[];function A(){var m,g;o=!0;for(var f=u.length;f;){for(g=u,u=[],m=-1;++m<f;)g[m]();f=u.length}o=!1}i.exports=function(m){u.push(m)!==1||o||a()}}).call(this,typeof Wp<"u"?Wp:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(t,i,n){var s=t("immediate");function a(){}var o={},l=["REJECTED"],c=["FULFILLED"],h=["PENDING"];function d(f){if(typeof f!="function")throw new TypeError("resolver must be a function");this.state=h,this.queue=[],this.outcome=void 0,f!==a&&m(this,f)}function p(f,v,b){this.promise=f,typeof v=="function"&&(this.onFulfilled=v,this.callFulfilled=this.otherCallFulfilled),typeof b=="function"&&(this.onRejected=b,this.callRejected=this.otherCallRejected)}function u(f,v,b){s(function(){var y;try{y=v(b)}catch(M){return o.reject(f,M)}y===f?o.reject(f,new TypeError("Cannot resolve promise with itself")):o.resolve(f,y)})}function A(f){var v=f&&f.then;if(f&&(typeof f=="object"||typeof f=="function")&&typeof v=="function")return function(){v.apply(f,arguments)}}function m(f,v){var b=!1;function y(S){b||(b=!0,o.reject(f,S))}function M(S){b||(b=!0,o.resolve(f,S))}var _=g(function(){v(M,y)});_.status==="error"&&y(_.value)}function g(f,v){var b={};try{b.value=f(v),b.status="success"}catch(y){b.status="error",b.value=y}return b}(i.exports=d).prototype.finally=function(f){if(typeof f!="function")return this;var v=this.constructor;return this.then(function(b){return v.resolve(f()).then(function(){return b})},function(b){return v.resolve(f()).then(function(){throw b})})},d.prototype.catch=function(f){return this.then(null,f)},d.prototype.then=function(f,v){if(typeof f!="function"&&this.state===c||typeof v!="function"&&this.state===l)return this;var b=new this.constructor(a);return this.state!==h?u(b,this.state===c?f:v,this.outcome):this.queue.push(new p(b,f,v)),b},p.prototype.callFulfilled=function(f){o.resolve(this.promise,f)},p.prototype.otherCallFulfilled=function(f){u(this.promise,this.onFulfilled,f)},p.prototype.callRejected=function(f){o.reject(this.promise,f)},p.prototype.otherCallRejected=function(f){u(this.promise,this.onRejected,f)},o.resolve=function(f,v){var b=g(A,v);if(b.status==="error")return o.reject(f,b.value);var y=b.value;if(y)m(f,y);else{f.state=c,f.outcome=v;for(var M=-1,_=f.queue.length;++M<_;)f.queue[M].callFulfilled(v)}return f},o.reject=function(f,v){f.state=l,f.outcome=v;for(var b=-1,y=f.queue.length;++b<y;)f.queue[b].callRejected(v);return f},d.resolve=function(f){return f instanceof this?f:o.resolve(new this(a),f)},d.reject=function(f){var v=new this(a);return o.reject(v,f)},d.all=function(f){var v=this;if(Object.prototype.toString.call(f)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=f.length,y=!1;if(!b)return this.resolve([]);for(var M=new Array(b),_=0,S=-1,w=new this(a);++S<b;)E(f[S],S);return w;function E(I,B){v.resolve(I).then(function(R){M[B]=R,++_!==b||y||(y=!0,o.resolve(w,M))},function(R){y||(y=!0,o.reject(w,R))})}},d.race=function(f){var v=this;if(Object.prototype.toString.call(f)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=f.length,y=!1;if(!b)return this.resolve([]);for(var M=-1,_=new this(a);++M<b;)S=f[M],v.resolve(S).then(function(w){y||(y=!0,o.resolve(_,w))},function(w){y||(y=!0,o.reject(_,w))});var S;return _}},{immediate:36}],38:[function(t,i,n){var s={};(0,t("./lib/utils/common").assign)(s,t("./lib/deflate"),t("./lib/inflate"),t("./lib/zlib/constants")),i.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(t,i,n){var s=t("./zlib/deflate"),a=t("./utils/common"),o=t("./utils/strings"),l=t("./zlib/messages"),c=t("./zlib/zstream"),h=Object.prototype.toString,d=0,p=-1,u=0,A=8;function m(f){if(!(this instanceof m))return new m(f);this.options=a.assign({level:p,method:A,chunkSize:16384,windowBits:15,memLevel:8,strategy:u,to:""},f||{});var v=this.options;v.raw&&0<v.windowBits?v.windowBits=-v.windowBits:v.gzip&&0<v.windowBits&&v.windowBits<16&&(v.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var b=s.deflateInit2(this.strm,v.level,v.method,v.windowBits,v.memLevel,v.strategy);if(b!==d)throw new Error(l[b]);if(v.header&&s.deflateSetHeader(this.strm,v.header),v.dictionary){var y;if(y=typeof v.dictionary=="string"?o.string2buf(v.dictionary):h.call(v.dictionary)==="[object ArrayBuffer]"?new Uint8Array(v.dictionary):v.dictionary,(b=s.deflateSetDictionary(this.strm,y))!==d)throw new Error(l[b]);this._dict_set=!0}}function g(f,v){var b=new m(v);if(b.push(f,!0),b.err)throw b.msg||l[b.err];return b.result}m.prototype.push=function(f,v){var b,y,M=this.strm,_=this.options.chunkSize;if(this.ended)return!1;y=v===~~v?v:v===!0?4:0,typeof f=="string"?M.input=o.string2buf(f):h.call(f)==="[object ArrayBuffer]"?M.input=new Uint8Array(f):M.input=f,M.next_in=0,M.avail_in=M.input.length;do{if(M.avail_out===0&&(M.output=new a.Buf8(_),M.next_out=0,M.avail_out=_),(b=s.deflate(M,y))!==1&&b!==d)return this.onEnd(b),!(this.ended=!0);M.avail_out!==0&&(M.avail_in!==0||y!==4&&y!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(a.shrinkBuf(M.output,M.next_out))):this.onData(a.shrinkBuf(M.output,M.next_out)))}while((0<M.avail_in||M.avail_out===0)&&b!==1);return y===4?(b=s.deflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===d):y!==2||(this.onEnd(d),!(M.avail_out=0))},m.prototype.onData=function(f){this.chunks.push(f)},m.prototype.onEnd=function(f){f===d&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg},n.Deflate=m,n.deflate=g,n.deflateRaw=function(f,v){return(v=v||{}).raw=!0,g(f,v)},n.gzip=function(f,v){return(v=v||{}).gzip=!0,g(f,v)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(t,i,n){var s=t("./zlib/inflate"),a=t("./utils/common"),o=t("./utils/strings"),l=t("./zlib/constants"),c=t("./zlib/messages"),h=t("./zlib/zstream"),d=t("./zlib/gzheader"),p=Object.prototype.toString;function u(m){if(!(this instanceof u))return new u(m);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},m||{});var g=this.options;g.raw&&0<=g.windowBits&&g.windowBits<16&&(g.windowBits=-g.windowBits,g.windowBits===0&&(g.windowBits=-15)),!(0<=g.windowBits&&g.windowBits<16)||m&&m.windowBits||(g.windowBits+=32),15<g.windowBits&&g.windowBits<48&&(15&g.windowBits)==0&&(g.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var f=s.inflateInit2(this.strm,g.windowBits);if(f!==l.Z_OK)throw new Error(c[f]);this.header=new d,s.inflateGetHeader(this.strm,this.header)}function A(m,g){var f=new u(g);if(f.push(m,!0),f.err)throw f.msg||c[f.err];return f.result}u.prototype.push=function(m,g){var f,v,b,y,M,_,S=this.strm,w=this.options.chunkSize,E=this.options.dictionary,I=!1;if(this.ended)return!1;v=g===~~g?g:g===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof m=="string"?S.input=o.binstring2buf(m):p.call(m)==="[object ArrayBuffer]"?S.input=new Uint8Array(m):S.input=m,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new a.Buf8(w),S.next_out=0,S.avail_out=w),(f=s.inflate(S,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&E&&(_=typeof E=="string"?o.string2buf(E):p.call(E)==="[object ArrayBuffer]"?new Uint8Array(E):E,f=s.inflateSetDictionary(this.strm,_)),f===l.Z_BUF_ERROR&&I===!0&&(f=l.Z_OK,I=!1),f!==l.Z_STREAM_END&&f!==l.Z_OK)return this.onEnd(f),!(this.ended=!0);S.next_out&&(S.avail_out!==0&&f!==l.Z_STREAM_END&&(S.avail_in!==0||v!==l.Z_FINISH&&v!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(b=o.utf8border(S.output,S.next_out),y=S.next_out-b,M=o.buf2string(S.output,b),S.next_out=y,S.avail_out=w-y,y&&a.arraySet(S.output,S.output,b,y,0),this.onData(M)):this.onData(a.shrinkBuf(S.output,S.next_out)))),S.avail_in===0&&S.avail_out===0&&(I=!0)}while((0<S.avail_in||S.avail_out===0)&&f!==l.Z_STREAM_END);return f===l.Z_STREAM_END&&(v=l.Z_FINISH),v===l.Z_FINISH?(f=s.inflateEnd(this.strm),this.onEnd(f),this.ended=!0,f===l.Z_OK):v!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(S.avail_out=0))},u.prototype.onData=function(m){this.chunks.push(m)},u.prototype.onEnd=function(m){m===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},n.Inflate=u,n.inflate=A,n.inflateRaw=function(m,g){return(g=g||{}).raw=!0,A(m,g)},n.ungzip=A},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(t,i,n){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";n.assign=function(l){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var h=c.shift();if(h){if(typeof h!="object")throw new TypeError(h+"must be non-object");for(var d in h)h.hasOwnProperty(d)&&(l[d]=h[d])}}return l},n.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var a={arraySet:function(l,c,h,d,p){if(c.subarray&&l.subarray)l.set(c.subarray(h,h+d),p);else for(var u=0;u<d;u++)l[p+u]=c[h+u]},flattenChunks:function(l){var c,h,d,p,u,A;for(c=d=0,h=l.length;c<h;c++)d+=l[c].length;for(A=new Uint8Array(d),c=p=0,h=l.length;c<h;c++)u=l[c],A.set(u,p),p+=u.length;return A}},o={arraySet:function(l,c,h,d,p){for(var u=0;u<d;u++)l[p+u]=c[h+u]},flattenChunks:function(l){return[].concat.apply([],l)}};n.setTyped=function(l){l?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,a)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,o))},n.setTyped(s)},{}],42:[function(t,i,n){var s=t("./common"),a=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var l=new s.Buf8(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function h(d,p){if(p<65537&&(d.subarray&&o||!d.subarray&&a))return String.fromCharCode.apply(null,s.shrinkBuf(d,p));for(var u="",A=0;A<p;A++)u+=String.fromCharCode(d[A]);return u}l[254]=l[254]=1,n.string2buf=function(d){var p,u,A,m,g,f=d.length,v=0;for(m=0;m<f;m++)(64512&(u=d.charCodeAt(m)))==55296&&m+1<f&&(64512&(A=d.charCodeAt(m+1)))==56320&&(u=65536+(u-55296<<10)+(A-56320),m++),v+=u<128?1:u<2048?2:u<65536?3:4;for(p=new s.Buf8(v),m=g=0;g<v;m++)(64512&(u=d.charCodeAt(m)))==55296&&m+1<f&&(64512&(A=d.charCodeAt(m+1)))==56320&&(u=65536+(u-55296<<10)+(A-56320),m++),u<128?p[g++]=u:(u<2048?p[g++]=192|u>>>6:(u<65536?p[g++]=224|u>>>12:(p[g++]=240|u>>>18,p[g++]=128|u>>>12&63),p[g++]=128|u>>>6&63),p[g++]=128|63&u);return p},n.buf2binstring=function(d){return h(d,d.length)},n.binstring2buf=function(d){for(var p=new s.Buf8(d.length),u=0,A=p.length;u<A;u++)p[u]=d.charCodeAt(u);return p},n.buf2string=function(d,p){var u,A,m,g,f=p||d.length,v=new Array(2*f);for(u=A=0;u<f;)if((m=d[u++])<128)v[A++]=m;else if(4<(g=l[m]))v[A++]=65533,u+=g-1;else{for(m&=g===2?31:g===3?15:7;1<g&&u<f;)m=m<<6|63&d[u++],g--;1<g?v[A++]=65533:m<65536?v[A++]=m:(m-=65536,v[A++]=55296|m>>10&1023,v[A++]=56320|1023&m)}return h(v,A)},n.utf8border=function(d,p){var u;for((p=p||d.length)>d.length&&(p=d.length),u=p-1;0<=u&&(192&d[u])==128;)u--;return u<0||u===0?p:u+l[d[u]]>p?u:p}},{"./common":41}],43:[function(t,i,n){i.exports=function(s,a,o,l){for(var c=65535&s|0,h=s>>>16&65535|0,d=0;o!==0;){for(o-=d=2e3<o?2e3:o;h=h+(c=c+a[l++]|0)|0,--d;);c%=65521,h%=65521}return c|h<<16|0}},{}],44:[function(t,i,n){i.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(t,i,n){var s=(function(){for(var a,o=[],l=0;l<256;l++){a=l;for(var c=0;c<8;c++)a=1&a?3988292384^a>>>1:a>>>1;o[l]=a}return o})();i.exports=function(a,o,l,c){var h=s,d=c+l;a^=-1;for(var p=c;p<d;p++)a=a>>>8^h[255&(a^o[p])];return-1^a}},{}],46:[function(t,i,n){var s,a=t("../utils/common"),o=t("./trees"),l=t("./adler32"),c=t("./crc32"),h=t("./messages"),d=0,p=4,u=0,A=-2,m=-1,g=4,f=2,v=8,b=9,y=286,M=30,_=19,S=2*y+1,w=15,E=3,I=258,B=I+E+1,R=42,U=113,C=1,F=2,O=3,H=4;function j(D,ae){return D.msg=h[ae],ae}function G(D){return(D<<1)-(4<D?9:0)}function re(D){for(var ae=D.length;0<=--ae;)D[ae]=0}function q(D){var ae=D.state,$=ae.pending;$>D.avail_out&&($=D.avail_out),$!==0&&(a.arraySet(D.output,ae.pending_buf,ae.pending_out,$,D.next_out),D.next_out+=$,ae.pending_out+=$,D.total_out+=$,D.avail_out-=$,ae.pending-=$,ae.pending===0&&(ae.pending_out=0))}function Y(D,ae){o._tr_flush_block(D,0<=D.block_start?D.block_start:-1,D.strstart-D.block_start,ae),D.block_start=D.strstart,q(D.strm)}function ye(D,ae){D.pending_buf[D.pending++]=ae}function Me(D,ae){D.pending_buf[D.pending++]=ae>>>8&255,D.pending_buf[D.pending++]=255&ae}function xe(D,ae){var $,Q,L=D.max_chain_length,te=D.strstart,de=D.prev_length,V=D.nice_match,ee=D.strstart>D.w_size-B?D.strstart-(D.w_size-B):0,P=D.window,x=D.w_mask,N=D.prev,X=D.strstart+I,Z=P[te+de-1],K=P[te+de];D.prev_length>=D.good_match&&(L>>=2),V>D.lookahead&&(V=D.lookahead);do if(P[($=ae)+de]===K&&P[$+de-1]===Z&&P[$]===P[te]&&P[++$]===P[te+1]){te+=2,$++;do;while(P[++te]===P[++$]&&P[++te]===P[++$]&&P[++te]===P[++$]&&P[++te]===P[++$]&&P[++te]===P[++$]&&P[++te]===P[++$]&&P[++te]===P[++$]&&P[++te]===P[++$]&&te<X);if(Q=I-(X-te),te=X-I,de<Q){if(D.match_start=ae,V<=(de=Q))break;Z=P[te+de-1],K=P[te+de]}}while((ae=N[ae&x])>ee&&--L!=0);return de<=D.lookahead?de:D.lookahead}function J(D){var ae,$,Q,L,te,de,V,ee,P,x,N=D.w_size;do{if(L=D.window_size-D.lookahead-D.strstart,D.strstart>=N+(N-B)){for(a.arraySet(D.window,D.window,N,N,0),D.match_start-=N,D.strstart-=N,D.block_start-=N,ae=$=D.hash_size;Q=D.head[--ae],D.head[ae]=N<=Q?Q-N:0,--$;);for(ae=$=N;Q=D.prev[--ae],D.prev[ae]=N<=Q?Q-N:0,--$;);L+=N}if(D.strm.avail_in===0)break;if(de=D.strm,V=D.window,ee=D.strstart+D.lookahead,P=L,x=void 0,x=de.avail_in,P<x&&(x=P),$=x===0?0:(de.avail_in-=x,a.arraySet(V,de.input,de.next_in,x,ee),de.state.wrap===1?de.adler=l(de.adler,V,x,ee):de.state.wrap===2&&(de.adler=c(de.adler,V,x,ee)),de.next_in+=x,de.total_in+=x,x),D.lookahead+=$,D.lookahead+D.insert>=E)for(te=D.strstart-D.insert,D.ins_h=D.window[te],D.ins_h=(D.ins_h<<D.hash_shift^D.window[te+1])&D.hash_mask;D.insert&&(D.ins_h=(D.ins_h<<D.hash_shift^D.window[te+E-1])&D.hash_mask,D.prev[te&D.w_mask]=D.head[D.ins_h],D.head[D.ins_h]=te,te++,D.insert--,!(D.lookahead+D.insert<E)););}while(D.lookahead<B&&D.strm.avail_in!==0)}function oe(D,ae){for(var $,Q;;){if(D.lookahead<B){if(J(D),D.lookahead<B&&ae===d)return C;if(D.lookahead===0)break}if($=0,D.lookahead>=E&&(D.ins_h=(D.ins_h<<D.hash_shift^D.window[D.strstart+E-1])&D.hash_mask,$=D.prev[D.strstart&D.w_mask]=D.head[D.ins_h],D.head[D.ins_h]=D.strstart),$!==0&&D.strstart-$<=D.w_size-B&&(D.match_length=xe(D,$)),D.match_length>=E)if(Q=o._tr_tally(D,D.strstart-D.match_start,D.match_length-E),D.lookahead-=D.match_length,D.match_length<=D.max_lazy_match&&D.lookahead>=E){for(D.match_length--;D.strstart++,D.ins_h=(D.ins_h<<D.hash_shift^D.window[D.strstart+E-1])&D.hash_mask,$=D.prev[D.strstart&D.w_mask]=D.head[D.ins_h],D.head[D.ins_h]=D.strstart,--D.match_length!=0;);D.strstart++}else D.strstart+=D.match_length,D.match_length=0,D.ins_h=D.window[D.strstart],D.ins_h=(D.ins_h<<D.hash_shift^D.window[D.strstart+1])&D.hash_mask;else Q=o._tr_tally(D,0,D.window[D.strstart]),D.lookahead--,D.strstart++;if(Q&&(Y(D,!1),D.strm.avail_out===0))return C}return D.insert=D.strstart<E-1?D.strstart:E-1,ae===p?(Y(D,!0),D.strm.avail_out===0?O:H):D.last_lit&&(Y(D,!1),D.strm.avail_out===0)?C:F}function ue(D,ae){for(var $,Q,L;;){if(D.lookahead<B){if(J(D),D.lookahead<B&&ae===d)return C;if(D.lookahead===0)break}if($=0,D.lookahead>=E&&(D.ins_h=(D.ins_h<<D.hash_shift^D.window[D.strstart+E-1])&D.hash_mask,$=D.prev[D.strstart&D.w_mask]=D.head[D.ins_h],D.head[D.ins_h]=D.strstart),D.prev_length=D.match_length,D.prev_match=D.match_start,D.match_length=E-1,$!==0&&D.prev_length<D.max_lazy_match&&D.strstart-$<=D.w_size-B&&(D.match_length=xe(D,$),D.match_length<=5&&(D.strategy===1||D.match_length===E&&4096<D.strstart-D.match_start)&&(D.match_length=E-1)),D.prev_length>=E&&D.match_length<=D.prev_length){for(L=D.strstart+D.lookahead-E,Q=o._tr_tally(D,D.strstart-1-D.prev_match,D.prev_length-E),D.lookahead-=D.prev_length-1,D.prev_length-=2;++D.strstart<=L&&(D.ins_h=(D.ins_h<<D.hash_shift^D.window[D.strstart+E-1])&D.hash_mask,$=D.prev[D.strstart&D.w_mask]=D.head[D.ins_h],D.head[D.ins_h]=D.strstart),--D.prev_length!=0;);if(D.match_available=0,D.match_length=E-1,D.strstart++,Q&&(Y(D,!1),D.strm.avail_out===0))return C}else if(D.match_available){if((Q=o._tr_tally(D,0,D.window[D.strstart-1]))&&Y(D,!1),D.strstart++,D.lookahead--,D.strm.avail_out===0)return C}else D.match_available=1,D.strstart++,D.lookahead--}return D.match_available&&(Q=o._tr_tally(D,0,D.window[D.strstart-1]),D.match_available=0),D.insert=D.strstart<E-1?D.strstart:E-1,ae===p?(Y(D,!0),D.strm.avail_out===0?O:H):D.last_lit&&(Y(D,!1),D.strm.avail_out===0)?C:F}function Pe(D,ae,$,Q,L){this.good_length=D,this.max_lazy=ae,this.nice_length=$,this.max_chain=Q,this.func=L}function Be(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=v,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*S),this.dyn_dtree=new a.Buf16(2*(2*M+1)),this.bl_tree=new a.Buf16(2*(2*_+1)),re(this.dyn_ltree),re(this.dyn_dtree),re(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(w+1),this.heap=new a.Buf16(2*y+1),re(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*y+1),re(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Ue(D){var ae;return D&&D.state?(D.total_in=D.total_out=0,D.data_type=f,(ae=D.state).pending=0,ae.pending_out=0,ae.wrap<0&&(ae.wrap=-ae.wrap),ae.status=ae.wrap?R:U,D.adler=ae.wrap===2?0:1,ae.last_flush=d,o._tr_init(ae),u):j(D,A)}function it(D){var ae=Ue(D);return ae===u&&(function($){$.window_size=2*$.w_size,re($.head),$.max_lazy_match=s[$.level].max_lazy,$.good_match=s[$.level].good_length,$.nice_match=s[$.level].nice_length,$.max_chain_length=s[$.level].max_chain,$.strstart=0,$.block_start=0,$.lookahead=0,$.insert=0,$.match_length=$.prev_length=E-1,$.match_available=0,$.ins_h=0})(D.state),ae}function qe(D,ae,$,Q,L,te){if(!D)return A;var de=1;if(ae===m&&(ae=6),Q<0?(de=0,Q=-Q):15<Q&&(de=2,Q-=16),L<1||b<L||$!==v||Q<8||15<Q||ae<0||9<ae||te<0||g<te)return j(D,A);Q===8&&(Q=9);var V=new Be;return(D.state=V).strm=D,V.wrap=de,V.gzhead=null,V.w_bits=Q,V.w_size=1<<V.w_bits,V.w_mask=V.w_size-1,V.hash_bits=L+7,V.hash_size=1<<V.hash_bits,V.hash_mask=V.hash_size-1,V.hash_shift=~~((V.hash_bits+E-1)/E),V.window=new a.Buf8(2*V.w_size),V.head=new a.Buf16(V.hash_size),V.prev=new a.Buf16(V.w_size),V.lit_bufsize=1<<L+6,V.pending_buf_size=4*V.lit_bufsize,V.pending_buf=new a.Buf8(V.pending_buf_size),V.d_buf=1*V.lit_bufsize,V.l_buf=3*V.lit_bufsize,V.level=ae,V.strategy=te,V.method=$,it(D)}s=[new Pe(0,0,0,0,function(D,ae){var $=65535;for($>D.pending_buf_size-5&&($=D.pending_buf_size-5);;){if(D.lookahead<=1){if(J(D),D.lookahead===0&&ae===d)return C;if(D.lookahead===0)break}D.strstart+=D.lookahead,D.lookahead=0;var Q=D.block_start+$;if((D.strstart===0||D.strstart>=Q)&&(D.lookahead=D.strstart-Q,D.strstart=Q,Y(D,!1),D.strm.avail_out===0)||D.strstart-D.block_start>=D.w_size-B&&(Y(D,!1),D.strm.avail_out===0))return C}return D.insert=0,ae===p?(Y(D,!0),D.strm.avail_out===0?O:H):(D.strstart>D.block_start&&(Y(D,!1),D.strm.avail_out),C)}),new Pe(4,4,8,4,oe),new Pe(4,5,16,8,oe),new Pe(4,6,32,32,oe),new Pe(4,4,16,16,ue),new Pe(8,16,32,32,ue),new Pe(8,16,128,128,ue),new Pe(8,32,128,256,ue),new Pe(32,128,258,1024,ue),new Pe(32,258,258,4096,ue)],n.deflateInit=function(D,ae){return qe(D,ae,v,15,8,0)},n.deflateInit2=qe,n.deflateReset=it,n.deflateResetKeep=Ue,n.deflateSetHeader=function(D,ae){return D&&D.state?D.state.wrap!==2?A:(D.state.gzhead=ae,u):A},n.deflate=function(D,ae){var $,Q,L,te;if(!D||!D.state||5<ae||ae<0)return D?j(D,A):A;if(Q=D.state,!D.output||!D.input&&D.avail_in!==0||Q.status===666&&ae!==p)return j(D,D.avail_out===0?-5:A);if(Q.strm=D,$=Q.last_flush,Q.last_flush=ae,Q.status===R)if(Q.wrap===2)D.adler=0,ye(Q,31),ye(Q,139),ye(Q,8),Q.gzhead?(ye(Q,(Q.gzhead.text?1:0)+(Q.gzhead.hcrc?2:0)+(Q.gzhead.extra?4:0)+(Q.gzhead.name?8:0)+(Q.gzhead.comment?16:0)),ye(Q,255&Q.gzhead.time),ye(Q,Q.gzhead.time>>8&255),ye(Q,Q.gzhead.time>>16&255),ye(Q,Q.gzhead.time>>24&255),ye(Q,Q.level===9?2:2<=Q.strategy||Q.level<2?4:0),ye(Q,255&Q.gzhead.os),Q.gzhead.extra&&Q.gzhead.extra.length&&(ye(Q,255&Q.gzhead.extra.length),ye(Q,Q.gzhead.extra.length>>8&255)),Q.gzhead.hcrc&&(D.adler=c(D.adler,Q.pending_buf,Q.pending,0)),Q.gzindex=0,Q.status=69):(ye(Q,0),ye(Q,0),ye(Q,0),ye(Q,0),ye(Q,0),ye(Q,Q.level===9?2:2<=Q.strategy||Q.level<2?4:0),ye(Q,3),Q.status=U);else{var de=v+(Q.w_bits-8<<4)<<8;de|=(2<=Q.strategy||Q.level<2?0:Q.level<6?1:Q.level===6?2:3)<<6,Q.strstart!==0&&(de|=32),de+=31-de%31,Q.status=U,Me(Q,de),Q.strstart!==0&&(Me(Q,D.adler>>>16),Me(Q,65535&D.adler)),D.adler=1}if(Q.status===69)if(Q.gzhead.extra){for(L=Q.pending;Q.gzindex<(65535&Q.gzhead.extra.length)&&(Q.pending!==Q.pending_buf_size||(Q.gzhead.hcrc&&Q.pending>L&&(D.adler=c(D.adler,Q.pending_buf,Q.pending-L,L)),q(D),L=Q.pending,Q.pending!==Q.pending_buf_size));)ye(Q,255&Q.gzhead.extra[Q.gzindex]),Q.gzindex++;Q.gzhead.hcrc&&Q.pending>L&&(D.adler=c(D.adler,Q.pending_buf,Q.pending-L,L)),Q.gzindex===Q.gzhead.extra.length&&(Q.gzindex=0,Q.status=73)}else Q.status=73;if(Q.status===73)if(Q.gzhead.name){L=Q.pending;do{if(Q.pending===Q.pending_buf_size&&(Q.gzhead.hcrc&&Q.pending>L&&(D.adler=c(D.adler,Q.pending_buf,Q.pending-L,L)),q(D),L=Q.pending,Q.pending===Q.pending_buf_size)){te=1;break}te=Q.gzindex<Q.gzhead.name.length?255&Q.gzhead.name.charCodeAt(Q.gzindex++):0,ye(Q,te)}while(te!==0);Q.gzhead.hcrc&&Q.pending>L&&(D.adler=c(D.adler,Q.pending_buf,Q.pending-L,L)),te===0&&(Q.gzindex=0,Q.status=91)}else Q.status=91;if(Q.status===91)if(Q.gzhead.comment){L=Q.pending;do{if(Q.pending===Q.pending_buf_size&&(Q.gzhead.hcrc&&Q.pending>L&&(D.adler=c(D.adler,Q.pending_buf,Q.pending-L,L)),q(D),L=Q.pending,Q.pending===Q.pending_buf_size)){te=1;break}te=Q.gzindex<Q.gzhead.comment.length?255&Q.gzhead.comment.charCodeAt(Q.gzindex++):0,ye(Q,te)}while(te!==0);Q.gzhead.hcrc&&Q.pending>L&&(D.adler=c(D.adler,Q.pending_buf,Q.pending-L,L)),te===0&&(Q.status=103)}else Q.status=103;if(Q.status===103&&(Q.gzhead.hcrc?(Q.pending+2>Q.pending_buf_size&&q(D),Q.pending+2<=Q.pending_buf_size&&(ye(Q,255&D.adler),ye(Q,D.adler>>8&255),D.adler=0,Q.status=U)):Q.status=U),Q.pending!==0){if(q(D),D.avail_out===0)return Q.last_flush=-1,u}else if(D.avail_in===0&&G(ae)<=G($)&&ae!==p)return j(D,-5);if(Q.status===666&&D.avail_in!==0)return j(D,-5);if(D.avail_in!==0||Q.lookahead!==0||ae!==d&&Q.status!==666){var V=Q.strategy===2?(function(ee,P){for(var x;;){if(ee.lookahead===0&&(J(ee),ee.lookahead===0)){if(P===d)return C;break}if(ee.match_length=0,x=o._tr_tally(ee,0,ee.window[ee.strstart]),ee.lookahead--,ee.strstart++,x&&(Y(ee,!1),ee.strm.avail_out===0))return C}return ee.insert=0,P===p?(Y(ee,!0),ee.strm.avail_out===0?O:H):ee.last_lit&&(Y(ee,!1),ee.strm.avail_out===0)?C:F})(Q,ae):Q.strategy===3?(function(ee,P){for(var x,N,X,Z,K=ee.window;;){if(ee.lookahead<=I){if(J(ee),ee.lookahead<=I&&P===d)return C;if(ee.lookahead===0)break}if(ee.match_length=0,ee.lookahead>=E&&0<ee.strstart&&(N=K[X=ee.strstart-1])===K[++X]&&N===K[++X]&&N===K[++X]){Z=ee.strstart+I;do;while(N===K[++X]&&N===K[++X]&&N===K[++X]&&N===K[++X]&&N===K[++X]&&N===K[++X]&&N===K[++X]&&N===K[++X]&&X<Z);ee.match_length=I-(Z-X),ee.match_length>ee.lookahead&&(ee.match_length=ee.lookahead)}if(ee.match_length>=E?(x=o._tr_tally(ee,1,ee.match_length-E),ee.lookahead-=ee.match_length,ee.strstart+=ee.match_length,ee.match_length=0):(x=o._tr_tally(ee,0,ee.window[ee.strstart]),ee.lookahead--,ee.strstart++),x&&(Y(ee,!1),ee.strm.avail_out===0))return C}return ee.insert=0,P===p?(Y(ee,!0),ee.strm.avail_out===0?O:H):ee.last_lit&&(Y(ee,!1),ee.strm.avail_out===0)?C:F})(Q,ae):s[Q.level].func(Q,ae);if(V!==O&&V!==H||(Q.status=666),V===C||V===O)return D.avail_out===0&&(Q.last_flush=-1),u;if(V===F&&(ae===1?o._tr_align(Q):ae!==5&&(o._tr_stored_block(Q,0,0,!1),ae===3&&(re(Q.head),Q.lookahead===0&&(Q.strstart=0,Q.block_start=0,Q.insert=0))),q(D),D.avail_out===0))return Q.last_flush=-1,u}return ae!==p?u:Q.wrap<=0?1:(Q.wrap===2?(ye(Q,255&D.adler),ye(Q,D.adler>>8&255),ye(Q,D.adler>>16&255),ye(Q,D.adler>>24&255),ye(Q,255&D.total_in),ye(Q,D.total_in>>8&255),ye(Q,D.total_in>>16&255),ye(Q,D.total_in>>24&255)):(Me(Q,D.adler>>>16),Me(Q,65535&D.adler)),q(D),0<Q.wrap&&(Q.wrap=-Q.wrap),Q.pending!==0?u:1)},n.deflateEnd=function(D){var ae;return D&&D.state?(ae=D.state.status)!==R&&ae!==69&&ae!==73&&ae!==91&&ae!==103&&ae!==U&&ae!==666?j(D,A):(D.state=null,ae===U?j(D,-3):u):A},n.deflateSetDictionary=function(D,ae){var $,Q,L,te,de,V,ee,P,x=ae.length;if(!D||!D.state||(te=($=D.state).wrap)===2||te===1&&$.status!==R||$.lookahead)return A;for(te===1&&(D.adler=l(D.adler,ae,x,0)),$.wrap=0,x>=$.w_size&&(te===0&&(re($.head),$.strstart=0,$.block_start=0,$.insert=0),P=new a.Buf8($.w_size),a.arraySet(P,ae,x-$.w_size,$.w_size,0),ae=P,x=$.w_size),de=D.avail_in,V=D.next_in,ee=D.input,D.avail_in=x,D.next_in=0,D.input=ae,J($);$.lookahead>=E;){for(Q=$.strstart,L=$.lookahead-(E-1);$.ins_h=($.ins_h<<$.hash_shift^$.window[Q+E-1])&$.hash_mask,$.prev[Q&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=Q,Q++,--L;);$.strstart=Q,$.lookahead=E-1,J($)}return $.strstart+=$.lookahead,$.block_start=$.strstart,$.insert=$.lookahead,$.lookahead=0,$.match_length=$.prev_length=E-1,$.match_available=0,D.next_in=V,D.input=ee,D.avail_in=de,$.wrap=te,u},n.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(t,i,n){i.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(t,i,n){i.exports=function(s,a){var o,l,c,h,d,p,u,A,m,g,f,v,b,y,M,_,S,w,E,I,B,R,U,C,F;o=s.state,l=s.next_in,C=s.input,c=l+(s.avail_in-5),h=s.next_out,F=s.output,d=h-(a-s.avail_out),p=h+(s.avail_out-257),u=o.dmax,A=o.wsize,m=o.whave,g=o.wnext,f=o.window,v=o.hold,b=o.bits,y=o.lencode,M=o.distcode,_=(1<<o.lenbits)-1,S=(1<<o.distbits)-1;e:do{b<15&&(v+=C[l++]<<b,b+=8,v+=C[l++]<<b,b+=8),w=y[v&_];t:for(;;){if(v>>>=E=w>>>24,b-=E,(E=w>>>16&255)===0)F[h++]=65535&w;else{if(!(16&E)){if((64&E)==0){w=y[(65535&w)+(v&(1<<E)-1)];continue t}if(32&E){o.mode=12;break e}s.msg="invalid literal/length code",o.mode=30;break e}I=65535&w,(E&=15)&&(b<E&&(v+=C[l++]<<b,b+=8),I+=v&(1<<E)-1,v>>>=E,b-=E),b<15&&(v+=C[l++]<<b,b+=8,v+=C[l++]<<b,b+=8),w=M[v&S];i:for(;;){if(v>>>=E=w>>>24,b-=E,!(16&(E=w>>>16&255))){if((64&E)==0){w=M[(65535&w)+(v&(1<<E)-1)];continue i}s.msg="invalid distance code",o.mode=30;break e}if(B=65535&w,b<(E&=15)&&(v+=C[l++]<<b,(b+=8)<E&&(v+=C[l++]<<b,b+=8)),u<(B+=v&(1<<E)-1)){s.msg="invalid distance too far back",o.mode=30;break e}if(v>>>=E,b-=E,(E=h-d)<B){if(m<(E=B-E)&&o.sane){s.msg="invalid distance too far back",o.mode=30;break e}if(U=f,(R=0)===g){if(R+=A-E,E<I){for(I-=E;F[h++]=f[R++],--E;);R=h-B,U=F}}else if(g<E){if(R+=A+g-E,(E-=g)<I){for(I-=E;F[h++]=f[R++],--E;);if(R=0,g<I){for(I-=E=g;F[h++]=f[R++],--E;);R=h-B,U=F}}}else if(R+=g-E,E<I){for(I-=E;F[h++]=f[R++],--E;);R=h-B,U=F}for(;2<I;)F[h++]=U[R++],F[h++]=U[R++],F[h++]=U[R++],I-=3;I&&(F[h++]=U[R++],1<I&&(F[h++]=U[R++]))}else{for(R=h-B;F[h++]=F[R++],F[h++]=F[R++],F[h++]=F[R++],2<(I-=3););I&&(F[h++]=F[R++],1<I&&(F[h++]=F[R++]))}break}}break}}while(l<c&&h<p);l-=I=b>>3,v&=(1<<(b-=I<<3))-1,s.next_in=l,s.next_out=h,s.avail_in=l<c?c-l+5:5-(l-c),s.avail_out=h<p?p-h+257:257-(h-p),o.hold=v,o.bits=b}},{}],49:[function(t,i,n){var s=t("../utils/common"),a=t("./adler32"),o=t("./crc32"),l=t("./inffast"),c=t("./inftrees"),h=1,d=2,p=0,u=-2,A=1,m=852,g=592;function f(R){return(R>>>24&255)+(R>>>8&65280)+((65280&R)<<8)+((255&R)<<24)}function v(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function b(R){var U;return R&&R.state?(U=R.state,R.total_in=R.total_out=U.total=0,R.msg="",U.wrap&&(R.adler=1&U.wrap),U.mode=A,U.last=0,U.havedict=0,U.dmax=32768,U.head=null,U.hold=0,U.bits=0,U.lencode=U.lendyn=new s.Buf32(m),U.distcode=U.distdyn=new s.Buf32(g),U.sane=1,U.back=-1,p):u}function y(R){var U;return R&&R.state?((U=R.state).wsize=0,U.whave=0,U.wnext=0,b(R)):u}function M(R,U){var C,F;return R&&R.state?(F=R.state,U<0?(C=0,U=-U):(C=1+(U>>4),U<48&&(U&=15)),U&&(U<8||15<U)?u:(F.window!==null&&F.wbits!==U&&(F.window=null),F.wrap=C,F.wbits=U,y(R))):u}function _(R,U){var C,F;return R?(F=new v,(R.state=F).window=null,(C=M(R,U))!==p&&(R.state=null),C):u}var S,w,E=!0;function I(R){if(E){var U;for(S=new s.Buf32(512),w=new s.Buf32(32),U=0;U<144;)R.lens[U++]=8;for(;U<256;)R.lens[U++]=9;for(;U<280;)R.lens[U++]=7;for(;U<288;)R.lens[U++]=8;for(c(h,R.lens,0,288,S,0,R.work,{bits:9}),U=0;U<32;)R.lens[U++]=5;c(d,R.lens,0,32,w,0,R.work,{bits:5}),E=!1}R.lencode=S,R.lenbits=9,R.distcode=w,R.distbits=5}function B(R,U,C,F){var O,H=R.state;return H.window===null&&(H.wsize=1<<H.wbits,H.wnext=0,H.whave=0,H.window=new s.Buf8(H.wsize)),F>=H.wsize?(s.arraySet(H.window,U,C-H.wsize,H.wsize,0),H.wnext=0,H.whave=H.wsize):(F<(O=H.wsize-H.wnext)&&(O=F),s.arraySet(H.window,U,C-F,O,H.wnext),(F-=O)?(s.arraySet(H.window,U,C-F,F,0),H.wnext=F,H.whave=H.wsize):(H.wnext+=O,H.wnext===H.wsize&&(H.wnext=0),H.whave<H.wsize&&(H.whave+=O))),0}n.inflateReset=y,n.inflateReset2=M,n.inflateResetKeep=b,n.inflateInit=function(R){return _(R,15)},n.inflateInit2=_,n.inflate=function(R,U){var C,F,O,H,j,G,re,q,Y,ye,Me,xe,J,oe,ue,Pe,Be,Ue,it,qe,D,ae,$,Q,L=0,te=new s.Buf8(4),de=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!R||!R.state||!R.output||!R.input&&R.avail_in!==0)return u;(C=R.state).mode===12&&(C.mode=13),j=R.next_out,O=R.output,re=R.avail_out,H=R.next_in,F=R.input,G=R.avail_in,q=C.hold,Y=C.bits,ye=G,Me=re,ae=p;e:for(;;)switch(C.mode){case A:if(C.wrap===0){C.mode=13;break}for(;Y<16;){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}if(2&C.wrap&&q===35615){te[C.check=0]=255&q,te[1]=q>>>8&255,C.check=o(C.check,te,2,0),Y=q=0,C.mode=2;break}if(C.flags=0,C.head&&(C.head.done=!1),!(1&C.wrap)||(((255&q)<<8)+(q>>8))%31){R.msg="incorrect header check",C.mode=30;break}if((15&q)!=8){R.msg="unknown compression method",C.mode=30;break}if(Y-=4,D=8+(15&(q>>>=4)),C.wbits===0)C.wbits=D;else if(D>C.wbits){R.msg="invalid window size",C.mode=30;break}C.dmax=1<<D,R.adler=C.check=1,C.mode=512&q?10:12,Y=q=0;break;case 2:for(;Y<16;){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}if(C.flags=q,(255&C.flags)!=8){R.msg="unknown compression method",C.mode=30;break}if(57344&C.flags){R.msg="unknown header flags set",C.mode=30;break}C.head&&(C.head.text=q>>8&1),512&C.flags&&(te[0]=255&q,te[1]=q>>>8&255,C.check=o(C.check,te,2,0)),Y=q=0,C.mode=3;case 3:for(;Y<32;){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}C.head&&(C.head.time=q),512&C.flags&&(te[0]=255&q,te[1]=q>>>8&255,te[2]=q>>>16&255,te[3]=q>>>24&255,C.check=o(C.check,te,4,0)),Y=q=0,C.mode=4;case 4:for(;Y<16;){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}C.head&&(C.head.xflags=255&q,C.head.os=q>>8),512&C.flags&&(te[0]=255&q,te[1]=q>>>8&255,C.check=o(C.check,te,2,0)),Y=q=0,C.mode=5;case 5:if(1024&C.flags){for(;Y<16;){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}C.length=q,C.head&&(C.head.extra_len=q),512&C.flags&&(te[0]=255&q,te[1]=q>>>8&255,C.check=o(C.check,te,2,0)),Y=q=0}else C.head&&(C.head.extra=null);C.mode=6;case 6:if(1024&C.flags&&(G<(xe=C.length)&&(xe=G),xe&&(C.head&&(D=C.head.extra_len-C.length,C.head.extra||(C.head.extra=new Array(C.head.extra_len)),s.arraySet(C.head.extra,F,H,xe,D)),512&C.flags&&(C.check=o(C.check,F,xe,H)),G-=xe,H+=xe,C.length-=xe),C.length))break e;C.length=0,C.mode=7;case 7:if(2048&C.flags){if(G===0)break e;for(xe=0;D=F[H+xe++],C.head&&D&&C.length<65536&&(C.head.name+=String.fromCharCode(D)),D&&xe<G;);if(512&C.flags&&(C.check=o(C.check,F,xe,H)),G-=xe,H+=xe,D)break e}else C.head&&(C.head.name=null);C.length=0,C.mode=8;case 8:if(4096&C.flags){if(G===0)break e;for(xe=0;D=F[H+xe++],C.head&&D&&C.length<65536&&(C.head.comment+=String.fromCharCode(D)),D&&xe<G;);if(512&C.flags&&(C.check=o(C.check,F,xe,H)),G-=xe,H+=xe,D)break e}else C.head&&(C.head.comment=null);C.mode=9;case 9:if(512&C.flags){for(;Y<16;){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}if(q!==(65535&C.check)){R.msg="header crc mismatch",C.mode=30;break}Y=q=0}C.head&&(C.head.hcrc=C.flags>>9&1,C.head.done=!0),R.adler=C.check=0,C.mode=12;break;case 10:for(;Y<32;){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}R.adler=C.check=f(q),Y=q=0,C.mode=11;case 11:if(C.havedict===0)return R.next_out=j,R.avail_out=re,R.next_in=H,R.avail_in=G,C.hold=q,C.bits=Y,2;R.adler=C.check=1,C.mode=12;case 12:if(U===5||U===6)break e;case 13:if(C.last){q>>>=7&Y,Y-=7&Y,C.mode=27;break}for(;Y<3;){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}switch(C.last=1&q,Y-=1,3&(q>>>=1)){case 0:C.mode=14;break;case 1:if(I(C),C.mode=20,U!==6)break;q>>>=2,Y-=2;break e;case 2:C.mode=17;break;case 3:R.msg="invalid block type",C.mode=30}q>>>=2,Y-=2;break;case 14:for(q>>>=7&Y,Y-=7&Y;Y<32;){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}if((65535&q)!=(q>>>16^65535)){R.msg="invalid stored block lengths",C.mode=30;break}if(C.length=65535&q,Y=q=0,C.mode=15,U===6)break e;case 15:C.mode=16;case 16:if(xe=C.length){if(G<xe&&(xe=G),re<xe&&(xe=re),xe===0)break e;s.arraySet(O,F,H,xe,j),G-=xe,H+=xe,re-=xe,j+=xe,C.length-=xe;break}C.mode=12;break;case 17:for(;Y<14;){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}if(C.nlen=257+(31&q),q>>>=5,Y-=5,C.ndist=1+(31&q),q>>>=5,Y-=5,C.ncode=4+(15&q),q>>>=4,Y-=4,286<C.nlen||30<C.ndist){R.msg="too many length or distance symbols",C.mode=30;break}C.have=0,C.mode=18;case 18:for(;C.have<C.ncode;){for(;Y<3;){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}C.lens[de[C.have++]]=7&q,q>>>=3,Y-=3}for(;C.have<19;)C.lens[de[C.have++]]=0;if(C.lencode=C.lendyn,C.lenbits=7,$={bits:C.lenbits},ae=c(0,C.lens,0,19,C.lencode,0,C.work,$),C.lenbits=$.bits,ae){R.msg="invalid code lengths set",C.mode=30;break}C.have=0,C.mode=19;case 19:for(;C.have<C.nlen+C.ndist;){for(;Pe=(L=C.lencode[q&(1<<C.lenbits)-1])>>>16&255,Be=65535&L,!((ue=L>>>24)<=Y);){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}if(Be<16)q>>>=ue,Y-=ue,C.lens[C.have++]=Be;else{if(Be===16){for(Q=ue+2;Y<Q;){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}if(q>>>=ue,Y-=ue,C.have===0){R.msg="invalid bit length repeat",C.mode=30;break}D=C.lens[C.have-1],xe=3+(3&q),q>>>=2,Y-=2}else if(Be===17){for(Q=ue+3;Y<Q;){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}Y-=ue,D=0,xe=3+(7&(q>>>=ue)),q>>>=3,Y-=3}else{for(Q=ue+7;Y<Q;){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}Y-=ue,D=0,xe=11+(127&(q>>>=ue)),q>>>=7,Y-=7}if(C.have+xe>C.nlen+C.ndist){R.msg="invalid bit length repeat",C.mode=30;break}for(;xe--;)C.lens[C.have++]=D}}if(C.mode===30)break;if(C.lens[256]===0){R.msg="invalid code -- missing end-of-block",C.mode=30;break}if(C.lenbits=9,$={bits:C.lenbits},ae=c(h,C.lens,0,C.nlen,C.lencode,0,C.work,$),C.lenbits=$.bits,ae){R.msg="invalid literal/lengths set",C.mode=30;break}if(C.distbits=6,C.distcode=C.distdyn,$={bits:C.distbits},ae=c(d,C.lens,C.nlen,C.ndist,C.distcode,0,C.work,$),C.distbits=$.bits,ae){R.msg="invalid distances set",C.mode=30;break}if(C.mode=20,U===6)break e;case 20:C.mode=21;case 21:if(6<=G&&258<=re){R.next_out=j,R.avail_out=re,R.next_in=H,R.avail_in=G,C.hold=q,C.bits=Y,l(R,Me),j=R.next_out,O=R.output,re=R.avail_out,H=R.next_in,F=R.input,G=R.avail_in,q=C.hold,Y=C.bits,C.mode===12&&(C.back=-1);break}for(C.back=0;Pe=(L=C.lencode[q&(1<<C.lenbits)-1])>>>16&255,Be=65535&L,!((ue=L>>>24)<=Y);){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}if(Pe&&(240&Pe)==0){for(Ue=ue,it=Pe,qe=Be;Pe=(L=C.lencode[qe+((q&(1<<Ue+it)-1)>>Ue)])>>>16&255,Be=65535&L,!(Ue+(ue=L>>>24)<=Y);){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}q>>>=Ue,Y-=Ue,C.back+=Ue}if(q>>>=ue,Y-=ue,C.back+=ue,C.length=Be,Pe===0){C.mode=26;break}if(32&Pe){C.back=-1,C.mode=12;break}if(64&Pe){R.msg="invalid literal/length code",C.mode=30;break}C.extra=15&Pe,C.mode=22;case 22:if(C.extra){for(Q=C.extra;Y<Q;){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}C.length+=q&(1<<C.extra)-1,q>>>=C.extra,Y-=C.extra,C.back+=C.extra}C.was=C.length,C.mode=23;case 23:for(;Pe=(L=C.distcode[q&(1<<C.distbits)-1])>>>16&255,Be=65535&L,!((ue=L>>>24)<=Y);){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}if((240&Pe)==0){for(Ue=ue,it=Pe,qe=Be;Pe=(L=C.distcode[qe+((q&(1<<Ue+it)-1)>>Ue)])>>>16&255,Be=65535&L,!(Ue+(ue=L>>>24)<=Y);){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}q>>>=Ue,Y-=Ue,C.back+=Ue}if(q>>>=ue,Y-=ue,C.back+=ue,64&Pe){R.msg="invalid distance code",C.mode=30;break}C.offset=Be,C.extra=15&Pe,C.mode=24;case 24:if(C.extra){for(Q=C.extra;Y<Q;){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}C.offset+=q&(1<<C.extra)-1,q>>>=C.extra,Y-=C.extra,C.back+=C.extra}if(C.offset>C.dmax){R.msg="invalid distance too far back",C.mode=30;break}C.mode=25;case 25:if(re===0)break e;if(xe=Me-re,C.offset>xe){if((xe=C.offset-xe)>C.whave&&C.sane){R.msg="invalid distance too far back",C.mode=30;break}J=xe>C.wnext?(xe-=C.wnext,C.wsize-xe):C.wnext-xe,xe>C.length&&(xe=C.length),oe=C.window}else oe=O,J=j-C.offset,xe=C.length;for(re<xe&&(xe=re),re-=xe,C.length-=xe;O[j++]=oe[J++],--xe;);C.length===0&&(C.mode=21);break;case 26:if(re===0)break e;O[j++]=C.length,re--,C.mode=21;break;case 27:if(C.wrap){for(;Y<32;){if(G===0)break e;G--,q|=F[H++]<<Y,Y+=8}if(Me-=re,R.total_out+=Me,C.total+=Me,Me&&(R.adler=C.check=C.flags?o(C.check,O,Me,j-Me):a(C.check,O,Me,j-Me)),Me=re,(C.flags?q:f(q))!==C.check){R.msg="incorrect data check",C.mode=30;break}Y=q=0}C.mode=28;case 28:if(C.wrap&&C.flags){for(;Y<32;){if(G===0)break e;G--,q+=F[H++]<<Y,Y+=8}if(q!==(4294967295&C.total)){R.msg="incorrect length check",C.mode=30;break}Y=q=0}C.mode=29;case 29:ae=1;break e;case 30:ae=-3;break e;case 31:return-4;default:return u}return R.next_out=j,R.avail_out=re,R.next_in=H,R.avail_in=G,C.hold=q,C.bits=Y,(C.wsize||Me!==R.avail_out&&C.mode<30&&(C.mode<27||U!==4))&&B(R,R.output,R.next_out,Me-R.avail_out)?(C.mode=31,-4):(ye-=R.avail_in,Me-=R.avail_out,R.total_in+=ye,R.total_out+=Me,C.total+=Me,C.wrap&&Me&&(R.adler=C.check=C.flags?o(C.check,O,Me,R.next_out-Me):a(C.check,O,Me,R.next_out-Me)),R.data_type=C.bits+(C.last?64:0)+(C.mode===12?128:0)+(C.mode===20||C.mode===15?256:0),(ye==0&&Me===0||U===4)&&ae===p&&(ae=-5),ae)},n.inflateEnd=function(R){if(!R||!R.state)return u;var U=R.state;return U.window&&(U.window=null),R.state=null,p},n.inflateGetHeader=function(R,U){var C;return R&&R.state?(2&(C=R.state).wrap)==0?u:((C.head=U).done=!1,p):u},n.inflateSetDictionary=function(R,U){var C,F=U.length;return R&&R.state?(C=R.state).wrap!==0&&C.mode!==11?u:C.mode===11&&a(1,U,F,0)!==C.check?-3:B(R,U,F,F)?(C.mode=31,-4):(C.havedict=1,p):u},n.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(t,i,n){var s=t("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],c=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];i.exports=function(h,d,p,u,A,m,g,f){var v,b,y,M,_,S,w,E,I,B=f.bits,R=0,U=0,C=0,F=0,O=0,H=0,j=0,G=0,re=0,q=0,Y=null,ye=0,Me=new s.Buf16(16),xe=new s.Buf16(16),J=null,oe=0;for(R=0;R<=15;R++)Me[R]=0;for(U=0;U<u;U++)Me[d[p+U]]++;for(O=B,F=15;1<=F&&Me[F]===0;F--);if(F<O&&(O=F),F===0)return A[m++]=20971520,A[m++]=20971520,f.bits=1,0;for(C=1;C<F&&Me[C]===0;C++);for(O<C&&(O=C),R=G=1;R<=15;R++)if(G<<=1,(G-=Me[R])<0)return-1;if(0<G&&(h===0||F!==1))return-1;for(xe[1]=0,R=1;R<15;R++)xe[R+1]=xe[R]+Me[R];for(U=0;U<u;U++)d[p+U]!==0&&(g[xe[d[p+U]]++]=U);if(S=h===0?(Y=J=g,19):h===1?(Y=a,ye-=257,J=o,oe-=257,256):(Y=l,J=c,-1),R=C,_=m,j=U=q=0,y=-1,M=(re=1<<(H=O))-1,h===1&&852<re||h===2&&592<re)return 1;for(;;){for(w=R-j,I=g[U]<S?(E=0,g[U]):g[U]>S?(E=J[oe+g[U]],Y[ye+g[U]]):(E=96,0),v=1<<R-j,C=b=1<<H;A[_+(q>>j)+(b-=v)]=w<<24|E<<16|I|0,b!==0;);for(v=1<<R-1;q&v;)v>>=1;if(v!==0?(q&=v-1,q+=v):q=0,U++,--Me[R]==0){if(R===F)break;R=d[p+g[U]]}if(O<R&&(q&M)!==y){for(j===0&&(j=O),_+=C,G=1<<(H=R-j);H+j<F&&!((G-=Me[H+j])<=0);)H++,G<<=1;if(re+=1<<H,h===1&&852<re||h===2&&592<re)return 1;A[y=q&M]=O<<24|H<<16|_-m|0}}return q!==0&&(A[_+q]=R-j<<24|64<<16|0),f.bits=O,0}},{"../utils/common":41}],51:[function(t,i,n){i.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(t,i,n){var s=t("../utils/common"),a=0,o=1;function l(L){for(var te=L.length;0<=--te;)L[te]=0}var c=0,h=29,d=256,p=d+1+h,u=30,A=19,m=2*p+1,g=15,f=16,v=7,b=256,y=16,M=17,_=18,S=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],w=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],E=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],I=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],B=new Array(2*(p+2));l(B);var R=new Array(2*u);l(R);var U=new Array(512);l(U);var C=new Array(256);l(C);var F=new Array(h);l(F);var O,H,j,G=new Array(u);function re(L,te,de,V,ee){this.static_tree=L,this.extra_bits=te,this.extra_base=de,this.elems=V,this.max_length=ee,this.has_stree=L&&L.length}function q(L,te){this.dyn_tree=L,this.max_code=0,this.stat_desc=te}function Y(L){return L<256?U[L]:U[256+(L>>>7)]}function ye(L,te){L.pending_buf[L.pending++]=255&te,L.pending_buf[L.pending++]=te>>>8&255}function Me(L,te,de){L.bi_valid>f-de?(L.bi_buf|=te<<L.bi_valid&65535,ye(L,L.bi_buf),L.bi_buf=te>>f-L.bi_valid,L.bi_valid+=de-f):(L.bi_buf|=te<<L.bi_valid&65535,L.bi_valid+=de)}function xe(L,te,de){Me(L,de[2*te],de[2*te+1])}function J(L,te){for(var de=0;de|=1&L,L>>>=1,de<<=1,0<--te;);return de>>>1}function oe(L,te,de){var V,ee,P=new Array(g+1),x=0;for(V=1;V<=g;V++)P[V]=x=x+de[V-1]<<1;for(ee=0;ee<=te;ee++){var N=L[2*ee+1];N!==0&&(L[2*ee]=J(P[N]++,N))}}function ue(L){var te;for(te=0;te<p;te++)L.dyn_ltree[2*te]=0;for(te=0;te<u;te++)L.dyn_dtree[2*te]=0;for(te=0;te<A;te++)L.bl_tree[2*te]=0;L.dyn_ltree[2*b]=1,L.opt_len=L.static_len=0,L.last_lit=L.matches=0}function Pe(L){8<L.bi_valid?ye(L,L.bi_buf):0<L.bi_valid&&(L.pending_buf[L.pending++]=L.bi_buf),L.bi_buf=0,L.bi_valid=0}function Be(L,te,de,V){var ee=2*te,P=2*de;return L[ee]<L[P]||L[ee]===L[P]&&V[te]<=V[de]}function Ue(L,te,de){for(var V=L.heap[de],ee=de<<1;ee<=L.heap_len&&(ee<L.heap_len&&Be(te,L.heap[ee+1],L.heap[ee],L.depth)&&ee++,!Be(te,V,L.heap[ee],L.depth));)L.heap[de]=L.heap[ee],de=ee,ee<<=1;L.heap[de]=V}function it(L,te,de){var V,ee,P,x,N=0;if(L.last_lit!==0)for(;V=L.pending_buf[L.d_buf+2*N]<<8|L.pending_buf[L.d_buf+2*N+1],ee=L.pending_buf[L.l_buf+N],N++,V===0?xe(L,ee,te):(xe(L,(P=C[ee])+d+1,te),(x=S[P])!==0&&Me(L,ee-=F[P],x),xe(L,P=Y(--V),de),(x=w[P])!==0&&Me(L,V-=G[P],x)),N<L.last_lit;);xe(L,b,te)}function qe(L,te){var de,V,ee,P=te.dyn_tree,x=te.stat_desc.static_tree,N=te.stat_desc.has_stree,X=te.stat_desc.elems,Z=-1;for(L.heap_len=0,L.heap_max=m,de=0;de<X;de++)P[2*de]!==0?(L.heap[++L.heap_len]=Z=de,L.depth[de]=0):P[2*de+1]=0;for(;L.heap_len<2;)P[2*(ee=L.heap[++L.heap_len]=Z<2?++Z:0)]=1,L.depth[ee]=0,L.opt_len--,N&&(L.static_len-=x[2*ee+1]);for(te.max_code=Z,de=L.heap_len>>1;1<=de;de--)Ue(L,P,de);for(ee=X;de=L.heap[1],L.heap[1]=L.heap[L.heap_len--],Ue(L,P,1),V=L.heap[1],L.heap[--L.heap_max]=de,L.heap[--L.heap_max]=V,P[2*ee]=P[2*de]+P[2*V],L.depth[ee]=(L.depth[de]>=L.depth[V]?L.depth[de]:L.depth[V])+1,P[2*de+1]=P[2*V+1]=ee,L.heap[1]=ee++,Ue(L,P,1),2<=L.heap_len;);L.heap[--L.heap_max]=L.heap[1],(function(K,Ie){var ge,ke,Oe,le,Ae,ze,Ne=Ie.dyn_tree,we=Ie.max_code,je=Ie.stat_desc.static_tree,z=Ie.stat_desc.has_stree,ve=Ie.stat_desc.extra_bits,me=Ie.stat_desc.extra_base,Re=Ie.stat_desc.max_length,pe=0;for(le=0;le<=g;le++)K.bl_count[le]=0;for(Ne[2*K.heap[K.heap_max]+1]=0,ge=K.heap_max+1;ge<m;ge++)Re<(le=Ne[2*Ne[2*(ke=K.heap[ge])+1]+1]+1)&&(le=Re,pe++),Ne[2*ke+1]=le,we<ke||(K.bl_count[le]++,Ae=0,me<=ke&&(Ae=ve[ke-me]),ze=Ne[2*ke],K.opt_len+=ze*(le+Ae),z&&(K.static_len+=ze*(je[2*ke+1]+Ae)));if(pe!==0){do{for(le=Re-1;K.bl_count[le]===0;)le--;K.bl_count[le]--,K.bl_count[le+1]+=2,K.bl_count[Re]--,pe-=2}while(0<pe);for(le=Re;le!==0;le--)for(ke=K.bl_count[le];ke!==0;)we<(Oe=K.heap[--ge])||(Ne[2*Oe+1]!==le&&(K.opt_len+=(le-Ne[2*Oe+1])*Ne[2*Oe],Ne[2*Oe+1]=le),ke--)}})(L,te),oe(P,Z,L.bl_count)}function D(L,te,de){var V,ee,P=-1,x=te[1],N=0,X=7,Z=4;for(x===0&&(X=138,Z=3),te[2*(de+1)+1]=65535,V=0;V<=de;V++)ee=x,x=te[2*(V+1)+1],++N<X&&ee===x||(N<Z?L.bl_tree[2*ee]+=N:ee!==0?(ee!==P&&L.bl_tree[2*ee]++,L.bl_tree[2*y]++):N<=10?L.bl_tree[2*M]++:L.bl_tree[2*_]++,P=ee,Z=(N=0)===x?(X=138,3):ee===x?(X=6,3):(X=7,4))}function ae(L,te,de){var V,ee,P=-1,x=te[1],N=0,X=7,Z=4;for(x===0&&(X=138,Z=3),V=0;V<=de;V++)if(ee=x,x=te[2*(V+1)+1],!(++N<X&&ee===x)){if(N<Z)for(;xe(L,ee,L.bl_tree),--N!=0;);else ee!==0?(ee!==P&&(xe(L,ee,L.bl_tree),N--),xe(L,y,L.bl_tree),Me(L,N-3,2)):N<=10?(xe(L,M,L.bl_tree),Me(L,N-3,3)):(xe(L,_,L.bl_tree),Me(L,N-11,7));P=ee,Z=(N=0)===x?(X=138,3):ee===x?(X=6,3):(X=7,4)}}l(G);var $=!1;function Q(L,te,de,V){Me(L,(c<<1)+(V?1:0),3),(function(ee,P,x,N){Pe(ee),ye(ee,x),ye(ee,~x),s.arraySet(ee.pending_buf,ee.window,P,x,ee.pending),ee.pending+=x})(L,te,de)}n._tr_init=function(L){$||((function(){var te,de,V,ee,P,x=new Array(g+1);for(ee=V=0;ee<h-1;ee++)for(F[ee]=V,te=0;te<1<<S[ee];te++)C[V++]=ee;for(C[V-1]=ee,ee=P=0;ee<16;ee++)for(G[ee]=P,te=0;te<1<<w[ee];te++)U[P++]=ee;for(P>>=7;ee<u;ee++)for(G[ee]=P<<7,te=0;te<1<<w[ee]-7;te++)U[256+P++]=ee;for(de=0;de<=g;de++)x[de]=0;for(te=0;te<=143;)B[2*te+1]=8,te++,x[8]++;for(;te<=255;)B[2*te+1]=9,te++,x[9]++;for(;te<=279;)B[2*te+1]=7,te++,x[7]++;for(;te<=287;)B[2*te+1]=8,te++,x[8]++;for(oe(B,p+1,x),te=0;te<u;te++)R[2*te+1]=5,R[2*te]=J(te,5);O=new re(B,S,d+1,p,g),H=new re(R,w,0,u,g),j=new re(new Array(0),E,0,A,v)})(),$=!0),L.l_desc=new q(L.dyn_ltree,O),L.d_desc=new q(L.dyn_dtree,H),L.bl_desc=new q(L.bl_tree,j),L.bi_buf=0,L.bi_valid=0,ue(L)},n._tr_stored_block=Q,n._tr_flush_block=function(L,te,de,V){var ee,P,x=0;0<L.level?(L.strm.data_type===2&&(L.strm.data_type=(function(N){var X,Z=4093624447;for(X=0;X<=31;X++,Z>>>=1)if(1&Z&&N.dyn_ltree[2*X]!==0)return a;if(N.dyn_ltree[18]!==0||N.dyn_ltree[20]!==0||N.dyn_ltree[26]!==0)return o;for(X=32;X<d;X++)if(N.dyn_ltree[2*X]!==0)return o;return a})(L)),qe(L,L.l_desc),qe(L,L.d_desc),x=(function(N){var X;for(D(N,N.dyn_ltree,N.l_desc.max_code),D(N,N.dyn_dtree,N.d_desc.max_code),qe(N,N.bl_desc),X=A-1;3<=X&&N.bl_tree[2*I[X]+1]===0;X--);return N.opt_len+=3*(X+1)+5+5+4,X})(L),ee=L.opt_len+3+7>>>3,(P=L.static_len+3+7>>>3)<=ee&&(ee=P)):ee=P=de+5,de+4<=ee&&te!==-1?Q(L,te,de,V):L.strategy===4||P===ee?(Me(L,2+(V?1:0),3),it(L,B,R)):(Me(L,4+(V?1:0),3),(function(N,X,Z,K){var Ie;for(Me(N,X-257,5),Me(N,Z-1,5),Me(N,K-4,4),Ie=0;Ie<K;Ie++)Me(N,N.bl_tree[2*I[Ie]+1],3);ae(N,N.dyn_ltree,X-1),ae(N,N.dyn_dtree,Z-1)})(L,L.l_desc.max_code+1,L.d_desc.max_code+1,x+1),it(L,L.dyn_ltree,L.dyn_dtree)),ue(L),V&&Pe(L)},n._tr_tally=function(L,te,de){return L.pending_buf[L.d_buf+2*L.last_lit]=te>>>8&255,L.pending_buf[L.d_buf+2*L.last_lit+1]=255&te,L.pending_buf[L.l_buf+L.last_lit]=255&de,L.last_lit++,te===0?L.dyn_ltree[2*de]++:(L.matches++,te--,L.dyn_ltree[2*(C[de]+d+1)]++,L.dyn_dtree[2*Y(te)]++),L.last_lit===L.lit_bufsize-1},n._tr_align=function(L){Me(L,2,3),xe(L,b,B),(function(te){te.bi_valid===16?(ye(te,te.bi_buf),te.bi_buf=0,te.bi_valid=0):8<=te.bi_valid&&(te.pending_buf[te.pending++]=255&te.bi_buf,te.bi_buf>>=8,te.bi_valid-=8)})(L)}},{"../utils/common":41}],53:[function(t,i,n){i.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,i,n){(function(s){(function(a,o){if(!a.setImmediate){var l,c,h,d,p=1,u={},A=!1,m=a.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(a);g=g&&g.setTimeout?g:a,l={}.toString.call(a.process)==="[object process]"?function(y){process.nextTick(function(){v(y)})}:(function(){if(a.postMessage&&!a.importScripts){var y=!0,M=a.onmessage;return a.onmessage=function(){y=!1},a.postMessage("","*"),a.onmessage=M,y}})()?(d="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",b,!1):a.attachEvent("onmessage",b),function(y){a.postMessage(d+y,"*")}):a.MessageChannel?((h=new MessageChannel).port1.onmessage=function(y){v(y.data)},function(y){h.port2.postMessage(y)}):m&&"onreadystatechange"in m.createElement("script")?(c=m.documentElement,function(y){var M=m.createElement("script");M.onreadystatechange=function(){v(y),M.onreadystatechange=null,c.removeChild(M),M=null},c.appendChild(M)}):function(y){setTimeout(v,0,y)},g.setImmediate=function(y){typeof y!="function"&&(y=new Function(""+y));for(var M=new Array(arguments.length-1),_=0;_<M.length;_++)M[_]=arguments[_+1];var S={callback:y,args:M};return u[p]=S,l(p),p++},g.clearImmediate=f}function f(y){delete u[y]}function v(y){if(A)setTimeout(v,0,y);else{var M=u[y];if(M){A=!0;try{(function(_){var S=_.callback,w=_.args;switch(w.length){case 0:S();break;case 1:S(w[0]);break;case 2:S(w[0],w[1]);break;case 3:S(w[0],w[1],w[2]);break;default:S.apply(o,w)}})(M)}finally{f(y),A=!1}}}}function b(y){y.source===a&&typeof y.data=="string"&&y.data.indexOf(d)===0&&v(+y.data.slice(d.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof Wp<"u"?Wp:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(yx)),yx.exports}var p8=u8();const _x=bx(p8);function Ex(r,e){return function(){return r.apply(e,arguments)}}const{toString:f8}=Object.prototype,{getPrototypeOf:U0}=Object,{iterator:qp,toStringTag:Mx}=Symbol,Xp=(r=>e=>{const t=f8.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),gs=r=>(r=r.toLowerCase(),e=>Xp(e)===r),Yp=r=>e=>typeof e===r,{isArray:Ll}=Array,kl=Yp("undefined");function gh(r){return r!==null&&!kl(r)&&r.constructor!==null&&!kl(r.constructor)&&Mn(r.constructor.isBuffer)&&r.constructor.isBuffer(r)}const wx=gs("ArrayBuffer");function m8(r){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(r):e=r&&r.buffer&&wx(r.buffer),e}const g8=Yp("string"),Mn=Yp("function"),Sx=Yp("number"),Ah=r=>r!==null&&typeof r=="object",A8=r=>r===!0||r===!1,Kp=r=>{if(Xp(r)!=="object")return!1;const e=U0(r);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Mx in r)&&!(qp in r)},v8=r=>{if(!Ah(r)||gh(r))return!1;try{return Object.keys(r).length===0&&Object.getPrototypeOf(r)===Object.prototype}catch{return!1}},b8=gs("Date"),y8=gs("File"),x8=gs("Blob"),_8=gs("FileList"),E8=r=>Ah(r)&&Mn(r.pipe),M8=r=>{let e;return r&&(typeof FormData=="function"&&r instanceof FormData||Mn(r.append)&&((e=Xp(r))==="formdata"||e==="object"&&Mn(r.toString)&&r.toString()==="[object FormData]"))},w8=gs("URLSearchParams"),[S8,C8,T8,I8]=["ReadableStream","Request","Response","Headers"].map(gs),P8=r=>r.trim?r.trim():r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function vh(r,e,{allOwnKeys:t=!1}={}){if(r===null||typeof r>"u")return;let i,n;if(typeof r!="object"&&(r=[r]),Ll(r))for(i=0,n=r.length;i<n;i++)e.call(null,r[i],i,r);else{if(gh(r))return;const s=t?Object.getOwnPropertyNames(r):Object.keys(r),a=s.length;let o;for(i=0;i<a;i++)o=s[i],e.call(null,r[o],o,r)}}function Cx(r,e){if(gh(r))return null;e=e.toLowerCase();const t=Object.keys(r);let i=t.length,n;for(;i-- >0;)if(n=t[i],e===n.toLowerCase())return n;return null}const so=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Tx=r=>!kl(r)&&r!==so;function F0(){const{caseless:r,skipUndefined:e}=Tx(this)&&this||{},t={},i=(n,s)=>{const a=r&&Cx(t,s)||s;Kp(t[a])&&Kp(n)?t[a]=F0(t[a],n):Kp(n)?t[a]=F0({},n):Ll(n)?t[a]=n.slice():(!e||!kl(n))&&(t[a]=n)};for(let n=0,s=arguments.length;n<s;n++)arguments[n]&&vh(arguments[n],i);return t}const R8=(r,e,t,{allOwnKeys:i}={})=>(vh(e,(n,s)=>{t&&Mn(n)?r[s]=Ex(n,t):r[s]=n},{allOwnKeys:i}),r),D8=r=>(r.charCodeAt(0)===65279&&(r=r.slice(1)),r),B8=(r,e,t,i)=>{r.prototype=Object.create(e.prototype,i),r.prototype.constructor=r,Object.defineProperty(r,"super",{value:e.prototype}),t&&Object.assign(r.prototype,t)},L8=(r,e,t,i)=>{let n,s,a;const o={};if(e=e||{},r==null)return e;do{for(n=Object.getOwnPropertyNames(r),s=n.length;s-- >0;)a=n[s],(!i||i(a,r,e))&&!o[a]&&(e[a]=r[a],o[a]=!0);r=t!==!1&&U0(r)}while(r&&(!t||t(r,e))&&r!==Object.prototype);return e},k8=(r,e,t)=>{r=String(r),(t===void 0||t>r.length)&&(t=r.length),t-=e.length;const i=r.indexOf(e,t);return i!==-1&&i===t},N8=r=>{if(!r)return null;if(Ll(r))return r;let e=r.length;if(!Sx(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=r[e];return t},U8=(r=>e=>r&&e instanceof r)(typeof Uint8Array<"u"&&U0(Uint8Array)),F8=(r,e)=>{const t=(r&&r[qp]).call(r);let i;for(;(i=t.next())&&!i.done;){const n=i.value;e.call(r,n[0],n[1])}},O8=(r,e)=>{let t;const i=[];for(;(t=r.exec(e))!==null;)i.push(t);return i},z8=gs("HTMLFormElement"),H8=r=>r.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,i){return t.toUpperCase()+i}),Ix=(({hasOwnProperty:r})=>(e,t)=>r.call(e,t))(Object.prototype),G8=gs("RegExp"),Px=(r,e)=>{const t=Object.getOwnPropertyDescriptors(r),i={};vh(t,(n,s)=>{let a;(a=e(n,s,r))!==!1&&(i[s]=a||n)}),Object.defineProperties(r,i)},V8=r=>{Px(r,(e,t)=>{if(Mn(r)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const i=r[t];if(Mn(i)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},Q8=(r,e)=>{const t={},i=n=>{n.forEach(s=>{t[s]=!0})};return Ll(r)?i(r):i(String(r).split(e)),t},W8=()=>{},j8=(r,e)=>r!=null&&Number.isFinite(r=+r)?r:e;function q8(r){return!!(r&&Mn(r.append)&&r[Mx]==="FormData"&&r[qp])}const X8=r=>{const e=new Array(10),t=(i,n)=>{if(Ah(i)){if(e.indexOf(i)>=0)return;if(gh(i))return i;if(!("toJSON"in i)){e[n]=i;const s=Ll(i)?[]:{};return vh(i,(a,o)=>{const l=t(a,n+1);!kl(l)&&(s[o]=l)}),e[n]=void 0,s}}return i};return t(r,0)},Y8=gs("AsyncFunction"),K8=r=>r&&(Ah(r)||Mn(r))&&Mn(r.then)&&Mn(r.catch),Rx=((r,e)=>r?setImmediate:e?((t,i)=>(so.addEventListener("message",({source:n,data:s})=>{n===so&&s===t&&i.length&&i.shift()()},!1),n=>{i.push(n),so.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",Mn(so.postMessage)),Z8=typeof queueMicrotask<"u"?queueMicrotask.bind(so):typeof process<"u"&&process.nextTick||Rx,J8=r=>r!=null&&Mn(r[qp]),Ce={isArray:Ll,isArrayBuffer:wx,isBuffer:gh,isFormData:M8,isArrayBufferView:m8,isString:g8,isNumber:Sx,isBoolean:A8,isObject:Ah,isPlainObject:Kp,isEmptyObject:v8,isReadableStream:S8,isRequest:C8,isResponse:T8,isHeaders:I8,isUndefined:kl,isDate:b8,isFile:y8,isBlob:x8,isRegExp:G8,isFunction:Mn,isStream:E8,isURLSearchParams:w8,isTypedArray:U8,isFileList:_8,forEach:vh,merge:F0,extend:R8,trim:P8,stripBOM:D8,inherits:B8,toFlatObject:L8,kindOf:Xp,kindOfTest:gs,endsWith:k8,toArray:N8,forEachEntry:F8,matchAll:O8,isHTMLForm:z8,hasOwnProperty:Ix,hasOwnProp:Ix,reduceDescriptors:Px,freezeMethods:V8,toObjectSet:Q8,toCamelCase:H8,noop:W8,toFiniteNumber:j8,findKey:Cx,global:so,isContextDefined:Tx,isSpecCompliantForm:q8,toJSONObject:X8,isAsyncFn:Y8,isThenable:K8,setImmediate:Rx,asap:Z8,isIterable:J8};function vt(r,e,t,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=r,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}Ce.inherits(vt,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Ce.toJSONObject(this.config),code:this.code,status:this.status}}});const Dx=vt.prototype,Bx={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(r=>{Bx[r]={value:r}}),Object.defineProperties(vt,Bx),Object.defineProperty(Dx,"isAxiosError",{value:!0}),vt.from=(r,e,t,i,n,s)=>{const a=Object.create(Dx);Ce.toFlatObject(r,a,function(c){return c!==Error.prototype},c=>c!=="isAxiosError");const o=r&&r.message?r.message:"Error",l=e==null&&r?r.code:e;return vt.call(a,o,l,t,i,n),r&&a.cause==null&&Object.defineProperty(a,"cause",{value:r,configurable:!0}),a.name=r&&r.name||"Error",s&&Object.assign(a,s),a};const $8=null;function O0(r){return Ce.isPlainObject(r)||Ce.isArray(r)}function Lx(r){return Ce.endsWith(r,"[]")?r.slice(0,-2):r}function kx(r,e,t){return r?r.concat(e).map(function(i,n){return i=Lx(i),!t&&n?"["+i+"]":i}).join(t?".":""):e}function ek(r){return Ce.isArray(r)&&!r.some(O0)}const tk=Ce.toFlatObject(Ce,{},null,function(r){return/^is[A-Z]/.test(r)});function Zp(r,e,t){if(!Ce.isObject(r))throw new TypeError("target must be an object");e=e||new FormData,t=Ce.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(u,A){return!Ce.isUndefined(A[u])});const i=t.metaTokens,n=t.visitor||c,s=t.dots,a=t.indexes,o=(t.Blob||typeof Blob<"u"&&Blob)&&Ce.isSpecCompliantForm(e);if(!Ce.isFunction(n))throw new TypeError("visitor must be a function");function l(u){if(u===null)return"";if(Ce.isDate(u))return u.toISOString();if(Ce.isBoolean(u))return u.toString();if(!o&&Ce.isBlob(u))throw new vt("Blob is not supported. Use a Buffer instead.");return Ce.isArrayBuffer(u)||Ce.isTypedArray(u)?o&&typeof Blob=="function"?new Blob([u]):Buffer.from(u):u}function c(u,A,m){let g=u;if(u&&!m&&typeof u=="object"){if(Ce.endsWith(A,"{}"))A=i?A:A.slice(0,-2),u=JSON.stringify(u);else if(Ce.isArray(u)&&ek(u)||(Ce.isFileList(u)||Ce.endsWith(A,"[]"))&&(g=Ce.toArray(u)))return A=Lx(A),g.forEach(function(f,v){!(Ce.isUndefined(f)||f===null)&&e.append(a===!0?kx([A],v,s):a===null?A:A+"[]",l(f))}),!1}return O0(u)?!0:(e.append(kx(m,A,s),l(u)),!1)}const h=[],d=Object.assign(tk,{defaultVisitor:c,convertValue:l,isVisitable:O0});function p(u,A){if(!Ce.isUndefined(u)){if(h.indexOf(u)!==-1)throw Error("Circular reference detected in "+A.join("."));h.push(u),Ce.forEach(u,function(m,g){(!(Ce.isUndefined(m)||m===null)&&n.call(e,m,Ce.isString(g)?g.trim():g,A,d))===!0&&p(m,A?A.concat(g):[g])}),h.pop()}}if(!Ce.isObject(r))throw new TypeError("data must be an object");return p(r),e}function Nx(r){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(r).replace(/[!'()~]|%20|%00/g,function(t){return e[t]})}function z0(r,e){this._pairs=[],r&&Zp(r,this,e)}const Ux=z0.prototype;Ux.append=function(r,e){this._pairs.push([r,e])},Ux.toString=function(r){const e=r?function(t){return r.call(this,t,Nx)}:Nx;return this._pairs.map(function(t){return e(t[0])+"="+e(t[1])},"").join("&")};function ik(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Fx(r,e,t){if(!e)return r;const i=t&&t.encode||ik;Ce.isFunction(t)&&(t={serialize:t});const n=t&&t.serialize;let s;if(n?s=n(e,t):s=Ce.isURLSearchParams(e)?e.toString():new z0(e,t).toString(i),s){const a=r.indexOf("#");a!==-1&&(r=r.slice(0,a)),r+=(r.indexOf("?")===-1?"?":"&")+s}return r}class Ox{constructor(){this.handlers=[]}use(e,t,i){return this.handlers.push({fulfilled:e,rejected:t,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Ce.forEach(this.handlers,function(t){t!==null&&e(t)})}}const zx={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},nk=typeof URLSearchParams<"u"?URLSearchParams:z0,sk=typeof FormData<"u"?FormData:null,rk=typeof Blob<"u"?Blob:null,ak={isBrowser:!0,classes:{URLSearchParams:nk,FormData:sk,Blob:rk},protocols:["http","https","file","blob","url","data"]},H0=typeof window<"u"&&typeof document<"u",G0=typeof navigator=="object"&&navigator||void 0,ok=H0&&(!G0||["ReactNative","NativeScript","NS"].indexOf(G0.product)<0),lk=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",ck=H0&&window.location.href||"http://localhost",hk=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:H0,hasStandardBrowserEnv:ok,hasStandardBrowserWebWorkerEnv:lk,navigator:G0,origin:ck},Symbol.toStringTag,{value:"Module"})),an={...hk,...ak};function dk(r,e){return Zp(r,new an.classes.URLSearchParams,{visitor:function(t,i,n,s){return an.isNode&&Ce.isBuffer(t)?(this.append(i,t.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...e})}function uk(r){return Ce.matchAll(/\w+|\[(\w*)]/g,r).map(e=>e[0]==="[]"?"":e[1]||e[0])}function pk(r){const e={},t=Object.keys(r);let i;const n=t.length;let s;for(i=0;i<n;i++)s=t[i],e[s]=r[s];return e}function Hx(r){function e(t,i,n,s){let a=t[s++];if(a==="__proto__")return!0;const o=Number.isFinite(+a),l=s>=t.length;return a=!a&&Ce.isArray(n)?n.length:a,l?(Ce.hasOwnProp(n,a)?n[a]=[n[a],i]:n[a]=i,!o):((!n[a]||!Ce.isObject(n[a]))&&(n[a]=[]),e(t,i,n[a],s)&&Ce.isArray(n[a])&&(n[a]=pk(n[a])),!o)}if(Ce.isFormData(r)&&Ce.isFunction(r.entries)){const t={};return Ce.forEachEntry(r,(i,n)=>{e(uk(i),n,t,0)}),t}return null}function fk(r,e,t){if(Ce.isString(r))try{return(e||JSON.parse)(r),Ce.trim(r)}catch(i){if(i.name!=="SyntaxError")throw i}return(t||JSON.stringify)(r)}const bh={transitional:zx,adapter:["xhr","http","fetch"],transformRequest:[function(r,e){const t=e.getContentType()||"",i=t.indexOf("application/json")>-1,n=Ce.isObject(r);if(n&&Ce.isHTMLForm(r)&&(r=new FormData(r)),Ce.isFormData(r))return i?JSON.stringify(Hx(r)):r;if(Ce.isArrayBuffer(r)||Ce.isBuffer(r)||Ce.isStream(r)||Ce.isFile(r)||Ce.isBlob(r)||Ce.isReadableStream(r))return r;if(Ce.isArrayBufferView(r))return r.buffer;if(Ce.isURLSearchParams(r))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),r.toString();let s;if(n){if(t.indexOf("application/x-www-form-urlencoded")>-1)return dk(r,this.formSerializer).toString();if((s=Ce.isFileList(r))||t.indexOf("multipart/form-data")>-1){const a=this.env&&this.env.FormData;return Zp(s?{"files[]":r}:r,a&&new a,this.formSerializer)}}return n||i?(e.setContentType("application/json",!1),fk(r)):r}],transformResponse:[function(r){const e=this.transitional||bh.transitional,t=e&&e.forcedJSONParsing,i=this.responseType==="json";if(Ce.isResponse(r)||Ce.isReadableStream(r))return r;if(r&&Ce.isString(r)&&(t&&!this.responseType||i)){const n=!(e&&e.silentJSONParsing)&&i;try{return JSON.parse(r,this.parseReviver)}catch(s){if(n)throw s.name==="SyntaxError"?vt.from(s,vt.ERR_BAD_RESPONSE,this,null,this.response):s}}return r}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:an.classes.FormData,Blob:an.classes.Blob},validateStatus:function(r){return r>=200&&r<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ce.forEach(["delete","get","head","post","put","patch"],r=>{bh.headers[r]={}});const mk=Ce.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),gk=r=>{const e={};let t,i,n;return r&&r.split(`
|
||
`).forEach(function(s){n=s.indexOf(":"),t=s.substring(0,n).trim().toLowerCase(),i=s.substring(n+1).trim(),!(!t||e[t]&&mk[t])&&(t==="set-cookie"?e[t]?e[t].push(i):e[t]=[i]:e[t]=e[t]?e[t]+", "+i:i)}),e},Gx=Symbol("internals");function yh(r){return r&&String(r).trim().toLowerCase()}function Jp(r){return r===!1||r==null?r:Ce.isArray(r)?r.map(Jp):String(r)}function Ak(r){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;for(;i=t.exec(r);)e[i[1]]=i[2];return e}const vk=r=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(r.trim());function V0(r,e,t,i,n){if(Ce.isFunction(i))return i.call(this,e,t);if(n&&(e=t),!!Ce.isString(e)){if(Ce.isString(i))return e.indexOf(i)!==-1;if(Ce.isRegExp(i))return i.test(e)}}function bk(r){return r.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,i)=>t.toUpperCase()+i)}function yk(r,e){const t=Ce.toCamelCase(" "+e);["get","set","has"].forEach(i=>{Object.defineProperty(r,i+t,{value:function(n,s,a){return this[i].call(this,e,n,s,a)},configurable:!0})})}let wn=class{constructor(r){r&&this.set(r)}set(r,e,t){const i=this;function n(a,o,l){const c=yh(o);if(!c)throw new Error("header name must be a non-empty string");const h=Ce.findKey(i,c);(!h||i[h]===void 0||l===!0||l===void 0&&i[h]!==!1)&&(i[h||o]=Jp(a))}const s=(a,o)=>Ce.forEach(a,(l,c)=>n(l,c,o));if(Ce.isPlainObject(r)||r instanceof this.constructor)s(r,e);else if(Ce.isString(r)&&(r=r.trim())&&!vk(r))s(gk(r),e);else if(Ce.isObject(r)&&Ce.isIterable(r)){let a={},o,l;for(const c of r){if(!Ce.isArray(c))throw TypeError("Object iterator must return a key-value pair");a[l=c[0]]=(o=a[l])?Ce.isArray(o)?[...o,c[1]]:[o,c[1]]:c[1]}s(a,e)}else r!=null&&n(e,r,t);return this}get(r,e){if(r=yh(r),r){const t=Ce.findKey(this,r);if(t){const i=this[t];if(!e)return i;if(e===!0)return Ak(i);if(Ce.isFunction(e))return e.call(this,i,t);if(Ce.isRegExp(e))return e.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(r,e){if(r=yh(r),r){const t=Ce.findKey(this,r);return!!(t&&this[t]!==void 0&&(!e||V0(this,this[t],t,e)))}return!1}delete(r,e){const t=this;let i=!1;function n(s){if(s=yh(s),s){const a=Ce.findKey(t,s);a&&(!e||V0(t,t[a],a,e))&&(delete t[a],i=!0)}}return Ce.isArray(r)?r.forEach(n):n(r),i}clear(r){const e=Object.keys(this);let t=e.length,i=!1;for(;t--;){const n=e[t];(!r||V0(this,this[n],n,r,!0))&&(delete this[n],i=!0)}return i}normalize(r){const e=this,t={};return Ce.forEach(this,(i,n)=>{const s=Ce.findKey(t,n);if(s){e[s]=Jp(i),delete e[n];return}const a=r?bk(n):String(n).trim();a!==n&&delete e[n],e[a]=Jp(i),t[a]=!0}),this}concat(...r){return this.constructor.concat(this,...r)}toJSON(r){const e=Object.create(null);return Ce.forEach(this,(t,i)=>{t!=null&&t!==!1&&(e[i]=r&&Ce.isArray(t)?t.join(", "):t)}),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([r,e])=>r+": "+e).join(`
|
||
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(r){return r instanceof this?r:new this(r)}static concat(r,...e){const t=new this(r);return e.forEach(i=>t.set(i)),t}static accessor(r){const e=(this[Gx]=this[Gx]={accessors:{}}).accessors,t=this.prototype;function i(n){const s=yh(n);e[s]||(yk(t,n),e[s]=!0)}return Ce.isArray(r)?r.forEach(i):i(r),this}};wn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Ce.reduceDescriptors(wn.prototype,({value:r},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>r,set(i){this[t]=i}}}),Ce.freezeMethods(wn);function Q0(r,e){const t=this||bh,i=e||t,n=wn.from(i.headers);let s=i.data;return Ce.forEach(r,function(a){s=a.call(t,s,n.normalize(),e?e.status:void 0)}),n.normalize(),s}function Vx(r){return!!(r&&r.__CANCEL__)}function Nl(r,e,t){vt.call(this,r??"canceled",vt.ERR_CANCELED,e,t),this.name="CanceledError"}Ce.inherits(Nl,vt,{__CANCEL__:!0});function Qx(r,e,t){const i=t.config.validateStatus;!t.status||!i||i(t.status)?r(t):e(new vt("Request failed with status code "+t.status,[vt.ERR_BAD_REQUEST,vt.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function xk(r){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return e&&e[1]||""}function _k(r,e){r=r||10;const t=new Array(r),i=new Array(r);let n=0,s=0,a;return e=e!==void 0?e:1e3,function(o){const l=Date.now(),c=i[s];a||(a=l),t[n]=o,i[n]=l;let h=s,d=0;for(;h!==n;)d+=t[h++],h=h%r;if(n=(n+1)%r,n===s&&(s=(s+1)%r),l-a<e)return;const p=c&&l-c;return p?Math.round(d*1e3/p):void 0}}function Ek(r,e){let t=0,i=1e3/e,n,s;const a=(o,l=Date.now())=>{t=l,n=null,s&&(clearTimeout(s),s=null),r(...o)};return[(...o)=>{const l=Date.now(),c=l-t;c>=i?a(o,l):(n=o,s||(s=setTimeout(()=>{s=null,a(n)},i-c)))},()=>n&&a(n)]}const $p=(r,e,t=3)=>{let i=0;const n=_k(50,250);return Ek(s=>{const a=s.loaded,o=s.lengthComputable?s.total:void 0,l=a-i,c=n(l),h=a<=o;i=a;const d={loaded:a,total:o,progress:o?a/o:void 0,bytes:l,rate:c||void 0,estimated:c&&o&&h?(o-a)/c:void 0,event:s,lengthComputable:o!=null,[e?"download":"upload"]:!0};r(d)},t)},Wx=(r,e)=>{const t=r!=null;return[i=>e[0]({lengthComputable:t,total:r,loaded:i}),e[1]]},jx=r=>(...e)=>Ce.asap(()=>r(...e)),Mk=an.hasStandardBrowserEnv?((r,e)=>t=>(t=new URL(t,an.origin),r.protocol===t.protocol&&r.host===t.host&&(e||r.port===t.port)))(new URL(an.origin),an.navigator&&/(msie|trident)/i.test(an.navigator.userAgent)):()=>!0,wk=an.hasStandardBrowserEnv?{write(r,e,t,i,n,s,a){if(typeof document>"u")return;const o=[`${r}=${encodeURIComponent(e)}`];Ce.isNumber(t)&&o.push(`expires=${new Date(t).toUTCString()}`),Ce.isString(i)&&o.push(`path=${i}`),Ce.isString(n)&&o.push(`domain=${n}`),s===!0&&o.push("secure"),Ce.isString(a)&&o.push(`SameSite=${a}`),document.cookie=o.join("; ")},read(r){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+r+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(r){this.write(r,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Sk(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function Ck(r,e){return e?r.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):r}function qx(r,e,t){let i=!Sk(e);return r&&(i||t==!1)?Ck(r,e):e}const Xx=r=>r instanceof wn?{...r}:r;function ro(r,e){e=e||{};const t={};function i(c,h,d,p){return Ce.isPlainObject(c)&&Ce.isPlainObject(h)?Ce.merge.call({caseless:p},c,h):Ce.isPlainObject(h)?Ce.merge({},h):Ce.isArray(h)?h.slice():h}function n(c,h,d,p){if(Ce.isUndefined(h)){if(!Ce.isUndefined(c))return i(void 0,c,d,p)}else return i(c,h,d,p)}function s(c,h){if(!Ce.isUndefined(h))return i(void 0,h)}function a(c,h){if(Ce.isUndefined(h)){if(!Ce.isUndefined(c))return i(void 0,c)}else return i(void 0,h)}function o(c,h,d){if(d in e)return i(c,h);if(d in r)return i(void 0,c)}const l={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:o,headers:(c,h,d)=>n(Xx(c),Xx(h),d,!0)};return Ce.forEach(Object.keys({...r,...e}),function(c){const h=l[c]||n,d=h(r[c],e[c],c);Ce.isUndefined(d)&&h!==o||(t[c]=d)}),t}const Yx=r=>{const e=ro({},r);let{data:t,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:s,headers:a,auth:o}=e;if(e.headers=a=wn.from(a),e.url=Fx(qx(e.baseURL,e.url,e.allowAbsoluteUrls),r.params,r.paramsSerializer),o&&a.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):""))),Ce.isFormData(t)){if(an.hasStandardBrowserEnv||an.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(Ce.isFunction(t.getHeaders)){const l=t.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([h,d])=>{c.includes(h.toLowerCase())&&a.set(h,d)})}}if(an.hasStandardBrowserEnv&&(i&&Ce.isFunction(i)&&(i=i(e)),i||i!==!1&&Mk(e.url))){const l=n&&s&&wk.read(s);l&&a.set(n,l)}return e},Tk=typeof XMLHttpRequest<"u",Ik=Tk&&function(r){return new Promise(function(e,t){const i=Yx(r);let n=i.data;const s=wn.from(i.headers).normalize();let{responseType:a,onUploadProgress:o,onDownloadProgress:l}=i,c,h,d,p,u;function A(){p&&p(),u&&u(),i.cancelToken&&i.cancelToken.unsubscribe(c),i.signal&&i.signal.removeEventListener("abort",c)}let m=new XMLHttpRequest;m.open(i.method.toUpperCase(),i.url,!0),m.timeout=i.timeout;function g(){if(!m)return;const v=wn.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),b={data:!a||a==="text"||a==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:v,config:r,request:m};Qx(function(y){e(y),A()},function(y){t(y),A()},b),m=null}"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(g)},m.onabort=function(){m&&(t(new vt("Request aborted",vt.ECONNABORTED,r,m)),m=null)},m.onerror=function(v){const b=v&&v.message?v.message:"Network Error",y=new vt(b,vt.ERR_NETWORK,r,m);y.event=v||null,t(y),m=null},m.ontimeout=function(){let v=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const b=i.transitional||zx;i.timeoutErrorMessage&&(v=i.timeoutErrorMessage),t(new vt(v,b.clarifyTimeoutError?vt.ETIMEDOUT:vt.ECONNABORTED,r,m)),m=null},n===void 0&&s.setContentType(null),"setRequestHeader"in m&&Ce.forEach(s.toJSON(),function(v,b){m.setRequestHeader(b,v)}),Ce.isUndefined(i.withCredentials)||(m.withCredentials=!!i.withCredentials),a&&a!=="json"&&(m.responseType=i.responseType),l&&([d,u]=$p(l,!0),m.addEventListener("progress",d)),o&&m.upload&&([h,p]=$p(o),m.upload.addEventListener("progress",h),m.upload.addEventListener("loadend",p)),(i.cancelToken||i.signal)&&(c=v=>{m&&(t(!v||v.type?new Nl(null,r,m):v),m.abort(),m=null)},i.cancelToken&&i.cancelToken.subscribe(c),i.signal&&(i.signal.aborted?c():i.signal.addEventListener("abort",c)));const f=xk(i.url);if(f&&an.protocols.indexOf(f)===-1){t(new vt("Unsupported protocol "+f+":",vt.ERR_BAD_REQUEST,r));return}m.send(n||null)})},Pk=(r,e)=>{const{length:t}=r=r?r.filter(Boolean):[];if(e||t){let i=new AbortController,n;const s=function(c){if(!n){n=!0,o();const h=c instanceof Error?c:this.reason;i.abort(h instanceof vt?h:new Nl(h instanceof Error?h.message:h))}};let a=e&&setTimeout(()=>{a=null,s(new vt(`timeout ${e} of ms exceeded`,vt.ETIMEDOUT))},e);const o=()=>{r&&(a&&clearTimeout(a),a=null,r.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),r=null)};r.forEach(c=>c.addEventListener("abort",s));const{signal:l}=i;return l.unsubscribe=()=>Ce.asap(o),l}},Rk=function*(r,e){let t=r.byteLength;if(t<e){yield r;return}let i=0,n;for(;i<t;)n=i+e,yield r.slice(i,n),i=n},Dk=async function*(r,e){for await(const t of Bk(r))yield*Rk(t,e)},Bk=async function*(r){if(r[Symbol.asyncIterator]){yield*r;return}const e=r.getReader();try{for(;;){const{done:t,value:i}=await e.read();if(t)break;yield i}}finally{await e.cancel()}},Kx=(r,e,t,i)=>{const n=Dk(r,e);let s=0,a,o=l=>{a||(a=!0,i&&i(l))};return new ReadableStream({async pull(l){try{const{done:c,value:h}=await n.next();if(c){o(),l.close();return}let d=h.byteLength;if(t){let p=s+=d;t(p)}l.enqueue(new Uint8Array(h))}catch(c){throw o(c),c}},cancel(l){return o(l),n.return()}},{highWaterMark:2})},Zx=64*1024,{isFunction:ef}=Ce,Lk=(({Request:r,Response:e})=>({Request:r,Response:e}))(Ce.global),{ReadableStream:Jx,TextEncoder:$x}=Ce.global,e_=(r,...e)=>{try{return!!r(...e)}catch{return!1}},kk=r=>{r=Ce.merge.call({skipUndefined:!0},Lk,r);const{fetch:e,Request:t,Response:i}=r,n=e?ef(e):typeof fetch=="function",s=ef(t),a=ef(i);if(!n)return!1;const o=n&&ef(Jx),l=n&&(typeof $x=="function"?(A=>m=>A.encode(m))(new $x):async A=>new Uint8Array(await new t(A).arrayBuffer())),c=s&&o&&e_(()=>{let A=!1;const m=new t(an.origin,{body:new Jx,method:"POST",get duplex(){return A=!0,"half"}}).headers.has("Content-Type");return A&&!m}),h=a&&o&&e_(()=>Ce.isReadableStream(new i("").body)),d={stream:h&&(A=>A.body)};n&&["text","arrayBuffer","blob","formData","stream"].forEach(A=>{!d[A]&&(d[A]=(m,g)=>{let f=m&&m[A];if(f)return f.call(m);throw new vt(`Response type '${A}' is not supported`,vt.ERR_NOT_SUPPORT,g)})});const p=async A=>{if(A==null)return 0;if(Ce.isBlob(A))return A.size;if(Ce.isSpecCompliantForm(A))return(await new t(an.origin,{method:"POST",body:A}).arrayBuffer()).byteLength;if(Ce.isArrayBufferView(A)||Ce.isArrayBuffer(A))return A.byteLength;if(Ce.isURLSearchParams(A)&&(A=A+""),Ce.isString(A))return(await l(A)).byteLength},u=async(A,m)=>Ce.toFiniteNumber(A.getContentLength())??p(m);return async A=>{let{url:m,method:g,data:f,signal:v,cancelToken:b,timeout:y,onDownloadProgress:M,onUploadProgress:_,responseType:S,headers:w,withCredentials:E="same-origin",fetchOptions:I}=Yx(A),B=e||fetch;S=S?(S+"").toLowerCase():"text";let R=Pk([v,b&&b.toAbortSignal()],y),U=null;const C=R&&R.unsubscribe&&(()=>{R.unsubscribe()});let F;try{if(_&&c&&g!=="get"&&g!=="head"&&(F=await u(w,f))!==0){let q=new t(m,{method:"POST",body:f,duplex:"half"}),Y;if(Ce.isFormData(f)&&(Y=q.headers.get("content-type"))&&w.setContentType(Y),q.body){const[ye,Me]=Wx(F,$p(jx(_)));f=Kx(q.body,Zx,ye,Me)}}Ce.isString(E)||(E=E?"include":"omit");const O=s&&"credentials"in t.prototype,H={...I,signal:R,method:g.toUpperCase(),headers:w.normalize().toJSON(),body:f,duplex:"half",credentials:O?E:void 0};U=s&&new t(m,H);let j=await(s?B(U,I):B(m,H));const G=h&&(S==="stream"||S==="response");if(h&&(M||G&&C)){const q={};["status","statusText","headers"].forEach(xe=>{q[xe]=j[xe]});const Y=Ce.toFiniteNumber(j.headers.get("content-length")),[ye,Me]=M&&Wx(Y,$p(jx(M),!0))||[];j=new i(Kx(j.body,Zx,ye,()=>{Me&&Me(),C&&C()}),q)}S=S||"text";let re=await d[Ce.findKey(d,S)||"text"](j,A);return!G&&C&&C(),await new Promise((q,Y)=>{Qx(q,Y,{data:re,headers:wn.from(j.headers),status:j.status,statusText:j.statusText,config:A,request:U})})}catch(O){throw C&&C(),O&&O.name==="TypeError"&&/Load failed|fetch/i.test(O.message)?Object.assign(new vt("Network Error",vt.ERR_NETWORK,A,U),{cause:O.cause||O}):vt.from(O,O&&O.code,A,U)}}},Nk=new Map,t_=r=>{let e=r&&r.env||{};const{fetch:t,Request:i,Response:n}=e,s=[i,n,t];let a=s.length,o=a,l,c,h=Nk;for(;o--;)l=s[o],c=h.get(l),c===void 0&&h.set(l,c=o?new Map:kk(e)),h=c;return c};t_();const W0={http:$8,xhr:Ik,fetch:{get:t_}};Ce.forEach(W0,(r,e)=>{if(r){try{Object.defineProperty(r,"name",{value:e})}catch{}Object.defineProperty(r,"adapterName",{value:e})}});const i_=r=>`- ${r}`,Uk=r=>Ce.isFunction(r)||r===null||r===!1;function Fk(r,e){r=Ce.isArray(r)?r:[r];const{length:t}=r;let i,n;const s={};for(let a=0;a<t;a++){i=r[a];let o;if(n=i,!Uk(i)&&(n=W0[(o=String(i)).toLowerCase()],n===void 0))throw new vt(`Unknown adapter '${o}'`);if(n&&(Ce.isFunction(n)||(n=n.get(e))))break;s[o||"#"+a]=n}if(!n){const a=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let o=t?a.length>1?`since :
|
||
`+a.map(i_).join(`
|
||
`):" "+i_(a[0]):"as no adapter specified";throw new vt("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return n}const n_={getAdapter:Fk,adapters:W0};function j0(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new Nl(null,r)}function s_(r){return j0(r),r.headers=wn.from(r.headers),r.data=Q0.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),n_.getAdapter(r.adapter||bh.adapter,r)(r).then(function(e){return j0(r),e.data=Q0.call(r,r.transformResponse,e),e.headers=wn.from(e.headers),e},function(e){return Vx(e)||(j0(r),e&&e.response&&(e.response.data=Q0.call(r,r.transformResponse,e.response),e.response.headers=wn.from(e.response.headers))),Promise.reject(e)})}const r_="1.13.2",tf={};["object","boolean","number","function","string","symbol"].forEach((r,e)=>{tf[r]=function(t){return typeof t===r||"a"+(e<1?"n ":" ")+r}});const a_={};tf.transitional=function(r,e,t){function i(n,s){return"[Axios v"+r_+"] Transitional option '"+n+"'"+s+(t?". "+t:"")}return(n,s,a)=>{if(r===!1)throw new vt(i(s," has been removed"+(e?" in "+e:"")),vt.ERR_DEPRECATED);return e&&!a_[s]&&(a_[s]=!0,console.warn(i(s," has been deprecated since v"+e+" and will be removed in the near future"))),r?r(n,s,a):!0}},tf.spelling=function(r){return(e,t)=>(console.warn(`${t} is likely a misspelling of ${r}`),!0)};function Ok(r,e,t){if(typeof r!="object")throw new vt("options must be an object",vt.ERR_BAD_OPTION_VALUE);const i=Object.keys(r);let n=i.length;for(;n-- >0;){const s=i[n],a=e[s];if(a){const o=r[s],l=o===void 0||a(o,s,r);if(l!==!0)throw new vt("option "+s+" must be "+l,vt.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new vt("Unknown option "+s,vt.ERR_BAD_OPTION)}}const nf={assertOptions:Ok,validators:tf},Ds=nf.validators;let ao=class{constructor(r){this.defaults=r||{},this.interceptors={request:new Ox,response:new Ox}}async request(r,e){try{return await this._request(r,e)}catch(t){if(t instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const n=i.stack?i.stack.replace(/^.+\n/,""):"";try{t.stack?n&&!String(t.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(t.stack+=`
|
||
`+n):t.stack=n}catch{}}throw t}}_request(r,e){typeof r=="string"?(e=e||{},e.url=r):e=r||{},e=ro(this.defaults,e);const{transitional:t,paramsSerializer:i,headers:n}=e;t!==void 0&&nf.assertOptions(t,{silentJSONParsing:Ds.transitional(Ds.boolean),forcedJSONParsing:Ds.transitional(Ds.boolean),clarifyTimeoutError:Ds.transitional(Ds.boolean)},!1),i!=null&&(Ce.isFunction(i)?e.paramsSerializer={serialize:i}:nf.assertOptions(i,{encode:Ds.function,serialize:Ds.function},!0)),e.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?e.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:e.allowAbsoluteUrls=!0),nf.assertOptions(e,{baseUrl:Ds.spelling("baseURL"),withXsrfToken:Ds.spelling("withXSRFToken")},!0),e.method=(e.method||this.defaults.method||"get").toLowerCase();let s=n&&Ce.merge(n.common,n[e.method]);n&&Ce.forEach(["delete","get","head","post","put","patch","common"],u=>{delete n[u]}),e.headers=wn.concat(s,n);const a=[];let o=!0;this.interceptors.request.forEach(function(u){typeof u.runWhen=="function"&&u.runWhen(e)===!1||(o=o&&u.synchronous,a.unshift(u.fulfilled,u.rejected))});const l=[];this.interceptors.response.forEach(function(u){l.push(u.fulfilled,u.rejected)});let c,h=0,d;if(!o){const u=[s_.bind(this),void 0];for(u.unshift(...a),u.push(...l),d=u.length,c=Promise.resolve(e);h<d;)c=c.then(u[h++],u[h++]);return c}d=a.length;let p=e;for(;h<d;){const u=a[h++],A=a[h++];try{p=u(p)}catch(m){A.call(this,m);break}}try{c=s_.call(this,p)}catch(u){return Promise.reject(u)}for(h=0,d=l.length;h<d;)c=c.then(l[h++],l[h++]);return c}getUri(r){r=ro(this.defaults,r);const e=qx(r.baseURL,r.url,r.allowAbsoluteUrls);return Fx(e,r.params,r.paramsSerializer)}};Ce.forEach(["delete","get","head","options"],function(r){ao.prototype[r]=function(e,t){return this.request(ro(t||{},{method:r,url:e,data:(t||{}).data}))}}),Ce.forEach(["post","put","patch"],function(r){function e(t){return function(i,n,s){return this.request(ro(s||{},{method:r,headers:t?{"Content-Type":"multipart/form-data"}:{},url:i,data:n}))}}ao.prototype[r]=e(),ao.prototype[r+"Form"]=e(!0)});let zk=class bM{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(n){t=n});const i=this;this.promise.then(n=>{if(!i._listeners)return;let s=i._listeners.length;for(;s-- >0;)i._listeners[s](n);i._listeners=null}),this.promise.then=n=>{let s;const a=new Promise(o=>{i.subscribe(o),s=o}).then(n);return a.cancel=function(){i.unsubscribe(s)},a},e(function(n,s,a){i.reason||(i.reason=new Nl(n,s,a),t(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=i=>{e.abort(i)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new bM(function(t){e=t}),cancel:e}}};function Hk(r){return function(e){return r.apply(null,e)}}function Gk(r){return Ce.isObject(r)&&r.isAxiosError===!0}const q0={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(q0).forEach(([r,e])=>{q0[e]=r});function o_(r){const e=new ao(r),t=Ex(ao.prototype.request,e);return Ce.extend(t,ao.prototype,e,{allOwnKeys:!0}),Ce.extend(t,e,null,{allOwnKeys:!0}),t.create=function(i){return o_(ro(r,i))},t}const gi=o_(bh);gi.Axios=ao,gi.CanceledError=Nl,gi.CancelToken=zk,gi.isCancel=Vx,gi.VERSION=r_,gi.toFormData=Zp,gi.AxiosError=vt,gi.Cancel=gi.CanceledError,gi.all=function(r){return Promise.all(r)},gi.spread=Hk,gi.isAxiosError=Gk,gi.mergeConfig=ro,gi.AxiosHeaders=wn,gi.formToJSON=r=>Hx(Ce.isHTMLForm(r)?new FormData(r):r),gi.getAdapter=n_.getAdapter,gi.HttpStatusCode=q0,gi.default=gi;const{Axios:fO,AxiosError:mO,CanceledError:gO,isCancel:AO,CancelToken:vO,VERSION:bO,all:yO,Cancel:xO,isAxiosError:_O,spread:EO,toFormData:MO,AxiosHeaders:wO,HttpStatusCode:SO,formToJSON:CO,getAdapter:TO,mergeConfig:IO}=gi;function xh(r,e,t){gi({method:"get",responseType:"blob",url:r}).then(n=>{let s=new window.File([n.data],"semantics",{type:"zip"});_x.loadAsync(s).then(a=>{for(let o in a.files){const l=a.file(a.files[o].name);l&&l.async("blob").then(c=>{i(c,"utf-8",function(h,d){e(d)})}).catch(()=>{t()})}}).catch(()=>{t()})}).catch(n=>{t()});function i(n,s,a){var o=new FileReader,l=new Blob([n]);o.onload=function(c){a(null,c.target.result)},o.onerror=function(c){a(c.error,null)},o.readAsText(l,s)}}const X0=new WeakMap;class Vk extends Qi{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,n){const s=new Yi(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,a=>{this.parse(a,t,n)},i,n)}parse(e,t,i=()=>{}){this.decodeDracoFile(e,t,null,null,Jt,i).catch(i)}decodeDracoFile(e,t,i,n,s=Ri,a=()=>{}){const o={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:s};return this.decodeGeometry(e,o).then(t).catch(a)}decodeGeometry(e,t){const i=JSON.stringify(t);if(X0.has(e)){const l=X0.get(e);if(l.key===i)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n;const s=this.workerNextTaskID++,a=e.byteLength,o=this._getWorker(s,a).then(l=>(n=l,new Promise((c,h)=>{n._callbacks[s]={resolve:c,reject:h},n.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return o.catch(()=>!0).then(()=>{n&&s&&this._releaseTask(n,s)}),X0.set(e,{key:i,promise:o}),o}_createGeometry(e){const t=new ot;e.index&&t.setIndex(new St(e.index.array,1));for(let i=0;i<e.attributes.length;i++){const{name:n,array:s,itemSize:a,stride:o,vertexColorSpace:l}=e.attributes[i];let c;if(a===o)c=new St(s,a);else{const h=new Vo(s,o);c=new Vs(h,a,0)}n==="color"&&(this._assignVertexColorSpace(c,l),c.normalized=!(s instanceof Float32Array)),t.setAttribute(n,c)}return t}_assignVertexColorSpace(e,t){if(t!==Jt)return;const i=new We;for(let n=0,s=e.count;n<s;n++)i.fromBufferAttribute(e,n),Et.colorSpaceToWorking(i,Jt),e.setXYZ(n,i.r,i.g,i.b)}_loadLibrary(e,t){const i=new Yi(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((n,s)=>{i.load(e,n,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(i=>{const n=i[0];e||(this.decoderConfig.wasmBinary=i[1]);const s=Qk.toString(),a=["/* draco decoder */",n,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
||
`);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(s){const a=s.data;switch(a.type){case"decode":n._callbacks[a.id].resolve(a);break;case"error":n._callbacks[a.id].reject(a);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+a.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,s){return n._taskLoad>s._taskLoad?-1:1});const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function Qk(){let r,e;onmessage=function(a){const o=a.data;switch(o.type){case"init":r=o.decoderConfig,e=new Promise(function(h){r.onModuleLoaded=function(d){h({draco:d})},DracoDecoderModule(r)});break;case"decode":const l=o.buffer,c=o.taskConfig;e.then(h=>{const d=h.draco,p=new d.Decoder;try{const u=t(d,p,new Int8Array(l),c),A=u.attributes.map(m=>m.array.buffer);u.index&&A.push(u.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:u},A)}catch(u){console.error(u),self.postMessage({type:"error",id:o.id,error:u.message})}finally{d.destroy(p)}});break}};function t(a,o,l,c){const h=c.attributeIDs,d=c.attributeTypes;let p,u;const A=o.GetEncodedGeometryType(l);if(A===a.TRIANGULAR_MESH)p=new a.Mesh,u=o.DecodeArrayToMesh(l,l.byteLength,p);else if(A===a.POINT_CLOUD)p=new a.PointCloud,u=o.DecodeArrayToPointCloud(l,l.byteLength,p);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!u.ok()||p.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+u.error_msg());const m={index:null,attributes:[]};for(const g in h){const f=self[d[g]];let v,b;if(c.useUniqueIDs)b=h[g],v=o.GetAttributeByUniqueId(p,b);else{if(b=o.GetAttributeId(p,a[h[g]]),b===-1)continue;v=o.GetAttribute(p,b)}const y=n(a,o,p,g,f,v);g==="color"&&(y.vertexColorSpace=c.vertexColorSpace),m.attributes.push(y)}return A===a.TRIANGULAR_MESH&&(m.index=i(a,o,p)),a.destroy(p),m}function i(a,o,l){const c=l.num_faces()*3,h=c*4,d=a._malloc(h);o.GetTrianglesUInt32Array(l,h,d);const p=new Uint32Array(a.HEAPF32.buffer,d,c).slice();return a._free(d),{array:p,itemSize:1}}function n(a,o,l,c,h,d){const p=l.num_points(),u=d.num_components(),A=s(a,h),m=u*h.BYTES_PER_ELEMENT,g=Math.ceil(m/4)*4,f=g/h.BYTES_PER_ELEMENT,v=p*m,b=p*g,y=a._malloc(v);o.GetAttributeDataArrayForAllPoints(l,d,A,v,y);const M=new h(a.HEAPF32.buffer,y,v/h.BYTES_PER_ELEMENT);let _;if(m===g)_=M.slice();else{_=new h(b/h.BYTES_PER_ELEMENT);let S=0;for(let w=0,E=M.length;w<E;w++){for(let I=0;I<u;I++)_[S+I]=M[w*u+I];S+=f}}return a._free(y),{name:c,count:p,itemSize:u,array:_,stride:f}}function s(a,o){switch(o){case Float32Array:return a.DT_FLOAT32;case Int8Array:return a.DT_INT8;case Int16Array:return a.DT_INT16;case Int32Array:return a.DT_INT32;case Uint8Array:return a.DT_UINT8;case Uint16Array:return a.DT_UINT16;case Uint32Array:return a.DT_UINT32}}}var Wk=(function(){var r="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuec:W:Odkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq;lZkdbk;jYi5ud9:du8Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCabaOad2fhXaAcethQaxaDfhiaOaeaoaeao6E9RhLalcl4cifcd4hKazcj;cbfaAfhYcbh8AazcjdfhEaHh3incbhodnawTmbaxa8Acd4fRbbhokaocFeGh5cbh8Eazcj;cbfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcj;cbfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcj;cbfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaK6mva8FaKfhidnaCTmbaPai9RcK6mbaocdtc:q1jjbfcj1jjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bbarcwf9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfag9c8F1:NghcKtc8F91aicdfa8J9c8N1:Nfg8KRbbG86bbarcVfcba8KahcjeGcr4fghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fag9c8F1:NgicKtc8F91aha8J9c8N1:NfghRbbG86bbarc96fcbahaicjeGcr4fgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbb83bbarcwfaicwf8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasa8Acd4fRbbgociGPlbedrbkaATmdaza8Afh8Fazcj;cbfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeaza8Afhaazcj;cbfhhcbhoceh8EaYh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaLaocefgofmbka8FaQfh8FcdhoaacdfhaahaQfhha8EceGhlcbh8EalmbxdkkaATmbcbaocl49Rh8Eaza8AfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaYhainazcj;cbfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E93aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3a8Aclfg8Aad6mbkaXazcjdfaAad2z:jjjjb8AazazcjdfaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaok:XseHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:kjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbaxcefgOavaiaqaDcsGfRbbgscl49RcsGcdtfydbascz6gPEhDavaias9RcsGcdtfydbaOaPfgzascsGgOEhsaOThOdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiaPfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaOfhiazaOfhxxekaxcbalRbbgHEgAaDc;:eSgDfhzaHcsGhCaHcl4hXdndnaHcs0mbazcefhOxekazhOavaiaX9RcsGcdtfydbhzkdndnaCmbaOcefhxxekaOhxavaiaH9RcsGcdtfydbhOkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhAascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaAhDxekaDcefhDkasce4cbasceG9R7amfgmhAkdndnaXcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhzaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkazhsxekascefhskaPce4cbaPceG9R7amfgmhzkdndnaCcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhOaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkaOhlxekalcefhlkaPce4cbaPceG9R7amfgmhOkdndnadcd9hmbabarcetfgDaA87ebaDclfaO87ebaDcdfaz87ebxekabarcdtfgDaABdbaDcwfaOBdbaDclfazBdbkavc;abfaocitfgDazBdbaDaABdlavaicdtfaABdbavc;abfaocefcsGcitfgDaOBdbaDazBdlavaicefgicsGcdtfazBdbavc;abfaocdfcsGcitfgDaABdbaDaOBdlavaiaHcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnaecvfal9nmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk::ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxabaiarcefciGfcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGfgkcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkabaiarcufciGfcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkabakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K1jjbgeabcifc98GfgbBd:K1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;teeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiaeydlBdlaiaeydwBdwaiaeydxBdxaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk:3eedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdxaialBdwaialBdlaialBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk81dbcjwk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:Kwkl8WNbb",e="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuec:q:6dkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:Ctklbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk:183lYud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxavaialfgmar9Rgoad;8qbbcj;abad9Uc;WFbGcjdadca0EhPdndndnadTmbaoadfhscbhzinaeaz9nmdamax9RaD6miabazad2fhHaxaDfhOaPaeaz9RazaPfae6EgAcsfgocl4cifcd4hCavcj;cbfaoc9WGgXcetfhQavcj;cbfaXci2fhLavcj;cbfaXfhKcbhYaoc;ab6h8AincbhodnawTmbaxaYcd4fRbbhokaocFeGhEcbh3avcj;cbfh5indndndndnaEa3cet4ciGgoc9:fPdebdkamaO9RaX6mwavcj;cbfa3aX2faOaX;8qbbaOaAfhOxdkavcj;cbfa3aX2fcbaX;8kbxekamaO9RaC6moaoclVcbawEhraOaCfhocbhidna8Ambamao9Rc;Gb6mbcbhlina5alfhidndndndndndnaOalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaiaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaiczfaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaicafaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngicitc:q1jjbfpbibaic:q:yjjbfRbbgipsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaiaoclffaqc:q:yjjbfRbbfhoxikaic8Wfaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngicitc:q1jjbfpbibaic:q:yjjbfRbbgipsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaiaocwffaqc:q:yjjbfRbbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitc:q1jjbfpbibaic:q:yjjbfRbbgipsaoRbegqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqc:q:yjjbfRbbfhokalc;abfhialcjefaX0meaihlamao9Rc;Fb0mbkkdnaiaX9pmbaici4hlinamao9RcK6mwa5aifhqdndndndndndnaOaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spkbbaaaoclffahc:q:yjjbfRbbfhoxikaqaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spkbbaaaocwffahc:q:yjjbfRbbfhoxdkaqaopbbbpkbbaoczfhoxekaqaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpkbbaaaocdffahc:q:yjjbfRbbfhokalcdfhlaiczfgiaX6mbkkaohOaoTmoka5aXfh5a3cefg3cl9hmbkdndndndnawTmbasaYcd4fRbbglciGPlbedwbkaXTmdavcjdfaYfhlavaYfpbdbhgcbhoinalavcj;cbfaofpblbg8JaKaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaQaofpblbg8MaLaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Ecep9Ta8Epxeeeeeeeeeeeeeeeeg8Fp9op9Hp9rg8Eagp9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8LaypmwDKYqk8AExm35Ps8E8Fg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Ug8Fp9Abbbaladfgla8Fa8Ea8Epmlvorlvorlvorlvorp9Ug8Fp9Abbbaladfgla8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9Ug8Fp9Abbbaladfgla8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9AbbbaladfhlaoczfgoaX6mbxikkaXTmeavcjdfaYfhlavaYfpbdbhgcbhoinalavcj;cbfaofpblbg8JaKaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaQaofpblbg8MaLaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Ecep:nea8Epxebebebebebebebebg8Fp9op:bep9rg8Eagp:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8LaypmwDKYqk8AExm35Ps8E8Fg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeg8Fp9Abbbaladfgla8Fa8Ea8Epmlvorlvorlvorlvorp:oeg8Fp9Abbbaladfgla8Fa8Ea8EpmwDqkwDqkwDqkwDqkp:oeg8Fp9Abbbaladfgla8Fa8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9AbbbaladfhlaoczfgoaX6mbxdkkaXTmbcbhocbalcl4gl9Rc8FGhiavcjdfaYfhravaYfpbdbh8Finaravcj;cbfaofpblbggaKaofpblbg8JpmbzeHdOiAlCvXoQrLg8KaQaofpblbg8LaLaofpblbg8MpmbzeHdOiAlCvXoQrLg8NpmbezHdiOAlvCXorQLg8Eaip:Rea8Ealp:Sep9qg8Ea8Fp9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Fa8Ka8NpmwDKYqk8AExm35Ps8E8Fg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Faga8JpmwKDYq8AkEx3m5P8Es8Fgga8La8MpmwKDYq8AkEx3m5P8Es8Fg8JpmbezHdiOAlvCXorQLg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Faga8JpmwDKYqk8AExm35Ps8E8Fg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9AbbbaradfhraoczfgoaX6mbkkaYclfgYad6mbkaHavcjdfaAad2;8qbbavavcjdfaAcufad2fad;8qbbaAazfhzc9:hoaOhxaOmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdaPaeao9RaoaPfae6Eaofgoae6mbkaial9Rhxkcbc99amax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbk:TseHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbaxcefgOavaiaqaDcsGfRbbgscl49RcsGcdtfydbascz6gPEhDavaias9RcsGcdtfydbaOaPfgzascsGgOEhsaOThOdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiaPfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaOfhiazaOfhxxekaxcbalRbbgHEgAaDc;:eSgDfhzaHcsGhCaHcl4hXdndnaHcs0mbazcefhOxekazhOavaiaX9RcsGcdtfydbhzkdndnaCmbaOcefhxxekaOhxavaiaH9RcsGcdtfydbhOkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhAascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaAhDxekaDcefhDkasce4cbasceG9R7amfgmhAkdndnaXcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhzaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkazhsxekascefhskaPce4cbaPceG9R7amfgmhzkdndnaCcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhOaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkaOhlxekalcefhlkaPce4cbaPceG9R7amfgmhOkdndnadcd9hmbabarcetfgDaA87ebaDclfaO87ebaDcdfaz87ebxekabarcdtfgDaABdbaDcwfaOBdbaDclfazBdbkavc;abfaocitfgDazBdbaDaABdlavaicdtfaABdbavc;abfaocefcsGcitfgDaOBdbaDazBdlavaicefgicsGcdtfazBdbavc;abfaocdfcsGcitfgDaABdbaDaOBdlavaiaHcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnaecvfal9nmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:2Pliur97eue978Jjjjjbc8W9Rhiaec98Ghldndnadcl9hmbdnalTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalaeSmeaipxbbbbbbbbbbbbbbbbgqpklbaiabalcdtfgdaeciGglcdtgv;8qbbdnalTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDaqp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkadaiav;8qbbskaipxFubbFubbFubbFubbgxpklbdnalTmbcbhvabhdinadczfgmampbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraipblbaDaopmlvorxmPsCXQL358E8Fp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgPp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;MeawaqawaPp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oaoarpmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgval6mbkkalaeSmbaiczfpxbbbbbbbbbbbbbbbbgopklbaiaopklbaiabalcitfgdaeciGglcitgv;8qbbaiaxpkladnalTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraipblaaDaopmlvorxmPsCXQL358E8Fp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgPp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;MeawaqawaPp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oaoarpmbezHdiOAlvCXorQLp9qpklbkadaiav;8qbbkk:Iwllue97euo978Jjjjjbca9Rhidnaec98GglTmbcbhvabhoinaocKfpx:ji:1S:ji:1S:ji:1S:ji:1SaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkpxibbbibbbibbbibbbp9qgxp;6ep;Negmaxaxp:1ep;7egxaxp;KearaDpmbediwDqkzHOAKY8AEgxczp:Reczp:Sep;6egrarp;Meaxczp:Sep;6egDaDp;Meaqczp:Reczp:Sep;6egqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gxp;KepxFFbbFFbbFFbbFFbbgPp9oamaDp;Meaxp;Keczp:Rep9qgDamarp;Meaxp;KeaPp9oamaqp;Meaxp;Keczp:Rep9qgxpmwDKYqk8AExm35Ps8E8Fgrp5eakclp:RegmpEi:T:j83ibawarp5bampEd:T:j83ibaocwfaDaxpmbezHdiOAlvCXorQLgxp5eampEe:T:j83ibaoaxp5bampEb:T:j83ibaocafhoavclfgval6mbkkdnalaeSmbaiczfpxbbbbbbbbbbbbbbbbgmpklbaiampklbaiabalcitfgoaeciGgvcitgw;8qbbdnavTmbaipx:ji:1S:ji:1S:ji:1S:ji:1SaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkpxibbbibbbibbbibbbp9qgxp;6ep;Negmaxaxp:1ep;7egxaxp;KearaDpmbediwDqkzHOAKY8AEgxczp:Reczp:Sep;6egrarp;Meaxczp:Sep;6egDaDp;Meaqczp:Reczp:Sep;6egqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gxp;KepxFFbbFFbbFFbbFFbbgPp9oamaDp;Meaxp;Keczp:Rep9qgDamarp;Meaxp;KeaPp9oamaqp;Meaxp;Keczp:Rep9qgxpmwDKYqk8AExm35Ps8E8Fgrp5eakclp:RegmpEi:T:j83iKaiarp5bampEd:T:j83izaiaDaxpmbezHdiOAlvCXorQLgxp5eampEe:T:j83iwaiaxp5bampEb:T:j83ibkaoaiaw;8qbbkk;uddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbheabhdinadadpbbbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbadczfhdaeclfgeav6mbkkdnavalSmbaic8WfpxbbbbbbbbbbbbbbbbgopklbaicafaopklbaiczfaopklbaiaopklbaiabavcdtfgdalciGgecdtgv;8qbbdnaeTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepklbkadaiav;8qbbkk:CPvdue97euw97eu8Jjjjjbc8W9Rhiaec98Ghldndnadcl9hmbaipxbbbbbbbbbbbbbbbbgvpklbdnalTmbcbhoabhdinadpbbbhradpxbbuJbbuJbbuJbbuJaipblbarcKp:Tep9qgwcep:Seawp9qgDcdp:SeaDp9qgDclp:SeaDp9qgqp;6ep;NegDarcwp:RecKp:SegkarpxFbbbFbbbFbbbFbbbgxp9ogmp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gPp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oaDamakp:Xearczp:RecKp:Segrp:Uep;6ep;MeaPp;Keaxp9op9qaDamakarp:Uep:Xep;6ep;MeaPp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qaDaqawcep:Rep9oawpxebbbebbbebbbebbbp9op9qp;6ep;MeaPp;KecKp:Rep9qpkbbadczfhdaoclfgoal6mbkkalaeSmeaiavpklaaicafabalcdtfgdaeciGglcdtgo;8qbbaiavpklbdnalTmbaipblahraipxbbuJbbuJbbuJbbuJaipblbarcKp:Tep9qgwcep:Seawp9qgDcdp:SeaDp9qgDclp:SeaDp9qgqp;6ep;NegDarcwp:RecKp:SegkarpxFbbbFbbbFbbbFbbbgxp9ogmp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gPp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oaDamakp:Xearczp:RecKp:Segrp:Uep;6ep;MeaPp;Keaxp9op9qaDamakarp:Uep:Xep;6ep;MeaPp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qaDaqawcep:Rep9oawpxebbbebbbebbbebbbp9op9qp;6ep;MeaPp;KecKp:Rep9qpklakadaicafao;8qbbskaipxbbbbbbbbbbbbbbbbgvpklbdnalTmbcbhoabhdinadczfgspxbFu9hbFu9hbFu9hbFu9hadpbbbgDaspbbbgPpmlvorxmPsCXQL358E8Fgmczp:Teaipblbp9qgrcep:Searp9qgwcdp:Seawp9qgwclp:Seawp9qgwcwp:Seawp9qgqp;6ep;NegwaDaPpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbgPp9ogkaDczp:Segxp:Ueamczp:Reczp:Segmp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gDp;KeaPp9oawakaxamp:Uep:Xep;6ep;MeaDp;Keczp:Rep9qgxawaqarcep:Rep9oarpxebbbebbbebbbebbbp9op9qp;6ep;MeaDp;Keczp:Reawamakp:Uep;6ep;MeaDp;KeaPp9op9qgrpmwDKYqk8AExm35Ps8E8FpkbbadaxarpmbezHdiOAlvCXorQLpkbbadcafhdaoclfgoal6mbkkalaeSmbaiczfpxbbbbbbbbbbbbbbbbgrpklbaiarpklbaiabalcitfgdaeciGglcitgo;8qbbaiavpkladnalTmbaipxbFu9hbFu9hbFu9hbFu9haipblbgDaipblzgPpmlvorxmPsCXQL358E8Fgmczp:Teaipblap9qgrcep:Searp9qgwcdp:Seawp9qgwclp:Seawp9qgwcwp:Seawp9qgqp;6ep;NegwaDaPpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbgPp9ogkaDczp:Segxp:Ueamczp:Reczp:Segmp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gDp;KeaPp9oawakaxamp:Uep:Xep;6ep;MeaDp;Keczp:Rep9qgxawaqarcep:Rep9oarpxebbbebbbebbbebbbp9op9qp;6ep;MeaDp;Keczp:Reawamakp:Uep;6ep;MeaDp;KeaPp9op9qgrpmwDKYqk8AExm35Ps8E8FpklzaiaxarpmbezHdiOAlvCXorQLpklbkadaiao;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz:Dbb",t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),i=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var n=WebAssembly.validate(t)?o(e):o(r),s,a=WebAssembly.instantiate(n,{}).then(function(f){s=f.instance,s.exports.__wasm_call_ctors()});function o(f){for(var v=new Uint8Array(f.length),b=0;b<f.length;++b){var y=f.charCodeAt(b);v[b]=y>96?y-97:y>64?y-39:y+4}for(var M=0,b=0;b<f.length;++b)v[M++]=v[b]<60?i[v[b]]:(v[b]-60)*64+v[++b];return v.buffer.slice(0,M)}function l(f,v,b,y,M,_,S){var w=f.exports.sbrk,E=y+3&-4,I=w(E*M),B=w(_.length),R=new Uint8Array(f.exports.memory.buffer);R.set(_,B);var U=v(I,y,M,B,_.length);if(U==0&&S&&S(I,E,M),b.set(R.subarray(I,I+y*M)),w(I-w(0)),U!=0)throw new Error("Malformed buffer data: "+U)}var c={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp",COLOR:"meshopt_decodeFilterColor"},h={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},d=[],p=0;function u(f){var v={object:new Worker(f),pending:0,requests:{}};return v.object.onmessage=function(b){var y=b.data;v.pending-=y.count,v.requests[y.id][y.action](y.value),delete v.requests[y.id]},v}function A(f){for(var v="self.ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(n)+"]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = "+g.name+";"+l.toString()+g.toString(),b=new Blob([v],{type:"text/javascript"}),y=URL.createObjectURL(b),M=d.length;M<f;++M)d[M]=u(y);for(var M=f;M<d.length;++M)d[M].object.postMessage({});d.length=f,URL.revokeObjectURL(y)}function m(f,v,b,y,M){for(var _=d[0],S=1;S<d.length;++S)d[S].pending<_.pending&&(_=d[S]);return new Promise(function(w,E){var I=new Uint8Array(b),B=++p;_.pending+=f,_.requests[B]={resolve:w,reject:E},_.object.postMessage({id:B,count:f,size:v,source:I,mode:y,filter:M},[I.buffer])})}function g(f){var v=f.data;if(!v.id)return self.close();self.ready.then(function(b){try{var y=new Uint8Array(v.count*v.size);l(b,b.exports[v.mode],y,v.count,v.size,v.source,b.exports[v.filter]),self.postMessage({id:v.id,count:v.count,action:"resolve",value:y},[y.buffer])}catch(M){self.postMessage({id:v.id,count:v.count,action:"reject",value:M})}})}return{ready:a,supported:!0,useWorkers:function(f){A(f)},decodeVertexBuffer:function(f,v,b,y,M){l(s,s.exports.meshopt_decodeVertexBuffer,f,v,b,y,s.exports[c[M]])},decodeIndexBuffer:function(f,v,b,y){l(s,s.exports.meshopt_decodeIndexBuffer,f,v,b,y)},decodeIndexSequence:function(f,v,b,y){l(s,s.exports.meshopt_decodeIndexSequence,f,v,b,y)},decodeGltfBuffer:function(f,v,b,y,M,_){l(s,s.exports[h[M]],f,v,b,y,s.exports[c[_]])},decodeGltfBufferAsync:function(f,v,b,y,M){return d.length>0?m(f,v,b,h[y],c[M]):a.then(function(){var _=new Uint8Array(f*v);return l(s,s.exports[h[y]],_,f,v,b,s.exports[c[M]]),_})}}})();class jk{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0,this.workerCreator=null}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const i=this.workersResolve[e];if(i&&i(t),this.queue.length){const{resolve:n,msg:s,transfer:a}=this.queue.shift();this.workersResolve[e]=n,this.workers[e].postMessage(s,a)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise(i=>{const n=this._getIdleWorker();n!==-1?(this._initWorker(n),this.workerStatus|=1<<n,this.workersResolve[n]=i,this.workers[n].postMessage(e,t)):this.queue.push({resolve:i,msg:e,transfer:t})})}dispose(){this.workers.forEach(e=>e.terminate()),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const qk=0,l_=2,Xk=1,c_=2,Yk=0,Kk=1,Zk=10,Jk=0,h_=9,d_=15,u_=16,p_=22,f_=37,m_=43,g_=76,A_=83,v_=97,b_=100,y_=103,x_=109,__=122,E_=123,M_=131,w_=132,S_=133,C_=134,T_=137,I_=138,P_=139,R_=140,D_=141,B_=142,L_=145,k_=146,N_=148,U_=152,F_=153,O_=154,z_=155,H_=156,G_=157,V_=158,Q_=165,W_=166,j_=1000054e3,q_=1000054001,X_=1000054004,Y_=1000054005,Y0=1000066e3,K_=1000066004;class _h{constructor(e,t,i,n){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(e.buffer,e.byteOffset+t,i),this._littleEndian=n,this._offset=0}_nextUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){const e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){const e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){const e=this._dataView.getUint32(this._offset,this._littleEndian)+4294967296*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e}_nextInt32(){const e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint8Array(e){const t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,e);return this._offset+=e,t}_skip(e){return this._offset+=e,this}_scan(e,t=0){const i=this._offset;let n=0;for(;this._dataView.getUint8(this._offset)!==t&&n<e;)n++,this._offset++;return n<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+i,n)}}const mn=[171,75,84,88,32,50,48,187,13,10,26,10];function Z_(r){return new TextDecoder().decode(r)}function $k(r){const e=new Uint8Array(r.buffer,r.byteOffset,mn.length);if(e[0]!==mn[0]||e[1]!==mn[1]||e[2]!==mn[2]||e[3]!==mn[3]||e[4]!==mn[4]||e[5]!==mn[5]||e[6]!==mn[6]||e[7]!==mn[7]||e[8]!==mn[8]||e[9]!==mn[9]||e[10]!==mn[10]||e[11]!==mn[11])throw new Error("Missing KTX 2.0 identifier.");const t={vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,supercompressionScheme:0,levels:[],dataFormatDescriptor:[{vendorId:0,descriptorType:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null},i=17*Uint32Array.BYTES_PER_ELEMENT,n=new _h(r,mn.length,i,!0);t.vkFormat=n._nextUint32(),t.typeSize=n._nextUint32(),t.pixelWidth=n._nextUint32(),t.pixelHeight=n._nextUint32(),t.pixelDepth=n._nextUint32(),t.layerCount=n._nextUint32(),t.faceCount=n._nextUint32(),t.levelCount=n._nextUint32(),t.supercompressionScheme=n._nextUint32();const s=n._nextUint32(),a=n._nextUint32(),o=n._nextUint32(),l=n._nextUint32(),c=n._nextUint64(),h=n._nextUint64(),d=3*Math.max(t.levelCount,1)*8,p=new _h(r,mn.length+i,d,!0);for(let q=0,Y=Math.max(t.levelCount,1);q<Y;q++)t.levels.push({levelData:new Uint8Array(r.buffer,r.byteOffset+p._nextUint64(),p._nextUint64()),uncompressedByteLength:p._nextUint64()});const u=new _h(r,s,a,!0);u._skip(4);const A=u._nextUint16(),m=u._nextUint16(),g=u._nextUint16(),f=u._nextUint16(),v={vendorId:A,descriptorType:m,versionNumber:g,colorModel:u._nextUint8(),colorPrimaries:u._nextUint8(),transferFunction:u._nextUint8(),flags:u._nextUint8(),texelBlockDimension:[u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8()],bytesPlane:[u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8()],samples:[]},b=(f/4-6)/4;for(let q=0;q<b;q++){const Y={bitOffset:u._nextUint16(),bitLength:u._nextUint8(),channelType:u._nextUint8(),samplePosition:[u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};64&Y.channelType?(Y.sampleLower=u._nextInt32(),Y.sampleUpper=u._nextInt32()):(Y.sampleLower=u._nextUint32(),Y.sampleUpper=u._nextUint32()),v.samples[q]=Y}t.dataFormatDescriptor.length=0,t.dataFormatDescriptor.push(v);const y=new _h(r,o,l,!0);for(;y._offset<l;){const q=y._nextUint32(),Y=y._scan(q),ye=Z_(Y);if(t.keyValue[ye]=y._nextUint8Array(q-Y.byteLength-1),ye.match(/^ktx/i)){const Me=Z_(t.keyValue[ye]);t.keyValue[ye]=Me.substring(0,Me.lastIndexOf("\0"))}y._skip(q%4?4-q%4:0)}if(h<=0)return t;const M=new _h(r,c,h,!0),_=M._nextUint16(),S=M._nextUint16(),w=M._nextUint32(),E=M._nextUint32(),I=M._nextUint32(),B=M._nextUint32(),R=[];for(let q=0,Y=Math.max(t.levelCount,1);q<Y;q++)R.push({imageFlags:M._nextUint32(),rgbSliceByteOffset:M._nextUint32(),rgbSliceByteLength:M._nextUint32(),alphaSliceByteOffset:M._nextUint32(),alphaSliceByteLength:M._nextUint32()});const U=c+M._offset,C=U+w,F=C+E,O=F+I,H=new Uint8Array(r.buffer,r.byteOffset+U,w),j=new Uint8Array(r.buffer,r.byteOffset+C,E),G=new Uint8Array(r.buffer,r.byteOffset+F,I),re=new Uint8Array(r.buffer,r.byteOffset+O,B);return t.globalData={endpointCount:_,selectorCount:S,imageDescs:R,endpointsData:H,selectorsData:j,tablesData:G,extendedData:re},t}let K0,hr,Z0;const J0={env:{emscripten_notify_memory_growth:function(r){Z0=new Uint8Array(hr.exports.memory.buffer)}}};class eN{init(){return K0||(K0=typeof fetch<"u"?fetch("data:application/wasm;base64,"+J_).then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,J0)).then(this._init):WebAssembly.instantiate(Buffer.from(J_,"base64"),J0).then(this._init),K0)}_init(e){hr=e.instance,J0.env.emscripten_notify_memory_growth(0)}decode(e,t=0){if(!hr)throw new Error("ZSTDDecoder: Await .init() before decoding.");const i=e.byteLength,n=hr.exports.malloc(i);Z0.set(e,n),t=t||Number(hr.exports.ZSTD_findDecompressedSize(n,i));const s=hr.exports.malloc(t),a=hr.exports.ZSTD_decompress(s,t,n,i),o=Z0.slice(s,s+a);return hr.exports.free(n),hr.exports.free(s),o}}const J_="AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21lbW9yeV9ncm93dGgABANpaAEFAAAFAgEFCwACAQABAgIFBQcAAwABDgsBAQcAEhMHAAUBDAQEAAANBwQCAgYCBAgDAwMDBgEACQkHBgICAAYGAgQUBwYGAwIGAAMCAQgBBwUGCgoEEQAEBAEIAwgDBQgDEA8IAAcABAUBcAECAgUEAQCAAgYJAX8BQaCgwAILB2AHBm1lbW9yeQIABm1hbGxvYwAoBGZyZWUAJgxaU1REX2lzRXJyb3IAaBlaU1REX2ZpbmREZWNvbXByZXNzZWRTaXplAFQPWlNURF9kZWNvbXByZXNzAEoGX3N0YXJ0ACQJBwEAQQELASQKussBaA8AIAAgACgCBCABajYCBAsZACAAKAIAIAAoAgRBH3F0QQAgAWtBH3F2CwgAIABBiH9LC34BBH9BAyEBIAAoAgQiA0EgTQRAIAAoAggiASAAKAIQTwRAIAAQDQ8LIAAoAgwiAiABRgRAQQFBAiADQSBJGw8LIAAgASABIAJrIANBA3YiBCABIARrIAJJIgEbIgJrIgQ2AgggACADIAJBA3RrNgIEIAAgBCgAADYCAAsgAQsUAQF/IAAgARACIQIgACABEAEgAgv3AQECfyACRQRAIABCADcCACAAQQA2AhAgAEIANwIIQbh/DwsgACABNgIMIAAgAUEEajYCECACQQRPBEAgACABIAJqIgFBfGoiAzYCCCAAIAMoAAA2AgAgAUF/ai0AACIBBEAgAEEIIAEQFGs2AgQgAg8LIABBADYCBEF/DwsgACABNgIIIAAgAS0AACIDNgIAIAJBfmoiBEEBTQRAIARBAWtFBEAgACABLQACQRB0IANyIgM2AgALIAAgAS0AAUEIdCADajYCAAsgASACakF/ai0AACIBRQRAIABBADYCBEFsDwsgAEEoIAEQFCACQQN0ams2AgQgAgsWACAAIAEpAAA3AAAgACABKQAINwAICy8BAX8gAUECdEGgHWooAgAgACgCAEEgIAEgACgCBGprQR9xdnEhAiAAIAEQASACCyEAIAFCz9bTvtLHq9lCfiAAfEIfiUKHla+vmLbem55/fgsdAQF/IAAoAgggACgCDEYEfyAAKAIEQSBGBUEACwuCBAEDfyACQYDAAE8EQCAAIAEgAhBnIAAPCyAAIAJqIQMCQCAAIAFzQQNxRQRAAkAgAkEBSARAIAAhAgwBCyAAQQNxRQRAIAAhAgwBCyAAIQIDQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADTw0BIAJBA3ENAAsLAkAgA0F8cSIEQcAASQ0AIAIgBEFAaiIFSw0AA0AgAiABKAIANgIAIAIgASgCBDYCBCACIAEoAgg2AgggAiABKAIMNgIMIAIgASgCEDYCECACIAEoAhQ2AhQgAiABKAIYNgIYIAIgASgCHDYCHCACIAEoAiA2AiAgAiABKAIkNgIkIAIgASgCKDYCKCACIAEoAiw2AiwgAiABKAIwNgIwIAIgASgCNDYCNCACIAEoAjg2AjggAiABKAI8NgI8IAFBQGshASACQUBrIgIgBU0NAAsLIAIgBE8NAQNAIAIgASgCADYCACABQQRqIQEgAkEEaiICIARJDQALDAELIANBBEkEQCAAIQIMAQsgA0F8aiIEIABJBEAgACECDAELIAAhAgNAIAIgAS0AADoAACACIAEtAAE6AAEgAiABLQACOgACIAIgAS0AAzoAAyABQQRqIQEgAkEEaiICIARNDQALCyACIANJBEADQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADRw0ACwsgAAsMACAAIAEpAAA3AAALQQECfyAAKAIIIgEgACgCEEkEQEEDDwsgACAAKAIEIgJBB3E2AgQgACABIAJBA3ZrIgE2AgggACABKAAANgIAQQALDAAgACABKAIANgAAC/cCAQJ/AkAgACABRg0AAkAgASACaiAASwRAIAAgAmoiBCABSw0BCyAAIAEgAhALDwsgACABc0EDcSEDAkACQCAAIAFJBEAgAwRAIAAhAwwDCyAAQQNxRQRAIAAhAwwCCyAAIQMDQCACRQ0EIAMgAS0AADoAACABQQFqIQEgAkF/aiECIANBAWoiA0EDcQ0ACwwBCwJAIAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQhBSAGQQR2IQRBICAAdCIAQQFyIQkgASgCACEPQQAhAiADIQYCQANAIAlBAkggAiAPS3JFBEAgAiEHAkAgCARAA0AgBEH//wNxQf//A0YEQCAHQRhqIQcgBiAQSQR/IAZBAmoiBigAACAFdgUgBUEQaiEFIARBEHYLIQQMAQsLA0AgBEEDcSIIQQNGBEAgBUECaiEFIARBAnYhBCAHQQNqIQcMAQsLIAcgCGoiByAPSw0EIAVBAmohBQNAIAIgB0kEQCANIAJBAXRqQQA7AQAgAkEBaiECDAELCyAGIA5LQQAgBiAFQQN1aiIHIAxLG0UEQCAHKAAAIAVBB3EiBXYhBAwCCyAEQQJ2IQQLIAYhBwsCfyALQX9qIAQgAEF/anEiBiAAQQF0QX9qIgggCWsiEUkNABogBCAIcSIEQQAgESAEIABIG2shBiALCyEIIA0gAkEBdGogBkF/aiIEOwEAIAlBASAGayAEIAZBAUgbayEJA0AgCSAASARAIABBAXUhACALQX9qIQsMAQsLAn8gByAOS0EAIAcgBSAIaiIFQQN1aiIGIAxLG0UEQCAFQQdxDAELIAUgDCIGIAdrQQN0awshBSACQQFqIQIgBEUhCCAGKAAAIAVBH3F2IQQMAQsLQWwgCUEBRyAFQSBKcg0BGiABIAJBf2o2AgAgBiAFQQdqQQN1aiADawwBC0FQCyEAIApBEGokACAACwkAQQFBBSAAGwsMACAAIAEoAAA2AAALqgMBCn8jAEHwAGsiCiQAIAJBAWohDiAAQQhqIQtBgIAEIAVBf2p0QRB1IQxBACECQQEhBkEBIAV0IglBf2oiDyEIA0AgAiAORkUEQAJAIAEgAkEBdCINai8BACIHQf//A0YEQCALIAhBA3RqIAI2AgQgCEF/aiEIQQEhBwwBCyAGQQAgDCAHQRB0QRB1ShshBgsgCiANaiAHOwEAIAJBAWohAgwBCwsgACAFNgIEIAAgBjYCACAJQQN2IAlBAXZqQQNqIQxBACEAQQAhBkEAIQIDQCAGIA5GBEADQAJAIAAgCUYNACAKIAsgAEEDdGoiASgCBCIGQQF0aiICIAIvAQAiAkEBajsBACABIAUgAhAUayIIOgADIAEgAiAIQf8BcXQgCWs7AQAgASAEIAZBAnQiAmooAgA6AAIgASACIANqKAIANgIEIABBAWohAAwBCwsFIAEgBkEBdGouAQAhDUEAIQcDQCAHIA1ORQRAIAsgAkEDdGogBjYCBANAIAIgDGogD3EiAiAISw0ACyAHQQFqIQcMAQsLIAZBAWohBgwBCwsgCkHwAGokAAsjAEIAIAEQCSAAhUKHla+vmLbem55/fkLj3MqV/M7y9YV/fAsQACAAQn43AwggACABNgIACyQBAX8gAARAIAEoAgQiAgRAIAEoAgggACACEQEADwsgABAmCwsfACAAIAEgAi8BABAINgIAIAEQBBogACACQQRqNgIEC0oBAX9BoCAoAgAiASAAaiIAQX9MBEBBiCBBMDYCAEF/DwsCQCAAPwBBEHRNDQAgABBmDQBBiCBBMDYCAEF/DwtBoCAgADYCACABC9cBAQh/Qbp/IQoCQCACKAIEIgggAigCACIJaiIOIAEgAGtLDQBBbCEKIAkgBCADKAIAIgtrSw0AIAAgCWoiBCACKAIIIgxrIQ0gACABQWBqIg8gCyAJQQAQKSADIAkgC2o2AgACQAJAIAwgBCAFa00EQCANIQUMAQsgDCAEIAZrSw0CIAcgDSAFayIAaiIBIAhqIAdNBEAgBCABIAgQDxoMAgsgBCABQQAgAGsQDyEBIAIgACAIaiIINgIEIAEgAGshBAsgBCAPIAUgCEEBECkLIA4hCgsgCgubAgEBfyMAQYABayINJAAgDSADNgJ8AkAgAkEDSwRAQX8hCQwBCwJAAkACQAJAIAJBAWsOAwADAgELIAZFBEBBuH8hCQwEC0FsIQkgBS0AACICIANLDQMgACAHIAJBAnQiAmooAgAgAiAIaigCABA7IAEgADYCAEEBIQkMAwsgASAJNgIAQQAhCQwCCyAKRQRAQWwhCQwCC0EAIQkgC0UgDEEZSHINAUEIIAR0QQhqIQBBACECA0AgAiAATw0CIAJBQGshAgwAAAsAC0FsIQkgDSANQfwAaiANQfgAaiAFIAYQFSICEAMNACANKAJ4IgMgBEsNACAAIA0gDSgCfCAHIAggAxAYIAEgADYCACACIQkLIA1BgAFqJAAgCQsLACAAIAEgAhALGgsQACAALwAAIAAtAAJBEHRyCy8AAn9BuH8gAUEISQ0AGkFyIAAoAAQiAEF3Sw0AGkG4fyAAQQhqIgAgACABSxsLCwkAIAAgATsAAAsDAAELigYBBX8gACAAKAIAIgVBfnE2AgBBACAAIAVBAXZqQYQgKAIAIgQgAEYbIQECQAJAIAAoAgQiAkUNACACKAIAIgNBAXENACACQQhqIgUgA0EBdkF4aiIDQQggA0EISxtnQR9zQQJ0QYAfaiIDKAIARgRAIAMgAigCDDYCAAsgAigCCCIDBEAgAyACKAIMNgIECyACKAIMIgMEQCADIAIoAgg2AgALIAIgAigCACAAKAIAQX5xajYCAEGEICEAAkACQCABRQ0AIAEgAjYCBCABKAIAIgNBAXENASADQQF2QXhqIgNBCCADQQhLG2dBH3NBAnRBgB9qIgMoAgAgAUEIakYEQCADIAEoAgw2AgALIAEoAggiAwRAIAMgASgCDDYCBAsgASgCDCIDBEAgAyABKAIINgIAQYQgKAIAIQQLIAIgAigCACABKAIAQX5xajYCACABIARGDQAgASABKAIAQQF2akEEaiEACyAAIAI2AgALIAIoAgBBAXZBeGoiAEEIIABBCEsbZ0Efc0ECdEGAH2oiASgCACEAIAEgBTYCACACIAA2AgwgAkEANgIIIABFDQEgACAFNgIADwsCQCABRQ0AIAEoAgAiAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAigCACABQQhqRgRAIAIgASgCDDYCAAsgASgCCCICBEAgAiABKAIMNgIECyABKAIMIgIEQCACIAEoAgg2AgBBhCAoAgAhBAsgACAAKAIAIAEoAgBBfnFqIgI2AgACQCABIARHBEAgASABKAIAQQF2aiAANgIEIAAoAgAhAgwBC0GEICAANgIACyACQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgIoAgAhASACIABBCGoiAjYCACAAIAE2AgwgAEEANgIIIAFFDQEgASACNgIADwsgBUEBdkF4aiIBQQggAUEISxtnQR9zQQJ0QYAfaiICKAIAIQEgAiAAQQhqIgI2AgAgACABNgIMIABBADYCCCABRQ0AIAEgAjYCAAsLDgAgAARAIABBeGoQJQsLgAIBA38CQCAAQQ9qQXhxQYQgKAIAKAIAQQF2ayICEB1Bf0YNAAJAQYQgKAIAIgAoAgAiAUEBcQ0AIAFBAXZBeGoiAUEIIAFBCEsbZ0Efc0ECdEGAH2oiASgCACAAQQhqRgRAIAEgACgCDDYCAAsgACgCCCIBBEAgASAAKAIMNgIECyAAKAIMIgFFDQAgASAAKAIINgIAC0EBIQEgACAAKAIAIAJBAXRqIgI2AgAgAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAygCACECIAMgAEEIaiIDNgIAIAAgAjYCDCAAQQA2AgggAkUNACACIAM2AgALIAELtwIBA38CQAJAIABBASAAGyICEDgiAA0AAkACQEGEICgCACIARQ0AIAAoAgAiA0EBcQ0AIAAgA0EBcjYCACADQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgAgAEEIakYEQCABIAAoAgw2AgALIAAoAggiAQRAIAEgACgCDDYCBAsgACgCDCIBBEAgASAAKAIINgIACyACECchAkEAIQFBhCAoAgAhACACDQEgACAAKAIAQX5xNgIAQQAPCyACQQ9qQXhxIgMQHSICQX9GDQIgAkEHakF4cSIAIAJHBEAgACACaxAdQX9GDQMLAkBBhCAoAgAiAUUEQEGAICAANgIADAELIAAgATYCBAtBhCAgADYCACAAIANBAXRBAXI2AgAMAQsgAEUNAQsgAEEIaiEBCyABC7kDAQJ/IAAgA2ohBQJAIANBB0wEQANAIAAgBU8NAiAAIAItAAA6AAAgAEEBaiEAIAJBAWohAgwAAAsACyAEQQFGBEACQCAAIAJrIgZBB00EQCAAIAItAAA6AAAgACACLQABOgABIAAgAi0AAjoAAiAAIAItAAM6AAMgAEEEaiACIAZBAnQiBkHAHmooAgBqIgIQFyACIAZB4B5qKAIAayECDAELIAAgAhAMCyACQQhqIQIgAEEIaiEACwJAAkACQAJAIAUgAU0EQCAAIANqIQEgBEEBRyAAIAJrQQ9Kcg0BA0AgACACEAwgAkEIaiECIABBCGoiACABSQ0ACwwFCyAAIAFLBEAgACEBDAQLIARBAUcgACACa0EPSnINASAAIQMgAiEEA0AgAyAEEAwgBEEIaiEEIANBCGoiAyABSQ0ACwwCCwNAIAAgAhAHIAJBEGohAiAAQRBqIgAgAUkNAAsMAwsgACEDIAIhBANAIAMgBBAHIARBEGohBCADQRBqIgMgAUkNAAsLIAIgASAAa2ohAgsDQCABIAVPDQEgASACLQAAOgAAIAFBAWohASACQQFqIQIMAAALAAsLQQECfyAAIAAoArjgASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigCACACaiAAQQZ2IgFBAnRBsB5qKAIAaiAAQSBxIgBFaiABRSAAQQV2cWoFQbh/CwsdACAAKAKQ4gEQWiAAQQA2AqDiASAAQgA3A5DiAQu1AwEFfyMAQZACayIKJABBuH8hBgJAIAVFDQAgBCwAACIIQf8BcSEHAkAgCEF/TARAIAdBgn9qQQF2IgggBU8NAkFsIQYgB0GBf2oiBUGAAk8NAiAEQQFqIQdBACEGA0AgBiAFTwRAIAUhBiAIIQcMAwUgACAGaiAHIAZBAXZqIgQtAABBBHY6AAAgACAGQQFyaiAELQAAQQ9xOgAAIAZBAmohBgwBCwAACwALIAcgBU8NASAAIARBAWogByAKEFMiBhADDQELIAYhBEEAIQYgAUEAQTQQECEJQQAhBQNAIAQgBkcEQCAAIAZqIggtAAAiAUELSwRAQWwhBgwDBSAJIAFBAnRqIgEgASgCAEEBajYCACAGQQFqIQZBASAILQAAdEEBdSAFaiEFDAILAAsLQWwhBiAFRQ0AIAUQFEEBaiIBQQxLDQAgAyABNgIAQQFBASABdCAFayIDEBQiAXQgA0cNACAAIARqIAFBAWoiADoAACAJIABBAnRqIgAgACgCAEEBajYCACAJKAIEIgBBAkkgAEEBcXINACACIARBAWo2AgAgB0EBaiEGCyAKQZACaiQAIAYLxhEBDH8jAEHwAGsiBSQAQWwhCwJAIANBCkkNACACLwAAIQogAi8AAiEJIAIvAAQhByAFQQhqIAQQDgJAIAMgByAJIApqakEGaiIMSQ0AIAUtAAohCCAFQdgAaiACQQZqIgIgChAGIgsQAw0BIAVBQGsgAiAKaiICIAkQBiILEAMNASAFQShqIAIgCWoiAiAHEAYiCxADDQEgBUEQaiACIAdqIAMgDGsQBiILEAMNASAAIAFqIg9BfWohECAEQQRqIQZBASELIAAgAUEDakECdiIDaiIMIANqIgIgA2oiDiEDIAIhBCAMIQcDQCALIAMgEElxBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgCS0AAyELIAcgBiAFQUBrIAgQAkECdGoiCS8BADsAACAFQUBrIAktAAIQASAJLQADIQogBCAGIAVBKGogCBACQQJ0aiIJLwEAOwAAIAVBKGogCS0AAhABIAktAAMhCSADIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgDS0AAyENIAAgC2oiCyAGIAVB2ABqIAgQAkECdGoiAC8BADsAACAFQdgAaiAALQACEAEgAC0AAyEAIAcgCmoiCiAGIAVBQGsgCBACQQJ0aiIHLwEAOwAAIAVBQGsgBy0AAhABIActAAMhByAEIAlqIgkgBiAFQShqIAgQAkECdGoiBC8BADsAACAFQShqIAQtAAIQASAELQADIQQgAyANaiIDIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgACALaiEAIAcgCmohByAEIAlqIQQgAyANLQADaiEDIAVB2ABqEA0gBUFAaxANciAFQShqEA1yIAVBEGoQDXJFIQsMAQsLIAQgDksgByACS3INAEFsIQsgACAMSw0BIAxBfWohCQNAQQAgACAJSSAFQdgAahAEGwRAIAAgBiAFQdgAaiAIEAJBAnRqIgovAQA7AAAgBUHYAGogCi0AAhABIAAgCi0AA2oiACAGIAVB2ABqIAgQAkECdGoiCi8BADsAACAFQdgAaiAKLQACEAEgACAKLQADaiEADAEFIAxBfmohCgNAIAVB2ABqEAQgACAKS3JFBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgACAJLQADaiEADAELCwNAIAAgCk0EQCAAIAYgBUHYAGogCBACQQJ0aiIJLwEAOwAAIAVB2ABqIAktAAIQASAAIAktAANqIQAMAQsLAkAgACAMTw0AIAAgBiAFQdgAaiAIEAIiAEECdGoiDC0AADoAACAMLQADQQFGBEAgBUHYAGogDC0AAhABDAELIAUoAlxBH0sNACAFQdgAaiAGIABBAnRqLQACEAEgBSgCXEEhSQ0AIAVBIDYCXAsgAkF9aiEMA0BBACAHIAxJIAVBQGsQBBsEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiIAIAYgBUFAayAIEAJBAnRqIgcvAQA7AAAgBUFAayAHLQACEAEgACAHLQADaiEHDAEFIAJBfmohDANAIAVBQGsQBCAHIAxLckUEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwNAIAcgDE0EQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwJAIAcgAk8NACAHIAYgBUFAayAIEAIiAEECdGoiAi0AADoAACACLQADQQFGBEAgBUFAayACLQACEAEMAQsgBSgCREEfSw0AIAVBQGsgBiAAQQJ0ai0AAhABIAUoAkRBIUkNACAFQSA2AkQLIA5BfWohAgNAQQAgBCACSSAFQShqEAQbBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2oiACAGIAVBKGogCBACQQJ0aiIELwEAOwAAIAVBKGogBC0AAhABIAAgBC0AA2ohBAwBBSAOQX5qIQIDQCAFQShqEAQgBCACS3JFBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsDQCAEIAJNBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsCQCAEIA5PDQAgBCAGIAVBKGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBKGogAi0AAhABDAELIAUoAixBH0sNACAFQShqIAYgAEECdGotAAIQASAFKAIsQSFJDQAgBUEgNgIsCwNAQQAgAyAQSSAFQRBqEAQbBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2oiACAGIAVBEGogCBACQQJ0aiICLwEAOwAAIAVBEGogAi0AAhABIAAgAi0AA2ohAwwBBSAPQX5qIQIDQCAFQRBqEAQgAyACS3JFBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsDQCADIAJNBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsCQCADIA9PDQAgAyAGIAVBEGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBEGogAi0AAhABDAELIAUoAhRBH0sNACAFQRBqIAYgAEECdGotAAIQASAFKAIUQSFJDQAgBUEgNgIUCyABQWwgBUHYAGoQCiAFQUBrEApxIAVBKGoQCnEgBUEQahAKcRshCwwJCwAACwALAAALAAsAAAsACwAACwALQWwhCwsgBUHwAGokACALC7UEAQ5/IwBBEGsiBiQAIAZBBGogABAOQVQhBQJAIARB3AtJDQAgBi0ABCEHIANB8ARqQQBB7AAQECEIIAdBDEsNACADQdwJaiIJIAggBkEIaiAGQQxqIAEgAhAxIhAQA0UEQCAGKAIMIgQgB0sNASADQdwFaiEPIANBpAVqIREgAEEEaiESIANBqAVqIQEgBCEFA0AgBSICQX9qIQUgCCACQQJ0aigCAEUNAAsgAkEBaiEOQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgASALaiAKNgIAIAVBAWohBSAKIAxqIQoMAQsLIAEgCjYCAEEAIQUgBigCCCELA0AgBSALRkUEQCABIAUgCWotAAAiDEECdGoiDSANKAIAIg1BAWo2AgAgDyANQQF0aiINIAw6AAEgDSAFOgAAIAVBAWohBQwBCwtBACEBIANBADYCqAUgBEF/cyAHaiEJQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgAyALaiABNgIAIAwgBSAJanQgAWohASAFQQFqIQUMAQsLIAcgBEEBaiIBIAJrIgRrQQFqIQgDQEEBIQUgBCAIT0UEQANAIAUgDk9FBEAgBUECdCIJIAMgBEE0bGpqIAMgCWooAgAgBHY2AgAgBUEBaiEFDAELCyAEQQFqIQQMAQsLIBIgByAPIAogESADIAIgARBkIAZBAToABSAGIAc6AAYgACAGKAIENgIACyAQIQULIAZBEGokACAFC8ENAQt/IwBB8ABrIgUkAEFsIQkCQCADQQpJDQAgAi8AACEKIAIvAAIhDCACLwAEIQYgBUEIaiAEEA4CQCADIAYgCiAMampBBmoiDUkNACAFLQAKIQcgBUHYAGogAkEGaiICIAoQBiIJEAMNASAFQUBrIAIgCmoiAiAMEAYiCRADDQEgBUEoaiACIAxqIgIgBhAGIgkQAw0BIAVBEGogAiAGaiADIA1rEAYiCRADDQEgACABaiIOQX1qIQ8gBEEEaiEGQQEhCSAAIAFBA2pBAnYiAmoiCiACaiIMIAJqIg0hAyAMIQQgCiECA0AgCSADIA9JcQRAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAACAGIAVBQGsgBxACQQF0aiIILQAAIQsgBUFAayAILQABEAEgAiALOgAAIAYgBUEoaiAHEAJBAXRqIggtAAAhCyAFQShqIAgtAAEQASAEIAs6AAAgBiAFQRBqIAcQAkEBdGoiCC0AACELIAVBEGogCC0AARABIAMgCzoAACAGIAVB2ABqIAcQAkEBdGoiCC0AACELIAVB2ABqIAgtAAEQASAAIAs6AAEgBiAFQUBrIAcQAkEBdGoiCC0AACELIAVBQGsgCC0AARABIAIgCzoAASAGIAVBKGogBxACQQF0aiIILQAAIQsgBUEoaiAILQABEAEgBCALOgABIAYgBUEQaiAHEAJBAXRqIggtAAAhCyAFQRBqIAgtAAEQASADIAs6AAEgA0ECaiEDIARBAmohBCACQQJqIQIgAEECaiEAIAkgBUHYAGoQDUVxIAVBQGsQDUVxIAVBKGoQDUVxIAVBEGoQDUVxIQkMAQsLIAQgDUsgAiAMS3INAEFsIQkgACAKSw0BIApBfWohCQNAIAVB2ABqEAQgACAJT3JFBEAgBiAFQdgAaiAHEAJBAXRqIggtAAAhCyAFQdgAaiAILQABEAEgACALOgAAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAASAAQQJqIQAMAQsLA0AgBUHYAGoQBCAAIApPckUEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCwNAIAAgCkkEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCyAMQX1qIQADQCAFQUBrEAQgAiAAT3JFBEAgBiAFQUBrIAcQAkEBdGoiCi0AACEJIAVBQGsgCi0AARABIAIgCToAACAGIAVBQGsgBxACQQF0aiIKLQAAIQkgBUFAayAKLQABEAEgAiAJOgABIAJBAmohAgwBCwsDQCAFQUBrEAQgAiAMT3JFBEAgBiAFQUBrIAcQAkEBdGoiAC0AACEKIAVBQGsgAC0AARABIAIgCjoAACACQQFqIQIMAQsLA0AgAiAMSQRAIAYgBUFAayAHEAJBAXRqIgAtAAAhCiAFQUBrIAAtAAEQASACIAo6AAAgAkEBaiECDAELCyANQX1qIQADQCAFQShqEAQgBCAAT3JFBEAgBiAFQShqIAcQAkEBdGoiAi0AACEKIAVBKGogAi0AARABIAQgCjoAACAGIAVBKGogBxACQQF0aiICLQAAIQogBUEoaiACLQABEAEgBCAKOgABIARBAmohBAwBCwsDQCAFQShqEAQgBCANT3JFBEAgBiAFQShqIAcQAkEBdGoiAC0AACECIAVBKGogAC0AARABIAQgAjoAACAEQQFqIQQMAQsLA0AgBCANSQRAIAYgBUEoaiAHEAJBAXRqIgAtAAAhAiAFQShqIAAtAAEQASAEIAI6AAAgBEEBaiEEDAELCwNAIAVBEGoQBCADIA9PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIAYgBUEQaiAHEAJBAXRqIgAtAAAhAiAFQRBqIAAtAAEQASADIAI6AAEgA0ECaiEDDAELCwNAIAVBEGoQBCADIA5PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIANBAWohAwwBCwsDQCADIA5JBEAgBiAFQRBqIAcQAkEBdGoiAC0AACECIAVBEGogAC0AARABIAMgAjoAACADQQFqIQMMAQsLIAFBbCAFQdgAahAKIAVBQGsQCnEgBUEoahAKcSAFQRBqEApxGyEJDAELQWwhCQsgBUHwAGokACAJC8oCAQR/IwBBIGsiBSQAIAUgBBAOIAUtAAIhByAFQQhqIAIgAxAGIgIQA0UEQCAEQQRqIQIgACABaiIDQX1qIQQDQCAFQQhqEAQgACAET3JFBEAgAiAFQQhqIAcQAkEBdGoiBi0AACEIIAVBCGogBi0AARABIAAgCDoAACACIAVBCGogBxACQQF0aiIGLQAAIQggBUEIaiAGLQABEAEgACAIOgABIABBAmohAAwBCwsDQCAFQQhqEAQgACADT3JFBEAgAiAFQQhqIAcQAkEBdGoiBC0AACEGIAVBCGogBC0AARABIAAgBjoAACAAQQFqIQAMAQsLA0AgACADT0UEQCACIAVBCGogBxACQQF0aiIELQAAIQYgBUEIaiAELQABEAEgACAGOgAAIABBAWohAAwBCwsgAUFsIAVBCGoQChshAgsgBUEgaiQAIAILtgMBCX8jAEEQayIGJAAgBkEANgIMIAZBADYCCEFUIQQCQAJAIANBQGsiDCADIAZBCGogBkEMaiABIAIQMSICEAMNACAGQQRqIAAQDiAGKAIMIgcgBi0ABEEBaksNASAAQQRqIQogBkEAOgAFIAYgBzoABiAAIAYoAgQ2AgAgB0EBaiEJQQEhBANAIAQgCUkEQCADIARBAnRqIgEoAgAhACABIAU2AgAgACAEQX9qdCAFaiEFIARBAWohBAwBCwsgB0EBaiEHQQAhBSAGKAIIIQkDQCAFIAlGDQEgAyAFIAxqLQAAIgRBAnRqIgBBASAEdEEBdSILIAAoAgAiAWoiADYCACAHIARrIQhBACEEAkAgC0EDTQRAA0AgBCALRg0CIAogASAEakEBdGoiACAIOgABIAAgBToAACAEQQFqIQQMAAALAAsDQCABIABPDQEgCiABQQF0aiIEIAg6AAEgBCAFOgAAIAQgCDoAAyAEIAU6AAIgBCAIOgAFIAQgBToABCAEIAg6AAcgBCAFOgAGIAFBBGohAQwAAAsACyAFQQFqIQUMAAALAAsgAiEECyAGQRBqJAAgBAutAQECfwJAQYQgKAIAIABHIAAoAgBBAXYiAyABa0F4aiICQXhxQQhHcgR/IAIFIAMQJ0UNASACQQhqC0EQSQ0AIAAgACgCACICQQFxIAAgAWpBD2pBeHEiASAAa0EBdHI2AgAgASAANgIEIAEgASgCAEEBcSAAIAJBAXZqIAFrIgJBAXRyNgIAQYQgIAEgAkH/////B3FqQQRqQYQgKAIAIABGGyABNgIAIAEQJQsLygIBBX8CQAJAAkAgAEEIIABBCEsbZ0EfcyAAaUEBR2oiAUEESSAAIAF2cg0AIAFBAnRB/B5qKAIAIgJFDQADQCACQXhqIgMoAgBBAXZBeGoiBSAATwRAIAIgBUEIIAVBCEsbZ0Efc0ECdEGAH2oiASgCAEYEQCABIAIoAgQ2AgALDAMLIARBHksNASAEQQFqIQQgAigCBCICDQALC0EAIQMgAUEgTw0BA0AgAUECdEGAH2ooAgAiAkUEQCABQR5LIQIgAUEBaiEBIAJFDQEMAwsLIAIgAkF4aiIDKAIAQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgBGBEAgASACKAIENgIACwsgAigCACIBBEAgASACKAIENgIECyACKAIEIgEEQCABIAIoAgA2AgALIAMgAygCAEEBcjYCACADIAAQNwsgAwvhCwINfwV+IwBB8ABrIgckACAHIAAoAvDhASIINgJcIAEgAmohDSAIIAAoAoDiAWohDwJAAkAgBUUEQCABIQQMAQsgACgCxOABIRAgACgCwOABIREgACgCvOABIQ4gAEEBNgKM4QFBACEIA0AgCEEDRwRAIAcgCEECdCICaiAAIAJqQazQAWooAgA2AkQgCEEBaiEIDAELC0FsIQwgB0EYaiADIAQQBhADDQEgB0EsaiAHQRhqIAAoAgAQEyAHQTRqIAdBGGogACgCCBATIAdBPGogB0EYaiAAKAIEEBMgDUFgaiESIAEhBEEAIQwDQCAHKAIwIAcoAixBA3RqKQIAIhRCEIinQf8BcSEIIAcoAkAgBygCPEEDdGopAgAiFUIQiKdB/wFxIQsgBygCOCAHKAI0QQN0aikCACIWQiCIpyEJIBVCIIghFyAUQiCIpyECAkAgFkIQiKdB/wFxIgNBAk8EQAJAIAZFIANBGUlyRQRAIAkgB0EYaiADQSAgBygCHGsiCiAKIANLGyIKEAUgAyAKayIDdGohCSAHQRhqEAQaIANFDQEgB0EYaiADEAUgCWohCQwBCyAHQRhqIAMQBSAJaiEJIAdBGGoQBBoLIAcpAkQhGCAHIAk2AkQgByAYNwNIDAELAkAgA0UEQCACBEAgBygCRCEJDAMLIAcoAkghCQwBCwJAAkAgB0EYakEBEAUgCSACRWpqIgNBA0YEQCAHKAJEQX9qIgMgA0VqIQkMAQsgA0ECdCAHaigCRCIJIAlFaiEJIANBAUYNAQsgByAHKAJINgJMCwsgByAHKAJENgJIIAcgCTYCRAsgF6chAyALBEAgB0EYaiALEAUgA2ohAwsgCCALakEUTwRAIAdBGGoQBBoLIAgEQCAHQRhqIAgQBSACaiECCyAHQRhqEAQaIAcgB0EYaiAUQhiIp0H/AXEQCCAUp0H//wNxajYCLCAHIAdBGGogFUIYiKdB/wFxEAggFadB//8DcWo2AjwgB0EYahAEGiAHIAdBGGogFkIYiKdB/wFxEAggFqdB//8DcWo2AjQgByACNgJgIAcoAlwhCiAHIAk2AmggByADNgJkAkACQAJAIAQgAiADaiILaiASSw0AIAIgCmoiEyAPSw0AIA0gBGsgC0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdBKGogACgCBBATQQAhBCAHQeAAaiEMIAdB5ABqIQoDQCAHQShqEARBAksgBCAXTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEJIAcoAkggBygCREEDdGopAgAiH0IgiKchCCAeQiCIISAgHUIgiKchAgJAIB9CEIinQf8BcSIDQQJPBEACQCAGRSADQRlJckUEQCAIIAdBKGogA0EgIAcoAixrIg0gDSADSxsiDRAFIAMgDWsiA3RqIQggB0EoahAEGiADRQ0BIAdBKGogAxAFIAhqIQgMAQsgB0EoaiADEAUgCGohCCAHQShqEAQaCyAHKQJUISEgByAINgJUIAcgITcDWAwBCwJAIANFBEAgAgRAIAcoAlQhCAwDCyAHKAJYIQgMAQsCQAJAIAdBKGpBARAFIAggAkVqaiIDQQNGBEAgBygCVEF/aiIDIANFaiEIDAELIANBAnQgB2ooAlQiCCAIRWohCCADQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAg2AlQLICCnIQMgCQRAIAdBKGogCRAFIANqIQMLIAkgC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgAmohAgsgB0EoahAEGiAHIAcoAmggAmoiCSADajYCaCAKIAwgCCAJSxsoAgAhDSAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogB0EoaiAfQhiIp0H/AXEQCCEOIAdB8ABqIARBBHRqIgsgCSANaiAIazYCDCALIAg2AgggCyADNgIEIAsgAjYCACAHIA4gH6dB//8DcWo2AkQgBEEBaiEEDAELCyAEIBdIDQEgEkFgaiEYIAdB4ABqIRogB0HkAGohGyABIQMDQCAHQShqEARBAksgBCAFTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEIIAcoAkggBygCREEDdGopAgAiH0IgiKchCSAeQiCIISAgHUIgiKchDAJAIB9CEIinQf8BcSICQQJPBEACQCAGRSACQRlJckUEQCAJIAdBKGogAkEgIAcoAixrIgogCiACSxsiChAFIAIgCmsiAnRqIQkgB0EoahAEGiACRQ0BIAdBKGogAhAFIAlqIQkMAQsgB0EoaiACEAUgCWohCSAHQShqEAQaCyAHKQJUISEgByAJNgJUIAcgITcDWAwBCwJAIAJFBEAgDARAIAcoAlQhCQwDCyAHKAJYIQkMAQsCQAJAIAdBKGpBARAFIAkgDEVqaiICQQNGBEAgBygCVEF/aiICIAJFaiEJDAELIAJBAnQgB2ooAlQiCSAJRWohCSACQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAk2AlQLICCnIRQgCARAIAdBKGogCBAFIBRqIRQLIAggC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgDGohDAsgB0EoahAEGiAHIAcoAmggDGoiGSAUajYCaCAbIBogCSAZSxsoAgAhHCAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogByAHQShqIB9CGIinQf8BcRAIIB+nQf//A3FqNgJEIAcgB0HwAGogBEEDcUEEdGoiDSkDCCIdNwPIASAHIA0pAwAiHjcDwAECQAJAAkAgBygCvAEiDiAepyICaiIWIBNLDQAgAyAHKALEASIKIAJqIgtqIBhLDQAgEiADayALQSBqTw0BCyAHIAcpA8gBNwMQIAcgBykDwAE3AwggAyASIAdBCGogB0G8AWogEyAPIBUgERAeIQsMAQsgAiADaiEIIAMgDhAHIAJBEU8EQCADQRBqIQIDQCACIA5BEGoiDhAHIAJBEGoiAiAISQ0ACwsgCCAdpyIOayECIAcgFjYCvAEgDiAIIA9rSwRAIA4gCCAVa0sEQEFsIQsMAgsgESACIA9rIgJqIhYgCmogEU0EQCAIIBYgChAPGgwCCyAIIBZBACACaxAPIQggByACIApqIgo2AsQBIAggAmshCCAPIQILIA5BEE8EQCAIIApqIQoDQCAIIAIQByACQRBqIQIgCEEQaiIIIApJDQALDAELAkAgDkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgDkECdCIKQcAeaigCAGoiAhAXIAIgCkHgHmooAgBrIQIgBygCxAEhCgwBCyAIIAIQDAsgCkEJSQ0AIAggCmohCiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAKSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAKSQ0ACwsgCxADBEAgCyEQDAQFIA0gDDYCACANIBkgHGogCWs2AgwgDSAJNgIIIA0gFDYCBCAEQQFqIQQgAyALaiEDDAILAAsLIAQgBUgNASAEIBdrIQtBACEEA0AgCyAFSARAIAcgB0HwAGogC0EDcUEEdGoiAikDCCIdNwPIASAHIAIpAwAiHjcDwAECQAJAAkAgBygCvAEiDCAepyICaiIKIBNLDQAgAyAHKALEASIJIAJqIhBqIBhLDQAgEiADayAQQSBqTw0BCyAHIAcpA8gBNwMgIAcgBykDwAE3AxggAyASIAdBGGogB0G8AWogEyAPIBUgERAeIRAMAQsgAiADaiEIIAMgDBAHIAJBEU8EQCADQRBqIQIDQCACIAxBEGoiDBAHIAJBEGoiAiAISQ0ACwsgCCAdpyIGayECIAcgCjYCvAEgBiAIIA9rSwRAIAYgCCAVa0sEQEFsIRAMAgsgESACIA9rIgJqIgwgCWogEU0EQCAIIAwgCRAPGgwCCyAIIAxBACACaxAPIQggByACIAlqIgk2AsQBIAggAmshCCAPIQILIAZBEE8EQCAIIAlqIQYDQCAIIAIQByACQRBqIQIgCEEQaiIIIAZJDQALDAELAkAgBkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgBkECdCIGQcAeaigCAGoiAhAXIAIgBkHgHmooAgBrIQIgBygCxAEhCQwBCyAIIAIQDAsgCUEJSQ0AIAggCWohBiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAGSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAGSQ0ACwsgEBADDQMgC0EBaiELIAMgEGohAwwBCwsDQCAEQQNHBEAgACAEQQJ0IgJqQazQAWogAiAHaigCVDYCACAEQQFqIQQMAQsLIAcoArwBIQgLQbp/IRAgEyAIayIAIBIgA2tLDQAgAwR/IAMgCCAAEAsgAGoFQQALIAFrIRALIAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY0AAQMyIFEAMiBg0AIANBHzYCfCADIANB/ABqIANB+ABqIAQgBCAFaiAGGyIEIAEgAmoiAiAEaxAVIgUQAw0AIAMoAnwiBkEfSw0AIAMoAngiB0EJTw0AIABBiCBqIAMgBkGAC0GADCAHEBggA0E0NgJ8IAMgA0H8AGogA0H4AGogBCAFaiIEIAIgBGsQFSIFEAMNACADKAJ8IgZBNEsNACADKAJ4IgdBCk8NACAAQZAwaiADIAZBgA1B4A4gBxAYIANBIzYCfCADIANB/ABqIANB+ABqIAQgBWoiBCACIARrEBUiBRADDQAgAygCfCIGQSNLDQAgAygCeCIHQQpPDQAgACADIAZBwBBB0BEgBxAYIAQgBWoiBEEMaiIFIAJLDQAgAiAFayEFQQAhAgNAIAJBA0cEQCAEKAAAIgZBf2ogBU8NAiAAIAJBAnRqQZzQAWogBjYCACACQQFqIQIgBEEEaiEEDAELCyAEIAFrIQgLIANBgAFqJAAgCAtGAQN/IABBCGohAyAAKAIEIQJBACEAA0AgACACdkUEQCABIAMgAEEDdGotAAJBFktqIQEgAEEBaiEADAELCyABQQggAmt0C4YDAQV/Qbh/IQcCQCADRQ0AIAItAAAiBEUEQCABQQA2AgBBAUG4fyADQQFGGw8LAn8gAkEBaiIFIARBGHRBGHUiBkF/Sg0AGiAGQX9GBEAgA0EDSA0CIAUvAABBgP4BaiEEIAJBA2oMAQsgA0ECSA0BIAItAAEgBEEIdHJBgIB+aiEEIAJBAmoLIQUgASAENgIAIAVBAWoiASACIANqIgNLDQBBbCEHIABBEGogACAFLQAAIgVBBnZBI0EJIAEgAyABa0HAEEHQEUHwEiAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBmCBqIABBCGogBUEEdkEDcUEfQQggASABIAZqIAgbIgEgAyABa0GAC0GADEGAFyAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBoDBqIABBBGogBUECdkEDcUE0QQkgASABIAZqIAgbIgEgAyABa0GADUHgDkGQGSAAKAKM4QEgACgCnOIBIAQQHyIAEAMNACAAIAFqIAJrIQcLIAcLrQMBCn8jAEGABGsiCCQAAn9BUiACQf8BSw0AGkFUIANBDEsNABogAkEBaiELIABBBGohCUGAgAQgA0F/anRBEHUhCkEAIQJBASEEQQEgA3QiB0F/aiIMIQUDQCACIAtGRQRAAkAgASACQQF0Ig1qLwEAIgZB//8DRgRAIAkgBUECdGogAjoAAiAFQX9qIQVBASEGDAELIARBACAKIAZBEHRBEHVKGyEECyAIIA1qIAY7AQAgAkEBaiECDAELCyAAIAQ7AQIgACADOwEAIAdBA3YgB0EBdmpBA2ohBkEAIQRBACECA0AgBCALRkUEQCABIARBAXRqLgEAIQpBACEAA0AgACAKTkUEQCAJIAJBAnRqIAQ6AAIDQCACIAZqIAxxIgIgBUsNAAsgAEEBaiEADAELCyAEQQFqIQQMAQsLQX8gAg0AGkEAIQIDfyACIAdGBH9BAAUgCCAJIAJBAnRqIgAtAAJBAXRqIgEgAS8BACIBQQFqOwEAIAAgAyABEBRrIgU6AAMgACABIAVB/wFxdCAHazsBACACQQFqIQIMAQsLCyEFIAhBgARqJAAgBQvjBgEIf0FsIQcCQCACQQNJDQACQAJAAkACQCABLQAAIgNBA3EiCUEBaw4DAwEAAgsgACgCiOEBDQBBYg8LIAJBBUkNAkEDIQYgASgAACEFAn8CQAJAIANBAnZBA3EiCEF+aiIEQQFNBEAgBEEBaw0BDAILIAVBDnZB/wdxIQQgBUEEdkH/B3EhAyAIRQwCCyAFQRJ2IQRBBCEGIAVBBHZB//8AcSEDQQAMAQsgBUEEdkH//w9xIgNBgIAISw0DIAEtAARBCnQgBUEWdnIhBEEFIQZBAAshBSAEIAZqIgogAksNAgJAIANBgQZJDQAgACgCnOIBRQ0AQQAhAgNAIAJBg4ABSw0BIAJBQGshAgwAAAsACwJ/IAlBA0YEQCABIAZqIQEgAEHw4gFqIQIgACgCDCEGIAUEQCACIAMgASAEIAYQXwwCCyACIAMgASAEIAYQXQwBCyAAQbjQAWohAiABIAZqIQEgAEHw4gFqIQYgAEGo0ABqIQggBQRAIAggBiADIAEgBCACEF4MAQsgCCAGIAMgASAEIAIQXAsQAw0CIAAgAzYCgOIBIABBATYCiOEBIAAgAEHw4gFqNgLw4QEgCUECRgRAIAAgAEGo0ABqNgIMCyAAIANqIgBBiOMBakIANwAAIABBgOMBakIANwAAIABB+OIBakIANwAAIABB8OIBakIANwAAIAoPCwJ/AkACQAJAIANBAnZBA3FBf2oiBEECSw0AIARBAWsOAgACAQtBASEEIANBA3YMAgtBAiEEIAEvAABBBHYMAQtBAyEEIAEQIUEEdgsiAyAEaiIFQSBqIAJLBEAgBSACSw0CIABB8OIBaiABIARqIAMQCyEBIAAgAzYCgOIBIAAgATYC8OEBIAEgA2oiAEIANwAYIABCADcAECAAQgA3AAggAEIANwAAIAUPCyAAIAM2AoDiASAAIAEgBGo2AvDhASAFDwsCfwJAAkACQCADQQJ2QQNxQX9qIgRBAksNACAEQQFrDgIAAgELQQEhByADQQN2DAILQQIhByABLwAAQQR2DAELIAJBBEkgARAhIgJBj4CAAUtyDQFBAyEHIAJBBHYLIQIgAEHw4gFqIAEgB2otAAAgAkEgahAQIQEgACACNgKA4gEgACABNgLw4QEgB0EBaiEHCyAHC0sAIABC+erQ0OfJoeThADcDICAAQgA3AxggAELP1tO+0ser2UI3AxAgAELW64Lu6v2J9eAANwMIIABCADcDACAAQShqQQBBKBAQGgviAgICfwV+IABBKGoiASAAKAJIaiECAn4gACkDACIDQiBaBEAgACkDECIEQgeJIAApAwgiBUIBiXwgACkDGCIGQgyJfCAAKQMgIgdCEol8IAUQGSAEEBkgBhAZIAcQGQwBCyAAKQMYQsXP2bLx5brqJ3wLIAN8IQMDQCABQQhqIgAgAk0EQEIAIAEpAAAQCSADhUIbiUKHla+vmLbem55/fkLj3MqV/M7y9YV/fCEDIAAhAQwBCwsCQCABQQRqIgAgAksEQCABIQAMAQsgASgAAK1Ch5Wvr5i23puef34gA4VCF4lCz9bTvtLHq9lCfkL5893xmfaZqxZ8IQMLA0AgACACSQRAIAAxAABCxc/ZsvHluuonfiADhUILiUKHla+vmLbem55/fiEDIABBAWohAAwBCwsgA0IhiCADhULP1tO+0ser2UJ+IgNCHYggA4VC+fPd8Zn2masWfiIDQiCIIAOFC+8CAgJ/BH4gACAAKQMAIAKtfDcDAAJAAkAgACgCSCIDIAJqIgRBH00EQCABRQ0BIAAgA2pBKGogASACECAgACgCSCACaiEEDAELIAEgAmohAgJ/IAMEQCAAQShqIgQgA2ogAUEgIANrECAgACAAKQMIIAQpAAAQCTcDCCAAIAApAxAgACkAMBAJNwMQIAAgACkDGCAAKQA4EAk3AxggACAAKQMgIABBQGspAAAQCTcDICAAKAJIIQMgAEEANgJIIAEgA2tBIGohAQsgAUEgaiACTQsEQCACQWBqIQMgACkDICEFIAApAxghBiAAKQMQIQcgACkDCCEIA0AgCCABKQAAEAkhCCAHIAEpAAgQCSEHIAYgASkAEBAJIQYgBSABKQAYEAkhBSABQSBqIgEgA00NAAsgACAFNwMgIAAgBjcDGCAAIAc3AxAgACAINwMICyABIAJPDQEgAEEoaiABIAIgAWsiBBAgCyAAIAQ2AkgLCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQEBogAwVBun8LCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQCxogAwVBun8LC6gCAQZ/IwBBEGsiByQAIABB2OABaikDAEKAgIAQViEIQbh/IQUCQCAEQf//B0sNACAAIAMgBBBCIgUQAyIGDQAgACgCnOIBIQkgACAHQQxqIAMgAyAFaiAGGyIKIARBACAFIAYbayIGEEAiAxADBEAgAyEFDAELIAcoAgwhBCABRQRAQbp/IQUgBEEASg0BCyAGIANrIQUgAyAKaiEDAkAgCQRAIABBADYCnOIBDAELAkACQAJAIARBBUgNACAAQdjgAWopAwBCgICACFgNAAwBCyAAQQA2ApziAQwBCyAAKAIIED8hBiAAQQA2ApziASAGQRRPDQELIAAgASACIAMgBSAEIAgQOSEFDAELIAAgASACIAMgBSAEIAgQOiEFCyAHQRBqJAAgBQtnACAAQdDgAWogASACIAAoAuzhARAuIgEQAwRAIAEPC0G4fyECAkAgAQ0AIABB7OABaigCACIBBEBBYCECIAAoApjiASABRw0BC0EAIQIgAEHw4AFqKAIARQ0AIABBkOEBahBDCyACCycBAX8QVyIERQRAQUAPCyAEIAAgASACIAMgBBBLEE8hACAEEFYgAAs/AQF/AkACQAJAIAAoAqDiAUEBaiIBQQJLDQAgAUEBaw4CAAECCyAAEDBBAA8LIABBADYCoOIBCyAAKAKU4gELvAMCB38BfiMAQRBrIgkkAEG4fyEGAkAgBCgCACIIQQVBCSAAKALs4QEiBRtJDQAgAygCACIHQQFBBSAFGyAFEC8iBRADBEAgBSEGDAELIAggBUEDakkNACAAIAcgBRBJIgYQAw0AIAEgAmohCiAAQZDhAWohCyAIIAVrIQIgBSAHaiEHIAEhBQNAIAcgAiAJECwiBhADDQEgAkF9aiICIAZJBEBBuH8hBgwCCyAJKAIAIghBAksEQEFsIQYMAgsgB0EDaiEHAn8CQAJAAkAgCEEBaw4CAgABCyAAIAUgCiAFayAHIAYQSAwCCyAFIAogBWsgByAGEEcMAQsgBSAKIAVrIActAAAgCSgCCBBGCyIIEAMEQCAIIQYMAgsgACgC8OABBEAgCyAFIAgQRQsgAiAGayECIAYgB2ohByAFIAhqIQUgCSgCBEUNAAsgACkD0OABIgxCf1IEQEFsIQYgDCAFIAFrrFINAQsgACgC8OABBEBBaiEGIAJBBEkNASALEEQhDCAHKAAAIAynRw0BIAdBBGohByACQXxqIQILIAMgBzYCACAEIAI2AgAgBSABayEGCyAJQRBqJAAgBgsuACAAECsCf0EAQQAQAw0AGiABRSACRXJFBEBBYiAAIAEgAhA9EAMNARoLQQALCzcAIAEEQCAAIAAoAsTgASABKAIEIAEoAghqRzYCnOIBCyAAECtBABADIAFFckUEQCAAIAEQWwsL0QIBB38jAEEQayIGJAAgBiAENgIIIAYgAzYCDCAFBEAgBSgCBCEKIAUoAgghCQsgASEIAkACQANAIAAoAuzhARAWIQsCQANAIAQgC0kNASADKAAAQXBxQdDUtMIBRgRAIAMgBBAiIgcQAw0EIAQgB2shBCADIAdqIQMMAQsLIAYgAzYCDCAGIAQ2AggCQCAFBEAgACAFEE5BACEHQQAQA0UNAQwFCyAAIAogCRBNIgcQAw0ECyAAIAgQUCAMQQFHQQAgACAIIAIgBkEMaiAGQQhqEEwiByIDa0EAIAMQAxtBCkdyRQRAQbh/IQcMBAsgBxADDQMgAiAHayECIAcgCGohCEEBIQwgBigCDCEDIAYoAgghBAwBCwsgBiADNgIMIAYgBDYCCEG4fyEHIAQNASAIIAFrIQcMAQsgBiADNgIMIAYgBDYCCAsgBkEQaiQAIAcLRgECfyABIAAoArjgASICRwRAIAAgAjYCxOABIAAgATYCuOABIAAoArzgASEDIAAgATYCvOABIAAgASADIAJrajYCwOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEEdCAAbiECCyAAQQh2IgEgAkEYbCIAQYwIaigCAGwgAEGICGooAgBqIgJBA3YgAmogAEGACGooAgAgAEGECGooAgAgAWxqSQs3ACAAIAMgBCAFQYAQEDMiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQMgVBuH8LC78DAQN/IwBBIGsiBSQAIAVBCGogAiADEAYiAhADRQRAIAAgAWoiB0F9aiEGIAUgBBAOIARBBGohAiAFLQACIQMDQEEAIAAgBkkgBUEIahAEGwRAIAAgAiAFQQhqIAMQAkECdGoiBC8BADsAACAFQQhqIAQtAAIQASAAIAQtAANqIgQgAiAFQQhqIAMQAkECdGoiAC8BADsAACAFQQhqIAAtAAIQASAEIAAtAANqIQAMAQUgB0F+aiEEA0AgBUEIahAEIAAgBEtyRQRAIAAgAiAFQQhqIAMQAkECdGoiBi8BADsAACAFQQhqIAYtAAIQASAAIAYtAANqIQAMAQsLA0AgACAES0UEQCAAIAIgBUEIaiADEAJBAnRqIgYvAQA7AAAgBUEIaiAGLQACEAEgACAGLQADaiEADAELCwJAIAAgB08NACAAIAIgBUEIaiADEAIiA0ECdGoiAC0AADoAACAALQADQQFGBEAgBUEIaiAALQACEAEMAQsgBSgCDEEfSw0AIAVBCGogAiADQQJ0ai0AAhABIAUoAgxBIUkNACAFQSA2AgwLIAFBbCAFQQhqEAobIQILCwsgBUEgaiQAIAILkgIBBH8jAEFAaiIJJAAgCSADQTQQCyEDAkAgBEECSA0AIAMgBEECdGooAgAhCSADQTxqIAgQIyADQQE6AD8gAyACOgA+QQAhBCADKAI8IQoDQCAEIAlGDQEgACAEQQJ0aiAKNgEAIARBAWohBAwAAAsAC0EAIQkDQCAGIAlGRQRAIAMgBSAJQQF0aiIKLQABIgtBAnRqIgwoAgAhBCADQTxqIAotAABBCHQgCGpB//8DcRAjIANBAjoAPyADIAcgC2siCiACajoAPiAEQQEgASAKa3RqIQogAygCPCELA0AgACAEQQJ0aiALNgEAIARBAWoiBCAKSQ0ACyAMIAo2AgAgCUEBaiEJDAELCyADQUBrJAALowIBCX8jAEHQAGsiCSQAIAlBEGogBUE0EAsaIAcgBmshDyAHIAFrIRADQAJAIAMgCkcEQEEBIAEgByACIApBAXRqIgYtAAEiDGsiCGsiC3QhDSAGLQAAIQ4gCUEQaiAMQQJ0aiIMKAIAIQYgCyAPTwRAIAAgBkECdGogCyAIIAUgCEE0bGogCCAQaiIIQQEgCEEBShsiCCACIAQgCEECdGooAgAiCEEBdGogAyAIayAHIA4QYyAGIA1qIQgMAgsgCUEMaiAOECMgCUEBOgAPIAkgCDoADiAGIA1qIQggCSgCDCELA0AgBiAITw0CIAAgBkECdGogCzYBACAGQQFqIQYMAAALAAsgCUHQAGokAA8LIAwgCDYCACAKQQFqIQoMAAALAAs0ACAAIAMgBCAFEDYiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQNAVBuH8LCyMAIAA/AEEQdGtB//8DakEQdkAAQX9GBEBBAA8LQQAQAEEBCzsBAX8gAgRAA0AgACABIAJBgCAgAkGAIEkbIgMQCyEAIAFBgCBqIQEgAEGAIGohACACIANrIgINAAsLCwYAIAAQAwsLqBUJAEGICAsNAQAAAAEAAAACAAAAAgBBoAgLswYBAAAAAQAAAAIAAAACAAAAJgAAAIIAAAAhBQAASgAAAGcIAAAmAAAAwAEAAIAAAABJBQAASgAAAL4IAAApAAAALAIAAIAAAABJBQAASgAAAL4IAAAvAAAAygIAAIAAAACKBQAASgAAAIQJAAA1AAAAcwMAAIAAAACdBQAASgAAAKAJAAA9AAAAgQMAAIAAAADrBQAASwAAAD4KAABEAAAAngMAAIAAAABNBgAASwAAAKoKAABLAAAAswMAAIAAAADBBgAATQAAAB8NAABNAAAAUwQAAIAAAAAjCAAAUQAAAKYPAABUAAAAmQQAAIAAAABLCQAAVwAAALESAABYAAAA2gQAAIAAAABvCQAAXQAAACMUAABUAAAARQUAAIAAAABUCgAAagAAAIwUAABqAAAArwUAAIAAAAB2CQAAfAAAAE4QAAB8AAAA0gIAAIAAAABjBwAAkQAAAJAHAACSAAAAAAAAAAEAAAABAAAABQAAAA0AAAAdAAAAPQAAAH0AAAD9AAAA/QEAAP0DAAD9BwAA/Q8AAP0fAAD9PwAA/X8AAP3/AAD9/wEA/f8DAP3/BwD9/w8A/f8fAP3/PwD9/38A/f//AP3//wH9//8D/f//B/3//w/9//8f/f//P/3//38AAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABEAAAASAAAAEwAAABQAAAAVAAAAFgAAABcAAAAYAAAAGQAAABoAAAAbAAAAHAAAAB0AAAAeAAAAHwAAAAMAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAwAAAANAAAADgAAAA8AAAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZAAAAGgAAABsAAAAcAAAAHQAAAB4AAAAfAAAAIAAAACEAAAAiAAAAIwAAACUAAAAnAAAAKQAAACsAAAAvAAAAMwAAADsAAABDAAAAUwAAAGMAAACDAAAAAwEAAAMCAAADBAAAAwgAAAMQAAADIAAAA0AAAAOAAAADAAEAQeAPC1EBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAEAAAABQAAAAcAAAAIAAAACQAAAAoAAAALAAAADAAAAA0AAAAOAAAADwAAABAAQcQQC4sBAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABIAAAAUAAAAFgAAABgAAAAcAAAAIAAAACgAAAAwAAAAQAAAAIAAAAAAAQAAAAIAAAAEAAAACAAAABAAAAAgAAAAQAAAAIAAAAAAAQBBkBIL5gQBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAAAEAAAAEAAAACAAAAAAAAAABAAEBBgAAAAAAAAQAAAAAEAAABAAAAAAgAAAFAQAAAAAAAAUDAAAAAAAABQQAAAAAAAAFBgAAAAAAAAUHAAAAAAAABQkAAAAAAAAFCgAAAAAAAAUMAAAAAAAABg4AAAAAAAEFEAAAAAAAAQUUAAAAAAABBRYAAAAAAAIFHAAAAAAAAwUgAAAAAAAEBTAAAAAgAAYFQAAAAAAABwWAAAAAAAAIBgABAAAAAAoGAAQAAAAADAYAEAAAIAAABAAAAAAAAAAEAQAAAAAAAAUCAAAAIAAABQQAAAAAAAAFBQAAACAAAAUHAAAAAAAABQgAAAAgAAAFCgAAAAAAAAULAAAAAAAABg0AAAAgAAEFEAAAAAAAAQUSAAAAIAABBRYAAAAAAAIFGAAAACAAAwUgAAAAAAADBSgAAAAAAAYEQAAAABAABgRAAAAAIAAHBYAAAAAAAAkGAAIAAAAACwYACAAAMAAABAAAAAAQAAAEAQAAACAAAAUCAAAAIAAABQMAAAAgAAAFBQAAACAAAAUGAAAAIAAABQgAAAAgAAAFCQAAACAAAAULAAAAIAAABQwAAAAAAAAGDwAAACAAAQUSAAAAIAABBRQAAAAgAAIFGAAAACAAAgUcAAAAIAADBSgAAAAgAAQFMAAAAAAAEAYAAAEAAAAPBgCAAAAAAA4GAEAAAAAADQYAIABBgBcLhwIBAAEBBQAAAAAAAAUAAAAAAAAGBD0AAAAAAAkF/QEAAAAADwX9fwAAAAAVBf3/HwAAAAMFBQAAAAAABwR9AAAAAAAMBf0PAAAAABIF/f8DAAAAFwX9/38AAAAFBR0AAAAAAAgE/QAAAAAADgX9PwAAAAAUBf3/DwAAAAIFAQAAABAABwR9AAAAAAALBf0HAAAAABEF/f8BAAAAFgX9/z8AAAAEBQ0AAAAQAAgE/QAAAAAADQX9HwAAAAATBf3/BwAAAAEFAQAAABAABgQ9AAAAAAAKBf0DAAAAABAF/f8AAAAAHAX9//8PAAAbBf3//wcAABoF/f//AwAAGQX9//8BAAAYBf3//wBBkBkLhgQBAAEBBgAAAAAAAAYDAAAAAAAABAQAAAAgAAAFBQAAAAAAAAUGAAAAAAAABQgAAAAAAAAFCQAAAAAAAAULAAAAAAAABg0AAAAAAAAGEAAAAAAAAAYTAAAAAAAABhYAAAAAAAAGGQAAAAAAAAYcAAAAAAAABh8AAAAAAAAGIgAAAAAAAQYlAAAAAAABBikAAAAAAAIGLwAAAAAAAwY7AAAAAAAEBlMAAAAAAAcGgwAAAAAACQYDAgAAEAAABAQAAAAAAAAEBQAAACAAAAUGAAAAAAAABQcAAAAgAAAFCQAAAAAAAAUKAAAAAAAABgwAAAAAAAAGDwAAAAAAAAYSAAAAAAAABhUAAAAAAAAGGAAAAAAAAAYbAAAAAAAABh4AAAAAAAAGIQAAAAAAAQYjAAAAAAABBicAAAAAAAIGKwAAAAAAAwYzAAAAAAAEBkMAAAAAAAUGYwAAAAAACAYDAQAAIAAABAQAAAAwAAAEBAAAABAAAAQFAAAAIAAABQcAAAAgAAAFCAAAACAAAAUKAAAAIAAABQsAAAAAAAAGDgAAAAAAAAYRAAAAAAAABhQAAAAAAAAGFwAAAAAAAAYaAAAAAAAABh0AAAAAAAAGIAAAAAAAEAYDAAEAAAAPBgOAAAAAAA4GA0AAAAAADQYDIAAAAAAMBgMQAAAAAAsGAwgAAAAACgYDBABBpB0L2QEBAAAAAwAAAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8BAAD/AwAA/wcAAP8PAAD/HwAA/z8AAP9/AAD//wAA//8BAP//AwD//wcA//8PAP//HwD//z8A//9/AP///wD///8B////A////wf///8P////H////z////9/AAAAAAEAAAACAAAABAAAAAAAAAACAAAABAAAAAgAAAAAAAAAAQAAAAIAAAABAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAcAAAAIAAAACQAAAAoAAAALAEGgIAsDwBBQ",tN="display-p3",iN="display-p3-linear";({...Et.spaces[Jt]});const $0=new WeakMap;let eA=0,tA;class Jn extends Qi{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new jk,this.workerSourceURL="",this.workerConfig=null,typeof MSC_TRANSCODER<"u"&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}async detectSupportAsync(e){return console.warn('KTX2Loader: "detectSupportAsync()" has been deprecated. Use "detectSupport()" and "await renderer.init();" when creating the renderer.'),await e.init(),this.detectSupport(e)}detectSupport(e){return e.isWebGPURenderer===!0?this.workerConfig={astcSupported:e.hasFeature("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:e.hasFeature("texture-compression-etc1"),etc2Supported:e.hasFeature("texture-compression-etc2"),dxtSupported:e.hasFeature("texture-compression-s3tc"),bptcSupported:e.hasFeature("texture-compression-bc"),pvrtcSupported:e.hasFeature("texture-compression-pvrtc")}:(this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),astcHDRSupported:e.extensions.has("WEBGL_compressed_texture_astc")&&e.extensions.get("WEBGL_compressed_texture_astc").getSupportedProfiles().includes("hdr"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},typeof navigator<"u"&&typeof navigator.platform<"u"&&typeof navigator.userAgent<"u"&&navigator.platform.indexOf("Linux")>=0&&navigator.userAgent.indexOf("Firefox")>=0&&this.workerConfig.astcSupported&&this.workerConfig.etc2Supported&&this.workerConfig.bptcSupported&&this.workerConfig.dxtSupported&&(this.workerConfig.astcSupported=!1,this.workerConfig.etc2Supported=!1)),this}init(){if(!this.transcoderPending){const e=new Yi(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),i=new Yi(this.manager);i.setPath(this.transcoderPath),i.setResponseType("arraybuffer"),i.setWithCredentials(this.withCredentials);const n=i.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,n]).then(([s,a])=>{const o=Jn.BasisWorker.toString(),l=["/* constants */","let _EngineFormat = "+JSON.stringify(Jn.EngineFormat),"let _EngineType = "+JSON.stringify(Jn.EngineType),"let _TranscoderFormat = "+JSON.stringify(Jn.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(Jn.BasisFormat),"/* basis_transcoder.js */",s,"/* worker */",o.substring(o.indexOf("{")+1,o.lastIndexOf("}"))].join(`
|
||
`);this.workerSourceURL=URL.createObjectURL(new Blob([l])),this.transcoderBinary=a,this.workerPool.setWorkerCreator(()=>{const c=new Worker(this.workerSourceURL),h=this.transcoderBinary.slice(0);return c.postMessage({type:"init",config:this.workerConfig,transcoderBinary:h},[h]),c})}),eA>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),eA++}return this.transcoderPending}load(e,t,i,n){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const s=new Yi(this.manager);s.setPath(this.path),s.setCrossOrigin(this.crossOrigin),s.setWithCredentials(this.withCredentials),s.setRequestHeader(this.requestHeader),s.setResponseType("arraybuffer"),s.load(e,a=>{this.parse(a,t,n)},i,n)}parse(e,t,i){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if($0.has(e))return $0.get(e).promise.then(t).catch(i);this._createTexture(e).then(n=>t?t(n):null).catch(i)}_createTextureFrom(e,t){const{type:i,error:n,data:{faces:s,width:a,height:o,format:l,type:c,dfdFlags:h}}=e;if(i==="error")return Promise.reject(n);let d;if(t.faceCount===6)d=new $v(s,l,c);else{const p=s[0].mipmaps;d=t.layerCount>1?new Jv(p,a,o,t.layerCount,l,c):new Ko(p,a,o,l,c)}return d.minFilter=s[0].mipmaps.length===1?_t:An,d.magFilter=_t,d.generateMipmaps=!1,d.needsUpdate=!0,d.colorSpace=$_(t),d.premultiplyAlpha=!!(h&Xk),d}async _createTexture(e,t={}){const i=$k(new Uint8Array(e)),n=i.vkFormat===Y0&&i.dataFormatDescriptor[0].colorModel===167;if(!(i.vkFormat===Jk||n&&!this.workerConfig.astcHDRSupported))return sN(i);const s=t,a=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:s},[e])).then(o=>this._createTextureFrom(o.data,i));return $0.set(e,{promise:a}),a}dispose(){this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),eA--}}Jn.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2},Jn.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16,BC6H:22,RGB_HALF:24,RGBA_HALF:25},Jn.EngineFormat={RGBAFormat:hi,RGBA_ASTC_4x4_Format:yr,RGB_BPTC_UNSIGNED_Format:cc,RGBA_BPTC_Format:ha,RGBA_ETC2_EAC_Format:Co,RGBA_PVRTC_4BPPV1_Format:la,RGBA_S3TC_DXT5_Format:br,RGB_ETC1_Format:sc,RGB_ETC2_Format:So,RGB_PVRTC_4BPPV1_Format:nc,RGBA_S3TC_DXT1_Format:vr},Jn.EngineType={UnsignedByteType:ut,HalfFloatType:Zt,FloatType:oi},Jn.BasisWorker=function(){let r,e,t;const i=_EngineFormat,n=_EngineType,s=_TranscoderFormat,a=_BasisFormat;self.addEventListener("message",function(A){const m=A.data;switch(m.type){case"init":r=m.config,o(m.transcoderBinary);break;case"transcode":e.then(()=>{try{const{faces:g,buffers:f,width:v,height:b,hasAlpha:y,format:M,type:_,dfdFlags:S}=l(m.buffer);self.postMessage({type:"transcode",id:m.id,data:{faces:g,width:v,height:b,hasAlpha:y,format:M,type:_,dfdFlags:S}},f)}catch(g){console.error(g),self.postMessage({type:"error",id:m.id,error:g.message})}});break}});function o(A){e=new Promise(m=>{t={wasmBinary:A,onRuntimeInitialized:m},BASIS(t)}).then(()=>{t.initializeBasis(),t.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function l(A){const m=new t.KTX2File(new Uint8Array(A));function g(){m.close(),m.delete()}if(!m.isValid())throw g(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");let f;if(m.isUASTC())f=a.UASTC;else if(m.isETC1S())f=a.ETC1S;else if(m.isHDR())f=a.UASTC_HDR;else throw new Error("THREE.KTX2Loader: Unknown Basis encoding");const v=m.getWidth(),b=m.getHeight(),y=m.getLayers()||1,M=m.getLevels(),_=m.getFaces(),S=m.getHasAlpha(),w=m.getDFDFlags(),{transcoderFormat:E,engineFormat:I,engineType:B}=d(f,v,b,S);if(!v||!b||!M)throw g(),new Error("THREE.KTX2Loader: Invalid texture");if(!m.startTranscoding())throw g(),new Error("THREE.KTX2Loader: .startTranscoding failed");const R=[],U=[];for(let C=0;C<_;C++){const F=[];for(let O=0;O<M;O++){const H=[];let j,G;for(let q=0;q<y;q++){const Y=m.getImageLevelInfo(O,q,C);C===0&&O===0&&q===0&&(Y.origWidth%4!==0||Y.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),M>1?(j=Y.origWidth,G=Y.origHeight):(j=Y.width,G=Y.height);let ye=new Uint8Array(m.getImageTranscodedSizeInBytes(O,q,0,E));const Me=m.transcodeImage(ye,O,q,C,E,0,-1,-1);if(B===n.HalfFloatType&&(ye=new Uint16Array(ye.buffer,ye.byteOffset,ye.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!Me)throw g(),new Error("THREE.KTX2Loader: .transcodeImage failed.");H.push(ye)}const re=u(H);F.push({data:re,width:j,height:G}),U.push(re.buffer)}R.push({mipmaps:F,width:v,height:b,format:I,type:B})}return g(),{faces:R,buffers:U,width:v,height:b,hasAlpha:S,dfdFlags:w,format:I,type:B}}const c=[{if:"astcSupported",basisFormat:[a.UASTC],transcoderFormat:[s.ASTC_4x4,s.ASTC_4x4],engineFormat:[i.RGBA_ASTC_4x4_Format,i.RGBA_ASTC_4x4_Format],engineType:[n.UnsignedByteType],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.BC7_M5,s.BC7_M5],engineFormat:[i.RGBA_BPTC_Format,i.RGBA_BPTC_Format],engineType:[n.UnsignedByteType],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.BC1,s.BC3],engineFormat:[i.RGBA_S3TC_DXT1_Format,i.RGBA_S3TC_DXT5_Format],engineType:[n.UnsignedByteType],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.ETC1,s.ETC2],engineFormat:[i.RGB_ETC2_Format,i.RGBA_ETC2_EAC_Format],engineType:[n.UnsignedByteType],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.ETC1],engineFormat:[i.RGB_ETC1_Format],engineType:[n.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.PVRTC1_4_RGB,s.PVRTC1_4_RGBA],engineFormat:[i.RGB_PVRTC_4BPPV1_Format,i.RGBA_PVRTC_4BPPV1_Format],engineType:[n.UnsignedByteType],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0},{if:"bptcSupported",basisFormat:[a.UASTC_HDR],transcoderFormat:[s.BC6H],engineFormat:[i.RGB_BPTC_UNSIGNED_Format],engineType:[n.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.RGBA32,s.RGBA32],engineFormat:[i.RGBAFormat,i.RGBAFormat],engineType:[n.UnsignedByteType,n.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[a.UASTC_HDR],transcoderFormat:[s.RGBA_HALF],engineFormat:[i.RGBAFormat],engineType:[n.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],h={[a.ETC1S]:c.filter(A=>A.basisFormat.includes(a.ETC1S)).sort((A,m)=>A.priorityETC1S-m.priorityETC1S),[a.UASTC]:c.filter(A=>A.basisFormat.includes(a.UASTC)).sort((A,m)=>A.priorityUASTC-m.priorityUASTC),[a.UASTC_HDR]:c.filter(A=>A.basisFormat.includes(a.UASTC_HDR)).sort((A,m)=>A.priorityHDR-m.priorityHDR)};function d(A,m,g,f){const v=h[A];for(let b=0;b<v.length;b++){const y=v[b];if(y.if&&!r[y.if]||!y.basisFormat.includes(A)||f&&y.transcoderFormat.length<2||y.needsPowerOfTwo&&!(p(m)&&p(g)))continue;const M=y.transcoderFormat[f?1:0],_=y.engineFormat[f?1:0],S=y.engineType[0];return{transcoderFormat:M,engineFormat:_,engineType:S}}throw new Error("THREE.KTX2Loader: Failed to identify transcoding target.")}function p(A){return A<=2?!0:(A&A-1)===0&&A!==0}function u(A){if(A.length===1)return A[0];let m=0;for(let v=0;v<A.length;v++){const b=A[v];m+=b.byteLength}const g=new Uint8Array(m);let f=0;for(let v=0;v<A.length;v++){const b=A[v];g.set(b,f),f+=b.byteLength}return g}};const nN=new Set([hi,Mo,Qn,Es]),iA={[x_]:hi,[y_]:Qn,[b_]:Es,[v_]:hi,[A_]:Qn,[g_]:Es,[m_]:hi,[f_]:hi,[p_]:Qn,[u_]:Qn,[d_]:Es,[h_]:Es,[E_]:Mo,[__]:Mo,[U_]:Co,[N_]:So,[F_]:rc,[O_]:ac,[z_]:oc,[H_]:lc,[Y0]:yr,[V_]:yr,[G_]:yr,[K_]:ca,[W_]:ca,[Q_]:ca,[C_]:vr,[S_]:vr,[w_]:oa,[M_]:oa,[I_]:br,[T_]:br,[R_]:dc,[P_]:hc,[B_]:pc,[D_]:uc,[k_]:ha,[L_]:ha,[Y_]:la,[q_]:la,[X_]:wo,[j_]:wo},Ul={[x_]:oi,[y_]:oi,[b_]:oi,[v_]:Zt,[A_]:Zt,[g_]:Zt,[m_]:ut,[f_]:ut,[p_]:ut,[u_]:ut,[d_]:ut,[h_]:ut,[E_]:$l,[__]:ec,[U_]:ut,[N_]:ut,[F_]:ut,[O_]:ut,[z_]:ut,[H_]:ut,[Y0]:Zt,[V_]:ut,[G_]:ut,[K_]:Zt,[W_]:ut,[Q_]:ut,[C_]:ut,[S_]:ut,[w_]:ut,[M_]:ut,[I_]:ut,[T_]:ut,[R_]:ut,[P_]:ut,[B_]:ut,[D_]:ut,[k_]:ut,[L_]:ut,[Y_]:ut,[q_]:ut,[X_]:ut,[j_]:ut};async function sN(r){const{vkFormat:e}=r;if(iA[e]===void 0)throw new Error("THREE.KTX2Loader: Unsupported vkFormat: "+e);Ul[e]===void 0&&console.warn('THREE.KTX2Loader: Missing ".type" for vkFormat: '+e);let t;r.supercompressionScheme===l_&&(tA||(tA=new Promise(async a=>{const o=new eN;await o.init(),a(o)})),t=await tA);const i=[];for(let a=0;a<r.levels.length;a++){const o=Math.max(1,r.pixelWidth>>a),l=Math.max(1,r.pixelHeight>>a),c=r.pixelDepth?Math.max(1,r.pixelDepth>>a):0,h=r.levels[a];let d;if(r.supercompressionScheme===qk)d=h.levelData;else if(r.supercompressionScheme===l_)d=t.decode(h.levelData,h.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let p;Ul[e]===oi?p=new Float32Array(d.buffer,d.byteOffset,d.byteLength/Float32Array.BYTES_PER_ELEMENT):Ul[e]===Zt?p=new Uint16Array(d.buffer,d.byteOffset,d.byteLength/Uint16Array.BYTES_PER_ELEMENT):Ul[e]===$l||Ul[e]===ec?p=new Uint32Array(d.buffer,d.byteOffset,d.byteLength/Uint32Array.BYTES_PER_ELEMENT):p=d,i.push({data:p,width:o,height:l,depth:c})}const n=r.levelCount===0||i.length>1;let s;if(nN.has(iA[e]))s=r.pixelDepth===0?new dn(i[0].data,r.pixelWidth,r.pixelHeight):new xc(i[0].data,r.pixelWidth,r.pixelHeight,r.pixelDepth),s.minFilter=n?Jl:Ht,s.magFilter=Ht,s.generateMipmaps=r.levelCount===0;else{if(r.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");s=new Ko(i,r.pixelWidth,r.pixelHeight),s.minFilter=n?An:_t,s.magFilter=_t}return s.mipmaps=i,s.type=Ul[e],s.format=iA[e],s.colorSpace=$_(r),s.needsUpdate=!0,Promise.resolve(s)}function $_(r){const e=r.dataFormatDescriptor[0];return e.colorPrimaries===Kk?e.transferFunction===c_?Jt:Ri:e.colorPrimaries===Zk?e.transferFunction===c_?tN:iN:(e.colorPrimaries===Yk||console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${e.colorPrimaries}"`),ts)}function rN(r,e,t,i){let n=0,s=0,a=0,o=r.models.find(u=>u.url==t),l=e.circularMeps,c=e.rectMeps?.filter(u=>u.type==="风管"),h=e.rectMeps?.filter(u=>u.type==="桥架"),d=e.ellipseMeps,p=r.scene;if(new Rt,new ot,l&&l.length){let u=[],A=0;for(let m of l)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new We(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+n,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+a},m.rotation={x:0,y:0,z:0},m.indexes=[[r.scene.children.length,A++,0,0]],o.nodesMap.set(Number(m.id),m),u.push(m);sf("Circle",p,u,t)}if(c&&c.length){let u=[],A=0;for(let m of c)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new We(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+n,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+a},m.rotation={x:0,y:0,z:0},m.indexes=[[r.scene.children.length,A++,0,0]],o.nodesMap.set(Number(m.id),m),u.push(m);sf("Rect",p,u,t)}if(d&&d.length){let u=[],A=0;for(let m of d)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new We(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+n,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+a},m.rotation={x:0,y:0,z:0},m.indexes=[[r.scene.children.length,A++,0,0]],o.nodesMap.set(Number(m.id),m),u.push(m);sf("Ellipse",p,u,t)}if(h&&h.length){let u=[],A=0;for(let m of h)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new We(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+n,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+a},m.rotation={x:0,y:0,z:0},m.indexes=[[r.scene.children.length,A++,0,0]],o.nodesMap.set(Number(m.id),m),u.push(m);sf("Bridge",p,u,t)}}function sf(r,e,t,i,n){let s,a,o={width:1,height:1,length:1,diameter:1,color:new We,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(r){case"Rect":a=rf("Rect",o);break;case"Bridge":a=rf("Bridge",o);break;case"Circle":a=rf("Circle",o);break;case"Ellipse":a=rf("Ellipse",o);break}a&&(s=new ni(a.geometry,a.material,t.length),s.url=i,e.add(s),s.index=e.children.length-1);let l=[],c=[];for(var h=0;h<t.length;h++){let u=t[h],A=new T(u.startPoint.X,0,-u.startPoint.Y),m=new T(u.endPoint.X,0,-u.endPoint.Y),g=new T(u.startPoint.X,u.startPoint.Z,-u.startPoint.Y),f=new T(u.endPoint.X,u.endPoint.Z,-u.endPoint.Y),v=0,b=0,y=0;if(Math.abs(m.clone().sub(A.clone()).z)<.01&&Math.abs(m.clone().sub(A.clone()).x)<.01){if(v=(u.startPoint.Z>u.endPoint.Z?1:-1)*Math.PI*.5,u.base_x!=null){var d=new T(u.base_x.X,0,-u.base_x.Y);b=(d.clone().cross(new T(0,0,1)).y<=0?1:-1)*d.angleTo(new T(0,0,1))+Math.PI*.5}}else b=(m.clone().sub(A.clone()).cross(new T(0,0,1)).y>0?-1:1)*m.clone().sub(A.clone()).angleTo(new T(0,0,1)),v=(u.startPoint.Z>u.endPoint.Z?1:-1)*m.clone().sub(A.clone()).angleTo(f.clone().sub(g.clone()));let M=new Ke;const _=new Di(v,b,y,"YXZ");let S=M.clone().makeRotationFromEuler(_),w,E;r==="Circle"?(w=u.diameter,E=u.diameter):(w=u.width,E=u.height);let I=M.clone().makeScale(w,E,u.length);M.multiplyMatrices(S,I),M.setPosition(u.position.x,u.position.y,u.position.z),s.setMatrixAt(h,M.clone()),s.setColorAt(h,u.color),s.geometry.computeBoundingBox();let B=s.geometry.boundingBox.min.clone().applyMatrix4(M.clone()),R=s.geometry.boundingBox.max.clone().applyMatrix4(M.clone()),U=new T(Math.min(B.x,R.x),Math.min(B.y,R.y),Math.min(B.z,R.z)),C=new T(Math.max(B.x,R.x),Math.max(B.y,R.y),Math.max(B.z,R.z)),F=U.clone().add(C.clone()).multiplyScalar(.5),O={name:u.name,min:U,max:C,center:F,dbid:h,materialName:a.material.name},H=null,j=null;r==="Circle"&&(H={x:u.startPoint.X*.3048,y:u.startPoint.Z*.3048,z:-u.startPoint.Y*.3048},j={x:u.endPoint.X*.3048,y:u.endPoint.Z*.3048,z:-u.endPoint.Y*.3048},O.minC=H,O.maxC=j),s.ids||(s.ids=[]),s.matrixs||(s.matrixs=[]),s.matrixs.push(M.clone()),c.push(M.clone()),s.ids.push(Number(u.id)),l.push(O)}s.castShadow=!0,s.ElementInfos=l,s.name="rootModel",s.TypeName="InstancedMesh-Pipe",s.PipeType=r,s.MeshId=null,s.realMaterial=s.material.clone(),s.originalMaterial=s.material.clone(),s.matrixsClone=c;let p=[];p={geometry:s.geometry,matrix:s.matrix,position:s.position,rotation:s.rotation},s.meshs=p,s.instanceMatrix&&s.instanceMatrix.array&&(s.cloneInstanceMatrix=Array.from(s.instanceMatrix.array))}function rf(r,e,t){let i=new Ws;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,r){case"Rect":i.moveTo(-e.width/2,-e.height/2),i.lineTo(-e.width/2,e.height/2),i.lineTo(e.width/2,e.height/2),i.lineTo(e.width/2,-e.height/2),i.lineTo(-e.width/2,-e.height/2);break;case"Ellipse":i.moveTo(-e.width/2,-e.height/2),i.lineTo(-e.width/2,e.height/2),i.lineTo(e.width/2,e.height/2),i.lineTo(e.width/2,-e.height/2),i.lineTo(-e.width/2,-e.height/2);break;case"Bridge":i.moveTo(-e.width/2,-e.height/2),i.lineTo(-e.width/2,e.height/2),i.lineTo(-e.width/2+.01,e.height/2),i.lineTo(-e.width/2+.01,-e.height/2+.01),i.lineTo(e.width/2-.01,-e.height/2+.01),i.lineTo(e.width/2-.01,e.height/2),i.lineTo(e.width/2,e.height/2),i.lineTo(e.width/2,-e.height/2),i.lineTo(-e.width/2,-e.height/2);break;case"Circle":i.moveTo(0,0),i.absarc(0,0,e.diameter*.5,0,Math.PI*2,!1);break}const n={depth:e.length*.3048,bevelEnabled:!1};return s(i,n,e.color,e.position,e.rotation);function s(a,o,l,c,h){let d=new Jo(a,o),p=new Ma({color:l,side:Vt}),u=new Ge(d,p);return u.position.set(c.x,c.y,c.z),u.rotation._order="YXZ",u.rotation.set(h.x,h.y,h.z),u}}function oo(r,e=!1){const t=r[0].index!==null,i=new Set(Object.keys(r[0].attributes)),n=new Set(Object.keys(r[0].morphAttributes)),s={},a={},o=r[0].morphTargetsRelative,l=new ot;let c=0;for(let h=0;h<r.length;++h){const d=r[h];let p=0;if(t!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const u in d.attributes){if(!i.has(u))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+u+'" attribute exists among all geometries, or in none of them.'),null;s[u]===void 0&&(s[u]=[]),s[u].push(d.attributes[u]),p++}if(p!==i.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(o!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const u in d.morphAttributes){if(!n.has(u))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;a[u]===void 0&&(a[u]=[]),a[u].push(d.morphAttributes[u])}if(e){let u;if(t)u=d.index.count;else if(d.attributes.position!==void 0)u=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,u,h),c+=u}}if(t){let h=0;const d=[];for(let p=0;p<r.length;++p){const u=r[p].index;for(let A=0;A<u.count;++A)d.push(u.getX(A)+h);h+=r[p].attributes.position.count}l.setIndex(d)}for(const h in s){const d=eE(s[h]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,d)}for(const h in a){const d=a[h][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let p=0;p<d;++p){const u=[];for(let m=0;m<a[h].length;++m)u.push(a[h][m][p]);const A=eE(u);if(!A)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(A)}}return l}function eE(r){let e,t,i,n=-1,s=0;for(let c=0;c<r.length;++c){const h=r[c];if(e===void 0&&(e=h.array.constructor),e!==h.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=h.itemSize),t!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(i===void 0&&(i=h.normalized),i!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(n===-1&&(n=h.gpuType),n!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=h.count*t}const a=new e(s),o=new St(a,t,i);let l=0;for(let c=0;c<r.length;++c){const h=r[c];if(h.isInterleavedBufferAttribute){const d=l/t;for(let p=0,u=h.count;p<u;p++)for(let A=0;A<t;A++){const m=h.getComponent(p,A);o.setComponent(p+d,A,m)}}else a.set(h.array,l);l+=h.count*t}return n!==void 0&&(o.gpuType=n),o}function tE(r,e){if(e===$A)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===Td||e===Tf){let t=r.getIndex();if(t===null){const a=[],o=r.getAttribute("position");if(o!==void 0){for(let l=0;l<o.count;l++)a.push(l);r.setIndex(a),t=r.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),r}const i=t.count-2,n=[];if(e===Td)for(let a=1;a<=i;a++)n.push(t.getX(0)),n.push(t.getX(a)),n.push(t.getX(a+1));else for(let a=0;a<i;a++)a%2===0?(n.push(t.getX(a)),n.push(t.getX(a+1)),n.push(t.getX(a+2))):(n.push(t.getX(a+2)),n.push(t.getX(a+1)),n.push(t.getX(a)));n.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=r.clone();return s.setIndex(n),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),r}function aN(r){const e=new Map,t=new Map,i=r.clone();return iE(r,i,function(n,s){e.set(s,n),t.set(n,s)}),i.traverse(function(n){if(!n.isSkinnedMesh)return;const s=n,a=e.get(n),o=a.skeleton.bones;s.skeleton=a.skeleton.clone(),s.bindMatrix.copy(a.bindMatrix),s.skeleton.bones=o.map(function(l){return t.get(l)}),s.bind(s.skeleton,s.bindMatrix)}),i}function iE(r,e,t){t(r,e);for(let i=0;i<r.children.length;i++)iE(r.children[i],e.children[i],t)}class oN extends Qi{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new uN(t)}),this.register(function(t){return new pN(t)}),this.register(function(t){return new _N(t)}),this.register(function(t){return new EN(t)}),this.register(function(t){return new MN(t)}),this.register(function(t){return new mN(t)}),this.register(function(t){return new gN(t)}),this.register(function(t){return new AN(t)}),this.register(function(t){return new vN(t)}),this.register(function(t){return new dN(t)}),this.register(function(t){return new bN(t)}),this.register(function(t){return new fN(t)}),this.register(function(t){return new xN(t)}),this.register(function(t){return new yN(t)}),this.register(function(t){return new cN(t)}),this.register(function(t){return new nE(t,Ct.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new nE(t,Ct.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new wN(t)})}load(e,t,i,n){const s=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const c=Ur.extractUrlBase(e);a=Ur.resolveURL(c,this.path)}else a=Ur.extractUrlBase(e);this.manager.itemStart(e);const o=function(c){n?n(c):console.error(c),s.manager.itemError(e),s.manager.itemEnd(e)},l=new Yi(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{s.parse(c,a,function(h){t(h),s.manager.itemEnd(e)},o)}catch(h){o(h)}},i,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,n){let s;const a={},o={},l=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===sE){try{a[Ct.KHR_BINARY_GLTF]=new SN(e)}catch(h){n&&n(h);return}s=JSON.parse(a[Ct.KHR_BINARY_GLTF].content)}else s=JSON.parse(l.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new ON(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const d=this.pluginCallbacks[h](c);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[d.name]=d,a[d.name]=!0}if(s.extensionsUsed)for(let h=0;h<s.extensionsUsed.length;++h){const d=s.extensionsUsed[h],p=s.extensionsRequired||[];switch(d){case Ct.KHR_MATERIALS_UNLIT:a[d]=new hN;break;case Ct.KHR_DRACO_MESH_COMPRESSION:a[d]=new CN(s,this.dracoLoader);break;case Ct.KHR_TEXTURE_TRANSFORM:a[d]=new TN;break;case Ct.KHR_MESH_QUANTIZATION:a[d]=new IN;break;default:p.indexOf(d)>=0&&o[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(a),c.setPlugins(o),c.parse(i,n)}parseAsync(e,t){const i=this;return new Promise(function(n,s){i.parse(e,t,n,s)})}}function lN(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}function _i(r,e,t){const i=r.json.materials[e];return i.extensions&&i.extensions[t]?i.extensions[t]:null}const Ct={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class cN{constructor(e){this.parser=e,this.name=Ct.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,n=t.length;i<n;i++){const s=t[i];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let n=t.cache.get(i);if(n)return n;const s=t.json,a=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let o;const l=new We(16777215);a.color!==void 0&&l.setRGB(a.color[0],a.color[1],a.color[2],Ri);const c=a.range!==void 0?a.range:0;switch(a.type){case"directional":o=new Nr(l),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new km(l),o.distance=c;break;case"spot":o=new Lm(l),o.distance=c,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,o.angle=a.spot.outerConeAngle,o.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return o.position.set(0,0,0),Bs(o,a),a.intensity!==void 0&&(o.intensity=a.intensity),o.name=t.createUniqueName(a.name||"light_"+e),n=Promise.resolve(o),t.cache.add(i,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,i=this.parser,n=i.json.nodes[e],s=(n.extensions&&n.extensions[this.name]||{}).light;return s===void 0?null:this._loadLight(s).then(function(a){return i._getNodeRef(t.cache,s,a)})}}class hN{constructor(){this.name=Ct.KHR_MATERIALS_UNLIT}getMaterialType(){return Rt}extendParams(e,t,i){const n=[];e.color=new We(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const a=s.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],Ri),e.opacity=a[3]}s.baseColorTexture!==void 0&&n.push(i.assignTexture(e,"map",s.baseColorTexture,Jt))}return Promise.all(n)}}class dN{constructor(e){this.parser=e,this.name=Ct.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=_i(this.parser,e,this.name);return i===null||i.emissiveStrength!==void 0&&(t.emissiveIntensity=i.emissiveStrength),Promise.resolve()}}class uN{constructor(e){this.parser=e,this.name=Ct.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return _i(this.parser,e,this.name)!==null?qn:null}extendMaterialParams(e,t){const i=_i(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];if(i.clearcoatFactor!==void 0&&(t.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&n.push(this.parser.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(n.push(this.parser.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){const s=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new be(s,s)}return Promise.all(n)}}class pN{constructor(e){this.parser=e,this.name=Ct.KHR_MATERIALS_DISPERSION}getMaterialType(e){return _i(this.parser,e,this.name)!==null?qn:null}extendMaterialParams(e,t){const i=_i(this.parser,e,this.name);return i===null||(t.dispersion=i.dispersion!==void 0?i.dispersion:0),Promise.resolve()}}class fN{constructor(e){this.parser=e,this.name=Ct.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return _i(this.parser,e,this.name)!==null?qn:null}extendMaterialParams(e,t){const i=_i(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];return i.iridescenceFactor!==void 0&&(t.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&n.push(this.parser.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),i.iridescenceIor!==void 0&&(t.iridescenceIOR=i.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),i.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),i.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),i.iridescenceThicknessTexture!==void 0&&n.push(this.parser.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(n)}}class mN{constructor(e){this.parser=e,this.name=Ct.KHR_MATERIALS_SHEEN}getMaterialType(e){return _i(this.parser,e,this.name)!==null?qn:null}extendMaterialParams(e,t){const i=_i(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];if(t.sheenColor=new We(0,0,0),t.sheenRoughness=0,t.sheen=1,i.sheenColorFactor!==void 0){const s=i.sheenColorFactor;t.sheenColor.setRGB(s[0],s[1],s[2],Ri)}return i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&n.push(this.parser.assignTexture(t,"sheenColorMap",i.sheenColorTexture,Jt)),i.sheenRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(n)}}class gN{constructor(e){this.parser=e,this.name=Ct.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return _i(this.parser,e,this.name)!==null?qn:null}extendMaterialParams(e,t){const i=_i(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];return i.transmissionFactor!==void 0&&(t.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&n.push(this.parser.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(n)}}class AN{constructor(e){this.parser=e,this.name=Ct.KHR_MATERIALS_VOLUME}getMaterialType(e){return _i(this.parser,e,this.name)!==null?qn:null}extendMaterialParams(e,t){const i=_i(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];t.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&n.push(this.parser.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const s=i.attenuationColor||[1,1,1];return t.attenuationColor=new We().setRGB(s[0],s[1],s[2],Ri),Promise.all(n)}}class vN{constructor(e){this.parser=e,this.name=Ct.KHR_MATERIALS_IOR}getMaterialType(e){return _i(this.parser,e,this.name)!==null?qn:null}extendMaterialParams(e,t){const i=_i(this.parser,e,this.name);return i===null||(t.ior=i.ior!==void 0?i.ior:1.5),Promise.resolve()}}class bN{constructor(e){this.parser=e,this.name=Ct.KHR_MATERIALS_SPECULAR}getMaterialType(e){return _i(this.parser,e,this.name)!==null?qn:null}extendMaterialParams(e,t){const i=_i(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];t.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&n.push(this.parser.assignTexture(t,"specularIntensityMap",i.specularTexture));const s=i.specularColorFactor||[1,1,1];return t.specularColor=new We().setRGB(s[0],s[1],s[2],Ri),i.specularColorTexture!==void 0&&n.push(this.parser.assignTexture(t,"specularColorMap",i.specularColorTexture,Jt)),Promise.all(n)}}class yN{constructor(e){this.parser=e,this.name=Ct.EXT_MATERIALS_BUMP}getMaterialType(e){return _i(this.parser,e,this.name)!==null?qn:null}extendMaterialParams(e,t){const i=_i(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];return t.bumpScale=i.bumpFactor!==void 0?i.bumpFactor:1,i.bumpTexture!==void 0&&n.push(this.parser.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(n)}}class xN{constructor(e){this.parser=e,this.name=Ct.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return _i(this.parser,e,this.name)!==null?qn:null}extendMaterialParams(e,t){const i=_i(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];return i.anisotropyStrength!==void 0&&(t.anisotropy=i.anisotropyStrength),i.anisotropyRotation!==void 0&&(t.anisotropyRotation=i.anisotropyRotation),i.anisotropyTexture!==void 0&&n.push(this.parser.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(n)}}class _N{constructor(e){this.parser=e,this.name=Ct.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,n=i.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const s=n.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,a)}}class EN{constructor(e){this.parser=e,this.name=Ct.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,i=this.parser,n=i.json,s=n.textures[e];if(!s.extensions||!s.extensions[t])return null;const a=s.extensions[t],o=n.images[a.source];let l=i.textureLoader;if(o.uri){const c=i.options.manager.getHandler(o.uri);c!==null&&(l=c)}return i.loadTextureImage(e,a.source,l)}}class MN{constructor(e){this.parser=e,this.name=Ct.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,i=this.parser,n=i.json,s=n.textures[e];if(!s.extensions||!s.extensions[t])return null;const a=s.extensions[t],o=n.images[a.source];let l=i.textureLoader;if(o.uri){const c=i.options.manager.getHandler(o.uri);c!==null&&(l=c)}return i.loadTextureImage(e,a.source,l)}}class nE{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const n=i.extensions[this.name],s=this.parser.getDependency("buffer",n.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(o){const l=n.byteOffset||0,c=n.byteLength||0,h=n.count,d=n.byteStride,p=new Uint8Array(o,l,c);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(h,d,p,n.mode,n.filter).then(function(u){return u.buffer}):a.ready.then(function(){const u=new ArrayBuffer(h*d);return a.decodeGltfBuffer(new Uint8Array(u),h,d,p,n.mode,n.filter),u})})}else return null}}class wN{constructor(e){this.name=Ct.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const n=t.meshes[i.mesh];for(const l of n.primitives)if(l.mode!==$n.TRIANGLES&&l.mode!==$n.TRIANGLE_STRIP&&l.mode!==$n.TRIANGLE_FAN&&l.mode!==void 0)return null;const s=i.extensions[this.name].attributes,a=[],o={};for(const l in s)a.push(this.parser.getDependency("accessor",s[l]).then(c=>(o[l]=c,o[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{const c=l.pop(),h=c.isGroup?c.children:[c],d=l[0].count,p=[];for(const u of h){const A=new Ke,m=new T,g=new Tt,f=new T(1,1,1),v=new ni(u.geometry,u.material,d);for(let b=0;b<d;b++)o.TRANSLATION&&m.fromBufferAttribute(o.TRANSLATION,b),o.ROTATION&&g.fromBufferAttribute(o.ROTATION,b),o.SCALE&&f.fromBufferAttribute(o.SCALE,b),v.setMatrixAt(b,A.compose(m,g,f));for(const b in o)if(b==="_COLOR_0"){const y=o[b];v.instanceColor=new Pr(y.array,y.itemSize,y.normalized)}else b!=="TRANSLATION"&&b!=="ROTATION"&&b!=="SCALE"&&u.geometry.setAttribute(b,o[b]);Mt.prototype.copy.call(v,u),this.parser.assignFinalMaterial(v),p.push(v)}return c.isGroup?(c.clear(),c.add(...p),c):p[0]}))}}const sE="glTF",Eh=12,rE={JSON:1313821514,BIN:5130562};class SN{constructor(e){this.name=Ct.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Eh),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==sE)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-Eh,s=new DataView(e,Eh);let a=0;for(;a<n;){const o=s.getUint32(a,!0);a+=4;const l=s.getUint32(a,!0);if(a+=4,l===rE.JSON){const c=new Uint8Array(e,Eh+a,o);this.content=i.decode(c)}else if(l===rE.BIN){const c=Eh+a;this.body=e.slice(c,c+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class CN{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Ct.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,n=this.dracoLoader,s=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},l={},c={};for(const h in a){const d=sA[h]||h.toLowerCase();o[d]=a[h]}for(const h in e.attributes){const d=sA[h]||h.toLowerCase();if(a[h]!==void 0){const p=i.accessors[e.attributes[h]],u=Fl[p.componentType];c[d]=u.name,l[d]=p.normalized===!0}}return t.getDependency("bufferView",s).then(function(h){return new Promise(function(d,p){n.decodeDracoFile(h,function(u){for(const A in u.attributes){const m=u.attributes[A],g=l[A];g!==void 0&&(m.normalized=g)}d(u)},o,c,Ri,p)})})}}class TN{constructor(){this.name=Ct.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class IN{constructor(){this.name=Ct.KHR_MESH_QUANTIZATION}}class aE extends Sa{constructor(e,t,i,n){super(e,t,i,n)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,s=e*n*3+n;for(let a=0;a!==n;a++)t[a]=i[s+a];return t}interpolate_(e,t,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=o*2,c=o*3,h=n-t,d=(i-t)/h,p=d*d,u=p*d,A=e*c,m=A-c,g=-2*u+3*p,f=u-p,v=1-g,b=f-p+d;for(let y=0;y!==o;y++){const M=a[m+y+o],_=a[m+y+l]*h,S=a[A+y+o],w=a[A+y]*h;s[y]=v*M+b*_+g*S+f*w}return s}}const PN=new Tt;class RN extends aE{interpolate_(e,t,i,n){const s=super.interpolate_(e,t,i,n);return PN.fromArray(s).normalize().toArray(s),s}}const $n={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Fl={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},oE={9728:Ht,9729:_t,9984:Jl,9985:_o,9986:aa,9987:An},lE={33071:ln,33648:xo,10497:Ji},nA={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},sA={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},$r={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},DN={CUBICSPLINE:void 0,LINEAR:Io,STEP:To},rA={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function BN(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new Ma({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Gn})),r.DefaultMaterial}function lo(r,e,t){for(const i in t.extensions)r[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=t.extensions[i])}function Bs(r,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(r.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function LN(r,e,t){let i=!1,n=!1,s=!1;for(let c=0,h=e.length;c<h;c++){const d=e[c];if(d.POSITION!==void 0&&(i=!0),d.NORMAL!==void 0&&(n=!0),d.COLOR_0!==void 0&&(s=!0),i&&n&&s)break}if(!i&&!n&&!s)return Promise.resolve(r);const a=[],o=[],l=[];for(let c=0,h=e.length;c<h;c++){const d=e[c];if(i){const p=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):r.attributes.position;a.push(p)}if(n){const p=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):r.attributes.normal;o.push(p)}if(s){const p=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):r.attributes.color;l.push(p)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then(function(c){const h=c[0],d=c[1],p=c[2];return i&&(r.morphAttributes.position=h),n&&(r.morphAttributes.normal=d),s&&(r.morphAttributes.color=p),r.morphTargetsRelative=!0,r})}function kN(r,e){if(r.updateMorphTargets(),e.weights!==void 0)for(let t=0,i=e.weights.length;t<i;t++)r.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(r.morphTargetInfluences.length===t.length){r.morphTargetDictionary={};for(let i=0,n=t.length;i<n;i++)r.morphTargetDictionary[t[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function NN(r){let e;const t=r.extensions&&r.extensions[Ct.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+aA(t.attributes):e=r.indices+":"+aA(r.attributes)+":"+r.mode,r.targets!==void 0)for(let i=0,n=r.targets.length;i<n;i++)e+=":"+aA(r.targets[i]);return e}function aA(r){let e="";const t=Object.keys(r).sort();for(let i=0,n=t.length;i<n;i++)e+=t[i]+":"+r[t[i]]+";";return e}function oA(r){switch(r){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function UN(r){return r.search(/\.jpe?g($|\?)/i)>0||r.search(/^data\:image\/jpeg/)===0?"image/jpeg":r.search(/\.webp($|\?)/i)>0||r.search(/^data\:image\/webp/)===0?"image/webp":r.search(/\.ktx2($|\?)/i)>0||r.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const FN=new Ke;class ON{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new lN,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,n=-1,s=!1,a=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const o=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(o)===!0;const l=o.match(/Version\/(\d+)/);n=i&&l?parseInt(l[1],10):-1,s=o.indexOf("Firefox")>-1,a=s?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&n<17||s&&a<98?this.textureLoader=new Da(this.options.manager):this.textureLoader=new Qb(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Yi(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,n=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(a){const o={scene:a[0][n.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:n.asset,parser:i,userData:{}};return lo(s,o,n),Bs(o,n),Promise.all(i._invokeAll(function(l){return l.afterRoot&&l.afterRoot(o)})).then(function(){for(const l of o.scenes)l.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let n=0,s=t.length;n<s;n++){const a=t[n].joints;for(let o=0,l=a.length;o<l;o++)e[a[o]].isBone=!0}for(let n=0,s=e.length;n<s;n++){const a=e[n];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(i[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,i){if(e.refs[t]<=1)return i;const n=i.clone(),s=(a,o)=>{const l=this.associations.get(a);l!=null&&this.associations.set(o,l);for(const[c,h]of a.children.entries())s(h,o.children[c])};return s(i,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const n=e(t[i]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let n=0;n<t.length;n++){const s=e(t[n]);s&&i.push(s)}return i}getDependency(e,t){const i=e+":"+t;let n=this.cache.get(i);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":n=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(i,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(s,a){return i.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],i=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Ct.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(s,a){i.load(Ur.resolveURL(t.uri,n.path),s,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(i){const n=t.byteLength||0,s=t.byteOffset||0;return i.slice(s,s+n)})}loadAccessor(e){const t=this,i=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const a=nA[n.type],o=Fl[n.componentType],l=n.normalized===!0,c=new o(n.count*a);return Promise.resolve(new St(c,a,l))}const s=[];return n.bufferView!==void 0?s.push(this.getDependency("bufferView",n.bufferView)):s.push(null),n.sparse!==void 0&&(s.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(s).then(function(a){const o=a[0],l=nA[n.type],c=Fl[n.componentType],h=c.BYTES_PER_ELEMENT,d=h*l,p=n.byteOffset||0,u=n.bufferView!==void 0?i.bufferViews[n.bufferView].byteStride:void 0,A=n.normalized===!0;let m,g;if(u&&u!==d){const f=Math.floor(p/u),v="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+f+":"+n.count;let b=t.cache.get(v);b||(m=new c(o,f*u,n.count*u/h),b=new Vo(m,u/h),t.cache.add(v,b)),g=new Vs(b,l,p%u/h,A)}else o===null?m=new c(n.count*l):m=new c(o,p,n.count*l),g=new St(m,l,A);if(n.sparse!==void 0){const f=nA.SCALAR,v=Fl[n.sparse.indices.componentType],b=n.sparse.indices.byteOffset||0,y=n.sparse.values.byteOffset||0,M=new v(a[1],b,n.sparse.count*f),_=new c(a[2],y,n.sparse.count*l);o!==null&&(g=new St(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let S=0,w=M.length;S<w;S++){const E=M[S];if(g.setX(E,_[S*l]),l>=2&&g.setY(E,_[S*l+1]),l>=3&&g.setZ(E,_[S*l+2]),l>=4&&g.setW(E,_[S*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=A}return g})}loadTexture(e){const t=this.json,i=this.options,n=t.textures[e].source,s=t.images[n];let a=this.textureLoader;if(s.uri){const o=i.manager.getHandler(s.uri);o!==null&&(a=o)}return this.loadTextureImage(e,n,a)}loadTextureImage(e,t,i){const n=this,s=this.json,a=s.textures[e],o=s.images[t],l=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,i).then(function(h){h.flipY=!1,h.name=a.name||o.name||"",h.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(h.name=o.uri);const d=(s.samplers||{})[a.sampler]||{};return h.magFilter=oE[d.magFilter]||_t,h.minFilter=oE[d.minFilter]||An,h.wrapS=lE[d.wrapS]||Ji,h.wrapT=lE[d.wrapT]||Ji,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==Ht&&h.minFilter!==_t,n.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const i=this,n=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const a=n.images[e],o=self.URL||self.webkitURL;let l=a.uri||"",c=!1;if(a.bufferView!==void 0)l=i.getDependency("bufferView",a.bufferView).then(function(d){c=!0;const p=new Blob([d],{type:a.mimeType});return l=o.createObjectURL(p),l});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(l).then(function(d){return new Promise(function(p,u){let A=p;t.isImageBitmapLoader===!0&&(A=function(m){const g=new ii(m);g.needsUpdate=!0,p(g)}),t.load(Ur.resolveURL(d,s.path),A,void 0,u)})}).then(function(d){return c===!0&&o.revokeObjectURL(l),Bs(d,a),d.userData.mimeType=a.mimeType||UN(a.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),d});return this.sourceCache[e]=h,h}assignTexture(e,t,i,n){const s=this;return this.getDependency("texture",i.index).then(function(a){if(!a)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(a=a.clone(),a.channel=i.texCoord),s.extensions[Ct.KHR_TEXTURE_TRANSFORM]){const o=i.extensions!==void 0?i.extensions[Ct.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const l=s.associations.get(a);a=s.extensions[Ct.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),s.associations.set(a,l)}}return n!==void 0&&(a.colorSpace=n),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const n=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+i.uuid;let l=this.cache.get(o);l||(l=new fu,Bi.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,l.sizeAttenuation=!1,this.cache.add(o,l)),i=l}else if(e.isLine){const o="LineBasicMaterial:"+i.uuid;let l=this.cache.get(o);l||(l=new si,Bi.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,this.cache.add(o,l)),i=l}if(n||s||a){let o="ClonedMaterial:"+i.uuid+":";n&&(o+="derivative-tangents:"),s&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let l=this.cache.get(o);l||(l=i.clone(),s&&(l.vertexColors=!0),a&&(l.flatShading=!0),n&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(o,l),this.associations.set(l,this.associations.get(i))),i=l}e.material=i}getMaterialType(){return Ma}loadMaterial(e){const t=this,i=this.json,n=this.extensions,s=i.materials[e];let a;const o={},l=s.extensions||{},c=[];if(l[Ct.KHR_MATERIALS_UNLIT]){const d=n[Ct.KHR_MATERIALS_UNLIT];a=d.getMaterialType(),c.push(d.extendParams(o,s,t))}else{const d=s.pbrMetallicRoughness||{};if(o.color=new We(1,1,1),o.opacity=1,Array.isArray(d.baseColorFactor)){const p=d.baseColorFactor;o.color.setRGB(p[0],p[1],p[2],Ri),o.opacity=p[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(o,"map",d.baseColorTexture,Jt)),o.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,o.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,"metalnessMap",d.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",d.metallicRoughnessTexture))),a=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,o)})))}s.doubleSided===!0&&(o.side=Vt);const h=s.alphaMode||rA.OPAQUE;if(h===rA.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===rA.MASK&&(o.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&a!==Rt&&(c.push(t.assignTexture(o,"normalMap",s.normalTexture)),o.normalScale=new be(1,1),s.normalTexture.scale!==void 0)){const d=s.normalTexture.scale;o.normalScale.set(d,d)}if(s.occlusionTexture!==void 0&&a!==Rt&&(c.push(t.assignTexture(o,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&a!==Rt){const d=s.emissiveFactor;o.emissive=new We().setRGB(d[0],d[1],d[2],Ri)}return s.emissiveTexture!==void 0&&a!==Rt&&c.push(t.assignTexture(o,"emissiveMap",s.emissiveTexture,Jt)),Promise.all(c).then(function(){const d=new a(o);return s.name&&(d.name=s.name),Bs(d,s),t.associations.set(d,{materials:e}),s.extensions&&lo(n,d,s),d})}createUniqueName(e){const t=Lt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,n=this.primitiveCache;function s(o){return i[Ct.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(l){return cE(l,o,t)})}const a=[];for(let o=0,l=e.length;o<l;o++){const c=e[o],h=NN(c),d=n[h];if(d)a.push(d.promise);else{let p;c.extensions&&c.extensions[Ct.KHR_DRACO_MESH_COMPRESSION]?p=s(c):p=cE(new ot,c,t),n[h]={primitive:c,promise:p},a.push(p)}}return Promise.all(a)}loadMesh(e){const t=this,i=this.json,n=this.extensions,s=i.meshes[e],a=s.primitives,o=[];for(let l=0,c=a.length;l<c;l++){const h=a[l].material===void 0?BN(this.cache):this.getDependency("material",a[l].material);o.push(h)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(l){const c=l.slice(0,l.length-1),h=l[l.length-1],d=[];for(let u=0,A=h.length;u<A;u++){const m=h[u],g=a[u];let f;const v=c[u];if(g.mode===$n.TRIANGLES||g.mode===$n.TRIANGLE_STRIP||g.mode===$n.TRIANGLE_FAN||g.mode===void 0)f=s.isSkinnedMesh===!0?new sm(m,v):new Ge(m,v),f.isSkinnedMesh===!0&&f.normalizeSkinWeights(),g.mode===$n.TRIANGLE_STRIP?f.geometry=tE(f.geometry,Tf):g.mode===$n.TRIANGLE_FAN&&(f.geometry=tE(f.geometry,Td));else if(g.mode===$n.LINES)f=new vi(m,v);else if(g.mode===$n.LINE_STRIP)f=new di(m,v);else if(g.mode===$n.LINE_LOOP)f=new cm(m,v);else if(g.mode===$n.POINTS)f=new Au(m,v);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(f.geometry.morphAttributes).length>0&&kN(f,s),f.name=t.createUniqueName(s.name||"mesh_"+e),Bs(f,s),g.extensions&&lo(n,f,g),t.assignFinalMaterial(f),d.push(f)}for(let u=0,A=d.length;u<A;u++)t.associations.set(d[u],{meshes:e,primitives:u});if(d.length===1)return s.extensions&&lo(n,d[0],s),d[0];const p=new Mi;s.extensions&&lo(n,p,s),t.associations.set(p,{meshes:e});for(let u=0,A=d.length;u<A;u++)p.add(d[u]);return p})}loadCamera(e){let t;const i=this.json.cameras[e],n=i[i.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?t=new pi(Dt.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):i.type==="orthographic"&&(t=new Ki(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),Bs(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let n=0,s=t.joints.length;n<s;n++)i.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(n){const s=n.pop(),a=n,o=[],l=[];for(let c=0,h=a.length;c<h;c++){const d=a[c];if(d){o.push(d);const p=new Ke;s!==null&&p.fromArray(s.array,c*16),l.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Dc(o,l)})}loadAnimation(e){const t=this.json,i=this,n=t.animations[e],s=n.name?n.name:"animation_"+e,a=[],o=[],l=[],c=[],h=[];for(let d=0,p=n.channels.length;d<p;d++){const u=n.channels[d],A=n.samplers[u.sampler],m=u.target,g=m.node,f=n.parameters!==void 0?n.parameters[A.input]:A.input,v=n.parameters!==void 0?n.parameters[A.output]:A.output;m.node!==void 0&&(a.push(this.getDependency("node",g)),o.push(this.getDependency("accessor",f)),l.push(this.getDependency("accessor",v)),c.push(A),h.push(m))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(c),Promise.all(h)]).then(function(d){const p=d[0],u=d[1],A=d[2],m=d[3],g=d[4],f=[];for(let b=0,y=p.length;b<y;b++){const M=p[b],_=u[b],S=A[b],w=m[b],E=g[b];if(M===void 0)continue;M.updateMatrix&&M.updateMatrix();const I=i._createAnimationTracks(M,_,S,w,E);if(I)for(let B=0;B<I.length;B++)f.push(I[B])}const v=new el(s,void 0,f);return Bs(v,n),v})}createNodeMesh(e){const t=this.json,i=this,n=t.nodes[e];return n.mesh===void 0?null:i.getDependency("mesh",n.mesh).then(function(s){const a=i._getNodeRef(i.meshCache,n.mesh,s);return n.weights!==void 0&&a.traverse(function(o){if(o.isMesh)for(let l=0,c=n.weights.length;l<c;l++)o.morphTargetInfluences[l]=n.weights[l]}),a})}loadNode(e){const t=this.json,i=this,n=t.nodes[e],s=i._loadNodeShallow(e),a=[],o=n.children||[];for(let c=0,h=o.length;c<h;c++)a.push(i.getDependency("node",o[c]));const l=n.skin===void 0?Promise.resolve(null):i.getDependency("skin",n.skin);return Promise.all([s,Promise.all(a),l]).then(function(c){const h=c[0],d=c[1],p=c[2];p!==null&&h.traverse(function(u){u.isSkinnedMesh&&u.bind(p,FN)});for(let u=0,A=d.length;u<A;u++)h.add(d[u]);if(h.userData.pivot!==void 0&&d.length>0){const u=h.userData.pivot,A=d[0];h.pivot=new T().fromArray(u),h.position.x-=u[0],h.position.y-=u[1],h.position.z-=u[2],A.position.set(0,0,0),delete h.userData.pivot}return h})}_loadNodeShallow(e){const t=this.json,i=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],a=s.name?n.createUniqueName(s.name):"",o=[],l=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&o.push(l),s.camera!==void 0&&o.push(n.getDependency("camera",s.camera).then(function(c){return n._getNodeRef(n.cameraCache,s.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let h;if(s.isBone===!0?h=new su:c.length>1?h=new Mi:c.length===1?h=c[0]:h=new Mt,h!==c[0])for(let d=0,p=c.length;d<p;d++)h.add(c[d]);if(s.name&&(h.userData.name=s.name,h.name=a),Bs(h,s),s.extensions&&lo(i,h,s),s.matrix!==void 0){const d=new Ke;d.fromArray(s.matrix),h.applyMatrix4(d)}else s.translation!==void 0&&h.position.fromArray(s.translation),s.rotation!==void 0&&h.quaternion.fromArray(s.rotation),s.scale!==void 0&&h.scale.fromArray(s.scale);if(!n.associations.has(h))n.associations.set(h,{});else if(s.mesh!==void 0&&n.meshCache.refs[s.mesh]>1){const d=n.associations.get(h);n.associations.set(h,{...d})}return n.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],n=this,s=new Mi;i.name&&(s.name=n.createUniqueName(i.name)),Bs(s,i),i.extensions&&lo(t,s,i);const a=i.nodes||[],o=[];for(let l=0,c=a.length;l<c;l++)o.push(n.getDependency("node",a[l]));return Promise.all(o).then(function(l){for(let h=0,d=l.length;h<d;h++){const p=l[h];p.parent!==null?s.add(aN(p)):s.add(p)}const c=h=>{const d=new Map;for(const[p,u]of n.associations)(p instanceof Bi||p instanceof ii)&&d.set(p,u);return h.traverse(p=>{const u=n.associations.get(p);u!=null&&d.set(p,u)}),d};return n.associations=c(s),s})}_createAnimationTracks(e,t,i,n,s){const a=[],o=e.name?e.name:e.uuid,l=[];$r[s.path]===$r.weights?e.traverse(function(p){p.morphTargetInfluences&&l.push(p.name?p.name:p.uuid)}):l.push(o);let c;switch($r[s.path]){case $r.weights:c=Ta;break;case $r.rotation:c=Ia;break;case $r.translation:case $r.scale:c=Ra;break;default:i.itemSize===1?c=Ta:c=Ra;break}const h=n.interpolation!==void 0?DN[n.interpolation]:Io,d=this._getArrayFromAccessor(i);for(let p=0,u=l.length;p<u;p++){const A=new c(l[p]+"."+$r[s.path],t.array,d,h);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(A),a.push(A)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const i=oA(t.constructor),n=new Float32Array(t.length);for(let s=0,a=t.length;s<a;s++)n[s]=t[s]*i;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(t){const i=this instanceof Ia?RN:aE;return new i(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function zN(r,e,t){const i=e.attributes,n=new Ft;if(i.POSITION!==void 0){const o=t.json.accessors[i.POSITION],l=o.min,c=o.max;if(l!==void 0&&c!==void 0){if(n.set(new T(l[0],l[1],l[2]),new T(c[0],c[1],c[2])),o.normalized){const h=oA(Fl[o.componentType]);n.min.multiplyScalar(h),n.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const o=new T,l=new T;for(let c=0,h=s.length;c<h;c++){const d=s[c];if(d.POSITION!==void 0){const p=t.json.accessors[d.POSITION],u=p.min,A=p.max;if(u!==void 0&&A!==void 0){if(l.setX(Math.max(Math.abs(u[0]),Math.abs(A[0]))),l.setY(Math.max(Math.abs(u[1]),Math.abs(A[1]))),l.setZ(Math.max(Math.abs(u[2]),Math.abs(A[2]))),p.normalized){const m=oA(Fl[p.componentType]);l.multiplyScalar(m)}o.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(o)}r.boundingBox=n;const a=new Gi;n.getCenter(a.center),a.radius=n.min.distanceTo(n.max)/2,r.boundingSphere=a}function cE(r,e,t){const i=e.attributes,n=[];function s(a,o){return t.getDependency("accessor",a).then(function(l){r.setAttribute(o,l)})}for(const a in i){const o=sA[a]||a.toLowerCase();o in r.attributes||n.push(s(i[a],o))}if(e.indices!==void 0&&!r.index){const a=t.getDependency("accessor",e.indices).then(function(o){r.setIndex(o)});n.push(a)}return Et.workingColorSpace!==Ri&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Et.workingColorSpace}" not supported.`),Bs(r,e),zN(r,e,t),Promise.all(n).then(function(){return e.targets!==void 0?LN(r,e.targets,t):r})}var Ai=(r=>(r.ModelLoadStart="model-load-start",r.ModelLoadProgress="model-load-progress",r.ModelLoaded="model-loaded",r.ModelError="model-error",r.SelectionChanged="selection-changed",r.HoverChanged="hover-changed",r.Click="click",r.MouseMove="mouse-move",r.CameraChanged="camera-changed",r.CameraIdle="camera-idle",r.EngineFree="engine-free",r.EngineBusy="engine-busy",r.MeasureChanged="measure-changed",r.MeasureClick="measure-click",r.SectionMove="section-move",r.LoadingCompleted="loading_completed",r))(Ai||{});let Mh=null,wh=null,hE=null;const HN=8,dE=24,GN=24,VN=64,QN=60,WN=10;function uE(){return new URL("draco/",document.baseURI).toString()}function pE(){return new URL("basis/",document.baseURI).toString()}function jN(){return Mh==null&&(Mh=new Vk,Mh.setDecoderPath(uE()),Mh.preload()),Mh}function qN(r){return wh==null&&(wh=new Jn,wh.setTranscoderPath(pE())),hE!==r&&(wh.detectSupport(r),hE=r),wh}function XN(r){const e=new oN;return e.setDRACOLoader(jN()),e.setMeshoptDecoder(Wk),r?.renderer?.capabilities!=null&&typeof r.renderer.getContext=="function"&&e.setKTX2Loader(qN(r.renderer)),e}function fE(){return new Promise(r=>{if(typeof requestAnimationFrame=="function"){requestAnimationFrame(()=>r());return}setTimeout(r,16)})}function YN(){const r=navigator?.scheduling;return typeof r?.isInputPending=="function"?r.isInputPending():!1}function KN(r){return r?.engineStatus?.isFree===!1||YN()}async function dr(r,e,t){if(e)return t;const i=performance.now();return KN(r)||i-t>=HN?(await fE(),performance.now()):t}function ZN(r){return new Promise((e,t)=>{xh(r,i=>{if(i==null){t(new Error(`[loadLightModel] empty zip json: ${r}`));return}e(i)},()=>{t(new Error(`[loadLightModel] failed to load zip json: ${r}`))})})}function JN(r){return gi({method:"get",responseType:"arraybuffer",url:r}).then(e=>_x.loadAsync(e.data))}function mE(r){return r.replace(/\\/g,"/").replace(/^\/+/,"")}function gE(r,e){const t=new Set(e.map(i=>mE(i)));for(const i of Object.keys(r.files))if(t.has(mE(i)))return r.files[i];return null}function AE(r,e){const t=gE(r,e);return t==null||t.dir?Promise.resolve(null):t.async("string")}function $N(r){return r.charCodeAt(0)===65279?r.slice(1):r}function lA(r){return JSON.parse($N(r))}function e6(r,e){const t=gE(r,e);return t==null||t.dir?Promise.resolve(null):t.async("arraybuffer")}function t6(r,e){return new Promise((t,i)=>{XN(r).parse(e,document.baseURI,t,i)})}function af(r,e){return r.models.find(t=>t.url==e)}function vE(r){r.loadStatus==null&&(r.loadStatus={}),r.loadStatus.modelMep==null&&(r.loadStatus.modelMep=!1),r.loadStatus.normal==null&&(r.loadStatus.normal=!1)}function i6(r){return vE(r),r.status==="loaded"&&r.loadStatus.normal===!0&&r.loadStatus.modelMep===!0}function bE(r){const e=r?.engineStatus?.models;!Array.isArray(e)||e.length===0||!e.every(t=>i6(t))||r.__loadingCompletedTriggered===!0||(r.__loadingCompletedTriggered=!0,r.events?.trigger?.(Ai.LoadingCompleted,{}))}function yE(r){return r===!0||r==="loading"}function xE(r){return r.index!=null?r.index.count:r.attributes.position?.count??0}async function n6(r,e,t){let i=performance.now();for(let n=0;n<e.length;n++){const s=e[n];s?.geometry!=null&&s.geometry.computeVertexNormals,(n+1)%GN===0&&(i=await dr(r,t,i))}}async function s6(r,e,t){const i=[],n=[{node:e.octreeBox,visited:!1}];let s=performance.now();for(;n.length>0;){const a=n.pop();if(a==null||a.node==null||a.node.status===!0)continue;const o=a.node;if(a.visited){const c=Array.isArray(o.children)?o.children:[];(c.length===0||c.findIndex(h=>h.status!=!0)===-1)&&(o.status=!0),s=await dr(r,t,s);continue}n.push({node:o,visited:!0}),Array.isArray(o.elements)&&i.push(...o.elements);const l=Array.isArray(o.children)?o.children:[];for(let c=l.length-1;c>=0;c--)n.push({node:l[c],visited:!1});s=await dr(r,t,s)}return i}async function r6(r,e,t,i){const n=af(r,e.url);if(n?.nodesMap==null)return[];const s=await s6(r,t,i);console.log("[loadLightModel] pending mesh ids",t.path,s.length);const a=[];let o=performance.now(),l=0;for(const c of s){if(!n.nodesMap.has(c))continue;const h=n.nodesMap.get(c),d=Array.isArray(h?.infos)?h.infos:[];for(const p of d){const u=t.glbs?.[p.glb]?.[p.mesh];if(u?.geometry==null||u.material==null)continue;const A=new Ke;A.elements=p.matrix;const m=u.geometry.clone();m.applyMatrix4(A),m.computeBoundingBox();const g=new Ge(m,u.material);p.box=m.boundingBox?.clone(),p.mesh=g,g.name=Number(c),g.glb=p.glb,g.url=e.url,m.attributes.position!=null&&a.push(g),l++,l%dE===0&&(o=await dr(r,i,o))}}return a}function a6(r,e,t,i,n){const s=oo(i.map(o=>o.geometry),!1),a=new Ge(s,n);return a.castShadow=!0,a.receiveShadow=!0,e.scene.add(a),a.index=e.scene.children.length-1,a.url=r,a.glb=t,a.materialClone=n,a.geometrys=i.map(o=>o.geometry),a.geometry.computeVertexNormals(),a}function o6(r,e,t,i){return r.scene.children.find(n=>{const s=n;return n instanceof Ge&&s.url==e&&s.glb==t&&s.materialClone===i})}function l6(r,e){const t=Array.isArray(r.geometrys)?r.geometrys:[],i=e.map(a=>a.geometry),n=[...t,...i],s=oo(n,!1);r.geometry!=null&&r.geometry.dispose(),r.geometry=s,r.geometrys=n,r.castShadow=!0,r.receiveShadow=!0}async function c6(r,e,t,i){const n=new Map;for(const o of t){const l=n.get(o.glb)??[];l.push(o),n.set(o.glb,l)}const s=af(e,r);let a=performance.now();for(const[o,l]of n.entries()){const c=i?l.length:QN;for(let h=0;h<l.length;h+=c){const d=l.slice(h,h+c);if(d.length===0)continue;const p=b6(d[0].material,e);let u=o6(e,r,o,p),A=0,m=0;u=null,u!=null?(A=Array.isArray(u.geometrys)?u.geometrys.length:0,m=xE(u.geometry),l6(u,d)):u=a6(r,e,o,d,p);const g=new Map;let f=m;d.forEach((v,b)=>{const y=Number(v.name),M=xE(v.geometry),_=g.get(y)??[];if(_.push([f,f+M]),g.set(y,_),s?.nodesMap?.has(y)){const S=s.nodesMap.get(y);S.indexes==null&&(S.indexes=[]),S.indexes.push([u.index,A+b,f,f+M])}f+=M}),u.indexes==null&&(u.indexes=new Map),g.forEach((v,b)=>{const y=u.indexes.get(b)??[];y.push(...v),u.indexes.set(b,y)}),a=await dr(e,i,a)}}}async function h6(r,e,t,i,n,s){if(i==null||n==null||n.length===0)return;const a=af(t,r);if(a==null)return;const o=new ni(i.geometry,i.material,n.length);t.scene.add(o);const l=new Float32Array(n.length*3);for(let d=0;d<n.length;d++)l[d*3]=1,l[d*3+1]=1,l[d*3+2]=1;o.instanceColor=new Pr(l,3);let c=performance.now();const h=[];for(let d=0;d<n.length;d++){const p=n[d],u=new Ke;if(u.elements=p.matrix,o.setMatrixAt(d,u),o.matrixs||(o.matrixs=[]),o.matrixs.push(u.clone()),h.push(u.clone()),a.nodesMap.has(p.id)){const A=a.nodesMap.get(p.id);A.indexes==null&&(A.indexes=[]),A.indexes.push([t.scene.children.length-1,d,0,0])}else a.nodesMap.set(p.id,{instance:!0,info:p,indexes:[[t.scene.children.length-1,d,0,0]]});(d+1)%VN===0&&(c=await dr(t,s,c))}o.instanceMatrix.needsUpdate=!0,o.instanceColor!=null&&(o.instanceColor.needsUpdate=!0),o.index=t.scene.children.length-1,o.materialClone=i.material,o.url=r,o.glb=i.glb,o.ids=n.map(d=>d.id),o.matrixsClone=h,o.meshIndex=e}async function d6(r,e,t,i){const n=e.instanceNodes;if(n==null)return;let s=performance.now();for(const a in n)if(n[a].isLoaded!==!0){n[a].isLoaded=!0;for(const o of n[a]){const l=e.glbs?.[a]?.[o.mesh];l!=null&&await h6(r.url,o.mesh,t,l,o.children,i)}s=await dr(t,i,s)}}async function u6(r,e,t,i){if(t.status===!0||t.meshPromise!=null){await t.meshPromise;return}t.meshPromise=(async()=>{console.log(`[loadLightModel] start build lod meshes ${Date.now()-window.startTime}ms`);const n=await r6(r,e,t,i);await c6(e.url,r,n,i),await d6(e,t,r,i),t.status=!0,console.log(`[loadLightModel] *****************************************************finish build lod meshes ${Date.now()-window.startTime}ms`)})().finally(()=>{t.meshPromise=null}),await t.meshPromise}async function p6(r,e,t,i){if(t.loadSuccess!==!0){if(t.preparePromise!=null){await t.preparePromise;return}t.preparePromise=(async()=>{console.log("[loadLightModel] loading GLB bundle",t.path),t.glbs=t.glbs??{};const n=await JN(e.url+t.path),s=await AE(n,["/nodes.json","nodes.json"]);if(s==null)return;const a=lA(s),o=af(r,e.url);if(o==null)return;o.nodesMap==null&&(o.nodesMap=new Map);let l=performance.now();for(const h of Object.keys(a)){const d=a[h];for(let u=0;u<d.length;u++){const A=d[u];if(A.glb=h,o.nodesMap.has(A.id)===!1)o.nodesMap.set(A.id,{infos:[A]});else{if(!o.nodesMap.get(A.id).infos)continue;o.nodesMap.get(A.id).infos.push(A)}(u+1)%dE===0&&(l=await dr(r,i,l))}const p=await e6(n,[`/${h}.glb`,`${h}.glb`,h+".glb"]);if(p==null){console.error("[loadLightModel] glb not found in zip",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,availableFiles:Object.keys(n.files)});continue}try{const u=await t6(r,p);t.glbs[h]=u.scene.children,t.glbs[h].forEach(A=>{A.matrixWorld}),await n6(r,t.glbs[h],i)}catch(u){console.error("[loadLightModel] failed to load glb",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,dracoDecoderPath:uE(),basisTranscoderPath:pE(),error:u})}l=await dr(r,i,l)}const c=await AE(n,["/instances.json","instances.json"]);t.instanceNodes=c!=null?lA(c):null,t.loadSuccess=!0})().finally(()=>{t.preparePromise=null}),await t.preparePromise}}function f6(r,e,t){if(t.boundingBox||(t.boundingBox=new Ft,t.boundingBox.min=new T(t.octreeBox.min.X,t.octreeBox.min.Z,-t.octreeBox.min.Y),t.boundingBox.max=new T(t.octreeBox.max.X,t.octreeBox.max.Z,-t.octreeBox.max.Y)),!t.maxSize)return 1e3;const i=t.boundingBox,n=i.min,s=i.max,a=n.clone().add(s.clone()).multiplyScalar(.5),o=n.distanceTo(s),l=new T,c=new T,h=new T,d=new T;if(e.getWorldDirection(h),e.getWorldPosition(d),e.matrixWorld.extractBasis(l,c,new T),e instanceof Ki){const f=Math.max((e.top-e.bottom)/e.zoom,1e-6),v=r?.cameraModule?.perspectiveCamera?.getEffectiveFOV?.()??20,b=Dt.degToRad(v*.5),y=b>0?f/(2*Math.tan(b)):f;d.copy(a).add(h.clone().multiplyScalar(-y))}if(d.distanceTo(a)<=o*.5)return 1e3;const p=a.clone().sub(d).dot(h);if(p<=0)return 0;const u=d.clone().add(h.multiplyScalar(Math.max(p,o))),A=u.clone().add(l.setLength(t.maxSize)),m=new zt(e,r.renderer,r.scene).worldToScreen(u),g=new zt(e,r.renderer,r.scene).worldToScreen(A);return m.distanceTo(g)}async function m6(r,e,t,i){t.maxSize<1e6&&t.path!="/lod0"&&(!(f6(r,r.camera,t)>=WN)||t.status===!0)||(await p6(r,e,t,i),t.loadSuccess===!0&&await u6(r,e,t,i))}function g6(r,e,t){yE(e.loadStatus.modelMep)||(e.loadStatus.modelMep="loading",e.info.modelMep==null&&(e.info.modelMep={}),(async()=>{t||await fE(),rN(r,e.info.modelMep,e.url),e.loadStatus.modelMep=!0,bE(r)})().catch(i=>{e.loadStatus.modelMep=!1,console.error("[loadLightModel] failed to load mep model",i)}))}function A6(r,e,t,i){const n=new Mi;n.name=e,r.scene.add(n),r.models||(r.models=[]),window.startTime=Date.now(),ZN(e+"/info").then(s=>{const a=lA(s);r.__loadingCompletedTriggered=!1,r.engineStatus.models.push({type:"light",info:a,name:a.baseInfo.name,status:"loading",url:e,elements:new Map,loadStatus:{modelMep:!1,normal:!1}}),r.models.push({url:e,nodesMap:new Map,grids:a.modelGrid,levels:a.modelLevel,rooms:a.modelRoom,views:a.modelView,boundingBox:{min:new T(a.baseInfo.min.X*.3048,a.baseInfo.min.Z*.3048,-a.baseInfo.min.Y*.3048),max:new T(a.baseInfo.max.X*.3048,a.baseInfo.max.Z*.3048,-a.baseInfo.max.Y*.3048)}}),r.models.length==i&&(r.viewCube.CameraGoHome(1),setTimeout(()=>{_E(r,null,!1)},100))}).catch(s=>{console.error("[loadLightModel] failed to load model info",{url:e,error:s})})}async function _E(r,e,t=!1){const i=r.engineStatus.models.filter(n=>e==null||n.url==e);for(const n of i)if(vE(n),!(n.status!=="loading"||n.type!=="light")&&(g6(r,n,t),!yE(n.loadStatus.normal))){n.loadStatus.normal="loading";try{await v6(r,n,t)}finally{const s=Array.isArray(n.info?.lods)&&n.info.lods.every(a=>a.status===!0);n.loadStatus.normal=s,s&&(n.status="loaded"),bE(r)}}}async function v6(r,e,t=!1){if(console.log(`[loadLightModel] start loadNode ${Date.now()-window.startTime}ms`),!(e.info==null||e.info.lods==null))for(const i of e.info.lods)await m6(r,e,i,t)}function b6(r,e){return r.map!=null&&(r.map.colorSpace=Jt,r.map.needsUpdate=!0),r.clipShadows=!0,e?.sectionPlane&&(r.clippingPlanes=e.sectionPlane),r}class y6{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const n of e)i(n)==="light"&&A6(this.engine,n,t,e.length);function i(n){const s=n.split(".").pop();return s==="glb"||s==="gltf"?"gltf":"light"}}}var Ol=(r=>(r.ModelLoadStart="model-load-start",r.ModelLoadProgress="model-load-progress",r.ModelLoaded="model-loaded",r.ModelError="model-error",r.SelectionChanged="selection-changed",r.HoverChanged="hover-changed",r.Click="click",r.MouseMove="mouse-move",r.CameraChanged="camera-changed",r.CameraIdle="camera-idle",r.ViewportResize="viewport-resize",r.EngineFree="engine-free",r.EngineBusy="engine-busy",r.MeasureChanged="measure-changed",r.SectionMove="section-move",r.LoadingCompleted="loading_completed",r))(Ol||{});class x6{engine;isFree;isForceFree;highlightModels;hideModels;translucentModels;models;constructor(e){this.engine=e,this.isFree=!0,this.isForceFree=!1,this.highlightModels=[],this.hideModels=[],this.translucentModels=[],this.models=[]}init(){this.engine.events.on(Ol.EngineFree,e=>{this.updateFree(!0),_E(this.engine,e,!1)}),this.engine.events.on(Ol.EngineBusy,()=>{this.updateFree(!1)})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}let _6=class{listeners=new Map;debugMode=!1;setDebugMode(r){this.debugMode=r}on(r,e){const t=String(r);this.listeners.has(t)||this.listeners.set(t,[]),this.listeners.get(t).push(e),this.debugMode&&console.debug(`[EventModule] 注册事件监听器: ${t}, 当前监听器数量: ${this.listeners.get(t).length}`)}off(r,e){const t=String(r);if(!this.listeners.has(t)){this.debugMode&&console.warn(`[EventModule] 尝试移除不存在的事件监听器: ${t}`);return}const i=this.listeners.get(t),n=i.indexOf(e);n!==-1?(i.splice(n,1),this.debugMode&&console.debug(`[EventModule] 移除事件监听器: ${t}, 剩余监听器数量: ${i.length}`)):this.debugMode&&console.warn(`[EventModule] 尝试移除的回调函数未找到: ${t}`)}trigger(r,e){const t=String(r);if(!this.listeners.has(t)){this.debugMode&&(console.warn(`[EventModule] 触发事件但未找到监听器: ${t}`),console.debug("[EventModule] 当前已注册的事件类型:",Array.from(this.listeners.keys())));return}const i=this.listeners.get(t);this.debugMode&&console.debug(`[EventModule] 触发事件: ${t}, 监听器数量: ${i.length}`,e),i.forEach((n,s)=>{try{n(e)}catch(a){console.error(`[EventModule] 事件监听器执行错误 [${t}] #${s}:`,a)}})}};class E6{engine;constructor(e){this.engine=e}init(){const e=new Nr(16777215,1);e.position.set(100,200,100),e.castShadow=!0,e.shadow.mapSize.width=2048,e.shadow.mapSize.height=2048,e.shadow.camera.near=.1,e.shadow.camera.far=5e3,e.shadow.bias=-5e-5,e.shadow.normalBias=.02;const t=50;e.shadow.camera.left=-t,e.shadow.camera.right=t,e.shadow.camera.top=t,e.shadow.camera.bottom=-t,e.shadow.radius=2;const i=new Nr(16777215,2);this.engine.scene.add(e),this.engine.scene.add(i),this.engine.scene.dirLight=i;const n=new il(16777215,2);this.engine.scene.add(n)}}class M6{engine;behavior;isCtrlDown=!1;isShiftDown=!1;hoverOldId=null;timeOutEvent;selectionBox=null;isBoxSelecting=!1;selectionStart=new be;selectionEnd=new be;suppressClickOnce=!1;selectionThreshold=5;tempInstanceMatrix=new Ke;tempScale=new T;constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved,this.ensureSelectionBox(),this.behavior.init(this)}active(){this.behavior.active()}disActive(){this.cancelBoxSelection(),this.behavior.disActive()}handelKeyCtrlUp(){this.isCtrlDown=!1,this.isBoxSelecting&&this.cancelBoxSelection()}handelKeyCtrlDown(){this.isCtrlDown=!0}handelKeyShiftUp(){this.isShiftDown=!1}handelKeyShiftDown(){this.isShiftDown=!0}handleMouseDown(e){e.button!==0||!this.isBoxSelectionModifierDown()||(this.isBoxSelecting=!0,this.selectionStart.set(e.offsetX,e.offsetY),this.selectionEnd.copy(this.selectionStart),this.suppressClickOnce=!1,this.clearHoverFeedback(),this.updateSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!1))}handleMouseMove(e){if(this.clearHoverTimeout(),this.isBoxSelecting){this.selectionEnd.set(e.offsetX,e.offsetY),this.clearHoverFeedback(),this.updateSelectionBox();return}if(e.catch!=null&&(this.engine.hoverHighLight.showModelNameTag(null,null),this.timeOutEvent=setTimeout(()=>{this.hoverOldId=null;const i=this.getCatchMeshs(e,!0);i!=null&&i.length>0&&this.engine.hoverHighLight.showModelNameTag({url:i[0].url,ids:[i[0].name]},e.catch.point)},1e3)),!this.engine.engineStatus.isFree){this.engine.hoverHighLight.clearHighlight();return}const t=this.getCatchMeshs(e);if(t!=null&&t.length>0){this.engine.hoverHighLight.hightMesh(t);return}}handleMouseUp(e){if(!this.isBoxSelecting)return;this.selectionEnd.set(e.offsetX,e.offsetY);const t=this.hasSelectionBox(),i=t?this.collectModelsInSelection():[];this.isBoxSelecting=!1,this.hideSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!0),t&&(this.isBoxDeselectMode()?this.applyBoxDeselection(i):this.applyBoxSelection(i),this.suppressClickOnce=!0)}getCatchMeshs(e,t=!1){if(e.catch==null)return this.hoverOldId=null,null;if(e.catch.object.isInstance){const a=e.catch.object,o=e.catch.object.id,l=this.engine.models.find(d=>d.url==a.url)?.nodesMap?.get(o),c=new Map;l?.indexes.forEach(d=>{this.getSceneModel(d[0])instanceof ni&&(c.has(d[0])||c.set(d[0],[]),c.get(d[0])?.push(d[1]))});const h=[];return c.forEach((d,p)=>{const u=this.getSceneModel(p);d.forEach(A=>{const m=u.geometry.clone();m.applyMatrix4(u.matrixs[A]),h.push(new Ge(m,u.material))})}),this.hoverOldId==o?[]:(this.hoverOldId=o,t||this.engine.hoverHighLight.clearHighlight(),h)}const i=e.catch.object,n=i.name,s=this.engine.models.find(a=>a.url===i.url)?.nodesMap?.get(n)?.infos?.map(a=>a.mesh)??[];return this.hoverOldId==n?[]:(this.hoverOldId=n,t||this.engine.hoverHighLight.clearHighlight(),s)}handleMouseClick(e){if(this.suppressClickOnce){this.suppressClickOnce=!1;return}if(this.isShiftDown&&!this.isCtrlDown)return;if(e.catch!=null){const i=e.catch,n=i.object;if(!this.isCtrlDown){this.engine.modelToolModule.unhighlightAllModels();const a=new CustomEvent("D3ElementClick",{detail:{id:-1}});window.dispatchEvent(a)}this.engine.controlModule.orbitControls.origin.set(i.point.x,i.point.y,i.point.z),this.engine.modelToolModule.highlightModel([{url:n.url,ids:[n.name]}]),this.engine.events.trigger(Ai.Click,[{url:n.url,ids:[n.name]}]);const s=new CustomEvent("D3ElementClick",{detail:{id:n.name}});window.dispatchEvent(s);return}const t=new CustomEvent("D3ElementClick",{detail:{id:-1}});window.dispatchEvent(t),this.engine.modelToolModule.unhighlightAllModels()}handleMouseDoubleClick(e){if(!e.catch){this.engine.viewCube.CameraGoHome(500);return}const t=e.catch,i=t.object,n=this.engine.models.find(o=>o.url===i.url)?.nodesMap?.get(i.name);if(!n)return;if(t.object.isInstance){const o=t.matrix,l=[];n.indexes.forEach(h=>{const d=this.getSceneModel(h[0]);d?.geometry?.boundingSphere||d?.geometry?.computeBoundingSphere?.();const p=d?.geometry?.boundingSphere;if(!p)return;const u=new Ft,A=p.center.clone().applyMatrix4(o),m=p.radius,g=new T().setFromMatrixScale(o),f=m*Math.max(g.x,g.y,g.z);u.min.set(A.x-f,A.y-f,A.z-f),u.max.set(A.x+f,A.y+f,A.z+f),l.push(u)});const c=this.getMergedBox(l);c!=null&&this.engine.viewCube.zoomToModel(c);return}const s=n.infos.map(o=>o.box).filter(o=>o instanceof Ft),a=this.getMergedBox(s);a!=null&&this.engine.viewCube.zoomToModel(a)}handleMouseClickInstance(e){return e.intersectObjects(this.engine.scene.children.filter(t=>t instanceof ni),!0)}ensureSelectionBox(){if(this.selectionBox!=null)return;const e=document.createElement("div");e.style.position="absolute",e.style.left="0px",e.style.top="0px",e.style.display="none",e.style.pointerEvents="none",e.style.border="1px dashed #00aaff",e.style.backgroundColor="rgba(0, 170, 255, 0.12)",e.style.boxSizing="border-box",e.style.zIndex="1001",this.engine.container?.appendChild(e),this.selectionBox=e}updateSelectionBox(){if(this.selectionBox==null)return;if(!this.hasSelectionBox()){this.selectionBox.style.display="none";return}const e=this.getSelectionRect();this.selectionBox.style.display="block",this.selectionBox.style.left=`${e.left}px`,this.selectionBox.style.top=`${e.top}px`,this.selectionBox.style.width=`${e.right-e.left}px`,this.selectionBox.style.height=`${e.bottom-e.top}px`}hideSelectionBox(){this.selectionBox!=null&&(this.selectionBox.style.display="none")}cancelBoxSelection(){this.isBoxSelecting=!1,this.hideSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!0)}clearHoverTimeout(){this.timeOutEvent!=null&&(clearTimeout(this.timeOutEvent),this.timeOutEvent=null)}clearHoverFeedback(){this.hoverOldId=null,this.engine.hoverHighLight.clearHighlight(),this.engine.hoverHighLight.showModelNameTag(null,null)}hasSelectionBox(){return Math.abs(this.selectionEnd.x-this.selectionStart.x)>=this.selectionThreshold&&Math.abs(this.selectionEnd.y-this.selectionStart.y)>=this.selectionThreshold}getSelectionRect(){return{left:Math.min(this.selectionStart.x,this.selectionEnd.x),top:Math.min(this.selectionStart.y,this.selectionEnd.y),right:Math.max(this.selectionStart.x,this.selectionEnd.x),bottom:Math.max(this.selectionStart.y,this.selectionEnd.y)}}isContainMode(){return this.selectionEnd.x>=this.selectionStart.x&&this.selectionEnd.y>=this.selectionStart.y}isBoxSelectionModifierDown(){return this.isCtrlDown}isBoxDeselectMode(){return this.isShiftDown}collectModelsInSelection(){const e=this.getSelectionRect(),t=this.isContainMode(),i=new Map;return this.engine.models?.forEach(n=>{!n?.url||!n?.nodesMap||n.nodesMap.forEach((s,a)=>{const o=this.getNodeWorldBox(s),l=this.projectBoxToScreenRect(o);l==null||!(t?this.containsRect(e,l):this.intersectsRect(e,l))||(i.has(n.url)||i.set(n.url,new Set),i.get(n.url)?.add(a))})}),Array.from(i.entries()).map(([n,s])=>({url:n,ids:Array.from(s)}))}applyBoxSelection(e){const t=this.excludeHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.highlightModel(t),this.engine.events.trigger(Ai.SelectionChanged,t))}applyBoxDeselection(e){const t=this.keepHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.unhighlightModel(t),this.removeModelsFromHighlightState(t),this.engine.events.trigger(Ai.SelectionChanged,t))}excludeHighlightedModels(e){const t=new Map;return(this.engine.engineStatus.highlightModels??[]).forEach(i=>{t.has(i.url)||t.set(i.url,new Set),i.ids.forEach(n=>t.get(i.url)?.add(n))}),e.map(i=>({url:i.url,ids:i.ids.filter(n=>!t.get(i.url)?.has(n))})).filter(i=>i.ids.length>0)}keepHighlightedModels(e){const t=new Map;return(this.engine.engineStatus.highlightModels??[]).forEach(i=>{t.has(i.url)||t.set(i.url,new Set),i.ids.forEach(n=>t.get(i.url)?.add(n))}),e.map(i=>({url:i.url,ids:i.ids.filter(n=>t.get(i.url)?.has(n))})).filter(i=>i.ids.length>0)}removeModelsFromHighlightState(e){const t=new Map;e.forEach(i=>{t.has(i.url)||t.set(i.url,new Set),i.ids.forEach(n=>t.get(i.url)?.add(n))}),this.engine.engineStatus.highlightModels=(this.engine.engineStatus.highlightModels??[]).map(i=>({url:i.url,ids:i.ids.filter(n=>!t.get(i.url)?.has(n))})).filter(i=>i.ids.length>0)}getNodeWorldBox(e){if(Array.isArray(e?.infos)&&e.infos.length>0){const t=e.infos.map(i=>i?.box).filter(i=>i instanceof Ft);return this.getMergedBox(t)}if(Array.isArray(e?.indexes)&&e.indexes.length>0){const t=[];return e.indexes.forEach(i=>{const n=this.getSceneModel(i[0]),s=this.getInstanceWorldBox(n,i[1]);s!=null&&t.push(s)}),this.getMergedBox(t)}return null}getInstanceWorldBox(e,t){if(!(e instanceof ni))return null;e.geometry.boundingBox||e.geometry.computeBoundingBox();const i=e.geometry.boundingBox;if(!i)return null;if(typeof e.getMatrixAt=="function")e.getMatrixAt(t,this.tempInstanceMatrix);else if(e.matrixs?.[t])this.tempInstanceMatrix.copy(e.matrixs[t]);else return null;return this.tempScale.setFromMatrixScale(this.tempInstanceMatrix),Math.abs(this.tempScale.x)+Math.abs(this.tempScale.y)+Math.abs(this.tempScale.z)<1e-6?null:i.clone().applyMatrix4(this.tempInstanceMatrix)}projectBoxToScreenRect(e){if(e==null||e.isEmpty())return null;const t=[new T(e.min.x,e.min.y,e.min.z),new T(e.min.x,e.min.y,e.max.z),new T(e.min.x,e.max.y,e.min.z),new T(e.min.x,e.max.y,e.max.z),new T(e.max.x,e.min.y,e.min.z),new T(e.max.x,e.min.y,e.max.z),new T(e.max.x,e.max.y,e.min.z),new T(e.max.x,e.max.y,e.max.z)];let i=1/0,n=1/0,s=-1/0,a=-1/0;return t.forEach(o=>{const l=new zt(this.engine.camera,this.engine.renderer,this.engine.scene).worldToScreen(o);!Number.isFinite(l.x)||!Number.isFinite(l.y)||(i=Math.min(i,l.x),n=Math.min(n,l.y),s=Math.max(s,l.x),a=Math.max(a,l.y))}),!Number.isFinite(i)||!Number.isFinite(n)||!Number.isFinite(s)||!Number.isFinite(a)?null:{left:i,top:n,right:s,bottom:a}}containsRect(e,t){return t.left>=e.left&&t.top>=e.top&&t.right<=e.right&&t.bottom<=e.bottom}intersectsRect(e,t){return!(t.right<e.left||t.left>e.right||t.bottom<e.top||t.top>e.bottom)}getMergedBox(e){if(e.length===0)return null;const t=new Ft().makeEmpty();return e.forEach(i=>t.union(i)),t.isEmpty()?null:t}getSceneModel(e){return this.engine.scene.children.find(t=>t.index===e)??this.engine.scene.children[e]}}class w6{engine;highlightMaterial;hideMaterial;translucentMaterial;constructor(e){this.engine=e,this.highlightMaterial=new Rt({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:Vt}),this.hideMaterial=new Rt({color:0,transparent:!0,opacity:0,side:Vt}),this.translucentMaterial=new Rt({color:16777215,transparent:!0,opacity:.05,side:Vt}),this.highlightMaterial.clippingPlanes=this.engine.sectionPlane,this.hideMaterial.clippingPlanes=this.engine.sectionPlane,this.translucentMaterial.clippingPlanes=this.engine.sectionPlane}split_merge_model(e){if(e.isSplit||e instanceof ni)return;let t=e.materialClone.clone(),i=oo(e.geometrys,!0);i.computeVertexNormals(),i.groups.forEach(n=>{n.materialIndex=0}),e.geometry=i,e.material=[t,this.highlightMaterial,this.translucentMaterial],e.needsUpdate=!0,e.isSplit=!0}un_split_merge_model(e){}getSceneModel(e){return this.engine.scene.children.find(t=>t.index==e)}highlightModel(e){e.forEach(t=>{let i=new Map;t.ids.forEach(s=>{let a=this.engine.models.find(o=>o.url==t.url).nodesMap.get(s);a!=null&&a.indexes!=null&&a.indexes.forEach(o=>{this.getSceneModel(o[0])instanceof ni?i.has(o[0])?i.get(o[0])?.push(o[1]):i.set(o[0],[o[1]]):(console.log(this.getSceneModel(o[0]).materialClone.color),this.split_merge_model(this.getSceneModel(o[0])),this.getSceneModel(o[0]).geometry.groups[o[1]].materialIndex=1)})}),S6(i,this.engine);let n=this.engine.engineStatus.highlightModels.find(s=>s.url==t.url);n!=null?n.ids.push(...t.ids):this.engine.engineStatus.highlightModels.push(t)})}unhighlightModel(e){e.forEach(t=>{let i=new Map;t.ids.forEach(n=>{let s=this.engine.models.find(a=>a.url==t.url).nodesMap.get(n);s!=null&&s.indexes!=null&&s.indexes.forEach(a=>{this.getSceneModel(a[0])instanceof ni?i.has(a[0])?i.get(a[0])?.push(a[1]):i.set(a[0],[a[1]]):this.getSceneModel(a[0]).geometry.groups[a[1]].materialIndex=0})}),EE(i,this.engine,"highlightModel")})}unhighlightAllModels(e=!0){this.engine.engineStatus.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus.highlightModels=[])}hideModel(e){e.forEach(t=>{let i=new Map;t.ids.forEach(s=>{let a=this.engine.models.find(o=>o.url==t.url).nodesMap.get(s);this.engine.modelEdge.hideModelEdge(t.url,s),a!=null&&a.indexes!=null&&a.indexes.forEach(o=>{const l=this.getSceneModel(o[0]);l instanceof ni?i.has(o[0])?i.get(o[0])?.push(o[1]):i.set(o[0],[o[1]]):(this.split_merge_model(this.getSceneModel(o[0])),l.geometry.groups[o[1]].materialIndex=-1,l.geometry.groups[o[1]].visible=!1)})}),i.size>0&&T6(i,this.engine);let n=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);n!=null?n.ids.push(...t.ids):this.engine.engineStatus.hideModels.push({url:t.url,ids:t.ids}),this.engine.engineStatus.highlightModels=[]})}showModel(e){e.forEach(t=>{let i=new Map;t.ids.forEach(s=>{let a=this.engine.models.find(o=>o.url==t.url).nodesMap.get(s);this.engine.modelEdge.showModelEdge(t.url,s),a!=null&&a.indexes!=null&&a.indexes.forEach(o=>{const l=this.getSceneModel(o[0]);l instanceof ni?i.has(o[0])?i.get(o[0])?.push(o[1]):i.set(o[0],[o[1]]):(l.geometry.groups[o[1]].materialIndex=0,l.geometry.groups[o[1]].visible=!0)})}),i.size>0&&ME(i,this.engine);let n=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);n&&(t.ids.forEach(s=>{const a=n.ids.indexOf(s);a!==-1&&n.ids.splice(a,1)}),n.ids.length===0&&(this.engine.engineStatus.hideModels=this.engine.engineStatus.hideModels.filter(s=>s!==n)))})}isolateModel(e){let t=[];this.engine.models.forEach(i=>{let n={url:i.url,ids:[]},s=e.find(a=>a.url==i.url);for(let a of i.nodesMap)s==null?n.ids.push(a[0]):s.ids.includes(a[0])||n.ids.push(a[0]);t.push(n)});debugger;this.unhighlightAllModels(),this.hideModel(t)}translucentOtherModel(e){let t=[];this.engine.models.forEach(i=>{let n={url:i.url,ids:[]},s=e.find(a=>a.url==i.url);for(let a of i.nodesMap)s==null?n.ids.push(a[0]):s.ids.includes(a[0])||n.ids.push(a[0]);t.push(n)}),this.translucentModel(t)}setModelColor(e,t){e.material.color.set(t)}setAllModelsColor(e){this.engine.scene.children.forEach(t=>{t.isMesh})}restoreAllModelsColor(){this.engine.scene.children.forEach(e=>{e.isMesh})}translucentModel(e){this.unhighlightAllModels(),e.forEach(t=>{let i=new Map;t.ids.forEach(s=>{let a=this.engine.models.find(o=>o.url==t.url).nodesMap.get(s);a!=null&&a.indexes!=null&&a.indexes.forEach(o=>{const l=this.getSceneModel(o[0]);l instanceof ni?i.has(o[0])?i.get(o[0])?.push(o[1]):i.set(o[0],[o[1]]):(this.split_merge_model(this.getSceneModel(o[0])),l.geometry.groups[o[1]].materialIndex=2)})}),C6(i,this.engine);let n=this.engine.engineStatus.translucentModels.find(s=>s.url==t.url);n!=null?n.ids.push(...t.ids):this.engine.engineStatus.translucentModels.push({url:t.url,ids:t.ids})}),this.engine.engineStatus.highlightModels=[]}unTranslucentModel(){this.engine.engineStatus.translucentModels.forEach(e=>{let t=new Map;e.ids.forEach(i=>{let n=this.engine.models.find(s=>s.url==e.url).nodesMap.get(i);n!=null&&n.indexes!=null&&n.indexes.forEach(s=>{const a=this.getSceneModel(s[0]);a instanceof ni?t.has(s[0])?t.get(s[0])?.push(s[1]):t.set(s[0],[s[1]]):(this.split_merge_model(this.getSceneModel(s[0])),a.geometry.groups[s[1]].materialIndex=0)})}),t.size>0&&ME(t,this.engine),EE(t,this.engine,"translucentModel")}),this.engine.engineStatus.translucentModels=[]}showAllModels(){this.engine.engineStatus.hideModels&&this.engine.engineStatus.hideModels.length>0&&this.showModel(this.engine.engineStatus.hideModels),this.engine.engineStatus.hideModels=[],this.unhighlightAllModels()}batchSelectSameLevelTypeModel(e){if(e.length==0)return;let t=e[0],i=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevelType(i.levelName,i.typeName,n=>{this.engine.modelToolModule.highlightModel(n)})}batchSelectSameLevelModel(e){if(e.length==0)return;let t=e[0],i=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevel(i.levelName,n=>{this.engine.modelToolModule.highlightModel(n)})}batchSelectSameTypeModel(e){if(e.length==0)return;let t=e[0],i=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithType(i.typeName,n=>{this.engine.modelToolModule.highlightModel(n)})}}function S6(r,e){r.forEach((t,i)=>{const n=Sh(e,i);if(!(n instanceof ni))return;const s=n.geometry,a=new Rt({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:Vt}),o=new ni(s,a,t.length);o.name="highlightModel",o.key=i;const l=new Map,c=new Ke,h=new Ke;h.makeScale(0,0,0),t.forEach((d,p)=>{n.getMatrixAt(d,c),l.set(d,c.clone()),n.setMatrixAt(d,h),o.setMatrixAt(p,c)}),n.instanceMatrix.needsUpdate=!0,o.instanceMatrix.needsUpdate=!0,e.scene.add(o)})}function EE(r,e,t){r.forEach((i,n)=>{const s=Sh(e,n);s instanceof ni&&(i.forEach(a=>{const o=s.matrixsClone[a];o&&s.setMatrixAt(a,o)}),s.instanceMatrix.needsUpdate=!0,e.scene.children.filter(a=>a.key==n&&a.name==t).forEach(a=>{e.scene.remove(a)}))})}function C6(r,e){r.forEach((t,i)=>{const n=Sh(e,i);if(!(n instanceof ni))return;const s=n.geometry,a=new Rt({color:16777215,transparent:!0,opacity:.05,side:Vt}),o=new ni(s,a,t.length);o.name="translucentModel",o.key=i;const l=new Map,c=new Ke,h=new Ke;h.makeScale(0,0,0),t.forEach((d,p)=>{n.getMatrixAt(d,c),l.set(d,c.clone()),n.setMatrixAt(d,h),o.setMatrixAt(p,c)}),n.instanceMatrix.needsUpdate=!0,o.instanceMatrix.needsUpdate=!0,e.scene.add(o)})}function T6(r,e){e.scene.children.filter(t=>t.name=="highlightModel").forEach(t=>{e.scene.remove(t)}),r.forEach((t,i)=>{const n=Sh(e,i);if(!(n instanceof ni))return;const s=new Map,a=new Ke,o=new Ke;o.makeScale(0,0,0),t.forEach((l,c)=>{n.getMatrixAt(l,a),s.set(l,a.clone()),n.setMatrixAt(l,o)}),n.instanceMatrix.needsUpdate=!0})}function ME(r,e){r.forEach((t,i)=>{const n=Sh(e,i);n instanceof ni&&(t.forEach(s=>{const a=n.matrixs[s];a&&n.setMatrixAt(s,a)}),n.instanceMatrix.needsUpdate=!0)})}function Sh(r,e){return r.scene.children.find(t=>t.index==e)}class I6{engine;currentMode="";isManualMode=!1;gtaoPass=null;ssaoPass=null;saturationPass=null;outputPass=null;fxaaPass=null;constructor(e){this.engine=e}init(){this.cachePassReferences(),this.autoSwitch("advanced")}switchModel(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}autoSwitch(e){this.isManualMode||(this.currentMode=e,this.applyMode(e))}enableAutoMode(){this.isManualMode=!1}get isManual(){return this.isManualMode}setMode(e){debugger;this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}getCurrentMode(){return this.currentMode}cachePassReferences(){this.engine.composerModule?.composer&&(this.engine.composerModule.gtaoPass&&(this.gtaoPass=this.engine.composerModule.gtaoPass),this.engine.composerModule.ssaoPass&&(this.ssaoPass=this.engine.composerModule.ssaoPass),this.engine.composerModule.saturationPass&&(this.saturationPass=this.engine.composerModule.saturationPass),this.engine.composerModule.outputPass&&(this.outputPass=this.engine.composerModule.outputPass),this.engine.composerModule.fxaaPass&&(this.fxaaPass=this.engine.composerModule.fxaaPass))}applyMode(e){switch(e){case"simple":this.setShadows(!1),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!0);break;case"balance":this.setShadows(!0),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!0);break;case"advanced":this.setShadows(!0),this.setSSAO(!1),this.setGTAO(!0),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!0);break;default:console.warn(`[EngineModelModule] Unknown mode: ${e}`)}this.engine.updateVersionDisplay?.()}setShadows(e){this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e);const t=this.engine.scene?.children.find(i=>i instanceof Nr);t&&(t.castShadow=e),this.engine.scene?.traverse(i=>{i.material&&(i.castShadow!==void 0&&(i.castShadow=e),i.receiveShadow!==void 0&&(i.receiveShadow=e))})}setGTAO(e){this.engine.composerModule?.composer&&this.gtaoPass&&(this.gtaoPass.enabled=e)}setSSAO(e){this.engine.composerModule?.composer&&this.ssaoPass&&(this.ssaoPass.enabled=e)}setSaturation(e){this.saturationPass&&(this.saturationPass.enabled=e)}setOutputPass(e){this.outputPass&&(this.outputPass.enabled=e)}setFXAA(e){this.fxaaPass&&(this.fxaaPass.enabled=e)}setPerformanceMode(){this.setMode("simple")}setBalancedMode(){this.setMode("balance")}setQualityMode(){this.setMode("advanced")}setSuperQualityMode(){this.setMode("superAdvanced")}setShadowQuality(e){const t=this.engine.scene?.children.find(n=>n instanceof Nr),i={low:1024,medium:2048,high:2048}[e];t?.shadow&&i&&(t.shadow.mapSize.width=i,t.shadow.mapSize.height=i,t.shadow.map?.dispose(),t.shadow.map=null)}setSaturationValue(e){this.saturationPass&&(this.saturationPass.uniforms.saturation.value=e)}setContrastValue(e){this.saturationPass&&(this.saturationPass.uniforms.contrast.value=e)}setGTAOIntensity(e){this.gtaoPass&&(this.gtaoPass.blendIntensity=e)}}class of{engine;overlayMaterial;overlayMeshes=[];animState="idle";animStartTime=0;static FADE_IN_MS=200;static FADE_OUT_MS=150;tagDiv;constructor(e){this.engine=e,this.init();const t=document.createElement("div");this.tagDiv=t,t.className="tagDiv",t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.borderRadius="10px",t.style.pointerEvents="none",this.engine.container.appendChild(this.tagDiv)}showModelNameTag(e,t){if(e==null){this.tagDiv.style.display="none";return}let i=this.engine.models.find(a=>a.url==e.url);if(i==null){this.tagDiv.style.display="none";return}let n=i.nodesMap.get(e.ids[0]);if(n.infos&&n.infos.length>0){let a=n.infos[0].name.replace(/\s*\[[a-f0-9-]+\]$/,"");this.tagDiv.innerHTML=a}const s=this.engine.worldToScreen.worldToScreen(t);this.tagDiv?(this.tagDiv.style.left=s.x+10+this.engine.reactBoundingClientRect.left+"px",this.tagDiv.style.top=s.y-10+this.engine.reactBoundingClientRect.top+"px",this.tagDiv.style.display="block"):this.tagDiv&&(this.tagDiv.style.display="none")}init(){this.overlayMaterial=new Rt({color:16777215,transparent:!0,opacity:0,blending:Vh,depthWrite:!1}),this.overlayMaterial.clippingPlanes=this.engine.sectionPlane}hightMesh(e,t=16777215,i=.15){this.animState==="fadeOut"&&this.removeOverlayMeshes();const n=(Array.isArray(e)?e:e?[e]:[]).filter(s=>s?.geometry);if(n.length===0){this.clearHighlight();return}this.overlayMaterial.color.set(t),this.overlayMaterial.opacity=0,this.overlayMaterial.userData.targetOpacity=i;for(const s of n){let a=s.geometry.clone();a.computeVertexNormals();const o=new Ge(a,this.overlayMaterial);s.updateWorldMatrix(!0,!1),o.matrix.copy(s.matrixWorld),o.matrixAutoUpdate=!1,this.engine.scene.add(o),this.overlayMeshes.push(o)}this.animState="fadeIn",this.animStartTime=performance.now()}clearHighlight(){this.overlayMeshes.length===0||this.animState==="fadeOut"||(this.animState="fadeOut",this.animStartTime=performance.now())}update(){if(this.animState==="idle"||this.overlayMeshes.length===0)return;const e=performance.now()-this.animStartTime,t=this.overlayMaterial.userData.targetOpacity??.35;if(this.animState==="fadeIn"){const i=Math.min(e/of.FADE_IN_MS,1);this.overlayMaterial.opacity=this.easeOutQuad(i)*t,i>=1&&(this.animState="idle")}else if(this.animState==="fadeOut"){const i=Math.min(e/of.FADE_OUT_MS,1);this.overlayMaterial.opacity=(1-this.easeOutQuad(i))*t,i>=1&&(this.removeOverlayMeshes(),this.animState="idle")}}removeOverlayMeshes(){for(const e of this.overlayMeshes)this.engine.scene.remove(e);this.overlayMeshes=[]}easeOutQuad(e){return 1-(1-e)*(1-e)}dispose(){this.removeOverlayMeshes(),this.overlayMaterial.dispose(),this.animState="idle"}}var cA={exports:{}},P6=cA.exports,wE;function R6(){return wE||(wE=1,(function(r,e){(function(t,i){r.exports=i()})(P6,function(){var t=function(){function i(u){return a.appendChild(u.dom),u}function n(u){for(var A=0;A<a.children.length;A++)a.children[A].style.display=A===u?"block":"none";s=u}var s=0,a=document.createElement("div");a.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",a.addEventListener("click",function(u){u.preventDefault(),n(++s%a.children.length)},!1);var o=(performance||Date).now(),l=o,c=0,h=i(new t.Panel("FPS","#0ff","#002")),d=i(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var p=i(new t.Panel("MB","#f08","#201"));return n(0),{REVISION:16,dom:a,addPanel:i,showPanel:n,begin:function(){o=(performance||Date).now()},end:function(){c++;var u=(performance||Date).now();if(d.update(u-o,200),u>l+1e3&&(h.update(1e3*c/(u-l),100),l=u,c=0,p)){var A=performance.memory;p.update(A.usedJSHeapSize/1048576,A.jsHeapSizeLimit/1048576)}return u},update:function(){o=this.end()},domElement:a,setMode:n}};return t.Panel=function(i,n,s){var a=1/0,o=0,l=Math.round,c=l(window.devicePixelRatio||1),h=80*c,d=48*c,p=3*c,u=2*c,A=3*c,m=15*c,g=74*c,f=30*c,v=document.createElement("canvas");v.width=h,v.height=d,v.style.cssText="width:80px;height:48px";var b=v.getContext("2d");return b.font="bold "+9*c+"px Helvetica,Arial,sans-serif",b.textBaseline="top",b.fillStyle=s,b.fillRect(0,0,h,d),b.fillStyle=n,b.fillText(i,p,u),b.fillRect(A,m,g,f),b.fillStyle=s,b.globalAlpha=.9,b.fillRect(A,m,g,f),{dom:v,update:function(y,M){a=Math.min(a,y),o=Math.max(o,y),b.fillStyle=s,b.globalAlpha=1,b.fillRect(0,0,h,m),b.fillStyle=n,b.fillText(l(y)+" "+i+" ("+l(a)+"-"+l(o)+")",p,u),b.drawImage(v,A+c,m,g-c,f,A,m,g-c,f),b.fillRect(A+g-c,m,c,f),b.fillStyle=s,b.globalAlpha=.9,b.fillRect(A+g-c,m,c,l((1-y/M)*f))}}},t})})(cA)),cA.exports}var D6=R6();const B6=bx(D6);var zl=Object.freeze({Linear:Object.freeze({None:function(r){return r},In:function(r){return r},Out:function(r){return r},InOut:function(r){return r}}),Quadratic:Object.freeze({In:function(r){return r*r},Out:function(r){return r*(2-r)},InOut:function(r){return(r*=2)<1?.5*r*r:-.5*(--r*(r-2)-1)}}),Cubic:Object.freeze({In:function(r){return r*r*r},Out:function(r){return--r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r:.5*((r-=2)*r*r+2)}}),Quartic:Object.freeze({In:function(r){return r*r*r*r},Out:function(r){return 1- --r*r*r*r},InOut:function(r){return(r*=2)<1?.5*r*r*r*r:-.5*((r-=2)*r*r*r-2)}}),Quintic:Object.freeze({In:function(r){return r*r*r*r*r},Out:function(r){return--r*r*r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r*r*r:.5*((r-=2)*r*r*r*r+2)}}),Sinusoidal:Object.freeze({In:function(r){return 1-Math.sin((1-r)*Math.PI/2)},Out:function(r){return Math.sin(r*Math.PI/2)},InOut:function(r){return .5*(1-Math.sin(Math.PI*(.5-r)))}}),Exponential:Object.freeze({In:function(r){return r===0?0:Math.pow(1024,r-1)},Out:function(r){return r===1?1:1-Math.pow(2,-10*r)},InOut:function(r){return r===0?0:r===1?1:(r*=2)<1?.5*Math.pow(1024,r-1):.5*(-Math.pow(2,-10*(r-1))+2)}}),Circular:Object.freeze({In:function(r){return 1-Math.sqrt(1-r*r)},Out:function(r){return Math.sqrt(1- --r*r)},InOut:function(r){return(r*=2)<1?-.5*(Math.sqrt(1-r*r)-1):.5*(Math.sqrt(1-(r-=2)*r)+1)}}),Elastic:Object.freeze({In:function(r){return r===0?0:r===1?1:-Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI)},Out:function(r){return r===0?0:r===1?1:Math.pow(2,-10*r)*Math.sin((r-.1)*5*Math.PI)+1},InOut:function(r){return r===0?0:r===1?1:(r*=2,r<1?-.5*Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI):.5*Math.pow(2,-10*(r-1))*Math.sin((r-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(r){var e=1.70158;return r===1?1:r*r*((e+1)*r-e)},Out:function(r){var e=1.70158;return r===0?0:--r*r*((e+1)*r+e)+1},InOut:function(r){var e=2.5949095;return(r*=2)<1?.5*(r*r*((e+1)*r-e)):.5*((r-=2)*r*((e+1)*r+e)+2)}}),Bounce:Object.freeze({In:function(r){return 1-zl.Bounce.Out(1-r)},Out:function(r){return r<1/2.75?7.5625*r*r:r<2/2.75?7.5625*(r-=1.5/2.75)*r+.75:r<2.5/2.75?7.5625*(r-=2.25/2.75)*r+.9375:7.5625*(r-=2.625/2.75)*r+.984375},InOut:function(r){return r<.5?zl.Bounce.In(r*2)*.5:zl.Bounce.Out(r*2-1)*.5+.5}}),generatePow:function(r){return r===void 0&&(r=4),r=r<Number.EPSILON?Number.EPSILON:r,r=r>1e4?1e4:r,{In:function(e){return Math.pow(e,r)},Out:function(e){return 1-Math.pow(1-e,r)},InOut:function(e){return e<.5?Math.pow(e*2,r)/2:(1-Math.pow(2-e*2,r))/2+.5}}}}),Ch=function(){return performance.now()},L6=(function(){function r(){this._tweens={},this._tweensAddedDuringUpdate={}}return r.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},r.prototype.removeAll=function(){this._tweens={}},r.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},r.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},r.prototype.update=function(e,t){e===void 0&&(e=Ch()),t===void 0&&(t=!1);var i=Object.keys(this._tweens);if(i.length===0)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var n=0;n<i.length;n++){var s=this._tweens[i[n]],a=!t;s&&s.update(e,a)===!1&&!t&&delete this._tweens[i[n]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},r})(),hA={Linear:function(r,e){var t=r.length-1,i=t*e,n=Math.floor(i),s=hA.Utils.Linear;return e<0?s(r[0],r[1],i):e>1?s(r[t],r[t-1],t-i):s(r[n],r[n+1>t?t:n+1],i-n)},Utils:{Linear:function(r,e,t){return(e-r)*t+r}}},SE=(function(){function r(){}return r.nextId=function(){return r._nextId++},r._nextId=0,r})(),dA=new L6,k6=(function(){function r(e,t){t===void 0&&(t=dA),this._object=e,this._group=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=zl.Linear.None,this._interpolationFunction=hA.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=SE.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return r.prototype.getId=function(){return this._id},r.prototype.isPlaying=function(){return this._isPlaying},r.prototype.isPaused=function(){return this._isPaused},r.prototype.getDuration=function(){return this._duration},r.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},r.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},r.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},r.prototype.start=function(e,t){if(e===void 0&&(e=Ch()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var i in this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i]}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 n={};for(var s in this._valuesEnd)n[s]=this._valuesEnd[s];this._valuesEnd=n}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},r.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},r.prototype._setupProperties=function(e,t,i,n,s){for(var a in i){var o=e[a],l=Array.isArray(o),c=l?"array":typeof o,h=!l&&Array.isArray(i[a]);if(!(c==="undefined"||c==="function")){if(h){var d=i[a];if(d.length===0)continue;for(var p=[o],u=0,A=d.length;u<A;u+=1){var m=this._handleRelativeValue(o,d[u]);if(isNaN(m)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}p.push(m)}h&&(i[a]=p)}if((c==="object"||l)&&o&&!h){t[a]=l?[]:{};var g=o;for(var f in g)t[a][f]=g[f];n[a]=l?[]:{};var d=i[a];if(!this._isDynamic){var v={};for(var f in d)v[f]=d[f];i[a]=d=v}this._setupProperties(g,t[a],d,n[a],s)}else(typeof t[a]>"u"||s)&&(t[a]=o),l||(t[a]*=1),h?n[a]=i[a].slice().reverse():n[a]=t[a]||0}}},r.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},r.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},r.prototype.pause=function(e){return e===void 0&&(e=Ch()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},r.prototype.resume=function(e){return e===void 0&&(e=Ch()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},r.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},r.prototype.group=function(e){return e===void 0&&(e=dA),this._group=e,this},r.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},r.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},r.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},r.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},r.prototype.easing=function(e){return e===void 0&&(e=zl.Linear.None),this._easingFunction=e,this},r.prototype.interpolation=function(e){return e===void 0&&(e=hA.Linear),this._interpolationFunction=e,this},r.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},r.prototype.onStart=function(e){return this._onStartCallback=e,this},r.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},r.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},r.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},r.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},r.prototype.onStop=function(e){return this._onStopCallback=e,this},r.prototype.update=function(e,t){var i=this,n;if(e===void 0&&(e=Ch()),t===void 0&&(t=!0),this._isPaused)return!0;var s,a=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>a)return!1;t&&this.start(e,!0)}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 o=e-this._startTime,l=this._duration+((n=this._repeatDelayTime)!==null&&n!==void 0?n:this._delayTime),c=this._duration+this._repeat*l,h=function(){if(i._duration===0||o>c)return 1;var g=Math.trunc(o/l),f=o-g*l,v=Math.min(f/i._duration,1);return v===0&&o===i._duration?1:v},d=h(),p=this._easingFunction(d);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,p),this._onUpdateCallback&&this._onUpdateCallback(this._object,d),this._duration===0||o>=this._duration)if(this._repeat>0){var u=Math.min(Math.trunc((o-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=u);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*u,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var A=0,m=this._chainedTweens.length;A<m;A++)this._chainedTweens[A].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},r.prototype._updateProperties=function(e,t,i,n){for(var s in i)if(t[s]!==void 0){var a=t[s]||0,o=i[s],l=Array.isArray(e[s]),c=Array.isArray(o),h=!l&&c;h?e[s]=this._interpolationFunction(o,n):typeof o=="object"&&o?this._updateProperties(e[s],a,o,n):(o=this._handleRelativeValue(a,o),typeof o=="number"&&(e[s]=a+(o-a)*n))}},r.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},r.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],i=this._valuesEnd[e];typeof i=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(i):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},r})();SE.nextId;var Ls=dA;Ls.getAll.bind(Ls),Ls.removeAll.bind(Ls),Ls.add.bind(Ls),Ls.remove.bind(Ls),Ls.update.bind(Ls);var Th={Easing:zl,Tween:k6};const CE={type:"change"},uA={type:"start"},TE={type:"end"},lf=new Ir,IE=new li,N6=Math.cos(70*Dt.DEG2RAD),zi=new T,Sn=2*Math.PI,Xt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},pA=1e-6;class U6 extends qu{constructor(e,t=null){super(e,t),this.state=Xt.NONE,this.target=new T,this.cursor=new T,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:Tn.ROTATE,MIDDLE:Tn.DOLLY,RIGHT:Tn.PAN},this.touches={ONE:In.ROTATE,TWO:In.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new T,this._lastQuaternion=new Tt,this._lastTargetPosition=new T,this._quat=new Tt().setFromUnitVectors(e.up,new T(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new rl,this._sphericalDelta=new rl,this._scale=1,this._panOffset=new T,this._rotateStart=new be,this._rotateEnd=new be,this._rotateDelta=new be,this._panStart=new be,this._panEnd=new be,this._panDelta=new be,this._dollyStart=new be,this._dollyEnd=new be,this._dollyDelta=new be,this._dollyDirection=new T,this._mouse=new be,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=O6.bind(this),this._onPointerDown=F6.bind(this),this._onPointerUp=z6.bind(this),this._onContextMenu=q6.bind(this),this._onMouseWheel=V6.bind(this),this._onKeyDown=Q6.bind(this),this._onTouchStart=W6.bind(this),this._onTouchMove=j6.bind(this),this._onMouseDown=H6.bind(this),this._onMouseMove=G6.bind(this),this._interceptControlDown=X6.bind(this),this._interceptControlUp=Y6.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(CE),this.update(),this.state=Xt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){const t=this.object.position;zi.copy(t).sub(this.target),zi.applyQuaternion(this._quat),this._spherical.setFromVector3(zi),this.autoRotate&&this.state===Xt.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 i=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(i)&&isFinite(n)&&(i<-Math.PI?i+=Sn:i>Math.PI&&(i-=Sn),n<-Math.PI?n+=Sn:n>Math.PI&&(n-=Sn),i<=n?this._spherical.theta=Math.max(i,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+n)/2?Math.max(i,this._spherical.theta):Math.min(n,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 s=!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),s=a!=this._spherical.radius}if(zi.setFromSpherical(this._spherical),zi.applyQuaternion(this._quatInverse),t.copy(this.target).add(zi),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 o=zi.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const o=new T(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=l!==this.object.zoom;const c=new T(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=zi.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):(lf.origin.copy(this.object.position),lf.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(lf.direction))<N6?this.object.lookAt(this.target):(IE.setFromNormalAndCoplanarPoint(this.object.up,this.target),lf.intersectPlane(IE,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(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>pA||8*(1-this._lastQuaternion.dot(this.object.quaternion))>pA||this._lastTargetPosition.distanceToSquared(this.target)>pA?(this.dispatchEvent(CE),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Sn/60*this.autoRotateSpeed*e:Sn/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){zi.setFromMatrixColumn(t,0),zi.multiplyScalar(-e),this._panOffset.add(zi)}_panUp(e,t){this.screenSpacePanning===!0?zi.setFromMatrixColumn(t,1):(zi.setFromMatrixColumn(t,0),zi.crossVectors(this.object.up,zi)),zi.multiplyScalar(e),this._panOffset.add(zi)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;zi.copy(n).sub(this.target);let s=zi.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/i.clientHeight,this.object.matrix),this._panUp(2*t*s/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.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 i=this.domElement.getBoundingClientRect(),n=e-i.left,s=t-i.top,a=i.width,o=i.height;this._mouse.x=n/a*2-1,this._mouse.y=-(s/o)*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(Sn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Sn*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(Sn*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(-Sn*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(Sn*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(-Sn*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),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(i,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(i,n)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,n=e.pageY-t.y,s=Math.sqrt(i*i+n*n);this._dollyStart.set(0,s)}_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 i=this._getSecondPointerPosition(e),n=.5*(e.pageX+i.x),s=.5*(e.pageY+i.y);this._rotateEnd.set(n,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Sn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Sn*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),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(i,n)}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),i=e.pageX-t.x,n=e.pageY-t.y,s=Math.sqrt(i*i+n*n);this._dollyEnd.set(0,s),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,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_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 be,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,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function F6(r){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(r.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(r)&&(this._addPointer(r),r.pointerType==="touch"?this._onTouchStart(r):this._onMouseDown(r),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function O6(r){this.enabled!==!1&&(r.pointerType==="touch"?this._onTouchMove(r):this._onMouseMove(r))}function z6(r){switch(this._removePointer(r),this._pointers.length){case 0:this.domElement.releasePointerCapture(r.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(TE),this.state=Xt.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function H6(r){let e;switch(r.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 Tn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(r),this.state=Xt.DOLLY;break;case Tn.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=Xt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=Xt.ROTATE}break;case Tn.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=Xt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=Xt.PAN}break;default:this.state=Xt.NONE}this.state!==Xt.NONE&&this.dispatchEvent(uA)}function G6(r){switch(this.state){case Xt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(r);break;case Xt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(r);break;case Xt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(r);break}}function V6(r){this.enabled===!1||this.enableZoom===!1||this.state!==Xt.NONE||(r.preventDefault(),this.dispatchEvent(uA),this._handleMouseWheel(this._customWheelEvent(r)),this.dispatchEvent(TE))}function Q6(r){this.enabled!==!1&&this._handleKeyDown(r)}function W6(r){switch(this._trackPointer(r),this._pointers.length){case 1:switch(this.touches.ONE){case In.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(r),this.state=Xt.TOUCH_ROTATE;break;case In.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(r),this.state=Xt.TOUCH_PAN;break;default:this.state=Xt.NONE}break;case 2:switch(this.touches.TWO){case In.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(r),this.state=Xt.TOUCH_DOLLY_PAN;break;case In.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(r),this.state=Xt.TOUCH_DOLLY_ROTATE;break;default:this.state=Xt.NONE}break;default:this.state=Xt.NONE}this.state!==Xt.NONE&&this.dispatchEvent(uA)}function j6(r){switch(this._trackPointer(r),this.state){case Xt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(r),this.update();break;case Xt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(r),this.update();break;case Xt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(r),this.update();break;case Xt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(r),this.update();break;default:this.state=Xt.NONE}}function q6(r){this.enabled!==!1&&r.preventDefault()}function X6(r){r.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Y6(r){r.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const co=new Ln,on=new T,ea=new T,ci=new Tt,PE={X:new T(1,0,0),Y:new T(0,1,0),Z:new T(0,0,1)},fA={type:"change"},RE={type:"mouseDown",mode:null},DE={type:"mouseUp",mode:null},BE={type:"objectChange"};class LE extends qu{constructor(e,t=null){super(void 0,t);const i=new tU(this);this._root=i;const n=new iU;this._gizmo=n,i.add(n);const s=new nU;this._plane=s,i.add(s);const a=this;function o(b,y){let M=y;Object.defineProperty(a,b,{get:function(){return M!==void 0?M:y},set:function(_){M!==_&&(M=_,s[b]=_,n[b]=_,a.dispatchEvent({type:b+"-changed",value:_}),a.dispatchEvent(fA))}}),a[b]=y,s[b]=y,n[b]=y}o("camera",e),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0),o("minX",-1/0),o("maxX",1/0),o("minY",-1/0),o("maxY",1/0),o("minZ",-1/0),o("maxZ",1/0);const l=new T,c=new T,h=new Tt,d=new Tt,p=new T,u=new Tt,A=new T,m=new T,g=new T,f=0,v=new T;o("worldPosition",l),o("worldPositionStart",c),o("worldQuaternion",h),o("worldQuaternionStart",d),o("cameraPosition",p),o("cameraQuaternion",u),o("pointStart",A),o("pointEnd",m),o("rotationAxis",g),o("rotationAngle",f),o("eye",v),this._offset=new T,this._startNorm=new T,this._endNorm=new T,this._cameraScale=new T,this._parentPosition=new T,this._parentQuaternion=new Tt,this._parentQuaternionInv=new Tt,this._parentScale=new T,this._worldScaleStart=new T,this._worldQuaternionInv=new Tt,this._worldScale=new T,this._positionStart=new T,this._quaternionStart=new Tt,this._scaleStart=new T,this._getPointer=K6.bind(this),this._onPointerDown=J6.bind(this),this._onPointerHover=Z6.bind(this),this._onPointerMove=$6.bind(this),this._onPointerUp=eU.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&co.setFromCamera(e,this.camera);const t=mA(this._gizmo.picker[this.mode],co);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&co.setFromCamera(e,this.camera);const t=mA(this._plane,co,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,RE.mode=this.mode,this.dispatchEvent(RE)}}pointerMove(e){const t=this.axis,i=this.mode,n=this.object;let s=this.space;if(i==="scale"?s="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(s="world"),n===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&co.setFromCamera(e,this.camera);const a=mA(this._plane,co,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),s==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),s==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(s==="local"&&(n.position.applyQuaternion(ci.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),s==="world"&&(n.parent&&n.position.add(on.setFromMatrixPosition(n.parent.matrixWorld)),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(on.setFromMatrixPosition(n.parent.matrixWorld)))),n.position.x=Math.max(this.minX,Math.min(this.maxX,n.position.x)),n.position.y=Math.max(this.minY,Math.min(this.maxY,n.position.y)),n.position.z=Math.max(this.minZ,Math.min(this.maxZ,n.position.z));else if(i==="scale"){if(t.search("XYZ")!==-1){let o=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(o*=-1),ea.set(o,o,o)}else on.copy(this.pointStart),ea.copy(this.pointEnd),on.applyQuaternion(this._worldQuaternionInv),ea.applyQuaternion(this._worldQuaternionInv),ea.divide(on),t.search("X")===-1&&(ea.x=1),t.search("Y")===-1&&(ea.y=1),t.search("Z")===-1&&(ea.z=1);n.scale.copy(this._scaleStart).multiply(ea),this.scaleSnap&&(t.search("X")!==-1&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const o=20/this.worldPosition.distanceTo(on.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(on.copy(this.rotationAxis).cross(this.eye))*o):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(PE[t]),on.copy(PE[t]),s==="local"&&on.applyQuaternion(this.worldQuaternion),on.cross(this.eye),on.length()===0?l=!0:this.rotationAngle=this._offset.dot(on.normalize())*o),(t==="E"||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),s==="local"&&t!=="E"&&t!=="XYZE"?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(ci.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(ci.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(fA),this.dispatchEvent(BE)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(DE.mode=this.mode,this.dispatchEvent(DE)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(fA),this.dispatchEvent(BE),this.pointStart.copy(this.pointEnd))}getRaycaster(){return co}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}setColors(e,t,i,n){const s=this._gizmo.materialLib;s.xAxis.color.set(e),s.yAxis.color.set(t),s.zAxis.color.set(i),s.active.color.set(n),s.xAxisTransparent.color.set(e),s.yAxisTransparent.color.set(t),s.zAxisTransparent.color.set(i),s.activeTransparent.color.set(n),s.xAxis._color&&s.xAxis._color.set(e),s.yAxis._color&&s.yAxis._color.set(t),s.zAxis._color&&s.zAxis._color.set(i),s.active._color&&s.active._color.set(n),s.xAxisTransparent._color&&s.xAxisTransparent._color.set(e),s.yAxisTransparent._color&&s.yAxisTransparent._color.set(t),s.zAxisTransparent._color&&s.zAxisTransparent._color.set(i),s.activeTransparent._color&&s.activeTransparent._color.set(n)}}function K6(r){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:r.button};{const e=this.domElement.getBoundingClientRect();return{x:(r.clientX-e.left)/e.width*2-1,y:-(r.clientY-e.top)/e.height*2+1,button:r.button}}}function Z6(r){if(this.enabled)switch(r.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(r));break}}function J6(r){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(r.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(r)),this.pointerDown(this._getPointer(r)))}function $6(r){this.enabled&&this.pointerMove(this._getPointer(r))}function eU(r){this.enabled&&(this.domElement.releasePointerCapture(r.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(r)))}function mA(r,e,t){const i=e.intersectObject(r,!0);for(let n=0;n<i.length;n++)if(i[n].object.visible||t)return i[n];return!1}const cf=new Di,$t=new T(0,1,0),kE=new T(0,0,0),NE=new Ke,hf=new Tt,df=new Tt,ks=new T,UE=new Ke,Ih=new T(1,0,0),ho=new T(0,1,0),Ph=new T(0,0,1),uf=new T,Rh=new T,Dh=new T;class tU extends Mt{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}}class iU extends Mt{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new Rt({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new si({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const n=t.clone();n.opacity=.5;const s=e.clone();s.color.setHex(16711680);const a=e.clone();a.color.setHex(65280);const o=e.clone();o.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const h=e.clone();h.color.setHex(255),h.opacity=.5;const d=e.clone();d.opacity=.25;const p=e.clone();p.color.setHex(16776960),p.opacity=.25;const u=e.clone();u.color.setHex(16776960);const A=e.clone();A.color.setHex(7895160),this.materialLib={xAxis:s,yAxis:a,zAxis:o,active:u,xAxisTransparent:l,yAxisTransparent:c,zAxisTransparent:h,activeTransparent:p};const m=new Li(0,.04,.1,12);m.translate(0,.05,0);const g=new ri(.08,.08,.08);g.translate(0,.04,0);const f=new ot;f.setAttribute("position",new tt([0,0,0,1,0,0],3));const v=new Li(.0075,.0075,.5,3);v.translate(0,.25,0);function b(F,O){const H=new qs(F,.0075,3,64,O*Math.PI*2);return H.rotateY(Math.PI/2),H.rotateX(Math.PI/2),H}function y(){const F=new ot;return F.setAttribute("position",new tt([0,0,0,1,1,1],3)),F}const M={X:[[new Ge(m,s),[.5,0,0],[0,0,-Math.PI/2]],[new Ge(m,s),[-.5,0,0],[0,0,Math.PI/2]],[new Ge(v,s),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new Ge(m,a),[0,.5,0]],[new Ge(m,a),[0,-.5,0],[Math.PI,0,0]],[new Ge(v,a)]],Z:[[new Ge(m,o),[0,0,.5],[Math.PI/2,0,0]],[new Ge(m,o),[0,0,-.5],[-Math.PI/2,0,0]],[new Ge(v,o),null,[Math.PI/2,0,0]]],XYZ:[[new Ge(new js(.1,0),d),[0,0,0]]],XY:[[new Ge(new ri(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new Ge(new ri(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ge(new ri(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]]},_={X:[[new Ge(new Li(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new Ge(new Li(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Ge(new Li(.2,0,.6,4),i),[0,.3,0]],[new Ge(new Li(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Ge(new Li(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new Ge(new Li(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new Ge(new js(.2,0),i)]],XY:[[new Ge(new ri(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new Ge(new ri(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ge(new ri(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},S={START:[[new Ge(new js(.01,2),n),null,null,null,"helper"]],END:[[new Ge(new js(.01,2),n),null,null,null,"helper"]],DELTA:[[new di(y(),n),null,null,null,"helper"]],X:[[new di(f,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new di(f,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new di(f,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},w={XYZE:[[new Ge(b(.5,1),A),null,[0,Math.PI/2,0]]],X:[[new Ge(b(.5,.5),s)]],Y:[[new Ge(b(.5,.5),a),null,[0,0,-Math.PI/2]]],Z:[[new Ge(b(.5,.5),o),null,[0,Math.PI/2,0]]],E:[[new Ge(b(.75,1),p),null,[0,Math.PI/2,0]]]},E={AXIS:[[new di(f,n),[-1e3,0,0],null,[1e6,1,1],"helper"]]},I={XYZE:[[new Ge(new Br(.25,10,8),i)]],X:[[new Ge(new qs(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new Ge(new qs(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new Ge(new qs(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new Ge(new qs(.75,.1,2,24),i)]]},B={X:[[new Ge(g,s),[.5,0,0],[0,0,-Math.PI/2]],[new Ge(v,s),[0,0,0],[0,0,-Math.PI/2]],[new Ge(g,s),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new Ge(g,a),[0,.5,0]],[new Ge(v,a)],[new Ge(g,a),[0,-.5,0],[0,0,Math.PI]]],Z:[[new Ge(g,o),[0,0,.5],[Math.PI/2,0,0]],[new Ge(v,o),[0,0,0],[Math.PI/2,0,0]],[new Ge(g,o),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new Ge(new ri(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new Ge(new ri(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ge(new ri(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Ge(new ri(.1,.1,.1),d)]]},R={X:[[new Ge(new Li(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new Ge(new Li(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Ge(new Li(.2,0,.6,4),i),[0,.3,0]],[new Ge(new Li(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Ge(new Li(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new Ge(new Li(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new Ge(new ri(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new Ge(new ri(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ge(new ri(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Ge(new ri(.2,.2,.2),i),[0,0,0]]]},U={X:[[new di(f,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new di(f,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new di(f,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function C(F){const O=new Mt;for(const H in F)for(let j=F[H].length;j--;){const G=F[H][j][0].clone(),re=F[H][j][1],q=F[H][j][2],Y=F[H][j][3],ye=F[H][j][4];G.name=H,G.tag=ye,re&&G.position.set(re[0],re[1],re[2]),q&&G.rotation.set(q[0],q[1],q[2]),Y&&G.scale.set(Y[0],Y[1],Y[2]),G.updateMatrix();const Me=G.geometry.clone();Me.applyMatrix4(G.matrix),G.geometry=Me,G.renderOrder=1/0,G.position.set(0,0,0),G.rotation.set(0,0,0),G.scale.set(1,1,1),O.add(G)}return O}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=C(M)),this.add(this.gizmo.rotate=C(w)),this.add(this.gizmo.scale=C(B)),this.add(this.picker.translate=C(_)),this.add(this.picker.rotate=C(I)),this.add(this.picker.scale=C(R)),this.add(this.helper.translate=C(S)),this.add(this.helper.rotate=C(E)),this.add(this.helper.scale=C(U)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const t=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:df;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let n=0;n<i.length;n++){const s=i[n];s.visible=!0,s.rotation.set(0,0,0),s.position.copy(this.worldPosition);let a;if(this.camera.isOrthographicCamera?a=(this.camera.top-this.camera.bottom)/this.camera.zoom:a=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),s.scale.set(1,1,1).multiplyScalar(a*this.size/4),s.tag==="helper"){s.visible=!1,s.name==="AXIS"?(s.visible=!!this.axis,this.axis==="X"&&(ci.setFromEuler(cf.set(0,0,0)),s.quaternion.copy(t).multiply(ci),Math.abs($t.copy(Ih).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),this.axis==="Y"&&(ci.setFromEuler(cf.set(0,0,Math.PI/2)),s.quaternion.copy(t).multiply(ci),Math.abs($t.copy(ho).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),this.axis==="Z"&&(ci.setFromEuler(cf.set(0,Math.PI/2,0)),s.quaternion.copy(t).multiply(ci),Math.abs($t.copy(Ph).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),this.axis==="XYZE"&&(ci.setFromEuler(cf.set(0,Math.PI/2,0)),$t.copy(this.rotationAxis),s.quaternion.setFromRotationMatrix(NE.lookAt(kE,$t,ho)),s.quaternion.multiply(ci),s.visible=this.dragging),this.axis==="E"&&(s.visible=!1)):s.name==="START"?(s.position.copy(this.worldPositionStart),s.visible=this.dragging):s.name==="END"?(s.position.copy(this.worldPosition),s.visible=this.dragging):s.name==="DELTA"?(s.position.copy(this.worldPositionStart),s.quaternion.copy(this.worldQuaternionStart),on.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),on.applyQuaternion(this.worldQuaternionStart.clone().invert()),s.scale.copy(on),s.visible=this.dragging):(s.quaternion.copy(t),this.dragging?s.position.copy(this.worldPositionStart):s.position.copy(this.worldPosition),this.axis&&(s.visible=this.axis.search(s.name)!==-1));continue}s.quaternion.copy(t),this.mode==="translate"||this.mode==="scale"?(s.name==="X"&&Math.abs($t.copy(Ih).applyQuaternion(t).dot(this.eye))>.99&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="Y"&&Math.abs($t.copy(ho).applyQuaternion(t).dot(this.eye))>.99&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="Z"&&Math.abs($t.copy(Ph).applyQuaternion(t).dot(this.eye))>.99&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="XY"&&Math.abs($t.copy(Ph).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="YZ"&&Math.abs($t.copy(Ih).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="XZ"&&Math.abs($t.copy(ho).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1)):this.mode==="rotate"&&(hf.copy(t),$t.copy(this.eye).applyQuaternion(ci.copy(t).invert()),s.name.search("E")!==-1&&s.quaternion.setFromRotationMatrix(NE.lookAt(this.eye,kE,ho)),s.name==="X"&&(ci.setFromAxisAngle(Ih,Math.atan2(-$t.y,$t.z)),ci.multiplyQuaternions(hf,ci),s.quaternion.copy(ci)),s.name==="Y"&&(ci.setFromAxisAngle(ho,Math.atan2($t.x,$t.z)),ci.multiplyQuaternions(hf,ci),s.quaternion.copy(ci)),s.name==="Z"&&(ci.setFromAxisAngle(Ph,Math.atan2($t.y,$t.x)),ci.multiplyQuaternions(hf,ci),s.quaternion.copy(ci))),s.visible=s.visible&&(s.name.indexOf("X")===-1||this.showX),s.visible=s.visible&&(s.name.indexOf("Y")===-1||this.showY),s.visible=s.visible&&(s.name.indexOf("Z")===-1||this.showZ),s.visible=s.visible&&(s.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),s.material._color=s.material._color||s.material.color.clone(),s.material._opacity=s.material._opacity||s.material.opacity,s.material.color.copy(s.material._color),s.material.opacity=s.material._opacity,this.enabled&&this.axis&&(s.name===this.axis?(s.material.color.copy(this.materialLib.active.color),s.material.opacity=1):this.axis.split("").some(function(o){return s.name===o})&&(s.material.color.copy(this.materialLib.active.color),s.material.opacity=1))}super.updateMatrixWorld(e)}}class nU extends Ge{constructor(){super(new jn(1e5,1e5,2,2),new Rt({visible:!1,wireframe:!0,side:Vt,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),uf.copy(Ih).applyQuaternion(t==="local"?this.worldQuaternion:df),Rh.copy(ho).applyQuaternion(t==="local"?this.worldQuaternion:df),Dh.copy(Ph).applyQuaternion(t==="local"?this.worldQuaternion:df),$t.copy(Rh),this.mode){case"translate":case"scale":switch(this.axis){case"X":$t.copy(this.eye).cross(uf),ks.copy(uf).cross($t);break;case"Y":$t.copy(this.eye).cross(Rh),ks.copy(Rh).cross($t);break;case"Z":$t.copy(this.eye).cross(Dh),ks.copy(Dh).cross($t);break;case"XY":ks.copy(Dh);break;case"YZ":ks.copy(uf);break;case"XZ":$t.copy(Dh),ks.copy(Rh);break;case"XYZ":case"E":ks.set(0,0,0);break}break;default:ks.set(0,0,0)}ks.length()===0?this.quaternion.copy(this.cameraQuaternion):(UE.lookAt(on.set(0,0,0),ks,$t),this.quaternion.setFromRotationMatrix(UE)),super.updateMatrixWorld(e)}}class sU extends Db{constructor(e){super(e),this.type=Zt}parse(e){const t=function(g,f){switch(g){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(f||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(f||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(f||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(f||""))}},i=function(g,f,v){f=f||1024;let b=g.pos,y=-1,M=0,_="",S=String.fromCharCode.apply(null,new Uint16Array(g.subarray(b,b+128)));for(;0>(y=S.indexOf(`
|
||
`))&&M<f&&b<g.byteLength;)_+=S,M+=S.length,b+=128,S+=String.fromCharCode.apply(null,new Uint16Array(g.subarray(b,b+128)));return-1<y?(g.pos+=M+y+1,_+S.slice(0,y)):!1},n=function(g){const f=/^#\?(\S+)/,v=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,b=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,y=/^\s*FORMAT=(\S+)\s*$/,M=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,_={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let S,w;for((g.pos>=g.byteLength||!(S=i(g)))&&t(1,"no header found"),(w=S.match(f))||t(3,"bad initial token"),_.valid|=1,_.programtype=w[1],_.string+=S+`
|
||
`;S=i(g),S!==!1;){if(_.string+=S+`
|
||
`,S.charAt(0)==="#"){_.comments+=S+`
|
||
`;continue}if((w=S.match(v))&&(_.gamma=parseFloat(w[1])),(w=S.match(b))&&(_.exposure=parseFloat(w[1])),(w=S.match(y))&&(_.valid|=2,_.format=w[1]),(w=S.match(M))&&(_.valid|=4,_.height=parseInt(w[1],10),_.width=parseInt(w[2],10)),_.valid&2&&_.valid&4)break}return _.valid&2||t(3,"missing format specifier"),_.valid&4||t(3,"missing image size specifier"),_},s=function(g,f,v){const b=f;if(b<8||b>32767||g[0]!==2||g[1]!==2||g[2]&128)return new Uint8Array(g);b!==(g[2]<<8|g[3])&&t(3,"wrong scanline width");const y=new Uint8Array(4*f*v);y.length||t(4,"unable to allocate buffer space");let M=0,_=0;const S=4*b,w=new Uint8Array(4),E=new Uint8Array(S);let I=v;for(;I>0&&_<g.byteLength;){_+4>g.byteLength&&t(1),w[0]=g[_++],w[1]=g[_++],w[2]=g[_++],w[3]=g[_++],(w[0]!=2||w[1]!=2||(w[2]<<8|w[3])!=b)&&t(3,"bad rgbe scanline format");let B=0,R;for(;B<S&&_<g.byteLength;){R=g[_++];const C=R>128;if(C&&(R-=128),(R===0||B+R>S)&&t(3,"bad scanline data"),C){const F=g[_++];for(let O=0;O<R;O++)E[B++]=F}else E.set(g.subarray(_,_+R),B),B+=R,_+=R}const U=b;for(let C=0;C<U;C++){let F=0;y[M]=E[C+F],F+=b,y[M+1]=E[C+F],F+=b,y[M+2]=E[C+F],F+=b,y[M+3]=E[C+F],M+=4}I--}return y},a=function(g,f,v,b){const y=g[f+3],M=Math.pow(2,y-128)/255;v[b+0]=g[f+0]*M,v[b+1]=g[f+1]*M,v[b+2]=g[f+2]*M,v[b+3]=1},o=function(g,f,v,b){const y=g[f+3],M=Math.pow(2,y-128)/255;v[b+0]=wc.toHalfFloat(Math.min(g[f+0]*M,65504)),v[b+1]=wc.toHalfFloat(Math.min(g[f+1]*M,65504)),v[b+2]=wc.toHalfFloat(Math.min(g[f+2]*M,65504)),v[b+3]=wc.toHalfFloat(1)},l=new Uint8Array(e);l.pos=0;const c=n(l),h=c.width,d=c.height,p=s(l.subarray(l.pos),h,d);let u,A,m;switch(this.type){case oi:m=p.length/4;const g=new Float32Array(m*4);for(let v=0;v<m;v++)a(p,v*4,g,v*4);u=g,A=oi;break;case Zt:m=p.length/4;const f=new Uint16Array(m*4);for(let v=0;v<m;v++)o(p,v*4,f,v*4);u=f,A=Zt;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:h,height:d,data:u,header:c.string,gamma:c.gamma,exposure:c.exposure,type:A}}setDataType(e){return this.type=e,this}load(e,t,i,n){function s(a,o){switch(a.type){case oi:case Zt:a.colorSpace=Ri,a.minFilter=_t,a.magFilter=_t,a.generateMipmaps=!1,a.flipY=!0;break}t&&t(a,o)}return super.load(e,s,i,n)}}function rU(){return new ga}function aU(r,e){r.appendChild(e.domElement)}function oU(r,e,t){var i=new Object;i.visible=!0;let n=null,s,a,o=[];i.init=function(){s||(c(),h(),m())},i.Hide=function(){s.style.display="none",i.visible=!1},i.Show=function(){s.style.display="block",i.visible=!0},i.RenderScene=function(){if(!d){i.camera.quaternion.copy(e.camera.quaternion);const v=new T(0,0,1).applyQuaternion(e.camera.quaternion);i.camera.position.copy(v.multiplyScalar(100))}i.orbitControls&&i.orbitControls.update(),i.sceneOrtho.renderer.render(i.sceneOrtho,i.camera)},i.ToggleDirectionView=function(v){var b=new T(0,0,0);v=="top"?b=new T(0,1,1e-5):v=="down"?b=new T(0,-1,1e-5):v=="front"?b=new T(0,0,1):v=="left"?b=new T(-1,0,0):v=="back"?b=new T(0,0,-1):v=="right"?b=new T(1,0,0):v=="top_front"?b=new T(1,1,0):v=="top_left"?b=new T(0,1,-1):v=="top_back"?b=new T(-1,1,0):v=="top_right"?b=new T(0,1,1):v=="down_front"?b=new T(1,-1,0):v=="down_left"?b=new T(0,-1,-1):v=="down_back"?b=new T(-1,-1,0):v=="down_right"?b=new T(0,-1,1):v=="front_right"?b=new T(1,0,1):v=="right_back"?b=new T(-1,0,1):v=="back_left"?b=new T(-1,0,-1):v=="left_front"?b=new T(1,0,-1):v=="top_left_front"?b=new T(1,1,-1):v=="top_front_right"?b=new T(1,1,1):v=="top_right_back"?b=new T(-1,1,1):v=="top_back_left"?b=new T(-1,1,-1):v=="button_left_front"?b=new T(1,-1,-1):v=="button_front_right"?b=new T(1,-1,1):v=="button_right_back"?b=new T(-1,1,1):v=="button_back_left"&&(b=new T(-1,-1,-1));var y=r.octreeBox.getBoundingBox(),M=y.min,_=y.max,S=M.clone().add(_.clone()).multiplyScalar(.5),w=S.clone().add(b.multiplyScalar(1*_.distanceTo(M)));l(e.camera.position,w,r.controls.target.clone(),S)},i.GetCameraPose=function(){var v=e.camera.quaternion,b=e.camera.position,y=r.controls.target,M={quaternion:v,position:b,target:y};return M},i.ReductionCameraPose=function(v,b=1e3,y){var M=new Tt(v.quaternion._x,v.quaternion._y,v.quaternion._z,v.quaternion._w),_=new T(v.position.x,v.position.y,v.position.z),S=new T(v.target.x,v.target.y,v.target.z);let w=!1;l(e.camera.position,_,r.controls.target.clone(),S,e.camera.quaternion,M,b,E=>{y&&(w||(y(E),w=!0))}),y&&setTimeout(()=>{w||(y(!0),w=!0)},b+10)},i.CameraGoHome=function(v=1e3){var b=r.octreeBox.getBoundingBox(),y=b.min.clone().add(b.max.clone()).multiplyScalar(.5);let M=new T(1,1,1);var _=b.max.distanceTo(b.min),S=y.clone().add(M.multiplyScalar(_*2));if(r.camera.far=_*5,e.camera.isOrthographicCamera){var w=r.container.clientWidth/r.container.clientHeight,E=_*.6;e.camera.left=-E*w,e.camera.right=E*w,e.camera.top=E,e.camera.bottom=-E,e.camera.zoom=1,e.camera.updateProjectionMatrix()}r.controlModule.orbitControls.origin=y.clone(),l(e.camera.position,S,r.controls.target.clone(),y,null,null,v)},i.zoomToBox=function(v){if(e.camera.isOrthographicCamera){let J=function(){n=requestAnimationFrame(J),xe.update()};var b=v.min.clone().add(v.max.clone()).multiplyScalar(.5),y=e.camera.position.clone().sub(r.controls.target.clone()).normalize(),M=e.camera.position.distanceTo(r.controls.target),_=b.clone().add(y.multiplyScalar(M)),S=e.camera.zoom,w=new T(1,0,0).applyQuaternion(e.camera.quaternion),E=new T(0,1,0).applyQuaternion(e.camera.quaternion),I=[new T(v.min.x,v.min.y,v.min.z),new T(v.max.x,v.min.y,v.min.z),new T(v.min.x,v.max.y,v.min.z),new T(v.max.x,v.max.y,v.min.z),new T(v.min.x,v.min.y,v.max.z),new T(v.max.x,v.min.y,v.max.z),new T(v.min.x,v.max.y,v.max.z),new T(v.max.x,v.max.y,v.max.z)],B=1/0,R=-1/0,U=1/0,C=-1/0;for(var F of I){var O=F.dot(w),H=F.dot(E);B=Math.min(B,O),R=Math.max(R,O),U=Math.min(U,H),C=Math.max(C,H)}var j=(R-B)/2,G=(C-U)/2,re=(e.camera.right-e.camera.left)/2,q=(e.camera.top-e.camera.bottom)/2;S=Math.min(re/j,q/G)*.75;var Y=e.camera.position.clone(),ye=r.controls.target.clone(),Me=e.camera.zoom,xe=new Th.Tween({x1:Y.x,y1:Y.y,z1:Y.z,x2:ye.x,y2:ye.y,z2:ye.z,zoom:Me}).to({x1:_.x,y1:_.y,z1:_.z,x2:b.x,y2:b.y,z2:b.z,zoom:S},1e3);xe.onUpdate(function(oe){r.controls&&(e.camera.position.set(oe.x1,oe.y1,oe.z1),r.controls.target.set(oe.x2,oe.y2,oe.z2),e.camera.isOrthographicCamera&&(e.camera.zoom=oe.zoom,e.camera.updateProjectionMatrix()),r.controls.auto=!0,r.controls.update(),i.RenderScene())}),xe.onComplete(function(){r.controls&&(r.controls.auto=!1,i.RenderScene(),cancelAnimationFrame(n),n=null)}),xe.easing(Th.Easing.Cubic.InOut),xe.start(),J()}else{var b=v.min.clone().add(v.max.clone()).multiplyScalar(.5);let oe=e.camera.position.clone().sub(r.controls.target.clone()).normalize();var _=b.clone().add(oe.multiplyScalar(2*v.max.distanceTo(v.min)));l(e.camera.position,_,r.controls.target.clone(),b)}};function l(v,b,y,M,_,S,w=1e3,E){var I;_&&S?(I=new Th.Tween({x1:v.x,y1:v.y,z1:v.z,x2:y.x,y2:y.y,z2:y.z,_x:_._x,_y:_._y,_z:_._z,_w:_._w}),I.to({x1:b.x,y1:b.y,z1:b.z,x2:M.x,y2:M.y,z2:M.z,_x:S._x,_y:S._y,_z:S._z,_w:S._w},w)):(I=new Th.Tween({x1:v.x,y1:v.y,z1:v.z,x2:y.x,y2:y.y,z2:y.z}),I.to({x1:b.x,y1:b.y,z1:b.z,x2:M.x,y2:M.y,z2:M.z},w)),I.onUpdate(function(R){r.controls&&(_&&S?(e.camera.quaternion._x=R._x,e.camera.quaternion._y=R._y,e.camera.quaternion._z=R._z,e.camera.quaternion._w=R._w):r.controls.auto=!0,e.camera.position.x=R.x1,e.camera.position.y=R.y1,e.camera.position.z=R.z1,r.controls.target.x=R.x2,r.controls.target.y=R.y2,r.controls.target.z=R.z2,r.controls.update(),i.RenderScene())}),I.onComplete(function(R){r.controls&&(r.controls.auto=!1,i.RenderScene(),E&&E(!0),cancelAnimationFrame(n),n=null)}),I.easing(Th.Easing.Cubic.InOut);function B(R){n=requestAnimationFrame(B),I.update()}I.start(),B()}function c(){s=document.createElement("div"),s.className="ViewCube",t.appendChild(s),a=document.createElement("div"),a.className="viewSettingWrapper",a.innerHTML="...",s.appendChild(a);var v=document.createElement("div");v.className="homeViewWrapper",v.addEventListener("mousedown",function(){console.log("归位"),i.CameraGoHome()}),s.appendChild(v);const b=document.createElement("div");b.className="cameraToggleWrapper",b.title="切换正交/透视视图",b.innerHTML="⊞",b.addEventListener("mousedown",function(w){w.stopPropagation(),console.log("切换视图"),i.ToggleCameraType(),_()}),s.appendChild(b);const y=document.createElement("div");y.className="screenshotWrapper",y.title="截图",y.innerHTML="📷",y.addEventListener("mousedown",function(w){w.stopPropagation(),console.log("截图"),i.TakeScreenshot(),_()}),s.appendChild(y);const M=document.createElement("div");M.className="fullscreenWrapper",M.title="全屏",M.innerHTML="⛶",M.addEventListener("mousedown",function(w){w.stopPropagation(),console.log("全屏"),i.ToggleFullscreen(),_()}),s.appendChild(M),a.addEventListener("mousedown",function(w){w.stopPropagation(),b.classList.contains("show")?(_(),console.log("隐藏功能按钮")):(S(),console.log("显示功能按钮"))});function _(){b.classList.remove("show"),y.classList.remove("show"),M.classList.remove("show")}function S(){b.classList.add("show"),y.classList.add("show"),M.classList.add("show")}}function h(){i.sceneOrtho=rU();var y=t.clientWidth,M=t.clientWidth,v=y>M?y/M:M/y,b=300;i.camera=new Ki(b*v/-2,b*v/2,b/2,b/-2,.01,1e4);var y=s.clientWidth,M=s.clientHeight,_=new $c({alpha:!0});_.setSize(y,M),_.setClearAlpha(0),i.sceneOrtho.renderer=_;let S=new il(16777215,.8);i.sceneOrtho.add(S),aU(s,_),i.orbitControls=new U6(i.camera,s),i.orbitControls.enableZoom=!1,i.orbitControls.enablePan=!1,i.orbitControls.enableDamping=!0,i.orbitControls.dampingFactor=.1,i.orbitControls.rotateSpeed=.5,i.orbitControls.addEventListener("start",p),i.orbitControls.addEventListener("change",u),i.orbitControls.addEventListener("end",A)}let d=!1;function p(){d=!0,r.controls&&(i._mainTarget=r.controls.target.clone(),i._mainDistance=e.camera.position.distanceTo(r.controls.target))}function u(){if(d){if(e.camera.quaternion.copy(i.camera.quaternion),r.controls&&i._mainTarget&&i._mainDistance){const v=new T(0,0,1).applyQuaternion(e.camera.quaternion);e.camera.position.copy(i._mainTarget.clone().add(v.multiplyScalar(i._mainDistance))),r.controls.update()}r.renderer&&e.camera&&r.renderer.render(e,e.camera)}}function A(){d=!1,i._mainTarget=null,i._mainDistance=null}function m(){const v="/assets/viewcube/";let b=[{label:"右",icon:v+"cn_right.png"},{label:"左",icon:v+"cn_left.png"},{label:"顶",icon:v+"cn_top.png"},{label:"底",icon:v+"cn_bottom.png"},{label:"前",icon:v+"cn_front.png"},{label:"后",icon:v+"cn_back.png"}];var y=[];for(const S of b)y.push(new Rt({color:16777215,map:new Da().load(S.icon)}));new Mm({color:255});var M=new Ge(new ri(110,110,110),y);i.sceneOrtho.add(M),g(122);let _={x:0,y:0};s.addEventListener("mousedown",S=>{_.x=S.clientX,_.y=S.clientY}),s.addEventListener("mouseup",S=>{if(d)return;const w=S.clientX-_.x,E=S.clientY-_.y;if(Math.sqrt(w*w+E*E)>5)return;var I={};I.x=S.offsetX/s.clientWidth*2-1,I.y=-(S.offsetY/s.clientHeight)*2+1;var B=new Ln;B.setFromCamera(I,i.camera);const R=B.intersectObjects(o,!1);R.length>0&&i.ToggleDirectionView(R[0].object.name)}),s.addEventListener("mousemove",S=>{var w={};w.x=S.offsetX/s.clientWidth*2-1,w.y=-(S.offsetY/s.clientHeight)*2+1;var E=new Ln;E.setFromCamera(w,i.camera);const I=E.intersectObjects(o,!1);for(var B of o)B.material.opacity=.01;I.length>0&&(I[0].object.material.opacity=.2)})}function g(v){for(var b=v*.5-20,y=[{name:"right",a:30,b:75,c:75,point:new T(b,0,0)},{name:"back",a:75,b:75,c:30,point:new T(0,0,-b)},{name:"left",a:30,b:75,c:75,point:new T(-b,0,0)},{name:"front",a:75,b:75,c:30,point:new T(0,0,b)},{name:"top",a:75,b:30,c:75,point:new T(0,b,0)},{name:"button",a:75,b:30,c:75,point:new T(0,-b,0)}],M=[{name:"top_right_back",a:30,b:30,c:30,point:new T(-b,b,b)},{name:"button_front_right",a:30,b:30,c:30,point:new T(-b,-b,b)},{name:"top_front_right",a:30,b:30,c:30,point:new T(b,b,b)},{name:"button_right_back",a:30,b:30,c:30,point:new T(b,-b,b)},{name:"top_back_left",a:30,b:30,c:30,point:new T(-b,b,-b)},{name:"button_back_left",a:30,b:30,c:30,point:new T(-b,-b,-b)},{name:"top_left_front",a:30,b:30,c:30,point:new T(b,b,-b)},{name:"button_left_front",a:30,b:30,c:30,point:new T(b,-b,-b)}],_=[{name:"top_front",a:30,b:30,c:75,point:new T(b,b,0)},{name:"top_right",a:75,b:30,c:30,point:new T(0,b,b)},{name:"top_back",a:30,b:30,c:75,point:new T(-b,b,0)},{name:"top_left",a:75,b:30,c:30,point:new T(0,b,-b)},{name:"button_front",a:30,b:30,c:75,point:new T(b,-b,0)},{name:"button_right",a:75,b:30,c:30,point:new T(0,-b,b)},{name:"button_back",a:30,b:30,c:75,point:new T(-b,-b,0)},{name:"button_left",a:75,b:30,c:30,point:new T(0,-b,-b)},{name:"front_right",a:30,b:75,c:30,point:new T(b,0,b)},{name:"right_back",a:30,b:75,c:30,point:new T(-b,0,b)},{name:"back_left",a:30,b:75,c:30,point:new T(-b,0,-b)},{name:"left_front",a:30,b:75,c:30,point:new T(b,0,-b)}],S=0;S<y.length;S++)o.push(f(y[S]));for(var S=0;S<M.length;S++)o.push(f(M[S]));for(var S=0;S<_.length;S++)o.push(f(_[S]))}function f(v){const b=new ri(v.a,v.b,v.c),y=new Rt({color:"blue",transparent:!0,opacity:.01}),M=new Ke().makeTranslation(v.point.x,v.point.y,v.point.z);let _=b.applyMatrix4(M),S=new Ge(_,y);return S.name=v.name,i.sceneOrtho.add(S),S}return i.ToggleCameraType=function(){r.cameraModule.switchCurrentCamera()},i.TakeScreenshot=function(){try{if(!r.renderer){console.error("渲染器未初始化");return}r.renderer.render(e,e.camera);const v=r.renderer.domElement.toDataURL("image/png"),b=document.createElement("a"),y=new Date().toISOString().replaceAll(/[:.]/g,"-");b.download=`screenshot_${y}.png`,b.href=v,b.click(),console.log("截图已保存")}catch(v){console.error("截图失败:",v)}},i.ToggleFullscreen=function(){const v=t||document.documentElement;!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.mozFullScreenElement&&!document.msFullscreenElement?(v.requestFullscreen?v.requestFullscreen():v.webkitRequestFullscreen?v.webkitRequestFullscreen():v.mozRequestFullScreen?v.mozRequestFullScreen():v.msRequestFullscreen&&v.msRequestFullscreen(),console.log("已进入全屏模式")):(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),console.log("已退出全屏模式"))},i}class lU{engine;cubeTool;constructor(e){this.engine=e}init(){this.cubeTool=oU(this.engine,this.engine.scene,this.engine.container),this.cubeTool.init()}CameraGoHome(e){this.cubeTool.CameraGoHome(e)}zoomToModel(e){this.cubeTool.zoomToBox(e)}zoomToModels(e){try{let t=this.engine.models.find(i=>i.url==e.url);this.cubeTool.zoomToBox(t.nodesMap.get(e.id).infos[0].box)}catch{}}hide(){}}function cU(r){let e=new Object;return e.getBoundingBox=function(){let t=r.models,i=new T(1e8,1e9,1e10),n=new T(-1e8,-1e9,-1e10);t.forEach(d=>{let p=new T(Math.min(d.boundingBox.min.x,d.boundingBox.max.x),Math.min(d.boundingBox.min.y,d.boundingBox.max.y),Math.min(d.boundingBox.min.z,d.boundingBox.max.z)),u=new T(Math.max(d.boundingBox.min.x,d.boundingBox.max.x),Math.max(d.boundingBox.min.y,d.boundingBox.max.y),Math.max(d.boundingBox.min.z,d.boundingBox.max.z));p.x<i.x&&(i.x=p.x),p.y<i.y&&(i.y=p.y),p.z<i.z&&(i.z=p.z),u.x>n.x&&(n.x=u.x),u.y>n.y&&(n.y=u.y),u.z>n.z&&(n.z=u.z)});let s=Math.min(i.x,n.x),a=Math.min(i.y,n.y),o=Math.min(i.z,n.z),l=Math.max(i.x,n.x),c=Math.max(i.y,n.y),h=Math.max(i.z,n.z);return{min:new T(s,a,o),max:new T(l,c,h)}},e.rayInterationModel=function(t,i){let n=[];return r.engineStatus.models.forEach(a=>{a.info.lods.forEach(o=>{let l=o.octreeBox;s(t,l,a)})}),n=n.filter(a=>a instanceof Ge),n=n.filter(a=>t.ray.intersectsBox(new Ft().setFromObject(a),!1)==!0),t.intersectObjects(n,!1);function s(a,o,l){if(o==null)return;let c=new T(o.min.X*.3048,o.min.Z*.3048,-o.min.Y*.3048),h=new T(o.max.X*.3048,o.max.Z*.3048,-o.max.Y*.3048),d=new T(Math.min(c.x,h.x),Math.min(c.y,h.y),Math.min(c.z,h.z)),p=new T(Math.max(h.x,c.x),Math.max(h.y,c.y),Math.max(h.z,c.z)),u=new Ft(d,p),A=a.ray.intersectsBox(u);if(!(A==null||A==!1))if(o.children==null||o.children.length==0){if(o.elements!=null)for(var m of o.elements){if(!r.engineStatus.isFree&&i==!1)continue;let g=r.engineStatus.hideModels.find(b=>b.url==l.url)?.ids;if(g!=null&&g.includes(m))continue;let f=r.engineStatus.translucentModels.find(b=>b.url==l.url)?.ids;if(f!=null&&f.includes(m))continue;let v=r.models.find(b=>b.url==l.url).nodesMap.get(m);v!=null&&!v.instance&&v.infos!=null&&v.infos.map(b=>b.mesh).forEach(b=>{n.push(b)})}}else{if(o.elements!=null)for(var m of o.elements){let f=r.engineStatus.hideModels.find(y=>y.url==l.url)?.ids;if(f!=null&&f.includes(m))continue;let v=r.engineStatus.translucentModels.find(y=>y.url==l.url)?.ids;if(v!=null&&v.includes(m))continue;let b=r.models.find(y=>y.url==l.url).nodesMap.get(m);b!=null&&!b.instance&&b.infos!=null&&b.infos.map(y=>y.mesh).forEach(y=>{n.push(y)})}for(let g of o.children)s(a,g,l)}}},e}class hU{engine;isDrawing=!1;startPoint=new be;endPoint=new be;selectionBox=null;worldToScreen=null;boundMouseDown;boundMouseMove;boundMouseUp;boundKeyDown;constructor(e){this.engine=e,this.boundMouseDown=this.onMouseDown.bind(this),this.boundMouseMove=this.onMouseMove.bind(this),this.boundMouseUp=this.onMouseUp.bind(this),this.boundKeyDown=this.onKeyDown.bind(this)}init(){this.createSelectionBoxElement(),this.engine.scene&&this.engine.camera&&this.engine.renderer&&(this.worldToScreen=new zt(this.engine.camera,this.engine.renderer,this.engine.scene))}active(){this.engine.controlModule.disActive();const e=this.engine.renderer?.domElement;e&&(e.addEventListener("mousedown",this.boundMouseDown),e.addEventListener("mousemove",this.boundMouseMove),e.addEventListener("mouseup",this.boundMouseUp),e.style.cursor="crosshair"),window.addEventListener("keydown",this.boundKeyDown)}disActive(){this.engine.controlModule.active();const e=this.engine.renderer?.domElement;e&&(e.removeEventListener("mousedown",this.boundMouseDown),e.removeEventListener("mousemove",this.boundMouseMove),e.removeEventListener("mouseup",this.boundMouseUp),e.style.cursor="default"),window.removeEventListener("keydown",this.boundKeyDown),this.isDrawing&&this.endDrawing()}createSelectionBoxElement(){this.selectionBox=document.createElement("div"),this.selectionBox.style.position="absolute",this.selectionBox.style.border="2px dashed #00aaff",this.selectionBox.style.backgroundColor="rgba(0, 170, 255, 0.1)",this.selectionBox.style.pointerEvents="none",this.selectionBox.style.display="none",this.selectionBox.style.zIndex="1000",this.selectionBox.style.boxSizing="border-box";const e=this.engine.renderer?.domElement;e&&e.parentElement&&e.parentElement.appendChild(this.selectionBox)}onMouseDown(e){e.button!==0||!this.engine.renderer?.domElement||(this.startPoint.set(e.offsetX,e.offsetY),this.endPoint.copy(this.startPoint),this.isDrawing=!0,this.selectionBox&&(this.selectionBox.style.display="block",this.updateSelectionBoxUI()),e.preventDefault(),e.stopPropagation())}onMouseMove(e){!this.isDrawing||!this.engine.renderer?.domElement||(this.endPoint.set(e.offsetX,e.offsetY),this.updateSelectionBoxUI(),e.preventDefault(),e.stopPropagation())}onMouseUp(e){this.isDrawing&&(this.endDrawing(),this.performZoom(),e.preventDefault(),e.stopPropagation(),this.disActive())}onKeyDown(e){e.key==="Escape"&&(this.disActive(),e.preventDefault(),e.stopPropagation())}endDrawing(){this.isDrawing&&(this.isDrawing=!1,this.selectionBox&&(this.selectionBox.style.display="none"))}updateSelectionBoxUI(){if(!this.selectionBox||!this.engine.renderer?.domElement)return;const e=Math.min(this.startPoint.x,this.endPoint.x),t=Math.min(this.startPoint.y,this.endPoint.y),i=Math.abs(this.endPoint.x-this.startPoint.x),n=Math.abs(this.endPoint.y-this.startPoint.y);this.selectionBox.style.left=`${e}px`,this.selectionBox.style.top=`${t}px`,this.selectionBox.style.width=`${i}px`,this.selectionBox.style.height=`${n}px`}performZoom(){const e=Math.abs(this.endPoint.x-this.startPoint.x),t=Math.abs(this.endPoint.y-this.startPoint.y);if(e<5||t<5)return;if(!this.worldToScreen){console.warn("RangeScale: 坐标转换工具未初始化");return}const i=Math.min(this.startPoint.x,this.endPoint.x),n=Math.max(this.startPoint.x,this.endPoint.x),s=Math.min(this.startPoint.y,this.endPoint.y),a=Math.max(this.startPoint.y,this.endPoint.y),o=[],l=[{x:i,y:s},{x:n,y:s},{x:n,y:a},{x:i,y:a}];for(const h of l){const d=this.worldToScreen.screenToWorld(h.x,h.y);d&&o.push(d)}if(o.length<3){console.warn("RangeScale: 框选区域未命中模型,无法执行缩放操作");return}if(o.length<3){console.warn("RangeScale: 无法将屏幕区域转换为世界坐标");return}const c=new Ft;for(const h of o)c.expandByPoint(h);if(c.isEmpty()){console.warn("RangeScale: 计算得到的包围盒无效");return}this.fitCameraToBoundingBox(c)}fitCameraToBoundingBox(e){const t=this.engine.camera,i=this.engine.controls;if(!t||!i){console.warn("RangeScale: 相机或控制器未初始化");return}const n=new T;e.getCenter(n);const s=new T;e.getSize(s);const a=Math.max(s.x,s.y,s.z);if(t instanceof pi){const o=t.fov*(Math.PI/180),l=a/(2*Math.tan(o/2))*1.2,c=new T;t.getWorldDirection(c);const h=n.clone().sub(t.position);c.dot(h.normalize())<0&&c.negate();const d=n.clone().sub(c.multiplyScalar(l));t.position.copy(d),i.target&&i.target.copy(n),t.lookAt(n),i.update()}else if(t instanceof Ki){const o=a*1.2,l=this.engine.renderer?.domElement,c=l?l.width/l.height:1;t.left=-o*c/2,t.right=o*c/2,t.top=o/2,t.bottom=-o/2,t.updateProjectionMatrix();const h=new T;t.getWorldDirection(h);const d=a*1.5,p=n.clone().sub(h.multiplyScalar(d));t.position.copy(p),i.target&&i.target.copy(n),t.lookAt(n),i.update()}}}const FE={render:{mode:"advanced",contrast:50,saturation:50,shadowIntensity:50,lightIntensity:50,gtaoIntensity:50},display:{showEdge:!1,edgeOpacity:30,showGrid:!1,showLevel:!1,showGround:!1,groundId:"0",groundHeight:0},environment:{type:"none",hdrId:"0",hdrIntensity:20,skyPreset:"sunrise_clear",skyParams:{},skyIntensity:20}};class dU{engine;settings;environmentApplyVersion=0;constructor(e){this.engine=e,this.settings=this._clone(FE)}init(){}getSettings(){return this._clone(this.settings)}getPresetLists(){const e=this.engine.ground?.getGroundList()||[],t=this.engine.hdr?.getHdrList()||[],i=this.engine.skyManager?.getPresetList()||[];return{ground:e.map(n=>this._toPresetItem(n)),hdr:t.map(n=>this._toPresetItem(n)),sky:i.map(n=>this._toPresetItem(n))}}async setSettings(e){e.render&&(Object.assign(this.settings.render,e.render),this._applyRenderSettings(this.settings.render)),e.display&&(Object.assign(this.settings.display,e.display),this._applyDisplaySettings(this.settings.display)),e.environment&&(this._mergeEnvironmentSettings(e.environment),await this._applyEnvironmentSettings(this._clone(this.settings.environment)))}async resetToDefault(){this.settings=this._clone(FE),this._applyRenderSettings(this.settings.render),this._applyDisplaySettings(this.settings.display),await this._applyEnvironmentSettings(this._clone(this.settings.environment))}setRenderMode(e){this.settings.render.mode=e,this.engine.engineModelModule?.switchModel(e)}setContrast(e){this.settings.render.contrast=e,this.engine.engineModelModule?.setContrastValue(.5+e/100)}setSaturation(e){this.settings.render.saturation=e,this.engine.engineModelModule?.setSaturationValue(.5+e/100)}setShadowIntensity(e){this.settings.render.shadowIntensity=e,this._updateDirectionalLight(t=>{t.shadow.intensity=e/100*2})}setLightIntensity(e){this.settings.render.lightIntensity=e,this.setAmbientLightIntensity(e/100)}setGTAOIntensity(e){this.settings.render.gtaoIntensity=e,this.engine.engineModelModule?.setGTAOIntensity(e/100)}setShowEdge(e){this.settings.display.showEdge=e,e?this.engine.modelEdge?.active():this.engine.modelEdge?.disActive()}setEdgeOpacity(e){this.settings.display.edgeOpacity=e,this.engine.modelEdge?.setOpacity(e/100)}setShowGrid(e){this.settings.display.showGrid=e,e?this.engine.grid?.show():this.engine.grid?.hide()}setShowLevel(e){this.settings.display.showLevel=e,e?this.engine.level?.show():this.engine.level?.hide()}setShowGround(e){this.settings.display.showGround=e,e?this.engine.ground?.show():this.engine.ground?.hide()}setGroundId(e){this.settings.display.groundId=e,this.engine.ground?.setGround(e)}setGroundHeight(e){this.settings.display.groundHeight=e,this.engine.ground?.setHeight(e)}async setEnvironmentType(e){this.settings.environment.type=e,await this._applyEnvironmentSettings(this._clone(this.settings.environment))}async setHdrId(e){this.settings.environment.hdrId=e,this.settings.environment.type==="hdr"&&await this._applyEnvironmentSettings(this._clone(this.settings.environment))}setHdrIntensity(e){this.settings.environment.hdrIntensity=e,this.settings.environment.type==="hdr"&&this.engine.hdr?.setIntensity(e/100)}setSkyPreset(e){this.settings.environment.skyPreset=e,this.settings.environment.skyParams={},this.settings.environment.type==="sky"&&this.engine.skyManager?.setPreset(e)}setSkyParams(e){this.settings.environment.skyParams=this._clone(e),this.settings.environment.type==="sky"&&this.engine.skyManager?.setParams(this.settings.environment.skyParams)}setSkyIntensity(e){this.settings.environment.skyIntensity=e,this.settings.environment.type==="sky"&&this.engine.skyManager?.setIntensity(e/100)}setAmbientLightIntensity(e){const t=this.engine.scene?.children.find(i=>i instanceof il);t&&(t.intensity=e)}_applyRenderSettings(e){this.setRenderMode(e.mode),this.setContrast(e.contrast),this.setSaturation(e.saturation),this.setShadowIntensity(e.shadowIntensity),this.setLightIntensity(e.lightIntensity),this.setGTAOIntensity(e.gtaoIntensity)}_applyDisplaySettings(e){this.setShowEdge(e.showEdge),this.setEdgeOpacity(e.edgeOpacity),this.setShowGrid(e.showGrid),this.setShowLevel(e.showLevel),this.setShowGround(e.showGround),this.setGroundId(e.groundId),this.setGroundHeight(e.groundHeight)}async _applyEnvironmentSettings(e){const t=++this.environmentApplyVersion;if(await this.engine.hdr?.setHdr("0"),t===this.environmentApplyVersion&&(this.engine.skyManager?.close(!0),t===this.environmentApplyVersion))switch(e.type){case"none":break;case"hdr":if(e.hdrId!=="0"){if(await this.engine.hdr?.setHdr(e.hdrId),t!==this.environmentApplyVersion){this._applyEnvironmentSettings(this._clone(this.settings.environment));return}this.engine.hdr?.setIntensity(e.hdrIntensity/100)}break;case"sky":this.engine.skyManager?.activate(),this.engine.skyManager?.setPreset(e.skyPreset),Object.keys(e.skyParams).length>0&&this.engine.skyManager?.setParams(this._clone(e.skyParams)),this.engine.skyManager?.setIntensity(e.skyIntensity/100);break}}_updateDirectionalLight(e){const t=this.engine.scene?.children.find(i=>i instanceof Nr);t&&e(t)}_mergeEnvironmentSettings(e){Object.assign(this.settings.environment,e),e.skyPreset!==void 0&&e.skyParams===void 0&&(this.settings.environment.skyParams={}),e.skyParams!==void 0&&(this.settings.environment.skyParams=this._clone(e.skyParams))}_toPresetItem(e){const t=Array.isArray(e.names)?[...e.names]:[];return{id:e.id,name:t[0]??e.id,names:t}}_clone(e){return JSON.parse(JSON.stringify(e))}}function ur(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){var e=Math.random()*16|0,t=r=="x"?e:e&3|8;return t.toString(16)})}class pr{engine;handelBehaved;setting;constructor(e){this.engine=e,this.handelBehaved=k0(e),this.handelBehaved.init(this,null),this.setting={unit:"m",precision:3}}getSetting(){return this.setting}saveSetting(e){this.setting=e}active(){this.handelBehaved.active()}disActive(){this.handelBehaved.disActive()}getMeasureText(e,t){if(e==null)return null;let i=this.setting.unit,n=i;return t==1?i=="mm"?e=e*1e3:i=="cm"?e=e*100:i=="dm"?e=e*10:i=="m"?e=e*1:i=="km"&&(e=e*.001):t==2&&(i=="mm"?e=e*1e3*1e3:i=="cm"?e=e*100*100:i=="dm"?e=e*10*10:i=="m"?e=e*1*1:i=="km"&&(e=e*.001*.001),n=n+"²"),e.toFixed(this.setting.precision)+" "+n}cancelCurrentSelectedAnnotation(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(i=>{i.highlight==!0&&(i.highlight=!1,i.container.classList.remove("Hight"),i.container.getElementsByTagName("svg")[0].classList.remove("Hight"))})}handelKeyEscDown(){this.cancelCurrentSelectedAnnotation();let e=this.engine.measure.annotationData;for(let t in e)for(let i=e[t].length-1;i>=0;i--){let n=e[t][i];n.isSelect==!0&&(n.container.remove(),e[t].splice(i,1))}this.engine.measure.clearAllPoints()}handelKeyDeleteDown(){let e=this.engine.measure.annotationData;for(let t in e)for(let i=e[t].length-1;i>=0;i--){let n=e[t][i];n.highlight==!0&&(n.container.remove(),e[t].splice(i,1))}}clearHighlight(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(i=>{i.highlight=!1,i.container.classList.remove("Hight"),i.container.getElementsByTagName("svg")[0].classList.remove("Hight")})}drawNormalAnnotation(){let e=this;this.engine.measure.annotationData.normalAnnotation.forEach(l=>{o(l)}),this.engine.measure.annotationData.elevationAnnotation.forEach(l=>{a(l)}),this.engine.measure.annotationData.coordinateAnnotation.forEach(l=>{s(l)}),this.engine.measure.annotationData.angleAnnotation.forEach(l=>{t(l)}),this.engine.measure.annotationData.areaAnnotation.forEach(l=>{i(l)}),this.engine.measure.annotationData.slopeAnnotation.forEach(l=>{n(l)});function t(l){if(l.container==null){let f=['<svg class="measureSvg">','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline class="measureLine" stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<polyline class="measureLine" stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+l.text+"</text>","</svg>"].join("");l.container=document.createElement("div"),l.container.className="angle-annotation",l.container.id=l.id,l.container.style.pointerEvents="none",l.container.innerHTML=f,e.engine.measure.annotationContainer.appendChild(l.container),l.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0,e.engine.events.trigger(Ai.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}let c=new zt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point1),h=new zt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point2),d=new zt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point3),p=e.engine.reactBoundingClientRect.left,u=e.engine.reactBoundingClientRect.top;c.x+=p,c.y+=u,h.x+=p,h.y+=u,d.x+=p,d.y+=u;let A=l.container;A.getElementsByTagName("circle")[0].setAttribute("cx",c.x),A.getElementsByTagName("circle")[0].setAttribute("cy",c.y),A.getElementsByTagName("circle")[1].setAttribute("cx",h.x),A.getElementsByTagName("circle")[1].setAttribute("cy",h.y),A.getElementsByTagName("circle")[2].setAttribute("cx",d.x),A.getElementsByTagName("circle")[2].setAttribute("cy",d.y),A.getElementsByTagName("polyline")[0].setAttribute("points",c.x+","+c.y+" "+h.x+","+h.y),A.getElementsByTagName("polyline")[1].setAttribute("points",h.x+","+h.y+" "+d.x+","+d.y);let m=h.x,g=h.y-30;A.getElementsByTagName("rect")[0].setAttribute("x",m-40),A.getElementsByTagName("rect")[0].setAttribute("y",g-12.5),A.getElementsByTagName("text")[0].setAttribute("x",m),A.getElementsByTagName("text")[0].setAttribute("y",g+4),A.getElementsByTagName("text")[0].innerHTML=l.text,A.style.top="0px",A.style.left="0px"}function i(l){if(l.container==null){let v=['<svg class="measureSvg">','<polygon fill="rgba(0, 0, 255, 0.1)" stroke="orange" stroke-width="2" points="" style="opacity: 0.3;"/>','<polyline class="measureLine" stroke="orange" stroke-width="2" points="" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(l.text,2)+"</text>","</svg>"].join("");l.container=document.createElement("div"),l.container.className="area-annotation",l.container.id=l.id,l.container.innerHTML=v,e.engine.measure.annotationContainer.appendChild(l.container),l.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0,e.engine.events.trigger(Ai.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}if(!l.points||l.points.length<3)return;let c=e.engine.reactBoundingClientRect.left,h=e.engine.reactBoundingClientRect.top,d=[],p=0,u=0;for(let v=0;v<l.points.length;v++){let b=new zt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.points[v]);b.x+=c,b.y+=h,d.push(b),p+=b.x,u+=b.y}p=p/d.length,u=u/d.length;let A=d.map(v=>v.x+","+v.y).join(" "),m=l.container;m.getElementsByTagName("polygon")[0].setAttribute("points",A),m.getElementsByTagName("polyline")[0].setAttribute("points",A);let g=p,f=u;m.getElementsByTagName("rect")[0].setAttribute("x",g-40),m.getElementsByTagName("rect")[0].setAttribute("y",f-12.5),m.getElementsByTagName("text")[0].setAttribute("x",g),m.getElementsByTagName("text")[0].setAttribute("y",f+4),m.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(l.text,2),m.style.top="0px",m.style.left="0px"}function n(l){if(l.container==null){let g=['<svg class="measureSvg">',"<defs>",'<marker id="slope-arrow-'+l.id+'" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto" markerUnits="strokeWidth">','<path class="measureLine" d="M0,0 L0,6 L9,3 z"/>',"</marker>","</defs>",'<polyline class="measureLine" stroke="orange" stroke-width="2" points="0,0 0,0" marker-end="url(#slope-arrow-'+l.id+')" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="50" y="16" text-anchor="middle" class="measureLabel">'+l.text+"</text>","</svg>"].join("");l.container=document.createElement("div"),l.container.className="slope-annotation",l.container.id=l.id,l.container.innerHTML=g,e.engine.measure.annotationContainer.appendChild(l.container),l.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0,e.engine.events.trigger(Ai.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}let c=new zt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point1),h=new zt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point2),d=e.engine.reactBoundingClientRect.left,p=e.engine.reactBoundingClientRect.top;c.x+=d,c.y+=p,h.x+=d,h.y+=p;let u=l.container;u.getElementsByTagName("polyline")[0].setAttribute("points",c.x+","+c.y+" "+h.x+","+h.y);let A=(c.x+h.x)/2,m=(c.y+h.y)/2-30;u.getElementsByTagName("rect")[0].setAttribute("x",A-50),u.getElementsByTagName("rect")[0].setAttribute("y",m-12.5),u.getElementsByTagName("text")[0].setAttribute("x",A),u.getElementsByTagName("text")[0].setAttribute("y",m+4),u.getElementsByTagName("text")[0].innerHTML=l.text,u.style.top="0px",u.style.left="0px"}function s(l){if(l.container==null){let f=['<svg class="measureSvg">','<circle class="measurePointer" cx="0" cy="0" r="5" fill="#f99d0b" />','<rect x="0" y="-25" width="100" height="25" class="measureBack" />','<text x="40" y="-11" text-anchor="middle" class="measureLabel">X: '+e.getMeasureText(l.textX,1)+"</text>",'<rect x="0" y="-10" width="100" height="25" class="measureBack" />','<text x="40" y="25" text-anchor="middle" class="measureLabel">Y: '+e.getMeasureText(-l.textZ,1)+"</text>",'<rect x="0" y="10" width="100" height="25" class="measureBack" />','<text x="40" y="51" text-anchor="middle" class="measureLabel">Z: '+e.getMeasureText(l.textY,1)+"</text>","</svg>"].join("");l.container=document.createElement("div"),l.container.className="coordinate-annotation",l.container.id=l.id,l.container.style.position="absolute",l.container.style.pointerEvents="none",l.container.innerHTML=f,e.engine.measure.annotationContainer.appendChild(l.container),l.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0,e.engine.events.trigger(Ai.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}let c=l.container,h=new zt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point),d=e.engine.reactBoundingClientRect.left,p=e.engine.reactBoundingClientRect.top;h.x+=d,h.y+=p,c.style.top="0px",c.style.left="0px";let u=c.getElementsByTagName("circle")[0];u&&(u.setAttribute("cx",h.x),u.setAttribute("cy",h.y));let A=c.getElementsByTagName("rect"),m=c.getElementsByTagName("text"),g=-55;A[0]&&(A[0].setAttribute("x",h.x+10),A[0].setAttribute("y",h.y+10+g)),m[0]&&(m[0].setAttribute("x",h.x+10+40),m[0].setAttribute("y",h.y+10+16+g)),A[1]&&(A[1].setAttribute("x",h.x+10),A[1].setAttribute("y",h.y+10+30+g)),m[1]&&(m[1].setAttribute("x",h.x+10+40),m[1].setAttribute("y",h.y+10+46+g)),A[2]&&(A[2].setAttribute("x",h.x+10),A[2].setAttribute("y",h.y+10+60+g)),m[2]&&(m[2].setAttribute("x",h.x+10+40),m[2].setAttribute("y",h.y+10+76+g)),m[0]&&(m[0].innerHTML="X: "+e.getMeasureText(l.textX,1)),m[1]&&(m[1].innerHTML="Y: "+e.getMeasureText(-l.textZ,1)),m[2]&&(m[2].innerHTML="Z: "+e.getMeasureText(l.textY,1))}function a(l){if(l.container==null){let u=['<svg width="100" height="50" class="measureSvg">','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(l.text,1)+"</text>",'<polyline class="measureLine" stroke-width="2" points="80,32 0,32 16,48 32,32" style="fill: none; opacity: 1;"/>',"</svg>"].join("");l.container=document.createElement("div"),l.container.className="elevation-annotation",l.container.id=l.id,l.container.style.position="absolute",l.container.style.pointerEvents="none",l.container.innerHTML=u,e.engine.measure.annotationContainer.appendChild(l.container),l.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0,e.engine.events.trigger(Ai.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}let c=l.container,h=new zt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point),d=e.engine.reactBoundingClientRect.left,p=e.engine.reactBoundingClientRect.top;c.style.top=h.y+p-48+"px",c.style.left=h.x+d-16+"px",c.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(l.text,1)}function o(l){if(l.container==null){let A=['<svg class="measureSvg">','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline class="measureLine" stroke="orange" stroke-width="2" points="80,32 0,32" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(l.text,1)+"</text>","</svg>"].join("");l.container=document.createElement("div"),l.container.className="normal-annotation",l.container.id=l.id,l.container.innerHTML=A,e.engine.measure.annotationContainer.appendChild(l.container),l.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0,e.engine.events.trigger(Ai.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}let c=l.container;if(l.point1==null||l.point2==null){c.style.display="none";return}else c.style.display="block";let h=new zt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point1),d=new zt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point2),p=e.engine.reactBoundingClientRect.left,u=e.engine.reactBoundingClientRect.top;h.x+=p,h.y+=u,d.x+=p,d.y+=u,c.getElementsByTagName("polyline")[0].setAttribute("points",h.x+","+h.y+" "+d.x+","+d.y),c.getElementsByTagName("circle")[0].setAttribute("cx",h.x),c.getElementsByTagName("circle")[0].setAttribute("cy",h.y),c.getElementsByTagName("circle")[1].setAttribute("cx",d.x),c.getElementsByTagName("circle")[1].setAttribute("cy",d.y),c.getElementsByTagName("rect")[0].setAttribute("x",h.x*.5+d.x*.5-40),c.getElementsByTagName("rect")[0].setAttribute("y",h.y*.5+d.y*.5-12.5),c.getElementsByTagName("text")[0].setAttribute("x",h.x*.5+d.x*.5+40-40),c.getElementsByTagName("text")[0].setAttribute("y",h.y*.5+d.y*.5+16-12.5),c.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(l.text,1),c.style.top="0px",c.style.left="0px"}}}class uU{engine;isActive=!1;tools;points=[];behavior;catchDir=0;type="point";constructor(e){this.engine=e,this.tools=new pr(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}setDirection(e){this.catchDir=e}setSelectType(e){this.type=e}getMeshesMinMaxY(e){if(!Array.isArray(e)||e.length===0)return null;let t=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(let n=0;n<e.length;n++){const s=e[n];if(!s)continue;typeof s.updateMatrixWorld=="function"&&s.updateMatrixWorld(!0);const a=new Ft().setFromObject(s);!Number.isFinite(a.min.y)||!Number.isFinite(a.max.y)||(a.min.y<t&&(t=a.min.y),a.max.y>i&&(i=a.max.y))}return!Number.isFinite(t)||!Number.isFinite(i)?null:{minY:t,maxY:i}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch.point;if(this.type=="element"){let s=this.engine.interactionModule.getCatchMeshs(e);var i=this.getMeshesMinMaxY(s);this.catchDir==0?t.set(t.x,i?.minY,t.z):t.set(t.x,i?.maxY,t.z)}else t=e.catch.point;if(this.points.length==0){this.engine.measure.tools.clearHighlight(),this.points.push(t);return}let n=this.engine.measure.annotationData.normalAnnotation.find(s=>s.isSelect==!0);n!=null&&(n.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(n=>n.isSelect==!0);t==null&&(t={text:null,id:ur(),isSelect:!0,type:"clear-height"},this.engine.measure.annotationData.normalAnnotation.push(t));let i=e.catch;if(this.type=="element"){let n=e.catch.point.clone();n.set(n.x,this.points[0].y,n.z);let s=new Ln(n.add(new T(0,.01,0)),new T(0,this.catchDir==0?-1:1,0));i.point=this.points[0];const a=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(s))??this.engine.octreeBox.rayInterationModel(s);if(a.length===0){t.point2=null;return}t.point1=n,t.point2=a[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Ai.MeasureChanged,t)}else{let n=new Ln(e.catch.point.clone().add(new T(0,.01,0)),new T(0,this.catchDir==0?-1:1,0));const s=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(n))??this.engine.octreeBox.rayInterationModel(n);if(s.length===0){t.point2=null;return}t.point1=i.point,t.point2=s[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Ai.MeasureChanged,t)}}}class pU{engine;tools;isActive=!1;points=[];behavior;constructor(e){this.engine=e,this.tools=new pr(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.isActive=!1,this.engine.handelBehaved.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.engine.measure.tools.clearHighlight(),this.points.push(t.point);else if(this.points.length==1){let i=this.engine.measure.annotationData.normalAnnotation.find(n=>n.isSelect==!0);if(i==null)return;i.point2=t.point,i.isSelect=!1,this.points=[],this.engine.events.trigger(Ai.MeasureChanged,i)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let i=this.engine.measure.annotationData.normalAnnotation.find(n=>n.isSelect==!0);i==null&&(i={id:ur(),point1:this.points[0].clone(),point2:t.point.clone(),text:this.points[0].clone().distanceTo(t.point.clone()),type:"distance",isSelect:!0},this.engine.measure.annotationData.normalAnnotation.push(i)),i.point2=t.point,i.text=i.point1.clone().distanceTo(i.point2.clone())}}}class fU{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new pr(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;if(this.points.length==0){this.engine.measure.tools.clearHighlight(),this.points.push(e.catch.point);return}let t=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);t!=null&&(t.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(a=>a.isSelect==!0);t==null&&(t={text:null,id:ur(),isSelect:!0,type:"clear-distance"},this.engine.measure.annotationData.normalAnnotation.push(t));let i=new Ln(e.catch.point.clone().add(e.catch.face.normal.clone().setLength(.01)),e.catch.face.normal);const n=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(i))??this.engine.octreeBox.rayInterationModel(i);if(n.length==0){t.point2=null;return}let s=e.catch;t.point1=s.point,t.point2=n[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Ai.MeasureChanged,t)}}class mU{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new pr(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active(),this.isActive=!0;let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.elevationAnnotation.find(i=>i.isSelect==!0);t==null&&(t={id:ur(),point:e.catch.point.clone(),text:e.catch.point.y,isSelect:!0,type:"elevation"},this.engine.measure.annotationData.elevationAnnotation.push(t)),t.point=e.catch.point.clone(),t.text=e.catch.point.y}handleMouseClick(e){if(e.catch==null)return;this.engine.measure.tools.clearHighlight();let t=this.engine.measure.annotationData.elevationAnnotation.find(i=>i.isSelect==!0);t!=null&&(t.isSelect=!1,t.point=e.catch.point.clone(),t.text=e.catch.point.y,this.engine.events.trigger(Ai.MeasureChanged,t))}}class gU{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new pr(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active(),this.isActive=!0;let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseUp(e){this.engine.deviceType!="PC"&&this.createMeasure()}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(i=>i.isSelect==!0);t==null&&(t={id:ur(),point:e.catch.point.clone(),text:Math.round(e.catch.point.y)+" m",isSelect:!0,type:"point"},this.engine.measure.annotationData.coordinateAnnotation.push(t)),t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z}handleMouseClick(e){if(e.catch==null)return;this.engine.measure.tools.clearHighlight();let t=this.engine.measure.annotationData.coordinateAnnotation.find(i=>i.isSelect==!0);t!=null&&(t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z,t.isSelect=!1,this.engine.events.trigger(Ai.MeasureChanged,t))}createMeasure(){let e=this.engine.measure.annotationData.coordinateAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1,this.engine.events.trigger(Ai.MeasureChanged,e))}}class AU{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new pr(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateAngle(e,t,i){const n=new T().subVectors(e,t),s=new T().subVectors(i,t),a=n.length(),o=s.length();if(a===0||o===0)return 0;const l=n.dot(s)/(a*o),c=Math.max(-1,Math.min(1,l));return Math.acos(c)*(180/Math.PI)}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.engine.measure.tools.clearHighlight(),this.points.push(t.point);else if(this.points.length==1)this.points.push(t.point);else if(this.points.length==2){let i=this.engine.measure.annotationData.angleAnnotation.find(n=>n.isSelect==!0);if(i==null)return;i.point3=t.point.clone(),i.angle=this.calculateAngle(i.point1,i.point2,i.point3),i.text=i.angle.toFixed(2)+"°",i.isSelect=!1,i.type="angle",this.points=[],this.engine.events.trigger(Ai.MeasureChanged,i)}}handleMouseMove(e){if(e.catch!=null&&this.points.length!=1&&this.points.length==2){let t=this.engine.measure.annotationData.angleAnnotation.find(i=>i.isSelect==!0);t==null&&(t={id:ur(),point1:this.points[0].clone(),point2:this.points[1].clone(),point3:e.catch.point.clone(),angle:0,text:"0.00°",isSelect:!0,type:"angle"},this.engine.measure.annotationData.angleAnnotation.push(t)),t.point3=e.catch.point.clone(),t.angle=this.calculateAngle(t.point1,t.point2,t.point3),t.text=t.angle.toFixed(2)+"°",console.log("角度",t.text)}}}class vU{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new pr(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateArea(e){if(e.length<3)return 0;let t=0;const i=e.length;for(let n=0;n<i;n++){const s=(n+1)%i;t+=e[n].x*e[s].z,t-=e[s].x*e[n].z}return t=Math.abs(t)/2,t}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.push(t.point.clone()),this.points.length>=3){let i=this.engine.measure.annotationData.areaAnnotation.find(n=>n.isSelect==!0);i==null?(i={id:ur(),points:this.points.map(n=>n.clone()),area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(i)):(this.points.push(t.point.clone()),i.points=this.points.map(n=>n.clone())),i.area=this.calculateArea(i.points),i.text=i.area,console.log("面积",i.text)}else this.engine.measure.tools.clearHighlight()}handleMouseMove(e){if(e.catch!=null&&this.points.length>=2){let t=this.engine.measure.annotationData.areaAnnotation.find(i=>i.isSelect==!0);if(t==null){if(this.points.length>=2){let i=this.points.map(n=>n.clone());i.push(e.catch.point.clone()),i.length>=3&&(t={id:ur(),points:i,area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(t))}}else if(t.points.length>0){const i=t.points.length-1;t.points[i]=e.catch.point.clone()}else t.points=this.points.map(i=>i.clone()),t.points.push(e.catch.point.clone());t&&t.points.length>=3&&(t.area=this.calculateArea(t.points),t.text=t.area)}}handelKeyEnterDown(){this.finishMeasure()}finishMeasure(){this.points=this.points.slice(0,this.points.length-1);let e=this.engine.measure.annotationData.areaAnnotation.find(t=>t.isSelect==!0);e!=null&&e.points.length>=3&&(e.points.length>this.points.length&&(e.points=this.points.map(t=>t.clone())),e.area=this.calculateArea(e.points),e.text=e.area,e.isSelect=!1,this.points=[],this.engine.events.trigger(Ai.MeasureChanged,e))}}class bU{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new pr(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateSlope(e,t){const i=t.y-e.y,n=t.x-e.x,s=t.z-e.z,a=Math.sqrt(n*n+s*s);if(a===0)return{percentage:0,angle:0,heightDiff:i,horizontalDist:0,type:"slope"};const o=i/a*100,l=Math.atan(i/a)*(180/Math.PI);return{percentage:o,angle:l,heightDiff:i,horizontalDist:a,type:"slope"}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.engine.measure.tools.clearHighlight(),this.points.push(t.point);else if(this.points.length==1){let i=this.engine.measure.annotationData.slopeAnnotation.find(s=>s.isSelect==!0);if(i==null)return;console.log("进来了"),i.point2=t.point.clone();const n=this.calculateSlope(i.point1,i.point2);i.slopePercentage=n.percentage,i.slopeAngle=n.angle,i.heightDiff=n.heightDiff,i.horizontalDist=n.horizontalDist,i.text=n.percentage.toFixed(2)+"% ("+n.angle.toFixed(2)+"°)",i.isSelect=!1,this.points=[],this.engine.events.trigger(Ai.MeasureChanged,i)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let i=this.engine.measure.annotationData.slopeAnnotation.find(s=>s.isSelect==!0);i==null&&(i={id:ur(),point1:this.points[0].clone(),point2:t.point.clone(),slopePercentage:0,slopeAngle:0,heightDiff:0,horizontalDist:0,text:"0.00% (0.00°)",isSelect:!0,type:"slope"},this.engine.measure.annotationData.slopeAnnotation.push(i)),i.point2=t.point.clone();const n=this.calculateSlope(i.point1,i.point2);i.slopePercentage=n.percentage,i.slopeAngle=n.angle,i.heightDiff=n.heightDiff,i.horizontalDist=n.horizontalDist,i.text=n.percentage.toFixed(2)+"% ("+n.angle.toFixed(2)+"°)"}}}class yU{isActive=!1;engine;clearHeightMeasure;distanceMeasure;clearDistanceMeasure;elevationMeasure;pointMeasure;angleMeasure;areaMeasure;slopeMeasure;tools;annotationContainer;annotationData={normalAnnotation:[],textAnnotation:[],coordinateAnnotation:[],angleAnnotation:[],distanceAnnotation:[],areaAnnotation:[],slopeAnnotation:[],elevationAnnotation:[],volumeAnnotation:[]};constructor(e){this.engine=e,this.clearHeightMeasure=new uU(e),this.distanceMeasure=new pU(e),this.clearDistanceMeasure=new fU(e),this.elevationMeasure=new mU(e),this.pointMeasure=new gU(e),this.angleMeasure=new AU(e),this.areaMeasure=new vU(e),this.slopeMeasure=new bU(e),this.tools=new pr(e),this.annotationContainer=document.createElement("div"),this.annotationContainer.className="annotation-container",e.container.appendChild(this.annotationContainer)}active(){this.isActive=!0,this.engine.modelEdge.loadModelEdge(),this.tools.active()}disActive(){this.tools.disActive(),this.clearAll(),this.isActive=!1,this.clearHeightMeasure.disActive(),this.distanceMeasure.disActive(),this.clearDistanceMeasure.disActive(),this.elevationMeasure.disActive(),this.pointMeasure.disActive(),this.angleMeasure.disActive(),this.areaMeasure.disActive(),this.slopeMeasure.disActive(),this.engine.interactionModule.init(),this.engine.interactionModule.active()}clearAllPoints(){this.clearHeightMeasure.clearAllPoints(),this.distanceMeasure.clearAllPoints(),this.clearDistanceMeasure.clearAllPoints(),this.elevationMeasure.clearAllPoints(),this.pointMeasure.clearAllPoints(),this.angleMeasure.clearAllPoints(),this.areaMeasure.clearAllPoints(),this.slopeMeasure.clearAllPoints()}clearAll(){e(this.annotationData.normalAnnotation),e(this.annotationData.textAnnotation),e(this.annotationData.coordinateAnnotation),e(this.annotationData.angleAnnotation),e(this.annotationData.distanceAnnotation),e(this.annotationData.areaAnnotation),e(this.annotationData.slopeAnnotation),e(this.annotationData.elevationAnnotation),e(this.annotationData.volumeAnnotation);function e(t){for(let i=0;i<t.length;i++)t[i].container.remove();t=[]}}saveSetting(e){this.tools.saveSetting(e)}getSetting(){return this.tools.getSetting()}update(){this.isActive&&this.tools.drawNormalAnnotation()}}class xU{engine;isActive=!1;isCtrlDown=!1;listenersAttached=!1;box;pickPoint;pickNormal;pickMesh;box_;plane;meshs;isDrag=!1;maxBox;faceIdleOpacity=0;faceHoverOpacity=.05;transformControls=new Map;transformAnchors=new Map;transformHelpers=new Map;faceMetaMap=new Map;isSyncingTransform=!1;handleNativeMouseDown=e=>{if(e.button!==0||!(this.isCtrlDown||e.ctrlKey))return;const t=this.createRaycasterFromMouseEvent(e),i=t.intersectObjects(this.getInteractiveMeshes(),!1);i.length!==0&&(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseDown({button:e.button,raycaster:t,intersects:i}))};handleNativeMouseMove=e=>{if(!this.isDrag&&!(this.isCtrlDown||e.ctrlKey)){this.resetMeshOpacity();return}const t=this.createRaycasterFromMouseEvent(e),i=t.intersectObjects(this.getInteractiveMeshes(),!1);this.isDrag&&(e.preventDefault(),e.stopImmediatePropagation()),this.handleMouseMove({raycaster:t,intersects:i})};handleNativeMouseUp=e=>{e.button!==0||!this.isDrag||(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseUp({button:e.button}))};handleNativeKeyDown=e=>{e.key==="Control"&&(this.isCtrlDown=!0)};handleNativeKeyUp=e=>{e.key==="Control"&&(this.isCtrlDown=!1,this.isDrag&&this.handleMouseUp({button:0}),this.resetMeshOpacity())};constructor(e,t){this.engine=e,this.meshs=[]}active(){this.isActive||(this.attachListeners(),this.init(),this.setTransformControlsVisible(!0),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!0)})}),this.isActive=!0)}disActive(){this.init(),this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0}),this.setTransformControlsVisible(!1),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!1)})})}disabled(){this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0}),this.setTransformControlsVisible(!1),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!1)})})}recover(){this.isActive||(this.attachListeners(),this.setTransformControlsVisible(!0),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!0)})}),this.isActive=!0)}init(){const e=this.engine.octreeBox.getBoundingBox();e.min.x-=.1,e.min.y-=.1,e.min.z-=.1,e.max.x+=.1,e.max.y+=.1,e.max.z+=.1,this.maxBox=JSON.parse(JSON.stringify(e)),this.box=e,this.updata_face(e)}getboxXyz(){return{minX:this.box.min.x,minY:this.box.min.y,minZ:this.box.min.z,maxX:this.box.max.x,maxY:this.box.max.y,maxZ:this.box.max.z}}setboxXyz(e){this.box.min.x=e.minX,this.box.min.y=e.minY,this.box.min.z=e.minZ,this.box.max.x=e.maxX,this.box.max.y=e.maxY,this.box.max.z=e.maxZ,this.updata_face(this.box)}setBox(e){this.box=e,this.updata_face(e)}reverseBox(){}handleMouseDown(e){const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);if(t!=null&&t.length>0){const i=t[0];this.isDrag=!0,this.pickPoint=i.point.clone(),this.pickMesh=i.object;const n=this.pickMesh?.userData?.dragNormal?.clone?.(),s=i.face?.normal?.clone?.();if(this.pickNormal=(n??s??new T(0,0,1)).clone().normalize(),this.engine.controls.enabled=!1,this.box_={min:this.box.min.clone(),max:this.box.max.clone()},this.pickNormal.y==0){const a=new li;a.setFromNormalAndCoplanarPoint(new T(0,1,0),this.pickPoint),this.plane=a}else{const a=new T(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z),o=new li;o.setFromNormalAndCoplanarPoint(a.clone().sub(this.pickPoint.clone()).setLength(1),this.pickPoint),this.plane=o}}else this.isDrag=!1}handleMouseUp(e){this.isDrag=!1,this.pickPoint=null,this.pickNormal=null,this.pickMesh=null,this.plane=null,this.engine.controls.enabled=!0}clampVector3(e,t,i){return new T(Math.max(t.x,Math.min(i.x,e.x)),Math.max(t.y,Math.min(i.y,e.y)),Math.max(t.z,Math.min(i.z,e.z)))}handleMouseMove(e){this.resetMeshOpacity();const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);if(t!=null&&t.length>0&&(t[0].object.material.opacity=this.faceHoverOpacity),this.pickPoint!=null){const i=new T;if(e.raycaster.ray.intersectPlane(this.plane,i)){const n=i.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());if(this.pickMesh?.userData?.isMinFace){const s=this.box_.min.clone().add(this.pickNormal.clone().setLength(n));this.box.min=this.clampVector3(s,this.maxBox.min,this.box.max)}else{const s=this.box_.max.clone().add(this.pickNormal.clone().setLength(n));this.box.max=this.clampVector3(s,this.box.min,this.maxBox.max)}this.updata_face(this.box),this.calculate_ratio()}}}calculate_ratio(){const e=this.maxBox.max.x-this.maxBox.min.x,t=this.maxBox.max.y-this.maxBox.min.y,i=this.maxBox.max.z-this.maxBox.min.z,n=this.toPercent((this.box.min.x-this.maxBox.min.x)/e*100),s=this.toPercent((this.box.max.x-this.maxBox.min.x)/e*100),a=this.toPercent((this.box.min.y-this.maxBox.min.y)/t*100),o=this.toPercent((this.box.max.y-this.maxBox.min.y)/t*100),l=this.toPercent((this.box.min.z-this.maxBox.min.z)/i*100),c=this.toPercent((this.box.max.z-this.maxBox.min.z)/i*100),h={x:{min:n,max:s},y:{min:a,max:o},z:{min:l,max:c}};this.engine.events.trigger(Ai.SectionMove,h)}toPercent(e){return e<0?0:e>100?100:e}getInteractiveMeshes(){return this.meshs.filter(e=>e.type==="Mesh")}createRaycasterFromMouseEvent(e){const t=new Ln,i=new be,n=this.engine.renderer.domElement.clientWidth,s=this.engine.renderer.domElement.clientHeight;return i.x=e.offsetX/n*2-1,i.y=-(e.offsetY/s)*2+1,t.setFromCamera(i,this.engine.camera),t}attachListeners(){if(this.listenersAttached)return;const e=this.engine.renderer?.domElement;e&&(e.addEventListener("mousedown",this.handleNativeMouseDown,!0),e.addEventListener("mousemove",this.handleNativeMouseMove,!0),e.addEventListener("mouseup",this.handleNativeMouseUp,!0),window.addEventListener("keydown",this.handleNativeKeyDown),window.addEventListener("keyup",this.handleNativeKeyUp),this.listenersAttached=!0)}detachListeners(){if(!this.listenersAttached)return;const e=this.engine.renderer?.domElement;e&&(e.removeEventListener("mousedown",this.handleNativeMouseDown,!0),e.removeEventListener("mousemove",this.handleNativeMouseMove,!0),e.removeEventListener("mouseup",this.handleNativeMouseUp,!0)),window.removeEventListener("keydown",this.handleNativeKeyDown),window.removeEventListener("keyup",this.handleNativeKeyUp),this.listenersAttached=!1,this.isCtrlDown=!1}resetMeshOpacity(){this.getInteractiveMeshes().forEach(e=>{e.material&&(e.material.opacity=this.faceIdleOpacity)})}getFaceTransformOffset(){if(!this.box)return .06;const e=this.box.min.distanceTo(this.box.max);return Math.max(e*.015,.06)}keepSingleDirectionArrow(e,t="X"){const i=e.getHelper(),n=[];i.traverse(s=>{if(s?.name!==t||!s.geometry)return;const a=s.geometry;a.boundingBox||a.computeBoundingBox();const o=a.boundingBox;if(!o)return;const l=o.getCenter(new T);if(!(t==="X"&&l.x<0||t==="Y"&&l.y<0||t==="Z"&&l.z<0))return;const c=a.parameters,h=c&&c.radiusTop===0&&c.radiusBottom===.04&&c.height===.1,d=c&&c.radiusTop===.2&&c.radiusBottom===0&&c.height===.6;(h||d)&&n.push(s)}),n.forEach(s=>{s.parent?.remove(s)})}setTransformControlsVisible(e){this.transformControls.forEach(t=>{t.enabled=e}),this.transformHelpers.forEach(t=>{t.visible=e}),this.transformAnchors.forEach(t=>{t.visible=e}),e||(this.engine.controls.enabled=!0)}ensureFaceTransformControl(e){if(this.transformControls.has(e)&&this.transformAnchors.has(e))return;const t=this.engine.renderer?.domElement,i=this.engine.camera;if(!t||!i)return;const n=new Mt;n.name=`SectionBoxTransformAnchor_${e}`,n.visible=this.isActive,this.engine.scene.add(n);const s=new LE(i,t);s.name=`SectionBoxTransformControl_${e}`,s.setMode("translate"),s.setSpace("local"),s.showX=!0,s.showY=!1,s.showZ=!1,s.size=.75,s.enabled=this.isActive,s.attach(n),this.keepSingleDirectionArrow(s,"X"),s.addEventListener("dragging-changed",o=>{this.engine.controls.enabled=!o.value}),s.addEventListener("objectChange",()=>{this.handleTransformObjectChange(e)});const a=s.getHelper();a.visible=this.isActive,this.engine.scene.add(a),this.transformAnchors.set(e,n),this.transformControls.set(e,s),this.transformHelpers.set(e,a)}updateFaceTransformControl(e,t,i,n){this.ensureFaceTransformControl(e);const s=this.transformAnchors.get(e),a=this.transformControls.get(e);if(!s||!a)return;const o=this.getFaceTransformOffset(),l=new Tt().setFromUnitVectors(new T(1,0,0),t.clone().normalize()),c=i.clone().add(t.clone().setLength(o));this.faceMetaMap.set(e,{normal:t.clone().normalize(),isMinFace:n,center:i.clone()}),this.isSyncingTransform=!0,s.position.copy(c),s.quaternion.copy(l),s.visible=this.isActive,a.object!==s&&a.attach(s),a.enabled=this.isActive;const h=this.transformHelpers.get(e);h&&(h.visible=this.isActive),this.isSyncingTransform=!1}getDominantAxis(e){const t=Math.abs(e.x),i=Math.abs(e.y),n=Math.abs(e.z);return t>=i&&t>=n?"x":i>=t&&i>=n?"y":"z"}handleTransformObjectChange(e){if(this.isSyncingTransform)return;const t=this.transformAnchors.get(e),i=this.faceMetaMap.get(e);if(!t||!i||!this.box||!this.maxBox)return;const n=i.normal,s=this.getDominantAxis(n),a=this.getFaceTransformOffset(),o=n[s],l=t.position[s]-o*a;if(i.isMinFace){const c=this.maxBox.min[s],h=this.box.max[s];this.box.min[s]=Math.max(c,Math.min(h,l))}else{const c=this.box.min[s],h=this.maxBox.max[s];this.box.max[s]=Math.max(c,Math.min(h,l))}this.updata_face(this.box),this.calculate_ratio()}updata_face(e){let t=this.engine.scene.children.find(i=>i.type=="Group"&&i.name=="ClippingBox");t==null&&(t=new Mi,t.name="ClippingBox",this.engine.scene.add(t)),[{name:"前",normal:new T(0,0,-1),isMinFace:!0,planePoint:e.min,vertices:[new T(e.min.x,e.max.y,e.min.z),new T(e.max.x,e.max.y,e.min.z),new T(e.max.x,e.min.y,e.min.z),new T(e.min.x,e.min.y,e.min.z)]},{name:"后",normal:new T(0,0,1),isMinFace:!1,planePoint:e.max,vertices:[new T(e.min.x,e.min.y,e.max.z),new T(e.max.x,e.min.y,e.max.z),new T(e.max.x,e.max.y,e.max.z),new T(e.min.x,e.max.y,e.max.z)]},{name:"右",normal:new T(1,0,0),isMinFace:!1,planePoint:e.max,vertices:[new T(e.max.x,e.min.y,e.max.z),new T(e.max.x,e.min.y,e.min.z),new T(e.max.x,e.max.y,e.min.z),new T(e.max.x,e.max.y,e.max.z)]},{name:"左",normal:new T(-1,0,0),isMinFace:!0,planePoint:e.min,vertices:[new T(e.min.x,e.min.y,e.min.z),new T(e.min.x,e.min.y,e.max.z),new T(e.min.x,e.max.y,e.max.z),new T(e.min.x,e.max.y,e.min.z)]},{name:"顶",normal:new T(0,1,0),isMinFace:!1,planePoint:e.max,vertices:[new T(e.min.x,e.max.y,e.max.z),new T(e.max.x,e.max.y,e.max.z),new T(e.max.x,e.max.y,e.min.z),new T(e.min.x,e.max.y,e.min.z)]},{name:"底",normal:new T(0,-1,0),isMinFace:!0,planePoint:e.min,vertices:[new T(e.min.x,e.min.y,e.min.z),new T(e.max.x,e.min.y,e.min.z),new T(e.max.x,e.min.y,e.max.z),new T(e.min.x,e.min.y,e.max.z)]}].forEach(i=>{this.createFace(t,i.vertices,i.normal,i.name,i.isMinFace,i.planePoint)}),this.engine.scene.children.filter(i=>i.type=="Mesh"&&i.url).forEach(i=>{i.material&&Array.isArray(i.material)?i.material.forEach(n=>{n.clippingPlanes=this.engine.sectionPlane}):i.material.clippingPlanes=this.engine.sectionPlane})}createFace(e,t,i,n,s,a){const o=new ot,l=new Float32Array([t[0].x,t[0].y,t[0].z,t[1].x,t[1].y,t[1].z,t[2].x,t[2].y,t[2].z,t[3].x,t[3].y,t[3].z]),c=[0,2,1,0,3,2];o.setAttribute("position",new St(l,3)),o.setIndex(c);let h=this.meshs.find(f=>f.name===n);if(h==null){const f=new Rt({color:65280,transparent:!0,opacity:this.faceIdleOpacity,side:Vt});f.polygonOffset=!0,f.polygonOffsetFactor=1,f.polygonOffsetUnits=4,h=new Ge(o,f),h.name=n,e.add(h),this.meshs.push(h)}else h.geometry=o;h.userData={dragNormal:i.clone(),isMinFace:s,faceName:n};const d=new Float32Array([t[0].x,t[0].y,t[0].z,t[1].x,t[1].y,t[1].z,t[2].x,t[2].y,t[2].z,t[3].x,t[3].y,t[3].z,t[0].x,t[0].y,t[0].z]),p=new si({color:255}),u=new ot;u.setAttribute("position",new St(d,3));let A=this.meshs.find(f=>f.name===n+"Line");A==null?(A=new di(u,p),A.name=n+"Line",e.add(A),this.meshs.push(A)):(A.geometry=u,A.material=p);const m=new T;t.forEach(f=>m.add(f)),m.multiplyScalar(1/t.length),this.updateFaceTransformControl(n,i,m,s);const g=this.engine.sectionPlane.find(f=>f.name==n);g&&g.setFromNormalAndCoplanarPoint(i.clone().setLength(-1),a)}}class _U{engine;isActive=!1;isDrag=!1;isCtrlDown=!1;listenersAttached=!1;meshs=[];box=null;pickPoint=null;pickNormal=null;plane=null;angleX=0;angleY=0;angleZ=0;direction=1;normal=new T(0,0,1);distance=0;center=null;current_center=null;dragStartDistance=0;idleOpacity=.02;hoverOpacity=.05;transformControl=null;transformAnchor=null;transformHelper=null;isSyncingTransformControl=!1;handleNativeMouseDown=e=>{if(e.button!==0||!(this.isCtrlDown||e.ctrlKey))return;const t=this.createRaycasterFromMouseEvent(e),i=t.intersectObjects(this.getInteractiveMeshes(),!1);i.length!==0&&(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseDown({button:e.button,raycaster:t,intersects:i}))};handleNativeMouseMove=e=>{if(!this.isDrag&&!(this.isCtrlDown||e.ctrlKey)){this.resetMeshOpacity();return}const t=this.createRaycasterFromMouseEvent(e),i=t.intersectObjects(this.getInteractiveMeshes(),!1);this.isDrag&&(e.preventDefault(),e.stopImmediatePropagation()),this.handleMouseMove({raycaster:t,intersects:i})};handleNativeMouseUp=e=>{e.button!==0||!this.isDrag||(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseUp({button:e.button}))};handleNativeKeyDown=e=>{e.key==="Control"&&(this.isCtrlDown=!0)};handleNativeKeyUp=e=>{e.key==="Control"&&(this.isCtrlDown=!1,this.isDrag&&this.handleMouseUp({button:0}),this.resetMeshOpacity())};handleTransformObjectChange=()=>{if(this.isSyncingTransformControl||!this.transformAnchor||!this.center)return;const e=this.normal.clone().normalize(),t=this.getDistanceRange(e),i=this.getTransformHandleOffset(),n=this.transformAnchor.position.clone().sub(this.center).dot(e)-i,s=Math.min(t.max,Math.max(t.min,n));Math.abs(s-Number(this.distance))>1e-5?this.updata_face(s):Math.abs(n-s)>1e-5&&this.updateTransformControl(e)};constructor(e){this.engine=e,this.meshs=[],this.box=null}active(){if(this.isActive==!0)return;this.isActive=!0,this.engine.scene.children.filter(t=>t.type=="Group"&&t.name=="ClippingBox").forEach(t=>{t.children.forEach(i=>{i.name.includes("face")&&(i.visible=!0)})}),this.attachListeners(),this.ensureTransformControl(),this.setTransformControlVisible(!0);const e=this;e.engine.scene.children.filter(t=>t.type=="Mesh"&&t.url).forEach(t=>{t.material&&Array.isArray(t.material)?t.material.forEach(i=>{i.clippingPlanes=e.engine.sectionPlane}):t.material.clippingPlanes=e.engine.sectionPlane,e.engine.clipping.clippingStencil?.addMesh(e.engine.sectionPlane.find(i=>i.name=="face"),t)}),this.init()}disActive(){this.init(),this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0}),this.setTransformControlVisible(!1);const e=this.engine.sectionPlane.find(t=>t.name=="face");e&&(e.constant=1e5),this.engine.scene.children.filter(t=>t.type=="Group"&&t.name=="ClippingBox").forEach(t=>{t.children.forEach(i=>{i.name.includes("face")&&(i.visible=!1)})})}init(e){const t=this.engine.octreeBox.getBoundingBox();this.box=t,this.distance=0,this.center=new T((t.min.x+t.max.x)/2,(t.min.y+t.max.y)/2,(t.min.z+t.max.z)/2),this.current_center=this.center.clone(),!e&&this.updata_face(0)}disabled(){this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0}),this.setTransformControlVisible(!1),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")&&(t.visible=!1)})})}recover(){this.isActive||(this.attachListeners(),this.setTransformControlVisible(!0),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")&&(t.visible=!0)})}),this.isActive=!0)}setFaceAngle(e,t,i){this.angleX=e,this.angleY=t,this.angleZ=i,this.distance=0,this.normal=new T(0,1,0).applyAxisAngle(new T(1,0,0),e).applyAxisAngle(new T(0,0,1),t).applyAxisAngle(new T(0,1,0),i).normalize(),this.updata_face(0)}setFaceNormal(e,t=0){this.normal=e.clone().normalize(),this.distance=t,this.updata_face(t)}setFaceNormalPlaneOnly(e,t){if(this.normal=e.clone().normalize(),this.distance=t,!this.center||!this.box)return;const i=this.engine.sectionPlane?.find(n=>n.name==="face");if(i){const n=this.center.clone().add(this.normal.clone().multiplyScalar(t));i.setFromNormalAndCoplanarPoint(this.normal.clone().multiplyScalar(this.direction),n)}}activateClippingOnly(){if(this.isActive)return;this.isActive=!0;const e=this;e.engine.scene.children.filter(t=>t.type==="Mesh"&&t.url).forEach(t=>{t.material&&Array.isArray(t.material)?t.material.forEach(i=>{i.clippingPlanes=e.engine.sectionPlane}):t.material.clippingPlanes=e.engine.sectionPlane,e.engine.clipping.clippingStencil?.addMesh(e.engine.sectionPlane.find(i=>i.name==="face"),t)})}reverse(){this.direction=this.direction*-1,this.updata_face(this.distance)}getFaceAngle(){return{angleX:this.angleX,angleY:this.angleY,angleZ:this.angleZ,direction:this.direction}}updata_face(e){if(!this.box)return;this.distance=e;let t=this.engine.scene.children.find(b=>b.type=="Group"&&b.name=="ClippingBox");t==null&&(t=new Mi,t.name="ClippingBox",this.engine.scene.add(t));const i=this.normal.clone().normalize(),n=this.center??new T((this.box.min.x+this.box.max.x)/2,(this.box.min.y+this.box.max.y)/2,(this.box.min.z+this.box.max.z)/2);this.center=n.clone();const{tangent:s,bitangent:a}=this.getPlaneBasis(i),o=this.getBoxCorners(this.box),l=this.box.min.distanceTo(this.box.max),c=Math.max(l*.02,.01);let h=1/0,d=-1/0,p=1/0,u=-1/0;o.forEach(b=>{const y=b.clone().sub(n),M=y.dot(s),_=y.dot(a);h=Math.min(h,M),d=Math.max(d,M),p=Math.min(p,_),u=Math.max(u,_)}),h-=c,d+=c,p-=c,u+=c;const A=i.clone().multiplyScalar(e),m=n.clone().add(s.clone().multiplyScalar(h)).add(a.clone().multiplyScalar(p)).add(A),g=n.clone().add(s.clone().multiplyScalar(d)).add(a.clone().multiplyScalar(p)).add(A),f=n.clone().add(s.clone().multiplyScalar(d)).add(a.clone().multiplyScalar(u)).add(A),v=n.clone().add(s.clone().multiplyScalar(h)).add(a.clone().multiplyScalar(u)).add(A);this.current_center=n.clone().add(A),this.createFace(t,[m,g,f,v],i,"face"),this.updateTransformControl(i)}createFace(e,t,i,n){const s=new ot,a=new Float32Array([t[0].x,t[0].y,t[0].z,t[1].x,t[1].y,t[1].z,t[2].x,t[2].y,t[2].z,t[3].x,t[3].y,t[3].z]),o=[0,1,2,0,2,3];s.setAttribute("position",new St(a,3)),s.setIndex(o);let l=this.meshs.find(A=>A.name==n);if(l==null){const A=new Rt({color:65280,transparent:!0,opacity:this.idleOpacity,side:Vt});A.polygonOffset=!0,A.polygonOffsetFactor=1,A.polygonOffsetUnits=4,l=new Ge(s,A),l.name=n,e.add(l),this.meshs.push(l)}else l.geometry=s;l.normal=i.clone();const c=new Float32Array([t[0].x,t[0].y,t[0].z,t[1].x,t[1].y,t[1].z,t[2].x,t[2].y,t[2].z,t[3].x,t[3].y,t[3].z,t[0].x,t[0].y,t[0].z]),h=new si({color:255}),d=new ot;d.setAttribute("position",new St(c,3));let p=this.meshs.find(A=>A.name==n+"Line");p==null?(p=new di(d,h),p.name=n+"Line",e.add(p),this.meshs.push(p)):(p.geometry=d,p.material=h);const u=this.engine.sectionPlane.find(A=>A.name==n);u&&this.current_center&&u.setFromNormalAndCoplanarPoint(i.clone().setLength(this.direction),this.current_center)}getPlaneBasis(e){const t=new T(1,0,0),i=new T(0,1,0),n=new T(0,0,1),s=Math.abs(e.dot(t)),a=Math.abs(e.dot(i)),o=Math.abs(e.dot(n));let l=t;a<=s&&a<=o?l=i:o<=s&&o<=a&&(l=n),l=l.clone().sub(e.clone().multiplyScalar(l.dot(e))).normalize();const c=new T().crossVectors(e,l).normalize();return{tangent:l,bitangent:c}}getBoxCorners(e){return[new T(e.min.x,e.min.y,e.min.z),new T(e.min.x,e.min.y,e.max.z),new T(e.min.x,e.max.y,e.min.z),new T(e.min.x,e.max.y,e.max.z),new T(e.max.x,e.min.y,e.min.z),new T(e.max.x,e.min.y,e.max.z),new T(e.max.x,e.max.y,e.min.z),new T(e.max.x,e.max.y,e.max.z)]}getDistanceRange(e){if(!this.box)return{min:0,max:0};const t=this.center??new T((this.box.min.x+this.box.max.x)/2,(this.box.min.y+this.box.max.y)/2,(this.box.min.z+this.box.max.z)/2),i=this.getBoxCorners(this.box);let n=1/0,s=-1/0;return i.forEach(a=>{const o=a.clone().sub(t).dot(e);n=Math.min(n,o),s=Math.max(s,o)}),{min:n,max:s}}getInteractiveMeshes(){return this.meshs.filter(e=>e.type==="Mesh")}getTransformHandleOffset(){if(!this.box)return .06;const e=this.box.min.distanceTo(this.box.max);return Math.max(e*.015,.06)}keepSingleDirectionArrow(e,t="X"){const i=e.getHelper(),n=[];i.traverse(s=>{if(s?.name!==t||!s.geometry)return;const a=s.geometry;a.boundingBox||a.computeBoundingBox();const o=a.boundingBox;if(!o)return;const l=o.getCenter(new T);if(!(t==="X"&&l.x<0||t==="Y"&&l.y<0||t==="Z"&&l.z<0))return;const c=a.parameters,h=c&&c.radiusTop===0&&c.radiusBottom===.04&&c.height===.1,d=c&&c.radiusTop===.2&&c.radiusBottom===0&&c.height===.6;(h||d)&&n.push(s)}),n.forEach(s=>{s.parent?.remove(s)})}ensureTransformControl(){if(this.transformControl&&this.transformAnchor)return;const e=this.engine.renderer?.domElement,t=this.engine.camera;if(!e||!t)return;const i=new Mt;i.name="SectionFaceTransformAnchor",i.visible=this.isActive,this.engine.scene.add(i);const n=new LE(t,e);n.name="SectionFaceTransformControl",n.setMode("translate"),n.setSpace("local"),n.showX=!0,n.showY=!1,n.showZ=!1,n.size=.85,n.enabled=this.isActive,n.attach(i),this.keepSingleDirectionArrow(n,"X"),n.addEventListener("dragging-changed",a=>{this.engine.controls.enabled=!a.value}),n.addEventListener("objectChange",this.handleTransformObjectChange);const s=n.getHelper();s.visible=this.isActive,this.engine.scene.add(s),this.transformAnchor=i,this.transformControl=n,this.transformHelper=s}setTransformControlVisible(e){this.ensureTransformControl(),this.transformControl&&(this.transformControl.enabled=e),this.transformHelper&&(this.transformHelper.visible=e),this.transformAnchor&&(this.transformAnchor.visible=e),e||(this.engine.controls.enabled=!0)}updateTransformControl(e){if(this.ensureTransformControl(),!this.transformControl||!this.transformAnchor||!this.current_center)return;const t=this.getTransformHandleOffset(),i=this.current_center.clone().add(e.clone().setLength(t)),n=new Tt().setFromUnitVectors(new T(1,0,0),e.clone().normalize());this.isSyncingTransformControl=!0,this.transformAnchor.position.copy(i),this.transformAnchor.quaternion.copy(n),this.transformAnchor.visible=this.isActive,this.transformControl.object!==this.transformAnchor&&this.transformControl.attach(this.transformAnchor),this.transformControl.enabled=this.isActive,this.transformHelper&&(this.transformHelper.visible=this.isActive),this.isSyncingTransformControl=!1}createRaycasterFromMouseEvent(e){const t=new Ln,i=new be,n=this.engine.renderer.domElement.clientWidth,s=this.engine.renderer.domElement.clientHeight;return i.x=e.offsetX/n*2-1,i.y=-(e.offsetY/s)*2+1,t.setFromCamera(i,this.engine.camera),t}attachListeners(){if(this.listenersAttached)return;const e=this.engine.renderer?.domElement;e&&(e.addEventListener("mousedown",this.handleNativeMouseDown,!0),e.addEventListener("mousemove",this.handleNativeMouseMove,!0),e.addEventListener("mouseup",this.handleNativeMouseUp,!0),window.addEventListener("keydown",this.handleNativeKeyDown),window.addEventListener("keyup",this.handleNativeKeyUp),this.listenersAttached=!0)}detachListeners(){if(!this.listenersAttached)return;const e=this.engine.renderer?.domElement;e&&(e.removeEventListener("mousedown",this.handleNativeMouseDown,!0),e.removeEventListener("mousemove",this.handleNativeMouseMove,!0),e.removeEventListener("mouseup",this.handleNativeMouseUp,!0)),window.removeEventListener("keydown",this.handleNativeKeyDown),window.removeEventListener("keyup",this.handleNativeKeyUp),this.listenersAttached=!1,this.isCtrlDown=!1}resetMeshOpacity(){this.getInteractiveMeshes().forEach(e=>{e.material&&(e.material.opacity=this.idleOpacity)})}handleMouseDown(e){const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);if(t!=null&&t.length>0){const i=t[0],n=i.point.clone();this.isDrag=!0,this.pickPoint=n;const s=(i.face?.normal?.clone()??this.normal.clone()).clone();if(s.dot(this.normal)<0&&s.multiplyScalar(-1),s.normalize(),this.pickNormal=s,this.engine.controls.enabled=!1,this.dragStartDistance=Number(this.distance)||0,s.y==0){const a=new li;a.setFromNormalAndCoplanarPoint(new T(0,1,0),n),this.plane=a}else{const a=new T(this.engine.camera.position.x,n.y,this.engine.camera.position.z),o=new li;o.setFromNormalAndCoplanarPoint(a.clone().sub(n.clone()).setLength(1),n),this.plane=o}}else this.isDrag=!1}handleMouseUp(e){this.isDrag=!1,this.pickPoint=null,this.pickNormal=null,this.plane=null,this.engine.controls.enabled=!0}handleMouseMove(e){this.resetMeshOpacity();const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);t!=null&&t.length>0&&(t[0].object.material.opacity=this.hoverOpacity);const i=this.pickPoint,n=this.pickNormal,s=this.plane;if(i!=null&&n!=null&&s!=null){const a=new T;if(e.raycaster.ray.intersectPlane(s,a)){const o=a.clone().sub(i.clone()).dot(n.clone()),l=this.getDistanceRange(this.normal.clone().normalize()),c=this.dragStartDistance+o;this.distance=Math.min(l.max,Math.max(l.min,c)),this.updata_face(this.distance)}}}}class EU{engine;callback_;constructor(e){this.engine=e}init(){this.engine.handelBehaved.init(this,{showCatch:!0}),this.engine.handelBehaved.active()}catch_face(e){this.callback_=e}handleMouseMove(e){}handleMouseClick(e){if(!e.catch?.normal||!e.catch?.point)return;let t=e.catch.normal.setLength(-1);this.engine.handelBehaved.disActive(),this.callback_({dir:t,position:e.catch.point})}}class MU{engine;clippingTolerance=1e-4;sectionBox;sectionFace;clippingStencil;currentClippingMode="";constructor(e){this.engine=e;let t=new li(new T(0,0,1),1e5);t.name="前";let i=new li(new T(0,0,1),1e5);i.name="左";let n=new li(new T(0,0,1),1e5);n.name="后";let s=new li(new T(0,0,1),1e5);s.name="右";let a=new li(new T(0,0,1),1e5);a.name="顶";let o=new li(new T(0,0,1),1e5);o.name="底";let l=new li(new T(0,0,1),1e5);l.name="face",this.engine.sectionPlane=[t,i,n,s,a,o,l]}init(){this.sectionBox=new xU(this.engine),this.sectionFace=new _U(this.engine)}scaleBox(){let e=this.engine.octreeBox.getBoundingBox();this.sectionBox.setBox(e)}clippingModel(e){let t=[];e.forEach(s=>{let a=this.engine.models.find(o=>o.url===s.url);s.ids.forEach(o=>{a.nodesMap.get(o).infos.forEach(l=>{t.push(l.box)})})}),this.active("box");let i=n(t);this.sectionBox.setBox(i);function n(s){let a=new T(1e8,1e9,1e10),o=new T(-1e8,-1e9,-1e10);return s.forEach(l=>{l.min.x<a.x&&(a.x=l.min.x),l.min.y<a.y&&(a.y=l.min.y),l.min.z<a.z&&(a.z=l.min.z),l.max.x>o.x&&(o.x=l.max.x),l.max.y>o.y&&(o.y=l.max.y),l.max.z>o.z&&(o.z=l.max.z)}),new Ft(a,o)}}updateClippingValue(e){let t=this.sectionBox.maxBox,i=t.min.x+(t.max.x-t.min.x)*e.x.min*.01,n=t.min.y+(t.max.y-t.min.y)*e.y.min*.01,s=t.min.z+(t.max.z-t.min.z)*e.z.min*.01,a=t.min.x+(t.max.x-t.min.x)*e.x.max*.01,o=t.min.y+(t.max.y-t.min.y)*e.y.max*.01,l=t.min.z+(t.max.z-t.min.z)*e.z.max*.01;this.sectionBox.setboxXyz({minX:i,minY:n,minZ:s,maxX:a,maxY:o,maxZ:l})}active(e){if(this.engine.engineStatus.isForceFree=!0,this.sectionFace.disActive(),this.sectionBox.disActive(),this.currentClippingMode=e,e=="x")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(Math.PI/2,0,0);else if(e=="y")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(0,Math.PI/2,0);else if(e=="z")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(0,0,Math.PI/2);else if(e=="box")this.sectionBox.init(),this.sectionBox.active();else if(e=="face"){let t=new EU(this.engine);t.init(),t.catch_face(i=>{this.sectionFace.init(),this.sectionFace.active();let n=this.engine.octreeBox.getBoundingBox(),s=n.min.clone().add(n.max.clone()).multiplyScalar(.5),a=i.position.clone().sub(s),o=new T(i.dir.x,i.dir.y,i.dir.z),l=a.dot(o);this.sectionFace.setFaceNormal(i.dir,l)})}}disabled(){this.currentClippingMode=="box"?this.sectionBox.disabled():this.sectionFace.disabled(),this.engine.engineStatus.isForceFree=!1}recover(){this.currentClippingMode=="box"?this.sectionBox.recover():this.sectionFace.recover()}reverse(){this.sectionFace.reverse()}disActive(){this.sectionFace.disActive(),this.sectionBox.disActive(),this.currentClippingMode="",this.engine.engineStatus.isForceFree=!1}isPointInClippingRange(e,t=this.clippingTolerance){if(!this.isVector3Like(e))return!1;const i=this.getEffectiveClippingPlanes();return i.length===0?!0:i.every(n=>n.distanceToPoint(e)>=-t)}filterIntersectionsByClipping(e,t=this.clippingTolerance){return!Array.isArray(e)||e.length===0?[]:e.filter(i=>this.isPointInClippingRange(i?.point,t))}getEffectiveClippingPlanes(){const e=Array.isArray(this.engine.sectionPlane)?this.engine.sectionPlane:[];if(this.currentClippingMode==="box")return e.slice(0,6).filter(t=>t instanceof li);if(this.currentClippingMode==="x"||this.currentClippingMode==="y"||this.currentClippingMode==="z"||this.currentClippingMode==="face"){const t=e[6];return t instanceof li?[t]:[]}return[]}isVector3Like(e){return e!=null&&typeof e.x=="number"&&typeof e.y=="number"&&typeof e.z=="number"}setSectionByView(e,t){this.sectionFace.disActive(),this.sectionBox.disActive(),this.scaleBox(),this.sectionFace.init(!0);const i=this.engine.octreeBox.getBoundingBox(),n=new T((i.min.x+i.max.x)/2,(i.min.y+i.max.y)/2,(i.min.z+i.max.z)/2),s=new T(t.x,t.y,t.z).normalize().clone().negate(),a=new T(e.x,e.y,e.z).clone().sub(n).dot(s);this.sectionFace.setFaceNormalPlaneOnly(s,a),this.sectionFace.activateClippingOnly(),this.currentClippingMode="face"}}class wU{engine;constructor(e){this.engine=e}getLevelTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeLevel,name:t.info.baseInfo.name,url:t.url})}),e}getTypeTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeType,name:t.info.baseInfo.name,url:t.url})}),e}getMajorTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeMajor,name:t.info.baseInfo.name,url:t.url})}),e}}class SU{engine;constructor(e){this.engine=e}getEngineInfo(){let e=0,t=0,i=0;return!this.engine||!this.engine.scene?{totalVertices:0,totalTriangles:0,meshCount:0}:(this.engine.scene.traverse(n=>{if(n instanceof Ge){const s=n.geometry;if(s&&s.attributes){const a=s.attributes.position;if(a){const o=a.count;e+=o;let l=0;s.index?l=s.index.count/3:l=o/3,t+=l}}}}),this.engine.engineStatus.models.forEach(n=>{i=i+(Array.isArray(n?.info?.modelEdge)?n.info.modelEdge.length:0)}),{totalVertices:Math.floor(e),totalTriangles:Math.floor(t),meshCount:i})}}class CU{engine;constructor(e){this.engine=e}init(){}getModelPropertiesWithName(e,t,i,n){let s=this.engine.engineStatus.models.find(o=>o.url===e);s.properties==null?xh(e+"/property",o=>{let l=JSON.parse(o);s.properties=l,setTimeout(()=>{a(l,i,t,n)},100)}):a(s.properties,i,t,n);function a(o,l,c,h){let d={};o.models[c.toString()||""].forEach(p=>{i.includes(o.names[p[1]])&&(d[o.names[p[1]]]=o.values[p[2]])}),h?.({id:c,properties:d})}}getModelProperties(e,t,i){let n=this.engine.engineStatus.models.find(a=>a.url===e);n.properties==null&&xh(e+"/property",a=>{let o=JSON.parse(a);n.properties=o,setTimeout(()=>{s(o,t,i)},100)}),s(n.properties,t,i);function s(a,o,l){let c=[],h=a.models[o.toString()||""],d=h.map(p=>p[0]);d=d.filter((p,u)=>d.indexOf(p)===u),d.forEach(p=>{let u={name:a.categorys[p],children:[]};c.push(u),h.filter(A=>A[0]===p).forEach(A=>{u.children.push({name:a.names[A[1]],value:a.values[A[2]]})})}),l?.({properties:c,materials:c})}}}class TU{engine;constructor(e){this.engine=e}getModelTypes(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.typeName)})}),e=e.filter((t,i,n)=>n.indexOf(t)===i),e}getModelMajors(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.majorName)})}),e=e.filter((t,i,n)=>n.indexOf(t)===i),e}getModelLevels(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.levelName)})}),e=e.filter((t,i,n)=>n.indexOf(t)===i),e}getModelMappers(e){}getModelMapper(e,t){let i=this.engine.engineStatus.models.find(n=>n.url==e);return i?i.info.modelMapper.find(n=>n.id==t):null}getModelsWithLevelType(e,t,i=null){let n=[];return this.engine.engineStatus.models.forEach(s=>{let a={url:s.url,ids:[]};n.push(a),s.info.modelMapper.filter(o=>o.levelName===e&&o.typeName===t).forEach(o=>{a.ids.push(Number(o.id))})}),i&&i(n),n}getModelsWithType(e,t=null){let i=[];return this.engine.engineStatus.models.forEach(n=>{let s={url:n.url,ids:[]};i.push(s),n.info.modelMapper.filter(a=>a.typeName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(i),i}getModelsWithLevel(e,t){let i=[];return this.engine.engineStatus.models.forEach(n=>{let s={url:n.url,ids:[]};i.push(s),n.info.modelMapper.filter(a=>a.levelName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(i),i}getModelsWithMajor(e,t){let i=[];return this.engine.engineStatus.models.forEach(n=>{let s={url:n.url,ids:[]};i.push(s),n.info.modelMapper.filter(a=>a.majorName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(i),i}}class IU{engine;isActive=!1;groupEdge;material;modelEdgeLoaded=!1;modelEdgeLoadingPromise=null;indexes=new Map;constructor(e){this.engine=e,this.groupEdge=this.engine.scene.getObjectByName("groupEdge"),this.material=new si({color:"#000000",depthTest:!0,transparent:!0,opacity:.3}),this.material.clippingPlanes=this.engine.sectionPlane}active(){this.isActive=!0,this.groupEdge.visible=!0,this.engine.scene.traverse(e=>{e.isMesh&&e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(t=>{t.polygonOffset=!0,t.polygonOffsetFactor=1,t.polygonOffsetUnits=4})}),this.show()}disActive(){this.isActive=!1,this.groupEdge.visible=!1,this.engine.scene.traverse(e=>{e.isMesh&&e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(t=>{t.polygonOffset=!1})})}hasPendingModelEdges(){return(this.engine?.engineStatus?.models??[]).some(e=>!this.indexes.has(e.url))}loadZipJsonAsync(e){return new Promise((t,i)=>{xh(e,n=>{if(n==null){i(new Error(`[ModelEdge] empty edge zip: ${e}`));return}t(n)},()=>{i(new Error(`[ModelEdge] failed to load edge zip: ${e}`))})})}async ensureModelEdgeData(e){const t=e?.info??{};if(Array.isArray(t.modelEdge))return t.modelEdge;try{const i=await this.loadZipJsonAsync(e.url+"/edge"),n=JSON.parse(i);t.modelEdge=Array.isArray(n)?n:[]}catch(i){console.error("[ModelEdge] failed to load model edge",{url:e?.url,error:i}),t.modelEdge=[]}return t.modelEdge}async loadModelEdge(){if(!(this.modelEdgeLoaded&&!this.hasPendingModelEdges())){if(this.modelEdgeLoadingPromise!=null){await this.modelEdgeLoadingPromise;return}this.modelEdgeLoadingPromise=(async()=>{const e=this.engine?.engineStatus?.models??[];for(const t of e){if(this.indexes.has(t.url))continue;const i=await this.ensureModelEdgeData(t),n=[],s=new Map;i.forEach(a=>{if(!Array.isArray(a?.points))return;const o=n.length;for(let l=0;l<a.points.length;l++)a.points[l]?.length===2&&(n.push(a.points[l][0].X),n.push(a.points[l][0].Z),n.push(-a.points[l][0].Y),n.push(a.points[l][1].X),n.push(a.points[l][1].Z),n.push(-a.points[l][1].Y));s.set(Number(a.id),[o,n.length,a.points])}),this.indexes.set(t.url,s)}this.modelEdgeLoaded=!this.hasPendingModelEdges()})().finally(()=>{this.modelEdgeLoadingPromise=null}),await this.modelEdgeLoadingPromise}}async show(){await this.loadModelEdge(),this.isActive&&this.indexes.forEach((e,t)=>{const i=this.groupEdge.children.find(o=>o.url==t);if(i){i.visible=!0;return}const n=[];if(e.forEach(o=>{o[2].forEach(l=>{l?.length===2&&(n.push(l[0].X),n.push(l[0].Z),n.push(-l[0].Y),n.push(l[1].X),n.push(l[1].Z),n.push(-l[1].Y))})}),n.length===0)return;const s=new ot;s.setAttribute("position",new tt(n,3));const a=new vi(s,this.material);a.url=t,this.groupEdge.add(a)})}getModelEdge(e,t){const i=this.indexes.get(e);if(i){const n=i.get(Number(t));if(n)return n.slice()}return this.loadModelEdge(),null}hideModelEdge(e,t){const i=this.indexes.get(e);if(!i){this.loadModelEdge();return}const n=i.get(Number(t));if(n){const[s,a]=n,o=this.groupEdge.children.find(l=>l.url==e);if(o){const l=o.geometry.attributes.position.array;for(let c=s;c<a;c++)l[c]=NaN;o.geometry.attributes.position.needsUpdate=!0}}}setOpacity(e){this.material.opacity=e}showModelEdge(e,t){const i=this.indexes.get(e);if(!i){this.loadModelEdge();return}const n=i.get(Number(t));if(n){const[s,a,o]=n,l=this.groupEdge.children.find(c=>c.url==e);if(l){const c=l.geometry.attributes.position.array;let h=0;for(let d=s;d<a;d+=3){const p=Math.floor(h/6),u=h%6>=3;if(o[p]&&o[p].length===2){const A=u?o[p][1]:o[p][0];c[d]=A.X,c[d+1]=A.Z,c[d+2]=-A.Y}h+=3}l.geometry.attributes.position.needsUpdate=!0}}}}class PU{config;constructor(e){this.config={temperature:.7,maxTokens:2e4,timeout:3e5,...e}}async chat(e){const t=new AbortController,i=setTimeout(()=>t.abort(),this.config.timeout);try{const n=await fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({model:this.config.model,messages:e,temperature:this.config.temperature,max_tokens:this.config.maxTokens,stream:!1}),signal:t.signal});if(clearTimeout(i),!n.ok){const s=await n.json().catch(()=>({}));throw new Error(`API请求失败 (${n.status}): ${s.error?.message||s.message||n.statusText}`)}return(await n.json()).choices?.[0]?.message?.content||""}catch(n){throw clearTimeout(i),n.name==="AbortError"?new Error("请求超时,请重试"):n.message.includes("Failed to fetch")?new Error(`网络请求失败,请检查:
|
||
1. 网络连接
|
||
2. API地址是否正确
|
||
3. 是否有CORS限制`):n}}async chatStream(e,t){const i=new AbortController,n=setTimeout(()=>i.abort(),this.config.timeout);try{const s=await fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({model:this.config.model,messages:e,temperature:this.config.temperature,max_tokens:this.config.maxTokens,stream:!0}),signal:i.signal});if(clearTimeout(n),!s.ok){const c=await s.json().catch(()=>({}));throw new Error(`API请求失败 (${s.status}): ${c.error?.message||c.message||s.statusText}`)}const a=s.body?.getReader();if(!a)throw new Error("无法读取响应流");const o=new TextDecoder;let l="";for(;;){const{done:c,value:h}=await a.read();if(c){t("",!0);break}l+=o.decode(h,{stream:!0});const d=l.split(`
|
||
`);l=d.pop()||"";for(const p of d){const u=p.trim();if(!u||!u.startsWith("data: "))continue;const A=u.slice(6);if(A!=="[DONE]")try{const m=JSON.parse(A).choices?.[0]?.delta?.content;m&&t(m,!1)}catch(m){console.warn("解析流式数据失败:",m)}}}}catch(s){throw clearTimeout(n),s.name==="AbortError"?new Error("请求超时,请重试"):s.message.includes("Failed to fetch")?new Error("网络请求失败,请检查网络连接"):s}}updateConfig(e){this.config={...this.config,...e}}getConfig(){return{...this.config}}}class RU{engine;steps=[];stepResults=new Map;conversationHistory=[];state="idle";llmApi=null;config=null;_callback_message;_callback_question;_callback_content;prompts={};constructor(e){this.engine=e}async init(e,t,i){this._callback_message=e,this._callback_question=t,this._callback_content=i,this.conversationHistory=[];let n={llmConfig:{baseURL:"https://open.bigmodel.cn/api/coding/paas/v4",apiKey:"4041336a72f14d8fa3800bd651a80fec.vZWUxssXOXB37vlV",model:"GLM-4.5-Air",temperature:.7,maxTokens:2e3},debug:!0,stepExecution:{maxRetries:5},prompts:{main:"",step:"",apiDoc:""}};try{this.config=n,this.llmApi=new PU(n.llmConfig);try{const s=await Promise.resolve().then(()=>R9);this.prompts.main=s.default;const a=await Promise.resolve().then(()=>D9);this.prompts.step=a.default;const o=await Promise.resolve().then(()=>B9);this.prompts.apiDoc=o.default}catch(s){throw console.error("[AI Manager] 提示词文件加载失败:",s),new Error(`提示词文件加载失败: ${s.message||"未知错误"}`)}}catch(s){throw console.error("[AI Manager] 初始化失败:",s),s}}async conversationV2(e){if(this.conversationHistory.length===0){const n={role:"system",content:`${this.prompts.main}`},s={role:"system",content:`## BIM引擎API文档
|
||
${this.prompts.apiDoc}`};this.conversationHistory.push(n),this.conversationHistory.push(s)}this.conversationHistory.push({role:"user",content:e});const t=await this.llmApi.chat(this.conversationHistory);this.conversationHistory.push({role:"assistant",content:t}),this.config?.debug&&console.log("[AI Manager] 大模型响应:",t);let i=await this.parseAnalysisResponse(t);i&&i.questions&&i.questions.length>0&&this._callback_question(i.questions)}async parseAnalysisResponse(e){try{if(e.includes("##question##")){const t=e.match(/##question##\s*([\s\S]*?)(?=##|$)/);if(t){let i=t[1].trim();i=i.replace(/^```json\n?/,"").replace(/^```\n?/,"").replace(/\n?```$/,"");const n=i.match(/(\[[\s\S]*\])/);n&&(i=n[1]);const s=JSON.parse(i);return this.state="waiting_answer",{state:"waiting_answer",questions:s}}}if(e.includes("##steps##")){const t=e.match(/##steps##\s*([\s\S]*?)(?=##|$)/);if(t){let i=t[1].trim();i=i.replace(/^```json\n?/,"").replace(/^```\n?/,"").replace(/\n?```$/,"");const n=i.match(/(\[[\s\S]*\])/);return n&&(i=n[1]),this.steps=JSON.parse(i),this.config?.debug&&console.log("[AI Manager] 步骤规划完成,共",this.steps.length,"个步骤"),this._callback_message(this.steps),await this.executeSteps()}}return{state:"completed",data:e}}catch(t){return console.error("[AI Manager] 解析响应失败:",t),{state:"error",error:"解析大模型响应失败: "+t.message}}}async executeSteps(){try{this.state="executing",this.stepResults.clear();for(const e of this.steps){this._callback_message(e),this.config?.debug&&console.log(`[AI Manager] 执行步骤 ${e.id}: ${e.content}`);const t=await this.getDependenciesOutput(e.dependencies),i=await this.executeStep(e,t);this.stepResults.set(e.id,i),this.config?.debug&&console.log(`[AI Manager] 步骤 ${e.id} 执行完成:`,i)}return this.state="completed",{state:"completed",steps:this.steps,result:Array.from(this.stepResults.values())}}catch(e){return console.error("[AI Manager] 步骤执行失败:",e),{state:"error",error:"步骤执行失败: "+e.message}}}async getDependenciesOutput(e){return e.length===0?null:e.length===1?this.stepResults.get(e[0]):e.map(t=>this.stepResults.get(t))}async executeStep(e,t){const i=this.config?.stepExecution?.maxRetries??1,n=[];let s=null,a=!1;for(let o=0;o<=i;o++)try{const l=n.length>0?n[n.length-1]:"",c=await(o===0?this.generateCode(e,t):a?this.regenerateCodeAfterFailure(e,t,l,s,o):this.generateCode(e,t));n.push(c),this.config?.debug&&console.log(`[AI Manager] 步骤 ${e.id} 第 ${o+1} 次生成的代码:
|
||
${c}`);try{const h=await this.executeCode(c,t);if(h instanceof Object&&h.success==!1||h instanceof String&&(h.includes("undefined")||h.includes("not"))){s=h,a=!0;debugger;throw h}debugger;return h}catch(h){debugger;throw s=h,a=!0,h}}catch(l){if(a||(s=l),o>=i)throw console.error(`[AI Manager] 执行步骤 ${e.id} 失败(已达重试上限):`,l),new Error(`步骤 ${e.id} (${e.content}) 执行失败: ${l.message}`);console.warn(`[AI Manager] 步骤 ${e.id} 第 ${o+1} 次执行失败,将尝试让AI修复后重试(剩余重试次数:${i-o}):`,l)}throw new Error(`步骤 ${e.id} (${e.content}) 执行失败: 未知错误`)}extractCodeFromResponse(e){const t=e.match(/##code##\s*([\s\S]*?)(?=##|$)/);if(t){let a=t[1].trim();if(a=a.replace(/^```javascript\n?/,"").replace(/^```js\n?/,"").replace(/^```\n?/,"").replace(/\n?```$/,""),a.length>0)return a}const i=[/```javascript\s*([\s\S]*?)```/i,/```js\s*([\s\S]*?)```/i,/```\s*([\s\S]*?)```/];for(const a of i){const o=e.match(a);if(o&&o[1]){const l=o[1].trim();if(l.length>0)return this.config?.debug&&console.warn("[AI Manager] 未找到 ##code## 标记,从 markdown 代码块中提取代码"),l}}const n=/[请|说明|注意|需要|应该|可以|如果|但是|因为|所以|例如|比如]/i.test(e),s=/(function|const|let|var|return|async|await|=>|engine\.|previousStepOutput)/.test(e);if(!n&&s){const a=e.trim().replace(/^[,。:;!?\s]+/,"").replace(/[,。:;!?\s]+$/,"");if(a.length>10)return this.config?.debug&&console.warn("[AI Manager] 未找到 ##code## 标记和代码块,尝试使用整个响应作为代码"),a}throw new Error(`无法从大模型响应中提取代码。响应内容:${e.substring(0,200)}...`)}async generateCode(e,t){try{const i={role:"system",content:`${this.prompts.step}`},n={role:"system",content:`
|
||
|
||
## BIM引擎API文档
|
||
${this.prompts.apiDoc}`},s={role:"user",content:`请根据以下步骤描述生成可执行的JavaScript代码:
|
||
|
||
步骤信息:
|
||
${JSON.stringify(e,null,2)}
|
||
|
||
前序步骤输出数据:
|
||
${t?JSON.stringify(t,null,2):"null"}
|
||
|
||
请严格按照##code##格式输出代码。`},a=[i,n,s],o=await this.llmApi.chat(a);return this.extractCodeFromResponse(o)}catch(i){throw console.error("[AI Manager] 代码生成失败:",i),i}}async regenerateCodeAfterFailure(e,t,i,n,s){try{const a={role:"system",content:`${this.prompts.step}`},o={role:"system",content:`
|
||
|
||
## BIM引擎API文档
|
||
${this.prompts.apiDoc}`},l={message:n?.message||(n instanceof Object?JSON.stringify(n):String(n)),name:n?.name,stack:n?.stack},c={role:"user",content:`上一次生成的代码在执行时失败了,请你修复后重新输出完整可执行的 JavaScript 代码(仍然要严格按 ##code## 格式输出)。
|
||
|
||
当前步骤信息:
|
||
${JSON.stringify(e,null,2)}
|
||
|
||
前序步骤输出数据:
|
||
${t?JSON.stringify(t,null,2):"null"}
|
||
|
||
上一次生成的代码:
|
||
${i?`
|
||
\`\`\`javascript
|
||
${i}
|
||
\`\`\`
|
||
`:`
|
||
(无)
|
||
`}
|
||
|
||
执行错误信息(第 ${s} 次重试前):
|
||
${JSON.stringify(l,null,2)}
|
||
|
||
修复要求(请务必遵守):
|
||
1) 不要输出解释文字,只输出 ##code## 段落里的代码
|
||
2) 如果是语法错误/引用未定义/缺少 await/返回值不一致,请直接修复
|
||
3) 尽量保持与步骤目标一致,避免引入与步骤无关的副作用
|
||
4) 代码需要能在浏览器环境运行(不要使用 Node 专属 API)`},h=await this.llmApi.chat([a,o,c]);try{return this.extractCodeFromResponse(h)}catch(d){throw new Error(`无法从大模型响应中提取代码(修复重试阶段):${d.message}`)}}catch(a){throw console.error("[AI Manager] 修复后代码生成失败:",a),a}}async executeCode(e,t){try{const i=this.engine;let n=e;n=n.replace(/\b(const|let|var)\s+previousStepOutput\s*=\s*[^;]*;/g,""),n=n.replace(/\b(const|let|var)\s+previousStepOutput\s*;/g,"");const s=new Function("engine","previousStepOutput",`
|
||
'use strict';
|
||
${n}
|
||
`)(i,t);return s&&typeof s.then=="function"?await s:s}catch(i){return console.error("[AI Manager] 代码执行失败:",i),"error"+i.message}}reset(){this.conversationHistory=[],this.steps=[],this.stepResults.clear(),this.state="idle",this.config?.debug&&console.log("[AI Manager] 对话已重置")}getState(){return this.state}getHistory(){return[...this.conversationHistory]}getSteps(){return[...this.steps]}getStepResults(){return new Map(this.stepResults)}}class DU{engine;points=[];isPlaying=!1;animationFrameId=null;playStartTime=0;playFromIndex=0;playToIndex=0;playOptions={};stayTimerId=null;playRangeToIndex=0;constructor(e){this.engine=e}init(){this.points=[],this.stop()}getCurrentPoint(){return{...this.engine.cameraModule.getCameraPose(),stayTime:0}}addPoint(e=0){const t=this.getCurrentPoint();return t.stayTime=e,this.points.push(t),this.points.length}addPoints(e){for(const t of e)this.points.push({...t});return this.points.length}savePoints(e){return this.addPoints(e)}removePoint(e){return e>=0&&e<this.points.length?(this.points.splice(e,1),!0):!1}clearPoints(){this.stop(),this.points=[]}getPoints(){return[...this.points]}getPointCount(){return this.points.length}updatePoint(e,t){return e>=0&&e<this.points.length?(this.points[e]={...t},!0):!1}jumpToPoint(e){return e>=0&&e<this.points.length?(this.stop(),this.engine.cameraModule.restoreCameraPose(this.points[e]),!0):!1}play(e={}){return this.points.length<2?(console.warn("PathRoaming: 至少需要2个点位才能播放"),!1):(this.isPlaying&&this.stop(),this.isPlaying=!0,this.playOptions={duration:3e3,loop:!1,...e},this.engine.controlModule.disActive(),this.playFromIndex=0,this.playToIndex=1,this.playRangeToIndex=this.points.length-1,this.playStartTime=performance.now(),this.animate(),!0)}playRange(e,t,i={}){return e<0||t>=this.points.length||e>=t?(console.warn("PathRoaming: 无效的索引范围"),!1):this.points.length<2?(console.warn("PathRoaming: 至少需要2个点位才能播放"),!1):(this.isPlaying&&this.stop(),this.isPlaying=!0,this.playOptions={duration:3e3,loop:!1,...i},this.engine.controlModule.disActive(),this.playFromIndex=e,this.playToIndex=e+1,this.playStartTime=performance.now(),this.playRangeToIndex=t,this.animate(),!0)}stop(){this.isPlaying=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.stayTimerId!==null&&(clearTimeout(this.stayTimerId),this.stayTimerId=null),this.engine.controlModule.active()}pause(){this.isPlaying&&(this.isPlaying=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.stayTimerId!==null&&(clearTimeout(this.stayTimerId),this.stayTimerId=null))}getIsPlaying(){return this.isPlaying}animate=()=>{if(!this.isPlaying)return;const e=performance.now()-this.playStartTime,t=this.playOptions.duration||3e3,i=Math.min(e/t,1),n=this.points[this.playFromIndex],s=this.points[this.playToIndex],a=this.interpolatePose(n,s,i);this.engine.cameraModule.restoreCameraPose(a),i>=1?this.onSegmentComplete():this.animationFrameId=requestAnimationFrame(this.animate)};onSegmentComplete(){const e=this.playToIndex;this.playOptions.onPointComplete&&this.playOptions.onPointComplete(e);const t=this.points[e];t.stayTime&&t.stayTime>0?this.stayTimerId=globalThis.setTimeout(()=>{this.stayTimerId=null,this.moveToNextSegment()},t.stayTime):this.moveToNextSegment()}moveToNextSegment(){const e=this.playToIndex>=this.playRangeToIndex,t=this.playToIndex>=this.points.length-1;e||t?this.playOptions.loop&&this.points.length>=2?(this.playFromIndex=0,this.playToIndex=1,this.playRangeToIndex=this.points.length-1,this.playStartTime=performance.now(),this.animate()):this.onPlayComplete():(this.playFromIndex=this.playToIndex,this.playToIndex=this.playToIndex+1,this.playStartTime=performance.now(),this.animate())}onPlayComplete(){this.stop(),this.playOptions.onComplete&&this.playOptions.onComplete()}interpolatePose(e,t,i){const n=this.easeInOutCubic(i),s={type:t.type,position:{x:Dt.lerp(e.position.x,t.position.x,n),y:Dt.lerp(e.position.y,t.position.y,n),z:Dt.lerp(e.position.z,t.position.z,n)},rotation:{x:Dt.lerp(e.rotation.x,t.rotation.x,n),y:Dt.lerp(e.rotation.y,t.rotation.y,n),z:Dt.lerp(e.rotation.z,t.rotation.z,n)},quaternion:{x:Dt.lerp(e.quaternion.x,t.quaternion.x,n),y:Dt.lerp(e.quaternion.y,t.quaternion.y,n),z:Dt.lerp(e.quaternion.z,t.quaternion.z,n),w:Dt.lerp(e.quaternion.w,t.quaternion.w,n)}};return e.target&&t.target?s.target={x:Dt.lerp(e.target.x,t.target.x,n),y:Dt.lerp(e.target.y,t.target.y,n),z:Dt.lerp(e.target.z,t.target.z,n)}:t.target&&(s.target={...t.target}),e.zoom!==void 0&&t.zoom!==void 0&&(s.zoom=Dt.lerp(e.zoom,t.zoom,n)),e.orthographicHeight!==void 0&&t.orthographicHeight!==void 0?s.orthographicHeight=Dt.lerp(e.orthographicHeight,t.orthographicHeight,n):t.orthographicHeight!==void 0&&(s.orthographicHeight=t.orthographicHeight),s}easeInOutCubic(e){return e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2}dispose(){this.stop(),this.points=[],this.playOptions={}}}class BU{engine;miniMapCamera=null;miniMapRenderer=null;miniMapContainer=null;overlayCanvas=null;overlayCtx=null;isVisible=!1;mapSize=200;currentHalfSize=100;minHalfSize=5;maxHalfSize=1e4;halfSizeInitialized=!1;camY=1e3;centerX=0;centerZ=0;dragMode=null;lastMouseX=0;lastMouseY=0;constructor(e){this.engine=e,this.init()}getstate(){return this.isVisible}init(){this.miniMapContainer=document.createElement("div"),this.miniMapContainer.style.position="absolute",this.miniMapContainer.style.bottom="20px",this.miniMapContainer.style.left="20px",this.miniMapContainer.style.width=`${this.mapSize}px`,this.miniMapContainer.style.height=`${this.mapSize}px`,this.miniMapContainer.style.border="2px solid rgba(255, 255, 255, 0.4)",this.miniMapContainer.style.borderRadius="4px",this.miniMapContainer.style.overflow="hidden",this.miniMapContainer.style.display="none",this.miniMapContainer.style.zIndex="200",this.miniMapContainer.style.pointerEvents="auto",this.miniMapContainer.style.cursor="crosshair",this.engine.container.appendChild(this.miniMapContainer),this.miniMapRenderer=new $c({alpha:!0,antialias:!1}),this.miniMapRenderer.setSize(this.mapSize,this.mapSize),this.miniMapRenderer.setPixelRatio(window.devicePixelRatio),this.miniMapRenderer.setClearColor(1710638,.85),this.miniMapContainer.appendChild(this.miniMapRenderer.domElement);const e=window.devicePixelRatio||1;this.overlayCanvas=document.createElement("canvas"),this.overlayCanvas.width=this.mapSize*e,this.overlayCanvas.height=this.mapSize*e,this.overlayCanvas.style.position="absolute",this.overlayCanvas.style.top="0",this.overlayCanvas.style.left="0",this.overlayCanvas.style.width=`${this.mapSize}px`,this.overlayCanvas.style.height=`${this.mapSize}px`,this.overlayCanvas.style.pointerEvents="none",this.miniMapContainer.appendChild(this.overlayCanvas),this.overlayCtx=this.overlayCanvas.getContext("2d"),this.overlayCtx&&this.overlayCtx.scale(e,e),this.miniMapCamera=new Ki(-this.currentHalfSize,this.currentHalfSize,this.currentHalfSize,-this.currentHalfSize,.1,1e3),this.miniMapCamera.up.set(0,0,-1),this.setupEvents()}worldToPixel(e,t){const i=this.currentHalfSize;return{x:((e-this.centerX)/i*.5+.5)*this.mapSize,y:((t-this.centerZ)/i*.5+.5)*this.mapSize}}pixelToWorld(e,t){const i=this.currentHalfSize;return{x:(e/this.mapSize-.5)*2*i+this.centerX,z:(t/this.mapSize-.5)*2*i+this.centerZ}}setupEvents(){const e=this.miniMapContainer;e.addEventListener("wheel",this.onWheel,{passive:!1}),e.addEventListener("mousedown",this.onMouseDown),e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("mouseup",this.onMouseUp),e.addEventListener("mouseleave",this.onMouseUp),e.addEventListener("contextmenu",t=>t.preventDefault()),["pointerdown","pointermove","pointerup","click","dblclick"].forEach(t=>e.addEventListener(t,i=>i.stopPropagation()))}onWheel=e=>{e.preventDefault(),e.stopPropagation();const t=e.deltaY>0?1.25:.8;this.currentHalfSize=Math.max(this.minHalfSize,Math.min(this.maxHalfSize,this.currentHalfSize*t))};onMouseDown=e=>{e.stopPropagation();const t=this.miniMapContainer.getBoundingClientRect(),i=e.clientX-t.left,n=e.clientY-t.top,s=this.engine.camera;if(!s)return;const{x:a,y:o}=this.worldToPixel(s.position.x,s.position.z);Math.hypot(i-a,n-o)<25?(this.dragMode="rotate",this.miniMapContainer.style.cursor="alias"):(this.dragMode=null,this.handleTeleport(i,n)),this.lastMouseX=i,this.lastMouseY=n};onMouseMove=e=>{if(e.stopPropagation(),this.dragMode!=="rotate")return;const t=this.miniMapContainer.getBoundingClientRect(),i=e.clientX-t.left,n=e.clientY-t.top;this.handleRotate(i,n),this.lastMouseX=i,this.lastMouseY=n};onMouseUp=e=>{e.stopPropagation(),this.dragMode=null,this.miniMapContainer&&(this.miniMapContainer.style.cursor="crosshair")};handleTeleport(e,t){const i=this.engine.camera,n=this.engine.controls;if(!i||!n)return;const{x:s,z:a}=this.pixelToWorld(e,t),o=s-i.position.x,l=a-i.position.z;i.position.x+=o,i.position.z+=l,n.target.x+=o,n.target.z+=l,n.update()}handleRotate(e,t){const i=this.engine.camera,n=this.engine.controls;if(!i||!n)return;const s=this.mapSize/2,a=this.mapSize/2,o=Math.atan2(this.lastMouseY-a,this.lastMouseX-s);let l=Math.atan2(t-a,e-s)-o;l>Math.PI&&(l-=2*Math.PI),l<-Math.PI&&(l+=2*Math.PI);const c=new T().copy(n.target).sub(i.position),h=new rl().setFromVector3(c);h.theta-=l,c.setFromSpherical(h),n.target.copy(i.position).add(c),n.update()}drawOverlay(){const e=this.overlayCtx,t=this.engine.camera;if(!e||!t)return;e.clearRect(0,0,this.mapSize,this.mapSize);const i=this.mapSize/2,n=this.mapSize/2,s=new T;t.getWorldDirection(s);const a=Math.atan2(s.x,-s.z),o=36,l=Math.PI/10;e.save(),e.translate(i,n),e.rotate(a);const c=e.createRadialGradient(0,0,2,0,0,o);c.addColorStop(0,"rgba(0, 230, 130, 0.9)"),c.addColorStop(1,"rgba(0, 230, 130, 0)");const h=-Math.sin(l)*o,d=-Math.cos(l)*o,p=Math.sin(l)*o,u=-Math.cos(l)*o;e.beginPath(),e.moveTo(0,0),e.lineTo(h,d),e.lineTo(p,u),e.closePath(),e.fillStyle=c,e.fill(),e.fillStyle="rgba(255, 255, 255, 0.95)",e.strokeStyle="rgba(0, 200, 110, 0.9)",e.lineWidth=1.5,e.beginPath(),e.arc(0,0,4,0,Math.PI*2),e.fill(),e.stroke(),e.restore()}show(){this.isVisible=!0,this.miniMapContainer&&(this.miniMapContainer.style.display="block")}hide(){this.isVisible=!1,this.miniMapContainer&&(this.miniMapContainer.style.display="none")}toggle(){this.isVisible?this.hide():this.show()}update(){if(!this.isVisible||!this.miniMapCamera||!this.miniMapRenderer)return;const e=this.engine.camera;if(!(!e||!this.engine.scene)){if(this.engine.octreeBox){const t=this.engine.octreeBox.getBoundingBox();if(t?.min&&t?.max){const i=t.max.x-t.min.x,n=t.max.z-t.min.z,s=t.max.y-t.min.y;this.camY=t.max.y+Math.max(i,n,s),!this.halfSizeInitialized&&i+n>0&&(this.currentHalfSize=Math.max(i,n)*2,this.halfSizeInitialized=!0)}}this.centerX=e.position.x,this.centerZ=e.position.z,this.miniMapCamera.left=-this.currentHalfSize,this.miniMapCamera.right=this.currentHalfSize,this.miniMapCamera.top=this.currentHalfSize,this.miniMapCamera.bottom=-this.currentHalfSize,this.miniMapCamera.updateProjectionMatrix(),this.miniMapCamera.position.set(this.centerX,this.camY,this.centerZ),this.miniMapCamera.lookAt(this.centerX,this.camY-1,this.centerZ),this.miniMapRenderer.render(this.engine.scene,this.miniMapCamera),this.drawOverlay()}}dispose(){this.miniMapContainer&&(this.miniMapContainer.removeEventListener("wheel",this.onWheel),this.miniMapContainer.removeEventListener("mousedown",this.onMouseDown),this.miniMapContainer.removeEventListener("mousemove",this.onMouseMove),this.miniMapContainer.removeEventListener("mouseup",this.onMouseUp),this.miniMapContainer.removeEventListener("mouseleave",this.onMouseUp)),this.miniMapRenderer&&(this.miniMapRenderer.dispose(),this.miniMapRenderer=null),this.miniMapContainer&&(this.miniMapContainer.remove(),this.miniMapContainer=null),this.miniMapCamera=null,this.overlayCtx=null,this.overlayCanvas=null}}const LU=Dt.degToRad(10),OE=.001,kU=[];class NU{engine;rootGroup=null;isVisible=!1;axes=[];coordinateMapper=e=>new T(e.X,e.Z,-e.Y);constructor(e){this.engine=e,this._initRoot()}setData(e=[]){this._clearAxes(),this.axes=e.map(t=>({data:t,group:null})),this.axes.forEach(t=>this._buildAxis(t))}setMockData(){const e=this.engine.models?.[0]?.grids;this.setData(Array.isArray(e)&&e.length>0?e:kU)}show(){this.isVisible=!0,this.rootGroup&&(this.rootGroup.visible=!0)}hide(){this.isVisible=!1,this.rootGroup&&(this.rootGroup.visible=!1)}toggle(){if(this.isVisible){this.hide();return}this.show()}update(){if(!this.isVisible||!this.rootGroup)return;const e=this.engine.camera,t=this.engine.renderer;if(!e||!t)return;let i=.5;if(e instanceof Ki){const n=(e.top-e.bottom)/e.zoom,s=t.domElement.clientHeight||1;i=30*n/s}this.rootGroup.traverse(n=>{n instanceof Rc&&n.scale.set(i,i,1)})}getLocationByPoint(e,t){const{url:i,targetPoint:n}=this.resolvePointLookupArgs(e,t),s=this.getGridData(i);debugger;if(s.length===0)return null;const a=this.toVector3(n),o=new be(a.x,a.z),l=this.buildAxisFamilies(s).sort((p,u)=>u.axes.length-p.axes.length).slice(0,2).map((p,u)=>({...p,familyIndex:u}));if(l.length===0)return null;const c=l.map(p=>this.resolveFamilyLocation(p,o)),h=this.sortFamiliesForDisplay(c),d=h.length===2&&h.every(p=>p.isInside);return{point:{x:a.x,y:a.y,z:a.z},description:this.formatGridDescription(h),families:h,isInside:d}}dispose(){this._clearAxes(),this.rootGroup&&(this.engine.scene&&this.engine.scene.remove(this.rootGroup),this.rootGroup=null)}_initRoot(){this.rootGroup=new Mi,this.rootGroup.name="GridRoot",this.rootGroup.visible=!1,this.engine.scene&&this.engine.scene.add(this.rootGroup)}_clearAxes(){this.axes.forEach(e=>{e.group&&(this.rootGroup?.remove(e.group),e.group.traverse(t=>{const i=t;if("geometry"in i&&i.geometry&&i.geometry.dispose(),"material"in i&&i.material){const n=i.material;"map"in n&&n.map&&n.map.dispose(),n.dispose()}}),e.group=null)}),this.axes=[]}_buildAxis(e){if(!this.rootGroup)return;const t=this.coordinateMapper(e.data.Points[0]),i=this.coordinateMapper(e.data.Points[1]),n=new Mi;n.name=`GridAxis_${e.data.Id}`;const s=new ot().setFromPoints([t,i]),a=new si({color:1609983,depthTest:!1}),o=new di(s,a);o.renderOrder=998,n.add(o),n.add(this._makeCircleSprite(e.data.Name,t)),n.add(this._makeCircleSprite(e.data.Name,i)),this.rootGroup.add(n),e.group=n}_makeCircleSprite(e,t){const i=document.createElement("canvas");i.width=128,i.height=128;const n=i.getContext("2d");if(!n)throw new Error("Grid sprite canvas context is not available");const s=128/2,a=128/2,o=128/2-4;n.beginPath(),n.arc(s,a,o,0,Math.PI*2),n.fillStyle="white",n.fill(),n.strokeStyle="#1890ff",n.lineWidth=6,n.stroke(),n.fillStyle="#1890ff",n.font=`bold ${Math.round(128*.38)}px Arial`,n.textAlign="center",n.textBaseline="middle",n.fillText(e,s,a);const l=new eb(i),c=new Vd({map:l,depthTest:!1,transparent:!0}),h=new Rc(c);return h.position.copy(t),h.scale.set(.5,.5,1),h.renderOrder=999,h}getGridData(e){if(e){const i=this.findModelByUrl(e);return Array.isArray(i?.grids)?i.grids:[]}if(this.axes.length>0)return this.axes.map(i=>i.data);if(!Array.isArray(this.engine.models))return[];const t=[];return this.engine.models.forEach(i=>{Array.isArray(i.grids)&&t.push(...i.grids)}),t}resolvePointLookupArgs(e,t){if(typeof e=="string"){if(!t)throw new Error("Grid.getLocationByPoint(url, point) requires a point argument.");return{url:e,targetPoint:t}}return{targetPoint:e}}findModelByUrl(e){return this.engine.models?.find(t=>t.url===e)}buildAxisFamilies(e){const t=[];return e.forEach(i=>{const n=this.createProjection(i);if(!n)return;const s=t.find(a=>a.direction.angleTo(n.direction)<=LU);if(s){s.axes.push(n);return}t.push({familyIndex:t.length,direction:n.direction.clone(),normal:new be(-n.direction.y,n.direction.x),axes:[n]})}),t.forEach(i=>{i.axes.sort((n,s)=>n.offset-s.offset)}),t}createProjection(e){const t=this.coordinateMapper(e.Points[0]),i=this.coordinateMapper(e.Points[1]),n=new be(t.x,t.z),s=new be(i.x,i.z),a=s.clone().sub(n);if(a.lengthSq()<=Number.EPSILON)return null;const o=this.normalizeDirection(a),l=new be(-o.y,o.x);return{data:e,start:n,end:s,direction:o,offset:n.dot(l)}}normalizeDirection(e){const t=e.clone().normalize();return(t.x<0||Math.abs(t.x)<=OE&&t.y<0)&&t.multiplyScalar(-1),t}resolveFamilyLocation(e,t){const i=t.dot(e.normal),n=e.axes.find(c=>Math.abs(c.offset-i)<=OE)??null;if(n){const c=e.axes.findIndex(d=>d.data.Id===n.data.Id),h=this.pickAxisPairAroundIndex(e.axes,c);return{familyIndex:e.familyIndex,description:h?this.formatAxisPair(h[0].data.Name,h[1].data.Name):n.data.Name,startAxisName:h?.[0].data.Name??n.data.Name,endAxisName:h?.[1].data.Name??n.data.Name,axisName:n.data.Name,pointOffset:i,isOnAxis:!0,isInside:h!==null}}let s=null,a=null;e.axes.forEach(c=>{if(c.offset<i){s=c;return}a||(a=c)});let o="",l=!1;if(s&&a)o=this.formatAxisPair(s.data.Name,a.data.Name),l=!0;else{const c=this.pickNearestBoundaryPair(e.axes,i);c&&(o=this.formatAxisPair(c[0].data.Name,c[1].data.Name))}return{familyIndex:e.familyIndex,description:o,startAxisName:s?.data.Name??null,endAxisName:a?.data.Name??null,axisName:null,pointOffset:i,isOnAxis:!1,isInside:l}}pickAxisPairAroundIndex(e,t){const i=e[t],n=t>0?e[t-1]:null,s=t<e.length-1?e[t+1]:null;if(!i)return null;if(n&&s){const a=Math.abs(i.offset-n.offset),o=Math.abs(s.offset-i.offset);return a<=o?[n,i]:[i,s]}return n?[n,i]:s?[i,s]:null}pickNearestBoundaryPair(e,t){if(e.length<2)return null;const i=[e[0],e[1]],n=[e[e.length-2],e[e.length-1]],s=Math.min(Math.abs(t-i[0].offset),Math.abs(t-i[1].offset)),a=Math.min(Math.abs(t-n[0].offset),Math.abs(t-n[1].offset));return s<=a?i:n}sortFamiliesForDisplay(e){return[...e].sort((t,i)=>{const n=this.getFamilySampleLabel(t),s=this.getFamilySampleLabel(i),a=this.isNumericLabel(n),o=this.isNumericLabel(s);return a!==o?a?1:-1:this.compareLabels(n,s)})}getFamilySampleLabel(e){return e.axisName??e.startAxisName??e.endAxisName??""}formatAxisPair(e,t){return this.compareLabels(e,t)<=0?`${e}-${t}`:`${t}-${e}`}formatGridDescription(e){if(e.length!==2)return"";const t=e.map(i=>i.description).filter(i=>i.length>0);return t.length!==2?"":`${t[0]}交${t[1]}`}compareLabels(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}isNumericLabel(e){return/^\d/.test(e.trim())}toVector3(e){return e instanceof T?e.clone():new T(e.x,e.y,e.z)}}const UU=.001,FU=[{Id:"339",Name:"L1",Elevation:-.32808398950131235},{Id:"2787",Name:"L2",Elevation:16.896325459317584},{Id:"236633",Name:"L3",Elevation:36.745406824146976}];class OU{engine;isVisible=!1;levels=[];svgContainer=null;svgOverlay=null;worldToScreen=null;halfSize=500;COLOR="#1890ff";PLANE_OPACITY=.08;constructor(e){this.engine=e,this._initSvg()}setData(e=[],t){this._clearAll(),this.levels=e.map(n=>({data:n,group:null,svgGroup:null}));const i=t??this.getMergedBoundingBox();this.levels.forEach(n=>this._buildThreeObject(n,i))}setMockData(){const e=this.engine.models?.[0]?.levels,t=this.engine.models?.[0]?.boundingBox;this.setData(Array.isArray(e)&&e.length>0?e:FU,t)}show(){this.isVisible=!0,this.svgContainer&&(this.svgContainer.style.display="block"),this.levels.forEach(e=>{e.group&&(e.group.visible=!0)})}hide(){this.isVisible=!1,this.svgContainer&&(this.svgContainer.style.display="none"),this.levels.forEach(e=>{e.group&&(e.group.visible=!1)})}toggle(){if(this.isVisible){this.hide();return}this.show()}update(){!this.isVisible||!this.svgOverlay||this.levels.length===0||!this.engine.camera||!this.engine.renderer||(this._initWorldToScreen(),this.levels.forEach(e=>this._updateSvgLabels(e)))}getLocationByPoint(e,t){const{url:i,targetPoint:n}=this.resolvePointLookupArgs(e,t),s=this.getLevelData(i).slice().sort((u,A)=>u.Elevation-A.Elevation);if(s.length===0)return null;const a=n.y,o=s.find(u=>Math.abs(u.Elevation-a)<=UU)??null;if(o)return{pointY:a,description:`${o.Name}`,currentLevel:o,lowerLevel:o,upperLevel:o,isOnLevel:!0,isInside:!0};let l=null,c=null;s.forEach(u=>{if(u.Elevation<a){l=u;return}c||(c=u)});const h=this.pickNearestLevel(a,l,c),d=h?`标高${h.Name}`:"";let p=!1;return l&&c&&(p=!0),{pointY:a,description:d,currentLevel:h,lowerLevel:l,upperLevel:c,isOnLevel:!1,isInside:p}}dispose(){this._clearAll(),this.svgContainer&&(this.svgContainer.remove(),this.svgContainer=null),this.svgOverlay=null,this.worldToScreen=null}_initSvg(){this.svgContainer=document.createElement("div"),this.svgContainer.style.position="absolute",this.svgContainer.style.top="0",this.svgContainer.style.left="0",this.svgContainer.style.width="100%",this.svgContainer.style.height="100%",this.svgContainer.style.pointerEvents="none",this.svgContainer.style.overflow="hidden",this.svgContainer.style.display="none",this.engine.container.appendChild(this.svgContainer),this.svgOverlay=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svgOverlay.style.position="absolute",this.svgOverlay.style.top="0",this.svgOverlay.style.left="0",this.svgOverlay.style.width="1920px",this.svgOverlay.style.height="1080px",this.svgOverlay.style.overflow="visible",this.svgContainer.appendChild(this.svgOverlay)}_initWorldToScreen(){this.engine.camera&&this.engine.renderer&&this.engine.scene&&(this.worldToScreen=new zt(this.engine.camera,this.engine.renderer,this.engine.scene))}_clearAll(){this.levels.forEach(e=>{e.group&&this.engine.scene&&(this.engine.scene.remove(e.group),e.group.traverse(t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(i=>i.dispose()):t.material.dispose())}),e.group=null),e.svgGroup&&(e.svgGroup.remove(),e.svgGroup=null)}),this.levels=[]}_buildThreeObject(e,t){if(!this.engine.scene)return;const i=new T(t.min.x,t.min.y,t.min.z),n=new T(t.max.x,t.max.y,t.max.z);this.halfSize=n.distanceTo(i);const s=e.data.Elevation,a=new Mi,o=new jn(this.halfSize*2,this.halfSize*2);o.rotateX(-Math.PI/2);const l=new Rt({color:this.COLOR,transparent:!0,opacity:this.PLANE_OPACITY,side:Vt,depthWrite:!1}),c=new Ge(o,l);c.position.y=s,a.add(c);const h=[new T(-this.halfSize,s,-this.halfSize),new T(this.halfSize,s,-this.halfSize),new T(this.halfSize,s,this.halfSize),new T(-this.halfSize,s,this.halfSize),new T(-this.halfSize,s,-this.halfSize)],d=new ot().setFromPoints(h),p=new si({color:this.COLOR,transparent:!0,opacity:.7});if(a.add(new di(d,p)),a.visible=this.isVisible,this.engine.scene.add(a),e.group=a,this.svgOverlay){const u=document.createElementNS("http://www.w3.org/2000/svg","g");u.dataset.levelId=e.data.Id;for(let A=0;A<4;A+=1)u.appendChild(this._makeLabel(e.data.Name,e.data.Elevation));this.svgOverlay.appendChild(u),e.svgGroup=u}}_updateSvgLabels(e){if(!e.svgGroup||!this.worldToScreen)return;const t=e.data.Elevation,i=[new T(-this.halfSize,t,-this.halfSize),new T(this.halfSize,t,-this.halfSize),new T(this.halfSize,t,this.halfSize),new T(-this.halfSize,t,this.halfSize)],n=Array.from(e.svgGroup.children);i.forEach((s,a)=>{const o=this.worldToScreen?.worldToScreen(s);o&&(n[a].setAttribute("x",String(o.x)),n[a].setAttribute("y",String(o.y)))})}_makeLabel(e,t){const i=document.createElementNS("http://www.w3.org/2000/svg","text");return i.textContent=`${e} ${t.toFixed(3)}m`,i.setAttribute("text-anchor","middle"),i.setAttribute("dominant-baseline","central"),i.setAttribute("fill",this.COLOR),i.setAttribute("font-size","12"),i.setAttribute("font-family","Arial, sans-serif"),i.setAttribute("font-weight","bold"),i.setAttribute("stroke","white"),i.setAttribute("stroke-width","2"),i.setAttribute("paint-order","stroke"),i.style.pointerEvents="none",i}getLevelData(e){if(e){const i=this.findModelByUrl(e);return Array.isArray(i?.levels)?i.levels:[]}if(this.levels.length>0)return this.levels.map(i=>i.data);if(!Array.isArray(this.engine.models))return[];const t=[];return this.engine.models.forEach(i=>{Array.isArray(i.levels)&&t.push(...i.levels)}),t}resolvePointLookupArgs(e,t){if(typeof e=="string"){if(!t)throw new Error("Level.getLocationByPoint(url, point) requires a point argument.");return{url:e,targetPoint:t}}return{targetPoint:e}}findModelByUrl(e){return this.engine.models?.find(t=>t.url===e)}pickNearestLevel(e,t,i){if(t&&i){const n=Math.abs(e-t.Elevation),s=Math.abs(i.Elevation-e);return n<=s?t:i}return t??i}getMergedBoundingBox(){if(!Array.isArray(this.engine.models)||this.engine.models.length===0)return{min:{x:-this.halfSize,y:-this.halfSize,z:-this.halfSize},max:{x:this.halfSize,y:this.halfSize,z:this.halfSize}};const e=new Ft;let t=!1;return this.engine.models.forEach(i=>{const n=i.boundingBox;if(!n)return;const s=new T(n.min.x,n.min.y,n.min.z),a=new T(n.max.x,n.max.y,n.max.z);if(!t){e.min.copy(s),e.max.copy(a),t=!0;return}e.expandByPoint(s),e.expandByPoint(a)}),t?e:{min:{x:-this.halfSize,y:-this.halfSize,z:-this.halfSize},max:{x:this.halfSize,y:this.halfSize,z:this.halfSize}}}}class zU{engine;constructor(e){this.engine=e}getMoldePosition(e){if(e==null||!Array.isArray(e.ids)||e.ids.length===0)return null;const t=e.url,i=e.ids[0],n=this.engine.models.find(l=>l.url===t);if(n==null)return null;const s=n.nodesMap.get(i)?.infos?.[0];if(s?.box==null)return null;const a=s.box.min.clone().add(s.box.max.clone()).multiplyScalar(.5),o=this.getPointContext(t,a);return{Floor:o.level?.description??"",Axis:o.grid?.description??"",ElementId:i,ElementName:"",modelJson:{url:t,ids:[i],point:o.point,camera:this.getCameraPose(),cameraRestorePose:this.getCameraRestorePose()}}}jumptoCamera(e){const t=this.resolveModelJson(e);if(t?.ids&&(t.ids=t.ids.map(n=>Number(n))),t==null)return;this.highlightIssueModel(t);const i=this.resolveFocusPoint(t);this.normalizeRestorePose(t.cameraRestorePose,i),this.zoomToIssueModel(t,i)}getPoint(e){const t=e instanceof T?e.clone():new T(e.x,e.y,e.z);return{x:t.x,y:t.y,z:t.z}}getModelPosition(e){return this.getPoint(e)}getPointContext(e,t){const{url:i,targetPoint:n}=this.resolvePointLookupArgs(e,t),s=this.getPoint(n);return{url:i,point:s,grid:this.engine.grid?.getLocationByPoint(i??s,i?s:void 0)??null,level:this.engine.level?.getLocationByPoint(i??s,i?s:void 0)??null}}getCameraPose(){const e=this.engine.camera;if(!e)return{position:{x:0,y:0,z:0},forwardDirection:{x:0,y:0,z:-1},upDirection:{x:0,y:1,z:0}};const t=new T;e.getWorldDirection(t);const i=e.up.clone().normalize().applyQuaternion(e.quaternion).normalize();return{position:{x:e.position.x,y:e.position.y,z:e.position.z},forwardDirection:{x:t.x,y:t.y,z:t.z},upDirection:{x:i.x,y:i.y,z:i.z}}}getCameraParams(){return this.getCameraPose()}getCameraRestorePose(){return this.engine.cameraModule.getCameraPose()}restoreCameraPose(e){this.engine.cameraModule.restoreCameraPose(e)}capture(e){return{...this.getPointContext(e),cameraPose:this.getCameraPose(),cameraRestorePose:this.getCameraRestorePose()}}captureByUrlAndPoint(e,t){return{url:e,...this.captureWithUrl(e,t)}}captureWithUrl(e,t){return{...this.getPointContext(e,t),cameraPose:this.getCameraPose(),cameraRestorePose:this.getCameraRestorePose()}}restore(e){if("cameraRestorePose"in e){this.restoreCameraPose(e.cameraRestorePose);return}this.restoreCameraPose(e)}dispose(){}resolvePointLookupArgs(e,t){if(typeof e=="string"){if(!t)throw new Error("IssueReport.getPointContext(url, point) requires a point argument.");return{url:e,targetPoint:t}}return{targetPoint:e}}resolveModelJson(e){const t=e?.modelJson??e;if(t==null)return null;if(typeof t=="string")try{return JSON.parse(t)}catch(i){return console.warn("IssueReport.jumptoCamera: failed to parse modelJson.",i),null}return t}highlightIssueModel(e){if(!e.url||!Array.isArray(e.ids)||e.ids.length===0)return;const t={url:e.url,ids:[...e.ids]},i=this.engine.engineStatus?.hideModels?.find(s=>s.url===t.url)?.ids??[],n=t.ids.filter(s=>i.includes(s));n.length>0&&this.engine.modelToolModule.showModel([{url:t.url,ids:n}]),this.engine.modelToolModule.unhighlightAllModels(),this.engine.modelToolModule.highlightModel([t])}restoreIssueCameraPose(e,t){const i=this.toVector3(e.position),n=this.toVector3(e.forwardDirection).normalize(),s=this.toVector3(e.upDirection).normalize();if(n.lengthSq()===0)return;const a=this.engine.camera;if(!a)return;const o=t?this.toVector3(t):i.clone().add(n),l=this.buildSafeUpDirection(n,s,a.up);a.position.copy(i),a.up.copy(l),a.lookAt(o),a.updateMatrix(),a.updateMatrixWorld(!0);const c={type:this.engine.cameraModule?.getCameraType?.()??$u.PERSPECTIVE,position:this.getPoint(i),rotation:{x:a.rotation.x,y:a.rotation.y,z:a.rotation.z},quaternion:{x:a.quaternion.x,y:a.quaternion.y,z:a.quaternion.z,w:a.quaternion.w},target:this.getPoint(o)};a instanceof Ki&&(c.zoom=a.zoom,c.orthographicHeight=this.engine.cameraModule.getOrthographicVisibleHeight(a)),this.restoreCameraPose(c),this.syncOrbitOrigin(c.target)}zoomToIssueModel(e,t){const i=this.resolveModelBox(e);if(i){this.engine.viewCube?.zoomToModel(i);const n=i.min.clone().add(i.max.clone()).multiplyScalar(.5);this.syncOrbitOrigin(this.getPoint(n));return}t&&this.engine.controls?.target&&(this.engine.controls.target.set(t.x,t.y,t.z),this.syncOrbitOrigin(t),this.engine.controls.update?.())}syncOrbitOrigin(e){e&&this.engine.controlModule?.orbitControls?.origin?.set(e.x,e.y,e.z)}toVector3(e){return new T(e.x,e.y,e.z)}resolveFocusPoint(e){if(e.point)return e.point;const t=this.resolveModelBox(e);if(t)return this.getPoint(t.min.clone().add(t.max.clone()).multiplyScalar(.5))}resolveModelBox(e){if(!e.url||!Array.isArray(e.ids)||e.ids.length===0)return null;const t=this.engine.models.find(s=>s.url===e.url);if(!t)return null;const i=e.ids.map(s=>t.nodesMap.get(s)).flatMap(s=>s?.infos?.map(a=>a?.box).filter(Boolean)??[]);if(i.length===0)return null;const n=new Ft;n.copy(i[0]);for(let s=1;s<i.length;s++)n.union(i[s]);return n}normalizeRestorePose(e,t){if(!e||!e.position)return null;const i=this.engine.camera,n={type:e.type??this.engine.cameraModule?.getCameraType?.()??$u.PERSPECTIVE,position:e.position,rotation:e.rotation??{x:0,y:0,z:0},quaternion:e.quaternion??{x:0,y:0,z:0,w:1},target:e.target??t};return n.quaternion&&Math.sqrt(n.quaternion.x**2+n.quaternion.y**2+n.quaternion.z**2+n.quaternion.w**2)<=1e-6&&(n.quaternion={x:0,y:0,z:0,w:1}),i instanceof Ki&&n.type===$u.ORTHOGRAPHIC&&(n.zoom=e.zoom??i.zoom,n.orthographicHeight=e.orthographicHeight??this.engine.cameraModule.getOrthographicVisibleHeight(i)),n}buildSafeUpDirection(e,t,i){const n=t.lengthSq()>0?t.clone():i.clone().normalize();if(Math.abs(n.dot(e))<.999)return n;const s=i.clone().normalize();return Math.abs(s.dot(e))<.999?s:new T(1,0,0)}}class HU{engine;constructor(e){}update(){}}class GU{engine;currentHdrId="0";isVisible=!0;currentIntensity=.2;currentTexture=null;currentEnvironmentTexture=null;skybox=null;textureCache=new Map;previousBackground=null;previousEnvironment=null;previousBackgroundIntensity=1;previousEnvironmentIntensity=1;previousAmbientLightIntensity=1;previousToneMapping=Xi;previousToneMappingExposure=1;hdrList=[{id:"0",names:["无","無","None"]},{id:"1",names:["纯净-多云","純淨-多雲","Pure - Cloudy"],url:"assets/hdr/1.hdr"},{id:"2",names:["纯净-落日","純淨-落日","Pure - Sunset"],url:"assets/hdr/2.hdr"},{id:"3",names:["纯净-少云","純淨-少雲","Pure - Few Clouds"],url:"assets/hdr/3.hdr"},{id:"4",names:["纯净-无云","純淨-無雲","Pure - Cloudless"],url:"assets/hdr/4.hdr"},{id:"5",names:["纯净-夜晚","純淨-夜晚","Pure - Night"],url:"assets/hdr/5.hdr"},{id:"6",names:["纯净-阴天","純淨-陰天","Pure - Overcast"],url:"assets/hdr/6.hdr"},{id:"7",names:["纯净-中云","純淨-中雲","Pure - Partly Cloudy"],url:"assets/hdr/7.hdr"},{id:"8",names:["废弃机场","廢棄機場","Abandoned Airport"],url:"assets/hdr/8.hdr"},{id:"9",names:["户外-无云","戶外-無雲","Outdoor - Cloudless"],url:"assets/hdr/9.hdr"},{id:"10",names:["郊区花园","郊區花園","Suburban Garden"],url:"assets/hdr/10.hdr"},{id:"11",names:["室内工作室01","室內工作室01","Indoor Studio 01"],url:"assets/hdr/11.hdr"},{id:"12",names:["室内工作室02","室內工作室02","Indoor Studio 02"],url:"assets/hdr/12.hdr"},{id:"13",names:["室内工作室03","室內工作室03","Indoor Studio 03"],url:"assets/hdr/13.hdr"},{id:"14",names:["室内工作室04","室內工作室04","Indoor Studio 04"],url:"assets/hdr/14.hdr"},{id:"15",names:["小镇教堂","小鎮教堂","Town Church"],url:"assets/hdr/15.hdr"},{id:"16",names:["小镇街道","小鎮街道","Town Street"],url:"assets/hdr/16.hdr"},{id:"17",names:["夜晚街道","夜晚街道","Night Street"],url:"assets/hdr/17.hdr"}];constructor(e){this.engine=e}getHdrList(){return this.hdrList}async setHdr(e){const t=this.hdrList.find(i=>i.id===e);if(!t){console.warn(`[Hdr] HDR id "${e}" not found`);return}if(e==="0"||!t.url){this._clearHdr(),this.currentHdrId="0";return}if(this.textureCache.has(e)){this._applyTexture(this.textureCache.get(e)),this.currentHdrId=e;return}try{const i=await this._loadHdr(t.url);this.textureCache.set(e,i),this._applyTexture(i),this.currentHdrId=e}catch(i){console.error(`[Hdr] Failed to load HDR "${t.url}":`,i)}}setVisible(e){this.isVisible=e,this.skybox&&(this.skybox.visible=e)}getCurrentHdrId(){return this.currentHdrId}getVisible(){return this.isVisible}setIntensity(e){this.currentIntensity=e,!(!this.engine.scene||this.currentHdrId==="0")&&(this.engine.scene.environmentIntensity=e,this._updateSkyboxIntensity())}getIntensity(){return this.currentIntensity}addHdrItem(e){const t=this.hdrList.find(i=>i.id===e.id);t?Object.assign(t,e):this.hdrList.push(e)}dispose(){this._clearHdr(),this.textureCache.forEach(e=>e.dispose()),this.textureCache.clear()}_loadHdr(e){return new Promise((t,i)=>{new sU().load(e,n=>{n.mapping=bo,t(n)},void 0,n=>i(n))})}_applyTexture(e){if(this.currentTexture=e,!this.engine.scene||!this.engine.renderer)return;this._captureSceneState(),this.currentEnvironmentTexture?.dispose();const t=new Kc(this.engine.renderer),i=t.fromEquirectangular(e).texture;t.dispose(),this.currentEnvironmentTexture=i,this.engine.scene.background=null,this.engine.scene.environment=i,this.engine.scene.environmentIntensity=this.currentIntensity,this.engine.renderer.toneMapping=ra,this.engine.renderer.toneMappingExposure=1,this._removeSkybox(),this._createSkybox(e),this._setAmbientLightIntensity(0)}_captureSceneState(){this.currentHdrId!=="0"||!this.engine.scene||(this.previousBackground=this.engine.scene.background,this.previousEnvironment=this.engine.scene.environment,this.previousBackgroundIntensity=this.engine.scene.backgroundIntensity??1,this.previousEnvironmentIntensity=this.engine.scene.environmentIntensity??1,this.previousAmbientLightIntensity=this._getAmbientLightIntensity(),this.previousToneMapping=this.engine.renderer?.toneMapping??Xi,this.previousToneMappingExposure=this.engine.renderer?.toneMappingExposure??1)}_createSkybox(e){if(!this.engine.scene)return;const t=new Br(1e3,64,32),i=new Rt({map:e,side:qi,depthWrite:!1,depthTest:!1,fog:!1,toneMapped:!0});this.skybox=new Ge(t,i),this.skybox.name="hdr_skybox",this.skybox.renderOrder=-1e3,this.skybox.frustumCulled=!1,this.skybox.visible=this.isVisible,this.skybox.onBeforeRender=(n,s,a)=>{this.skybox?.position.copy(a.position)},this._updateSkyboxIntensity(),this.engine.scene.add(this.skybox)}_updateSkyboxIntensity(){this.skybox&&this.skybox.material.color.setScalar(Math.max(this.currentIntensity,1))}_removeSkybox(){!this.skybox||!this.engine.scene||(this.engine.scene.remove(this.skybox),this.skybox.geometry.dispose(),this.skybox.material.dispose(),this.skybox=null)}_clearHdr(){this.currentTexture=null,this._removeSkybox(),this.engine.scene&&(this.currentEnvironmentTexture?.dispose(),this.currentEnvironmentTexture=null,this.engine.scene.background=this.previousBackground,this.engine.scene.environment=this.previousEnvironment,this.engine.scene.backgroundIntensity=this.previousBackgroundIntensity,this.engine.scene.environmentIntensity=this.previousEnvironmentIntensity,this._setAmbientLightIntensity(this.previousAmbientLightIntensity),this.engine.renderer&&(this.engine.renderer.toneMapping=this.previousToneMapping,this.engine.renderer.toneMappingExposure=this.previousToneMappingExposure),this.previousBackground=null,this.previousEnvironment=null,this.previousBackgroundIntensity=1,this.previousEnvironmentIntensity=1,this.previousAmbientLightIntensity=1,this.previousToneMapping=Xi,this.previousToneMappingExposure=1)}_getAmbientLightIntensity(){return this.engine.scene?.children.find(e=>e instanceof il)?.intensity??1}_setAmbientLightIntensity(e){this.engine.setting.setAmbientLightIntensity(e)}}class VU extends Ge{constructor(e,t={}){super(e),this.isWater=!0;const i=this,n=t.textureWidth!==void 0?t.textureWidth:512,s=t.textureHeight!==void 0?t.textureHeight:512,a=t.clipBias!==void 0?t.clipBias:0,o=t.alpha!==void 0?t.alpha:1,l=t.time!==void 0?t.time:0,c=t.waterNormals!==void 0?t.waterNormals:null,h=t.sunDirection!==void 0?t.sunDirection:new T(.70707,.70707,0),d=new We(t.sunColor!==void 0?t.sunColor:16777215),p=new We(t.waterColor!==void 0?t.waterColor:8355711),u=t.eye!==void 0?t.eye:new T(0,0,0),A=t.distortionScale!==void 0?t.distortionScale:20,m=t.side!==void 0?t.side:Gn,g=t.fog!==void 0?t.fog:!1,f=new li,v=new T,b=new T,y=new T,M=new Ke,_=new T(0,0,-1),S=new Gt,w=new T,E=new T,I=new Gt,B=new Ke,R=new pi,U=new Ei(n,s,{type:Zt}),C={name:"MirrorShader",uniforms:nn.merge([Ze.fog,Ze.lights,{normalSampler:{value:null},mirrorSampler:{value:null},alpha:{value:1},time:{value:0},size:{value:1},distortionScale:{value:20},textureMatrix:{value:new Ke},sunColor:{value:new We(8355711)},sunDirection:{value:new T(.70707,.70707,0)},eye:{value:new T},waterColor:{value:new We(5592405)}}]),vertexShader:`
|
||
uniform mat4 textureMatrix;
|
||
uniform float time;
|
||
|
||
varying vec4 mirrorCoord;
|
||
varying vec4 worldPosition;
|
||
|
||
#include <common>
|
||
#include <fog_pars_vertex>
|
||
#include <shadowmap_pars_vertex>
|
||
#include <logdepthbuf_pars_vertex>
|
||
|
||
void main() {
|
||
mirrorCoord = modelMatrix * vec4( position, 1.0 );
|
||
worldPosition = mirrorCoord.xyzw;
|
||
mirrorCoord = textureMatrix * mirrorCoord;
|
||
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
||
gl_Position = projectionMatrix * mvPosition;
|
||
|
||
#include <beginnormal_vertex>
|
||
#include <defaultnormal_vertex>
|
||
#include <logdepthbuf_vertex>
|
||
#include <fog_vertex>
|
||
#include <shadowmap_vertex>
|
||
}`,fragmentShader:`
|
||
uniform sampler2D mirrorSampler;
|
||
uniform float alpha;
|
||
uniform float time;
|
||
uniform float size;
|
||
uniform float distortionScale;
|
||
uniform sampler2D normalSampler;
|
||
uniform vec3 sunColor;
|
||
uniform vec3 sunDirection;
|
||
uniform vec3 eye;
|
||
uniform vec3 waterColor;
|
||
|
||
varying vec4 mirrorCoord;
|
||
varying vec4 worldPosition;
|
||
|
||
vec4 getNoise( vec2 uv ) {
|
||
vec2 uv0 = ( uv / 103.0 ) + vec2(time / 17.0, time / 29.0);
|
||
vec2 uv1 = uv / 107.0-vec2( time / -19.0, time / 31.0 );
|
||
vec2 uv2 = uv / vec2( 8907.0, 9803.0 ) + vec2( time / 101.0, time / 97.0 );
|
||
vec2 uv3 = uv / vec2( 1091.0, 1027.0 ) - vec2( time / 109.0, time / -113.0 );
|
||
vec4 noise = texture2D( normalSampler, uv0 ) +
|
||
texture2D( normalSampler, uv1 ) +
|
||
texture2D( normalSampler, uv2 ) +
|
||
texture2D( normalSampler, uv3 );
|
||
return noise * 0.5 - 1.0;
|
||
}
|
||
|
||
void sunLight( const vec3 surfaceNormal, const vec3 eyeDirection, float shiny, float spec, float diffuse, inout vec3 diffuseColor, inout vec3 specularColor ) {
|
||
vec3 reflection = normalize( reflect( -sunDirection, surfaceNormal ) );
|
||
float direction = max( 0.0, dot( eyeDirection, reflection ) );
|
||
specularColor += pow( direction, shiny ) * sunColor * spec;
|
||
diffuseColor += max( dot( sunDirection, surfaceNormal ), 0.0 ) * sunColor * diffuse;
|
||
}
|
||
|
||
#include <common>
|
||
#include <packing>
|
||
#include <bsdfs>
|
||
#include <fog_pars_fragment>
|
||
#include <logdepthbuf_pars_fragment>
|
||
#include <lights_pars_begin>
|
||
#include <shadowmap_pars_fragment>
|
||
#include <shadowmask_pars_fragment>
|
||
|
||
void main() {
|
||
|
||
#include <logdepthbuf_fragment>
|
||
vec4 noise = getNoise( worldPosition.xz * size );
|
||
vec3 surfaceNormal = normalize( noise.xzy * vec3( 1.5, 1.0, 1.5 ) );
|
||
|
||
vec3 diffuseLight = vec3(0.0);
|
||
vec3 specularLight = vec3(0.0);
|
||
|
||
vec3 worldToEye = eye-worldPosition.xyz;
|
||
vec3 eyeDirection = normalize( worldToEye );
|
||
sunLight( surfaceNormal, eyeDirection, 100.0, 2.0, 0.5, diffuseLight, specularLight );
|
||
|
||
float distance = length(worldToEye);
|
||
|
||
vec2 distortion = surfaceNormal.xz * ( 0.001 + 1.0 / distance ) * distortionScale;
|
||
vec3 reflectionSample = vec3( texture2D( mirrorSampler, mirrorCoord.xy / mirrorCoord.w + distortion ) );
|
||
|
||
float theta = max( dot( eyeDirection, surfaceNormal ), 0.0 );
|
||
float rf0 = 0.02;
|
||
float reflectance = rf0 + ( 1.0 - rf0 ) * pow( ( 1.0 - theta ), 5.0 );
|
||
vec3 scatter = max( 0.0, dot( surfaceNormal, eyeDirection ) ) * waterColor;
|
||
vec3 albedo = mix( ( sunColor * diffuseLight * 0.3 + scatter ) * getShadowMask(), reflectionSample + specularLight, reflectance );
|
||
vec3 outgoingLight = albedo;
|
||
gl_FragColor = vec4( outgoingLight, alpha );
|
||
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
#include <fog_fragment>
|
||
}`},F=new ei({name:C.name,uniforms:nn.clone(C.uniforms),vertexShader:C.vertexShader,fragmentShader:C.fragmentShader,lights:!0,side:m,fog:g});F.uniforms.mirrorSampler.value=U.texture,F.uniforms.textureMatrix.value=B,F.uniforms.alpha.value=o,F.uniforms.time.value=l,F.uniforms.normalSampler.value=c,F.uniforms.sunColor.value=d,F.uniforms.waterColor.value=p,F.uniforms.sunDirection.value=h,F.uniforms.distortionScale.value=A,F.uniforms.eye.value=u,i.material=F,i.onBeforeRender=function(O,H,j){if(b.setFromMatrixPosition(i.matrixWorld),y.setFromMatrixPosition(j.matrixWorld),M.extractRotation(i.matrixWorld),v.set(0,0,1),v.applyMatrix4(M),w.subVectors(b,y),w.dot(v)>0)return;w.reflect(v).negate(),w.add(b),M.extractRotation(j.matrixWorld),_.set(0,0,-1),_.applyMatrix4(M),_.add(y),E.subVectors(b,_),E.reflect(v).negate(),E.add(b),R.position.copy(w),R.up.set(0,1,0),R.up.applyMatrix4(M),R.up.reflect(v),R.lookAt(E),R.far=j.far,R.updateMatrixWorld(),R.projectionMatrix.copy(j.projectionMatrix),B.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),B.multiply(R.projectionMatrix),B.multiply(R.matrixWorldInverse),f.setFromNormalAndCoplanarPoint(v,b),f.applyMatrix4(R.matrixWorldInverse),S.set(f.normal.x,f.normal.y,f.normal.z,f.constant);const G=R.projectionMatrix;I.x=(Math.sign(S.x)+G.elements[8])/G.elements[0],I.y=(Math.sign(S.y)+G.elements[9])/G.elements[5],I.z=-1,I.w=(1+G.elements[10])/G.elements[14],S.multiplyScalar(2/S.dot(I)),G.elements[2]=S.x,G.elements[6]=S.y,G.elements[10]=S.z+1-a,G.elements[14]=S.w,u.setFromMatrixPosition(j.matrixWorld);const re=O.getRenderTarget(),q=O.xr.enabled,Y=O.shadowMap.autoUpdate;i.visible=!1,O.xr.enabled=!1,O.shadowMap.autoUpdate=!1,O.setRenderTarget(U),O.state.buffers.depth.setMask(!0),O.autoClear===!1&&O.clear(),O.render(H,R),i.visible=!0,O.xr.enabled=q,O.shadowMap.autoUpdate=Y,O.setRenderTarget(re);const ye=j.viewport;ye!==void 0&&O.state.viewport(ye)}}}class gA{engine;currentId="0";groundGroup;groundMesh=null;isWaterAddon=!1;clock;groundY=0;static DEFAULT_WATER_NORMALS="/texture/waternormals.jpg";groundList=[{id:"0",names:["无","無","None"]},{id:"1",names:["草地1","草地1","Grass 1"],color:4881486,roughness:.9,metalness:0,map:"/texture/ground/grass01.jpg"},{id:"2",names:["草地2","草地2","Grass 2"],color:4881486,roughness:.9,metalness:0,map:"/texture/ground/grass02.jpg"},{id:"3",names:["草地3","草地3","Grass 3"],color:4881486,roughness:.9,metalness:0,map:"/texture/ground/grass03.jpg"},{id:"4",names:["草地4","草地4","Grass 4"],color:4881486,roughness:.9,metalness:0,map:"/texture/ground/grass04.jpg"},{id:"5",names:["混凝土1","混凝土1","Concrete 1"],color:15790320,roughness:.85,metalness:.1,map:"/texture/ground/concrete01.jpg"},{id:"5",names:["混凝土1","混凝土1","Concrete 1"],color:15790320,roughness:.85,metalness:.1,map:"/texture/ground/concrete02.jpg"},{id:"6",names:["马路1","馬路1","Road 1"],color:15790320,roughness:.55,metalness:.1,map:"/texture/ground/road01.jpg"},{id:"7",names:["马路2","馬路2","Road 2"],color:15790320,roughness:.55,metalness:.1,map:"/texture/ground/road02.jpg"},{id:"8",names:["泥土1","泥土1","Soil 1"],color:15790320,roughness:.55,metalness:.1,map:"/texture/ground/tiles01.jpg"},{id:"9",names:["泥土2","泥土2","Soil 2"],color:15790320,roughness:.55,metalness:.1,map:"/texture/ground/tiles02.jpg"},{id:"10",names:["木板","木板","Wood Board"],color:15790320,roughness:.55,metalness:.1,map:"/texture/ground/wood01.jpg"},{id:"11",names:["地砖1","地磚1","Floor Tile 1"],color:15790320,roughness:.55,metalness:.1,map:"/texture/ground/z01.jpg"},{id:"12",names:["地砖2","地磚2","Floor Tile 2"],color:15790320,roughness:.55,metalness:.1,map:"/texture/ground/z02.jpg"},{id:"13",names:["湖面","湖面","Lake Surface"],water:!0,waterColor:5929582,distortionScale:2.5,size:1},{id:"14",names:["海面","海面","Sea Surface"],water:!0,waterColor:28062,distortionScale:3.7,size:1}];constructor(e){this.engine=e,this.groundGroup=new Mi,this.groundGroup.name="groundGroup",this.clock=new t1}init(){this.engine.scene.add(this.groundGroup)}setGround(e,t){if(this._dispose(),this.currentId=e,e==="0")return;const i=this.groundList.find(s=>s.id===e);debugger;if(!i)return;const n=t?.size??3e4;if(i.water){const s=new jn(n,n),a=gA.DEFAULT_WATER_NORMALS,o=new Da().load(a,u=>{u.wrapS=u.wrapT=Ji}),l=t?.sunDirection??new T(.5,.8,.5).normalize(),c=t?.distortionScale??i.distortionScale??3.7,h=t?.waterSize??i.size??1,d=t?.opacity??.92,p=new VU(s,{textureWidth:512,textureHeight:512,waterNormals:o,sunDirection:l.clone(),sunColor:16777215,waterColor:i.waterColor??28062,distortionScale:c,alpha:d,fog:!!this.engine.scene?.fog});p.rotation.x=-Math.PI/2,p.position.y=-.01,p.name="groundMesh",p.receiveShadow=!0,p.castShadow=!1,this.ensureWaterShadowUniforms(p.material),p.material.uniforms.size.value=h,this.groundMesh=p,this.isWaterAddon=!0,this.groundGroup.add(p)}else{const s=new jn(n,n,1,1);s.rotateX(-Math.PI/2);const a=new Ma({color:i.color,roughness:i.roughness,metalness:i.metalness}),o=t?.textureUrl??i.map;o&&new Da().load(o,c=>{c.wrapS=c.wrapT=Ji,c.repeat.set(1e4,1e4),a.map=c,a.needsUpdate=!0},void 0,()=>{});const l=new Ge(s,a);l.name="groundMesh",l.receiveShadow=!0,l.castShadow=!1,l.position.y=-.01,this.groundMesh=l,this.isWaterAddon=!1,this.groundGroup.add(l)}this.groundGroup.position.y=this.groundY,this.clock.start()}setHeight(e){this.groundY=e,this.groundGroup.position.y=e}getHeight(){return this.groundY}update(){if(!this.groundMesh||!this.isWaterAddon)return;const e=this.groundMesh.material?.uniforms;if(!e)return;e.time.value+=1/60;const t=this.engine.scene?.dirLight;t&&e.sunDirection&&e.sunDirection.value.copy(t.position).normalize();const i=this.engine.camera;i&&e.eye&&e.eye.value.setFromMatrixPosition(i.matrixWorld)}getGroundList(){return this.groundList.map(({id:e,names:t})=>({id:e,names:t}))}getCurrentId(){return this.currentId}show(){this.groundGroup.visible=!0}hide(){this.groundGroup.visible=!1}dispose(){this._dispose(),this.engine.scene.remove(this.groundGroup)}ensureWaterShadowUniforms(e){const t=e.uniforms;t.directionalShadowMap||(t.directionalShadowMap={value:[]}),t.spotShadowMap||(t.spotShadowMap={value:[]}),t.pointShadowMap||(t.pointShadowMap={value:[]}),e.uniformsNeedUpdate=!0}_dispose(){if(!this.groundMesh)return;this.groundMesh.geometry.dispose();const e=this.groundMesh.material;Array.isArray(e)?e.forEach(t=>t.dispose()):e.dispose(),this.groundGroup.remove(this.groundMesh),this.groundMesh=null,this.isWaterAddon=!1}}class pf extends Ge{constructor(){const e=pf.SkyShader,t=new ei({name:e.name,uniforms:nn.clone(e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,side:qi,depthWrite:!1});super(new ri(1,1,1),t),this.isSky=!0}}pf.SkyShader={name:"SkyShader",uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new T},up:{value:new T(0,1,0)},cloudScale:{value:2e-4},cloudSpeed:{value:1e-4},cloudCoverage:{value:.4},cloudDensity:{value:.4},cloudElevation:{value:.5},time:{value:0}},vertexShader:`
|
||
uniform vec3 sunPosition;
|
||
uniform float rayleigh;
|
||
uniform float turbidity;
|
||
uniform float mieCoefficient;
|
||
uniform vec3 up;
|
||
|
||
varying vec3 vWorldPosition;
|
||
varying vec3 vSunDirection;
|
||
varying float vSunfade;
|
||
varying vec3 vBetaR;
|
||
varying vec3 vBetaM;
|
||
varying float vSunE;
|
||
|
||
// constants for atmospheric scattering
|
||
const float e = 2.71828182845904523536028747135266249775724709369995957;
|
||
const float pi = 3.141592653589793238462643383279502884197169;
|
||
|
||
// wavelength of used primaries, according to preetham
|
||
const vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );
|
||
// this pre-calculation replaces older TotalRayleigh(vec3 lambda) function:
|
||
// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))
|
||
const vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );
|
||
|
||
// mie stuff
|
||
// K coefficient for the primaries
|
||
const float v = 4.0;
|
||
const vec3 K = vec3( 0.686, 0.678, 0.666 );
|
||
// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K
|
||
const vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );
|
||
|
||
// earth shadow hack
|
||
// cutoffAngle = pi / 1.95;
|
||
const float cutoffAngle = 1.6110731556870734;
|
||
const float steepness = 1.5;
|
||
const float EE = 1000.0;
|
||
|
||
float sunIntensity( float zenithAngleCos ) {
|
||
zenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );
|
||
return EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );
|
||
}
|
||
|
||
vec3 totalMie( float T ) {
|
||
float c = ( 0.2 * T ) * 10E-18;
|
||
return 0.434 * c * MieConst;
|
||
}
|
||
|
||
void main() {
|
||
|
||
vec4 worldPosition = modelMatrix * vec4( position, 1.0 );
|
||
vWorldPosition = worldPosition.xyz;
|
||
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
gl_Position.z = gl_Position.w; // set z to camera.far
|
||
|
||
vSunDirection = normalize( sunPosition );
|
||
|
||
vSunE = sunIntensity( dot( vSunDirection, up ) );
|
||
|
||
vSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );
|
||
|
||
float rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );
|
||
|
||
// extinction (absorption + out scattering)
|
||
// rayleigh coefficients
|
||
vBetaR = totalRayleigh * rayleighCoefficient;
|
||
|
||
// mie coefficients
|
||
vBetaM = totalMie( turbidity ) * mieCoefficient;
|
||
|
||
}`,fragmentShader:`
|
||
varying vec3 vWorldPosition;
|
||
varying vec3 vSunDirection;
|
||
varying vec3 vBetaR;
|
||
varying vec3 vBetaM;
|
||
varying float vSunE;
|
||
|
||
uniform float mieDirectionalG;
|
||
uniform vec3 up;
|
||
uniform float cloudScale;
|
||
uniform float cloudSpeed;
|
||
uniform float cloudCoverage;
|
||
uniform float cloudDensity;
|
||
uniform float cloudElevation;
|
||
uniform float time;
|
||
|
||
// Cloud noise functions
|
||
float hash( vec2 p ) {
|
||
return fract( sin( dot( p, vec2( 127.1, 311.7 ) ) ) * 43758.5453123 );
|
||
}
|
||
|
||
float noise( vec2 p ) {
|
||
vec2 i = floor( p );
|
||
vec2 f = fract( p );
|
||
f = f * f * ( 3.0 - 2.0 * f );
|
||
float a = hash( i );
|
||
float b = hash( i + vec2( 1.0, 0.0 ) );
|
||
float c = hash( i + vec2( 0.0, 1.0 ) );
|
||
float d = hash( i + vec2( 1.0, 1.0 ) );
|
||
return mix( mix( a, b, f.x ), mix( c, d, f.x ), f.y );
|
||
}
|
||
|
||
float fbm( vec2 p ) {
|
||
float value = 0.0;
|
||
float amplitude = 0.5;
|
||
for ( int i = 0; i < 5; i ++ ) {
|
||
value += amplitude * noise( p );
|
||
p *= 2.0;
|
||
amplitude *= 0.5;
|
||
}
|
||
return value;
|
||
}
|
||
|
||
// constants for atmospheric scattering
|
||
const float pi = 3.141592653589793238462643383279502884197169;
|
||
|
||
const float n = 1.0003; // refractive index of air
|
||
const float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)
|
||
|
||
// optical length at zenith for molecules
|
||
const float rayleighZenithLength = 8.4E3;
|
||
const float mieZenithLength = 1.25E3;
|
||
// 66 arc seconds -> degrees, and the cosine of that
|
||
const float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;
|
||
|
||
// 3.0 / ( 16.0 * pi )
|
||
const float THREE_OVER_SIXTEENPI = 0.05968310365946075;
|
||
// 1.0 / ( 4.0 * pi )
|
||
const float ONE_OVER_FOURPI = 0.07957747154594767;
|
||
|
||
float rayleighPhase( float cosTheta ) {
|
||
return THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );
|
||
}
|
||
|
||
float hgPhase( float cosTheta, float g ) {
|
||
float g2 = pow( g, 2.0 );
|
||
float inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );
|
||
return ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );
|
||
}
|
||
|
||
void main() {
|
||
|
||
vec3 direction = normalize( vWorldPosition - cameraPosition );
|
||
|
||
// optical length
|
||
// cutoff angle at 90 to avoid singularity in next formula.
|
||
float zenithAngle = acos( max( 0.0, dot( up, direction ) ) );
|
||
float inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );
|
||
float sR = rayleighZenithLength * inverse;
|
||
float sM = mieZenithLength * inverse;
|
||
|
||
// combined extinction factor
|
||
vec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );
|
||
|
||
// in scattering
|
||
float cosTheta = dot( direction, vSunDirection );
|
||
|
||
float rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );
|
||
vec3 betaRTheta = vBetaR * rPhase;
|
||
|
||
float mPhase = hgPhase( cosTheta, mieDirectionalG );
|
||
vec3 betaMTheta = vBetaM * mPhase;
|
||
|
||
vec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );
|
||
Lin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );
|
||
|
||
// nightsky
|
||
float theta = acos( direction.y ); // elevation --> y-axis, [-pi/2, pi/2]
|
||
float phi = atan( direction.z, direction.x ); // azimuth --> x-axis [-pi/2, pi/2]
|
||
vec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );
|
||
vec3 L0 = vec3( 0.1 ) * Fex;
|
||
|
||
// composition + solar disc
|
||
float sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );
|
||
L0 += ( vSunE * 19000.0 * Fex ) * sundisk;
|
||
|
||
vec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );
|
||
|
||
// Clouds
|
||
if ( direction.y > 0.0 && cloudCoverage > 0.0 ) {
|
||
|
||
// Project to cloud plane (higher elevation = clouds appear lower/closer)
|
||
float elevation = mix( 1.0, 0.1, cloudElevation );
|
||
vec2 cloudUV = direction.xz / ( direction.y * elevation );
|
||
cloudUV *= cloudScale;
|
||
cloudUV += time * cloudSpeed;
|
||
|
||
// Multi-octave noise for fluffy clouds
|
||
float cloudNoise = fbm( cloudUV * 1000.0 );
|
||
cloudNoise += 0.5 * fbm( cloudUV * 2000.0 + 3.7 );
|
||
cloudNoise = cloudNoise * 0.5 + 0.5;
|
||
|
||
// Apply coverage threshold
|
||
float cloudMask = smoothstep( 1.0 - cloudCoverage, 1.0 - cloudCoverage + 0.3, cloudNoise );
|
||
|
||
// Fade clouds near horizon (adjusted by elevation)
|
||
float horizonFade = smoothstep( 0.0, 0.1 + 0.2 * cloudElevation, direction.y );
|
||
cloudMask *= horizonFade;
|
||
|
||
// Cloud lighting based on sun position
|
||
float sunInfluence = dot( direction, vSunDirection ) * 0.5 + 0.5;
|
||
float daylight = max( 0.0, vSunDirection.y * 2.0 );
|
||
|
||
// Base cloud color affected by atmosphere
|
||
vec3 atmosphereColor = Lin * 0.04;
|
||
vec3 cloudColor = mix( vec3( 0.3 ), vec3( 1.0 ), daylight );
|
||
cloudColor = mix( cloudColor, atmosphereColor + vec3( 1.0 ), sunInfluence * 0.5 );
|
||
cloudColor *= vSunE * 0.00002;
|
||
|
||
// Blend clouds with sky
|
||
texColor = mix( texColor, cloudColor, cloudMask * cloudDensity );
|
||
|
||
}
|
||
|
||
gl_FragColor = vec4( texColor, 1.0 );
|
||
|
||
#include <tonemapping_fragment>
|
||
#include <colorspace_fragment>
|
||
|
||
}`};const zE={turbidity:10,rayleigh:3,mieCoefficient:.005,mieDirectionalG:.7,elevation:2,azimuth:180,exposure:.5,orthoExposureScale:1.5,cloudCoverage:.4,cloudDensity:.4,cloudElevation:.5,showSunDisc:!0},QU="sunrise_clear",AA=[{id:"sunrise_clear",names:["晴朗日出","晴朗日出","Clear Sunrise"],params:{turbidity:4,rayleigh:1.8,mieCoefficient:.004,mieDirectionalG:.72,elevation:8,azimuth:105,exposure:.42,cloudCoverage:.12,cloudDensity:.2,cloudElevation:.45,showSunDisc:!0}},{id:"morning_mist",names:["晨雾薄云","晨雾薄云","Misty Morning"],params:{turbidity:14,rayleigh:2.4,mieCoefficient:.018,mieDirectionalG:.68,elevation:12,azimuth:120,exposure:.35,cloudCoverage:.45,cloudDensity:.5,cloudElevation:.35,showSunDisc:!0}},{id:"noon_clear",names:["晴空正午","晴空正午","Clear Noon"],params:{turbidity:2,rayleigh:1,mieCoefficient:.002,mieDirectionalG:.82,elevation:68,azimuth:180,exposure:.58,cloudCoverage:.05,cloudDensity:.12,cloudElevation:.55,showSunDisc:!0}},{id:"afternoon_cloudy",names:["午后多云","午后多云","Cloudy Afternoon"],params:{turbidity:8,rayleigh:1.7,mieCoefficient:.008,mieDirectionalG:.74,elevation:42,azimuth:220,exposure:.5,cloudCoverage:.48,cloudDensity:.42,cloudElevation:.52,showSunDisc:!0}},{id:"sunset_glow",names:["落日晚霞","落日晚霞","Sunset Glow"],params:{turbidity:10,rayleigh:2,mieCoefficient:.006,mieDirectionalG:.7,elevation:6,azimuth:245,exposure:.6,cloudCoverage:.3,cloudDensity:.36,cloudElevation:.5,showSunDisc:!0}},{id:"blue_hour",names:["暮色蓝调","暮色蓝调","Blue Hour"],params:{turbidity:7,rayleigh:1.2,mieCoefficient:.003,mieDirectionalG:.76,elevation:-4,azimuth:255,exposure:.22,cloudCoverage:.2,cloudDensity:.24,cloudElevation:.48,showSunDisc:!1}},{id:"overcast_day",names:["阴天白昼","阴天白昼","Overcast Day"],params:{turbidity:20,rayleigh:2,mieCoefficient:.02,mieDirectionalG:.6,elevation:32,azimuth:180,exposure:.38,cloudCoverage:.86,cloudDensity:.68,cloudElevation:.4,showSunDisc:!1}},{id:"storm_rain",names:["暴雨雷云","暴雨雷云","Storm Rain"],params:{turbidity:19,rayleigh:.9,mieCoefficient:.03,mieDirectionalG:.58,elevation:18,azimuth:210,exposure:.2,cloudCoverage:.95,cloudDensity:.9,cloudElevation:.28,showSunDisc:!1}},{id:"snow_day",names:["雪天漫射","雪天漫射","Snowy Day"],params:{turbidity:15,rayleigh:2.6,mieCoefficient:.012,mieDirectionalG:.65,elevation:24,azimuth:170,exposure:.5,cloudCoverage:.78,cloudDensity:.72,cloudElevation:.43,showSunDisc:!1}},{id:"moonlit_night",names:["月夜星空","月夜星空","Moonlit Night"],params:{turbidity:4,rayleigh:.35,mieCoefficient:.001,mieDirectionalG:.82,elevation:-18,azimuth:160,exposure:.14,cloudCoverage:.1,cloudDensity:.14,cloudElevation:.55,showSunDisc:!1}}],HE=AA.reduce((r,e)=>(r[e.id]=e,r),{}),GE=2e6;class WU{engine;sky=null;sun=new T;params={...zE,...HE[QU].params};currentIntensity=.2;currentEnvironmentTarget=null;skyScale=45e4;skyName="bim_engine_sky";savedCameraFar=null;previousBackground=null;previousEnvironment=null;previousBackgroundIntensity=1;previousEnvironmentIntensity=1;previousToneMapping=Xi;previousToneMappingExposure=1;hasCapturedSceneState=!1;constructor(e){this.engine=e}activate(){if(!this.engine?.scene)return;if(this.sky){this.sky.visible=!0,this._captureSceneState(),this._expandCameraFarForSky(),this._applyParamsToSky();return}const e=new pf;e.scale.setScalar(this.skyScale),e.name=this.skyName,this.sky=e,this.engine.scene.add(e),this._captureSceneState(),this._expandCameraFarForSky(),this.engine.renderer&&(this.engine.renderer.toneMapping=ra,this.engine.scene.background=null),this._applyParamsToSky()}close(e=!0){this.sky&&(this._restoreCameraFar(),this._restoreSceneState(e),e?(this.engine?.scene?.remove(this.sky),this.sky.material.dispose(),this.sky.geometry.dispose(),this.sky=null):this.sky.visible=!1)}isActive(){return this.sky!=null&&this.engine?.scene?.children?.includes(this.sky)}getParams(){return{...this.params}}setParams(e){Object.assign(this.params,e),this._applyParamsToSky(),this.engine?.renderer&&(e.exposure!==void 0||e.orthoExposureScale!==void 0)&&(this.engine.renderer.toneMappingExposure=this._getEffectiveExposure())}setPreset(e){const t=HE[e];t&&(this.params={...zE,...t.params},this._applyParamsToSky(),this.engine?.renderer&&(this.engine.renderer.toneMappingExposure=this._getEffectiveExposure()))}getPresetNames(){return AA.map(e=>e.id)}getPresetList(){return AA.map(e=>({id:e.id,names:[...e.names],params:{...e.params}}))}setIntensity(e){if(this.currentIntensity=Math.max(e,0),!(!this.sky?.visible||!this.engine?.scene)){if(!this.currentEnvironmentTarget){this._refreshEnvironmentMap();return}this.engine.scene.environmentIntensity=this.currentIntensity}}getIntensity(){return this.currentIntensity}update(e){if(!this.sky?.visible)return;const t=this.sky.material.uniforms;t&&"time"in t&&(t.time.value=e??performance.now()*.001),this.engine?.renderer&&(this.engine.renderer.toneMappingExposure=this._getEffectiveExposure())}_isOrthographicCamera(){const e=this.engine?.camera;return e!=null&&e.type==="OrthographicCamera"}_getEffectiveExposure(){const e=this.params.exposure;return this._isOrthographicCamera()?e*this.params.orthoExposureScale:e}_expandCameraFarForSky(){const e=this.engine?.camera;if(!e||typeof e.far!="number")return;const t=e.far;t>=GE||(this.savedCameraFar==null&&(this.savedCameraFar=t),e.far=GE,typeof e.updateProjectionMatrix=="function"&&e.updateProjectionMatrix())}_restoreCameraFar(){if(this.savedCameraFar==null||!this.engine?.camera)return;const e=this.engine.camera;typeof e.far=="number"&&(e.far=this.savedCameraFar,typeof e.updateProjectionMatrix=="function"&&e.updateProjectionMatrix(),this.savedCameraFar=null)}_applyParamsToSky(){if(!this.sky)return;const e=this.sky.material.uniforms;this._setUniformValue(e,"turbidity",this.params.turbidity),this._setUniformValue(e,"rayleigh",this.params.rayleigh),this._setUniformValue(e,"mieCoefficient",this.params.mieCoefficient),this._setUniformValue(e,"mieDirectionalG",this.params.mieDirectionalG),this._setUniformValue(e,"cloudCoverage",this.params.cloudCoverage),this._setUniformValue(e,"cloudDensity",this.params.cloudDensity),this._setUniformValue(e,"cloudElevation",this.params.cloudElevation),this._setUniformValue(e,"showSunDisc",this.params.showSunDisc?1:0);const t=Dt.degToRad(90-this.params.elevation),i=Dt.degToRad(this.params.azimuth);this.sun.setFromSphericalCoords(1,t,i),this._setUniformValue(e,"sunPosition",this.sun),this.engine?.renderer&&(this.engine.renderer.toneMapping=ra,this.engine.renderer.toneMappingExposure=this._getEffectiveExposure(),this.sky.visible&&this._refreshEnvironmentMap())}_captureSceneState(){this.hasCapturedSceneState||!this.engine?.scene||(this.previousBackground=this.engine.scene.background,this.previousEnvironment=this.engine.scene.environment,this.previousBackgroundIntensity=this.engine.scene.backgroundIntensity??1,this.previousEnvironmentIntensity=this.engine.scene.environmentIntensity??1,this.previousToneMapping=this.engine.renderer?.toneMapping??Xi,this.previousToneMappingExposure=this.engine.renderer?.toneMappingExposure??1,this.hasCapturedSceneState=!0)}_restoreSceneState(e){!this.hasCapturedSceneState||!this.engine?.scene||(this.engine.scene.background=this.previousBackground,this.engine.scene.environment=this.previousEnvironment,this.engine.scene.backgroundIntensity=this.previousBackgroundIntensity,this.engine.scene.environmentIntensity=this.previousEnvironmentIntensity,this.engine.renderer&&(this.engine.renderer.toneMapping=this.previousToneMapping,this.engine.renderer.toneMappingExposure=this.previousToneMappingExposure),e&&(this._disposeEnvironmentTarget(),this.previousBackground=null,this.previousEnvironment=null,this.previousBackgroundIntensity=1,this.previousEnvironmentIntensity=1,this.previousToneMapping=Xi,this.previousToneMappingExposure=1,this.hasCapturedSceneState=!1))}_refreshEnvironmentMap(){if(!this.sky||!this.engine?.renderer||!this.engine?.scene)return;this._disposeEnvironmentTarget();const e=new ga,t=this.sky.clone();t.material=this.sky.material.clone(),e.add(t);const i=new Kc(this.engine.renderer);this.currentEnvironmentTarget=i.fromScene(e,0,.1,this.skyScale*2),i.dispose(),this.engine.scene.background=null,this.engine.scene.environment=this.currentEnvironmentTarget.texture,this.engine.scene.environmentIntensity=this.currentIntensity,t.material.dispose()}_disposeEnvironmentTarget(){this.currentEnvironmentTarget?.dispose(),this.currentEnvironmentTarget=null}_setUniformValue(e,t,i){const n=e[t];n&&(i instanceof T&&typeof n.value?.copy=="function"?n.value.copy(i):n.value=i)}}let jU=class{engine;constructor(r){this.engine=r,this.active()}active(){window.addEventListener("D2ElementClick",this.listenElementClick)}disActive(){window.removeEventListener("D2ElementClick",this.listenElementClick)}listenElementClick=r=>{let e=!0;this.engine.models.forEach(t=>{t.nodesMap.has(Number(r.detail.id))&&(e=!1,this.engine.modelToolModule.highlightModel([{url:t.url,ids:[Number(r.detail.id)]}]),this.engine.viewCube.zoomToModels({url:t.url,id:Number(r.detail.id)}))}),(Number(r.detail.id)==-1||e)&&this.engine.modelToolModule.unhighlightAllModels()}},qU=class{engine;constructor(r){this.engine=r,this.active()}active(){window.addEventListener("D2ViewControl",this.listenViewUpdate)}disActive(){window.removeEventListener("D2ViewControl",this.listenViewUpdate)}listenViewUpdate=r=>{const e=r?.detail;e&&(e.position&&this.applyPosition(e.position),typeof e.rotation=="number"&&this.applyRotation(e.rotation))};applyPosition(r){const e=this.engine.camera;if(!e)return;const t=this.engine.controls,i=e.position.clone(),n=typeof r.y=="number"?r.y:i.y;e.position.set(r.x,n,r.z),t?.target?(t.target.set(t.target.x+(r.x-i.x),t.target.y+(n-i.y),t.target.z+(r.z-i.z)),t.update(),t.dispatchEvent?.({type:"change"})):e.updateMatrixWorld()}applyRotation(r){const e=this.engine.camera;if(!e)return;const t=this.engine.controls,i=t?.target;let n=10;i&&(n=Math.max(1,e.position.distanceTo(i)));const s=new T(Math.sin(r),0,-Math.cos(r)),a=i?i.y:e.position.y,o=new T(e.position.x+s.x*n,a,e.position.z+s.z*n);t?.target?(t.target.copy(o),t.update(),t.dispatchEvent?.({type:"change"})):e.lookAt(o)}};class XU{engine;apiKey;baseURL="https://api.deepseek.com";constructor(e,t){this.engine=e,this.apiKey=t||"sk-4677b153277a40b096c6716686c29ac4",console.log("OneClickEncoding 初始化,API Key:",this.apiKey?.substring(0,8)+"...")}start(){let e=["注释","族名称"],t=[];this.engine.models.forEach(i=>{i.nodesMap.forEach((n,s)=>{this.engine.modelProperties.getModelPropertiesWithName(i.url,s,e,a=>{t.push(a),t.length==i.nodesMap.size&&this.startChat(i.url,JSON.stringify(t))})})})}async startChat(e,t){let i=await this.chat(t);const n=i.match(/```json\s*([\s\S]*?)\s*```/),s=n?n[1]:i,a=JSON.parse(s);console.log("解析后的编码结果:",a);let o=this.engine.models.find(l=>l.url==e);o!=null&&a.forEach(l=>{let c=o.nodesMap.get(Number(l.id));c!=null&&(c.code=l.code)})}async chat(e){let t=`你是一个经验丰富的桥梁工程师,你要为我的BIM模型进行编码,按一定的规则进行编码。
|
||
【输入信息】
|
||
- 1. json字符串,里面会包含构件名称,构件类型,里程等等等。
|
||
- 2. 项目的基本信息,如项目名称,桥梁名称等
|
||
【编码规则】
|
||
请按照以下层级生成编码(用”-”连接):
|
||
第一层:工程部位(固定为”桥梁工程”)
|
||
第二层:构件类型(主梁/桥墩/桩基/盖梁/支座等)
|
||
第三层:具体位置标识(线路+墩号+构件编号)
|
||
|
||
【示例格式】
|
||
桥梁工程-桩基-左线1#_2桩基
|
||
|
||
【输出要求】
|
||
请根据上述规则,为输入构件生成标准编码,必须每个构件都具有编码。
|
||
|
||
【输出格式】
|
||
输出格式要严格的json格式,包含构件id,构件编码,格式如下
|
||
[
|
||
{“id”:0,”code”:”code”}
|
||
]
|
||
`;try{console.log("正在调用 DeepSeek API..."),console.log("API Key 前8位:",this.apiKey?.substring(0,8)+"...");const i=await fetch(`${this.baseURL}/v1/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({model:"deepseek-chat",messages:[{role:"system",content:t},{role:"user",content:e}],temperature:.7})});if(!i.ok){const s=await i.text();throw console.error("API 错误详情:",s),new Error(`API request failed: ${i.status} - ${s}`)}const n=await i.json();return console.log("API 调用成功:",n),n.choices[0].message.content}catch(i){throw console.error("DeepSeek API call failed:",i),i}}}class YU{engine;constructor(e){this.engine=e}getViewTreeData(e){return this.engine.models.find(t=>t.url===e)?.views}openView(e,t){t="771513";const i=this.engine.models.find(l=>l.url===e)?.views?.Sections.find(l=>l.id===t||l.Id===t);if(!i)return;const n=i.Origin||i.origin,s=i.ViewDirection||i.viewDirection;if(!n||!s)return;const a=new T(n.X??n.x,-(n.Z??n.z),n.Y??n.y).setLength(.3048),o=new T(s.X??s.x,-(s.Z??s.z),s.Y??s.y).setLength(-1);this.engine.cameraModule.setViewFromOriginAndDirection(a,o),(i.ViewType||i.viewType||"")==="剖面视图"&&(this.engine.clipping.setSectionByView(a,o),this.engine.merge2d.attachSectionPlane(e,t,a,o))}}var On=(r=>(r.ModelLoadStart="model-load-start",r.ModelLoadProgress="model-load-progress",r.ModelLoaded="model-loaded",r.ModelLoadError="model-load-error",r.RenderStart="render-start",r.RenderEnd="render-end",r.CameraChanged="camera-changed",r.CameraReset="camera-reset",r.SelectionChanged="selection-changed",r.HoverChanged="hover-changed",r.EntityClick="entity-click",r.LayerVisibilityChanged="layer-visibility-changed",r.LayerColorChanged="layer-color-changed",r.ViewZoomChanged="view-zoom-changed",r.ViewPanChanged="view-pan-changed",r.ToolActivated="tool-activated",r.ToolDeactivated="tool-deactivated",r.Error="error",r.Warning="warning",r))(On||{});class KU{listeners=new Map;onceListeners=new Map;debugMode=!1;constructor(e=!1){this.debugMode=e,this.initializeEvents()}initializeEvents(){Object.values(On).forEach(e=>{this.listeners.set(e,new Set),this.onceListeners.set(e,new Set)})}on(e,t){return this.listeners.has(e)?(this.listeners.get(e).add(t),this.debugMode&&console.log(`[EventModule2d] Listener added for ${e}`),()=>this.off(e,t)):(console.warn(`Event type ${e} is not registered`),()=>{})}once(e,t){if(!this.onceListeners.has(e)){console.warn(`Event type ${e} is not registered`);return}this.onceListeners.get(e).add(t),this.debugMode&&console.log(`[EventModule2d] Once listener added for ${e}`)}off(e,t){const i=this.listeners.get(e);i&&(i.delete(t),this.debugMode&&console.log(`[EventModule2d] Listener removed for ${e}`))}trigger(e,t){this.debugMode&&console.log(`[EventModule2d] Triggering ${e}`,t);const i=this.listeners.get(e);i&&i.size>0&&i.forEach(s=>{try{s(t)}catch(a){console.error(`[EventModule2d] Error in listener for ${e}:`,a)}});const n=this.onceListeners.get(e);n&&n.size>0&&(n.forEach(s=>{try{s(t)}catch(a){console.error(`[EventModule2d] Error in once listener for ${e}:`,a)}}),n.clear())}removeAllListeners(){this.listeners.forEach(e=>e.clear()),this.onceListeners.forEach(e=>e.clear()),this.debugMode&&console.log("[EventModule2d] All listeners removed")}removeListenersOfType(e){const t=this.listeners.get(e),i=this.onceListeners.get(e);t&&t.clear(),i&&i.clear(),this.debugMode&&console.log(`[EventModule2d] All listeners removed for ${e}`)}getListenerCount(e){const t=this.listeners.get(e),i=this.onceListeners.get(e);return(t?.size||0)+(i?.size||0)}setDebugMode(e){this.debugMode=e}getAllEventTypes(){return Object.values(On)}dispose(){this.removeAllListeners(),this.listeners.clear(),this.onceListeners.clear(),this.debugMode&&console.log("[EventModule2d] Disposed")}}class ZU extends Jo{constructor(e,t={}){const i=t.font;if(i===void 0)super();else{const n=i.generateShapes(e,t.size,t.direction);t.depth===void 0&&(t.depth=50),t.bevelThickness===void 0&&(t.bevelThickness=10),t.bevelSize===void 0&&(t.bevelSize=8),t.bevelEnabled===void 0&&(t.bevelEnabled=!1),super(n,t)}this.type="TextGeometry"}}class JU extends Qi{constructor(e){super(e)}load(e,t,i,n){const s=this,a=new Yi(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){const l=s.parse(JSON.parse(o));t&&t(l)},i,n)}parse(e){return new $U(e)}}class $U{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100,i="ltr"){const n=[],s=eF(e,t,this.data,i);for(let a=0,o=s.length;a<o;a++)n.push(...s[a].toShapes());return n}}function eF(r,e,t,i){const n=Array.from(r),s=e/t.resolution,a=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*s,o=[];let l=0,c=0;(i=="rtl"||i=="tb")&&n.reverse();for(let h=0;h<n.length;h++){const d=n[h];if(d===`
|
||
`)l=0,c-=a;else{const p=tF(d,s,l,c,t);i=="tb"?(l=0,c+=t.ascender*s):l+=p.offsetX,o.push(p.path)}}return o}function tF(r,e,t,i,n){const s=n.glyphs[r]||n.glyphs["?"];if(!s){console.error('THREE.Font: character "'+r+'" does not exists in font family '+n.familyName+".");return}const a=new u1;let o,l,c,h,d,p,u,A;if(s.o){const m=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let g=0,f=m.length;g<f;)switch(m[g++]){case"m":o=m[g++]*e+t,l=m[g++]*e+i,a.moveTo(o,l);break;case"l":o=m[g++]*e+t,l=m[g++]*e+i,a.lineTo(o,l);break;case"q":c=m[g++]*e+t,h=m[g++]*e+i,d=m[g++]*e+t,p=m[g++]*e+i,a.quadraticCurveTo(d,p,c,h);break;case"b":c=m[g++]*e+t,h=m[g++]*e+i,d=m[g++]*e+t,p=m[g++]*e+i,u=m[g++]*e+t,A=m[g++]*e+i,a.bezierCurveTo(d,p,u,A,c,h);break}}return{offsetX:s.ha*e,path:a}}class Bh{static async fromUrl(e,t){const i=await fetch(e);if(!i.ok)throw new Error(`FontJsonGenerator: 无法加载 ${e} (${i.status})`);const n=await i.arrayBuffer();return Bh.fromArrayBuffer(n,t)}static fromArrayBuffer(e,t){const i=xM.parse(e);return Bh._convert(i,t?.chars)}static toThreeFont(e){return new JU().parse(e)}static _convert(e,t){const i={},n=e.unitsPerEm,s=d=>Math.round(d),a=d=>{const p=e.charToGlyph(d);if(!p||p.index===0)return;const u=p.path.commands,A=[];for(const g of u)switch(g.type){case"M":A.push(`m ${s(g.x)} ${s(g.y)}`);break;case"L":A.push(`l ${s(g.x)} ${s(g.y)}`);break;case"Q":A.push(`q ${s(g.x1)} ${s(g.y1)} ${s(g.x)} ${s(g.y)}`);break;case"C":A.push(`b ${s(g.x1)} ${s(g.y1)} ${s(g.x2)} ${s(g.y2)} ${s(g.x)} ${s(g.y)}`);break;case"Z":A.push("z");break}const m=p.getBoundingBox();i[d]={x_min:m.x1,x_max:m.x2,ha:p.advanceWidth??0,o:A.join(" ")}};if(t)for(const d of t)a(d);else{const d=e.tables.cmap?.glyphIndexMap??{};for(const p of Object.keys(d)){const u=Number.parseInt(p,10);u>0&&a(String.fromCodePoint(u))}}if(!i[" "]){const d=e.charToGlyph(" ");i[" "]={x_min:0,x_max:0,ha:d?.advanceWidth??Math.round(n/4),o:""}}const o=e.names,l=d=>o[d]?.en??o[d]?.zh??"",c=l("fontFamily")||"Custom Font",h=l("fontSubfamily")||"Regular";return{familyName:c,ascender:e.ascender,descender:e.descender,underlinePosition:e.tables.post?.underlinePosition??-100,underlineThickness:e.tables.post?.underlineThickness??50,boundingBox:{yMin:e.descender,xMin:0,yMax:e.ascender,xMax:n},resolution:n,original_font_information:{fontFamily:c,fontSubfamily:h},cssFontStyle:h.toLowerCase().includes("italic")?"italic":"normal",cssFontWeight:h.toLowerCase().includes("bold")?"bold":"normal",glyphs:i}}}class iF{panel=null;listEl=null;isVisible=!1;delegate;constructor(e,t){this.delegate=t,this._buildPanel(e)}show(){this.panel&&(this.panel.style.display="flex",this.isVisible=!0)}hide(){this.panel&&(this.panel.style.display="none",this.isVisible=!1)}toggle(){this.isVisible?this.hide():this.show()}refresh(){this._renderList()}_buildPanel(e){const t=document.createElement("div");t.style.cssText=`
|
||
position:absolute; top:10px; right:10px;
|
||
width:220px; max-height:480px;
|
||
background:var(--e2d-bg,#1e1f22);
|
||
border:1px solid var(--e2d-border2,#333);
|
||
border-radius:4px;
|
||
box-shadow:0 4px 16px var(--e2d-shadow,rgba(0,0,0,.6));
|
||
display:none; flex-direction:column;
|
||
z-index:100; user-select:none;
|
||
font-size:13px; color:var(--e2d-text,#e0e0e0);
|
||
font-family:system-ui,sans-serif;
|
||
`,this.panel=t;const i=document.createElement("div");i.style.cssText=`
|
||
display:flex; align-items:center; justify-content:space-between;
|
||
padding:8px 10px;
|
||
background:var(--e2d-bg3,#222);
|
||
border-bottom:1px solid var(--e2d-border2,#333);
|
||
border-radius:4px 4px 0 0; cursor:move; flex-shrink:0;
|
||
`;const n=document.createElement("span");n.textContent="图层",n.style.cssText="font-size:13px; font-weight:500; color:var(--e2d-text,#e0e0e0);";const s=document.createElement("button");s.textContent="×",s.style.cssText=`
|
||
background:none; border:none;
|
||
color:var(--e2d-close,#aaa);
|
||
font-size:18px; line-height:1; cursor:pointer; padding:0 2px;
|
||
transition:color 0.15s;
|
||
`,s.onmouseenter=()=>{s.style.color="var(--e2d-close-hover,#fff)"},s.onmouseleave=()=>{s.style.color="var(--e2d-close,#aaa)"},s.onclick=()=>this.hide(),i.appendChild(n),i.appendChild(s),this._makeDraggable(t,i);const a=this._createRow(),o=this._createEye(!0),l=document.createElement("span");l.textContent="全部图层",l.style.cssText="flex:1; font-weight:500; color:var(--e2d-text,#e0e0e0);",a.appendChild(o),a.appendChild(l),a.onclick=()=>{const p=!this.delegate.isAllVisible();this.delegate.setAllLayersVisible(p),this._renderList(),this._updateEye(o,p)};const c=document.createElement("div");c.style.cssText="height:1px; background:var(--e2d-border2,#333); margin:0 8px; flex-shrink:0;";const h=document.createElement("div");h.style.cssText=`
|
||
overflow-y:auto; flex:1;
|
||
scrollbar-width:thin;
|
||
scrollbar-color:var(--e2d-scrollbar,#444) transparent;
|
||
`,this.listEl=h,t.appendChild(i),t.appendChild(a),t.appendChild(c),t.appendChild(h);const d=this._renderList.bind(this);this._renderList=()=>{d(),this._updateEye(o,this.delegate.isAllVisible())},this._renderList(),e.style.position="relative",e.appendChild(t)}_renderList(){const e=this.listEl;if(e){e.innerHTML="";for(const t of this.delegate.getLayers()){const i=this._createRow(),n=this._createEye(t.visible),s=document.createElement("span");s.style.cssText=`
|
||
width:14px; height:14px; border-radius:2px; flex-shrink:0;
|
||
border:1px solid var(--e2d-swatch-border,#444);
|
||
background:${this._colorToHex(t.color)};
|
||
`;const a=document.createElement("span");a.textContent=t.name,a.style.cssText=`
|
||
flex:1; white-space:nowrap; overflow:hidden;
|
||
text-overflow:ellipsis; font-size:12px;
|
||
color:${t.visible?"var(--e2d-text,#ddd)":"var(--e2d-text4,#666)"};
|
||
transition:color 0.15s;
|
||
`,i.appendChild(n),i.appendChild(s),i.appendChild(a),i.onclick=()=>{const o=this.delegate.toggleLayer(t.name);this._updateEye(n,o),a.style.color=o?"var(--e2d-text,#ddd)":"var(--e2d-text4,#666)"},e.appendChild(i)}}}_createRow(){const e=document.createElement("div");return e.style.cssText=`
|
||
display:flex; align-items:center; gap:8px;
|
||
padding:5px 10px; cursor:pointer;
|
||
border-bottom:1px solid var(--e2d-border2,#222);
|
||
transition:background 0.1s;
|
||
`,e.onmouseenter=()=>{e.style.background="var(--e2d-bg-hover,#2a2a2a)"},e.onmouseleave=()=>{e.style.background=""},e}_createEye(e){const t=document.createElement("span");return t.style.cssText="display:flex; align-items:center; flex-shrink:0; width:16px;",this._updateEye(t,e),t}_updateEye(e,t){e.style.color=t?"var(--e2d-close,#aaa)":"var(--e2d-text4,#555)",e.innerHTML=t?`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||
<path d="M8 3C4.5 3 1.5 8 1.5 8C1.5 8 4.5 13 8 13C11.5 13 14.5 8 14.5 8C14.5 8 11.5 3 8 3Z" stroke="currentColor" stroke-width="1.2"/>
|
||
<circle cx="8" cy="8" r="2" stroke="currentColor" stroke-width="1.2"/>
|
||
</svg>`:`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||
<path d="M2 2L14 14" stroke="currentColor" stroke-width="1.2"/>
|
||
<path d="M8 3C4.5 3 1.5 8 1.5 8C2.2 9.3 3.3 10.5 4.5 11.5" stroke="currentColor" stroke-width="1.2"/>
|
||
<path d="M11.5 11.5C12.7 10.5 13.8 9.3 14.5 8C14.5 8 11.5 3 8 3" stroke="currentColor" stroke-width="1.2"/>
|
||
</svg>`}_colorToHex(e){return"#"+e.toString(16).padStart(6,"0")}_makeDraggable(e,t){t.onmousedown=i=>{i.preventDefault();const n=e.getBoundingClientRect(),s=e.offsetParent?.getBoundingClientRect()??{left:0,top:0};e.style.left=n.left-s.left+"px",e.style.top=n.top-s.top+"px",e.style.right="auto",e.style.bottom="auto";const a=i.clientX-n.left,o=i.clientY-n.top,l=h=>{e.style.left=h.clientX-a-s.left+"px",e.style.top=h.clientY-o-s.top+"px"},c=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c)};document.addEventListener("mousemove",l),document.addEventListener("mouseup",c)}}dispose(){this.panel?.remove(),this.panel=null,this.listEl=null}}class VE{engine;layerMap=new Map;panelUI=null;constructor(e){this.engine=e;const t=document.getElementById(e?.options?.containerId??"")??e?.container??null;t&&(this.panelUI=new iF(t,this))}_loadLayers(){let e=this.engine.dwgData.layers;this.layerMap.clear();for(const t of e)this.layerMap.set(t.name,{...t}),this.panelUI?.refresh()}syncFromModel(e){e?.length>0&&(this._loadLayers(e),this.panelUI?.refresh())}getLayers(){return Array.from(this.layerMap.values())}setLayerVisible(e,t){const i=this.layerMap.get(e);i&&(i.visible=t),this._applyVisibility(e,t)}toggleLayer(e){const t=this.layerMap.get(e);if(!t)return!0;const i=!t.visible;return this.setLayerVisible(e,i),i}setAllLayersVisible(e){for(const t of this.layerMap.keys()){const i=this.layerMap.get(t);i.visible=e,this._applyVisibility(t,e)}}isAllVisible(){return Array.from(this.layerMap.values()).every(e=>e.visible)}_applyVisibility(e,t){const i=this.engine?.scene;if(!i)return;const n=e+"||";i.children.forEach(s=>{s.name?.startsWith(n)&&(s.visible=t)})}show(){this.panelUI?.show()}hide(){this.panelUI?.hide()}toggle(){this.panelUI?.toggle()}dispose(){this.panelUI?.dispose(),this.panelUI=null,this.layerMap.clear()}}class QE{engine;data=null;enableValidation=!0;constructor(e){for(this.engine=e,this.engine.modelGroup=new Mi,this.engine.modelGroup.name="model2d",this.engine.scene.add(this.engine.modelGroup);this.engine.modelGroup.children.length>0;)this.engine.modelGroup.remove(this.engine.modelGroup.children[0])}async loadModel(e,t={}){if(!e.includes(".json"))this.engine.events&&this.engine.events.trigger(On.ModelLoadStart,{url:e}),xh(e,async i=>{const n=JSON.parse(i);this.engine.dwgData=n,this.data=n,await this.buildScene(n);try{this.engine.fitToView()}catch{}this.engine.layerManager||(this.engine.layerManager=new VE(this.engine)),this.engine.layerManager._loadLayers(),this.engine.events&&this.engine.events.trigger(On.ModelLoaded,{})},i=>{this._emitProgress(0,"抱歉,图纸加载失败")});else{this.engine.events&&this.engine.events.trigger(On.ModelLoadStart,{url:e}),this._emitProgress(10,"请求数据...");const i=await this.fetchJson(e);this._emitProgress(20,"解析数据...");const n=this.parseData(i);if(this.engine.dwgData=n,!n)throw new Error("Failed to parse DWG data");this.data=n,await this.buildScene(n),this.engine.fitToView(),this.engine.layerManager._loadLayers(),this.engine.events&&this.engine.events.trigger(On.ModelLoaded,{})}}async fetchJson(e){const t=await fetch(e);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return await t.json()}parseData(e){return e?this.enableValidation&&!this.validateDataStructure(e)?(console.error("[LoaderModule2d] Invalid data structure"),null):e:(console.error("[LoaderModule2d] Empty JSON data"),null)}validateDataStructure(e){return e.version||console.warn("[LoaderModule2d] Missing version"),e.metadata||console.warn("[LoaderModule2d] Missing metadata"),Array.isArray(e.layers)?Array.isArray(e.entities)?!0:(console.error("[LoaderModule2d] Invalid or missing entities array"),!1):(console.error("[LoaderModule2d] Invalid or missing layers array"),!1)}model={};totalBlock=new Map;font=null;async loadFont(){const e=this.engine.options?.fontUrl??"/fonts/simfang.ttf",t=await Bh.fromUrl(e);return Bh.toThreeFont(t)}_emitProgress(e,t){this.engine.events&&this.engine.events.trigger(On.ModelLoadProgress,{progress:e,text:t})}async buildScene(e){this._emitProgress(10,"正在加载"),this.font=await this.loadFont(),this.model.layers=e.layers,this.model.modelMap=new Map,this.model.hatchMap=new Map,this.model.textMap=new Map,this.model.nodeMap=new Map,console.log(this.model.layers),this._emitProgress(10,"正在加载..."),await Promise.resolve(),e.blocks.forEach(t=>{this.loadBlock(t,t.name,!0)}),this._emitProgress(10,"正在加载..."),await Promise.resolve(),this.loadBlock({entities:e.entities},"",!1),this._emitProgress(10,"正在加载..."),await Promise.resolve(),this.model.modelMap.forEach((t,i)=>{let n=[];if(t.forEach(a=>{for(const o of a)n.push(o)}),n.length!=0){const a=new ot().setFromPoints(n);let o=parseInt(i.split("||")[1]);if(o==0){var s=this.model.layers.find(d=>d.name==i.split("||")[0]);o=s.color}const l=new si({color:o}),c=new vi(a,l);c.name=i,c.clonePoints=[],n.forEach(d=>{c.clonePoints.push(d.x),c.clonePoints.push(d.y),c.clonePoints.push(d.z)}),c.materialClone=l.clone(),this.engine.modelGroup.add(c);let h=0;t.forEach((d,p)=>{this.model.nodeMap.has(p)?this.model.nodeMap.get(p).push({indexes:[this.engine.modelGroup.children.length-1,h,h+d.length*3],min:new T(Math.min(...d.map(u=>u.x)),Math.min(...d.map(u=>u.y)),0),max:new T(Math.max(...d.map(u=>u.x)),Math.max(...d.map(u=>u.y)),0)}):this.model.nodeMap.set(p,[{indexes:[this.engine.modelGroup.children.length-1,h,h+d.length*3],min:new T(Math.min(...d.map(u=>u.x)),Math.min(...d.map(u=>u.y)),0),max:new T(Math.max(...d.map(u=>u.x)),Math.max(...d.map(u=>u.y)),0)}]),h=h+d.length*3})}}),this._emitProgress(85,"正在加载..."),await Promise.resolve(),this.model.textMap.forEach((t,i)=>{const n=oo(t.map(c=>c.geometry),!1);let s=Number.parseInt(i.split("||")[1]);if(s===0){const c=this.model.layers.find(h=>h.name===i.split("||")[0]);c&&(s=c.color)}const a=new Rt({color:s,side:Vt});i.includes("_hitbox")&&(a.visible=!1);let o=new Ge(n,a);o.name=i,o.materialClone=a.clone(),o.isSplit=!1,o.geometrys=t.map(c=>c.geometry),this.engine.modelGroup.add(o);let l=0;t.forEach(c=>{this.model.nodeMap.has(c.info.linkId)?this.model.nodeMap.get(c.info.linkId).push({indexes:[this.engine.modelGroup.children.length-1,l++],min:new T(c.info.min[0],c.info.min[1],0),max:new T(c.info.max[0],c.info.max[1],0)}):this.model.nodeMap.set(c.info.linkId,[{indexes:[this.engine.modelGroup.children.length-1,l++],min:new T(c.info.min[0],c.info.min[1],0),max:new T(c.info.max[0],c.info.max[1],0)}])})}),this._emitProgress(93,"正在加载..."),await Promise.resolve(),this.model.hatchMap.forEach((t,i)=>{let n=oo(t.map(h=>h.geometry),!1),s=parseInt(i.split("||")[1]);if(s==0){var a=this.model.layers.find(h=>h.name==i.split("||")[0]);s=a.color}const o=new Rt({color:s,side:Vt,transparent:!0,opacity:.5});let l=new Ge(n,o);l.name=i,l.materialClone=o.clone(),l.isSplit=!1,l.geometrys=t.map(h=>h.geometry),this.engine.modelGroup.add(l);let c=0;t.forEach(h=>{this.model.nodeMap.has(h.info.linkId)?this.model.nodeMap.get(h.info.linkId).push({indexes:[this.engine.modelGroup.children.length-1,c++],min:new T(h.info.min[0],h.info.min[1],0),max:new T(h.info.max[0],h.info.max[1],0)}):this.model.nodeMap.set(h.info.linkId,[{indexes:[this.engine.modelGroup.children.length-1,c++],min:new T(h.info.min[0],h.info.min[1],0),max:new T(h.info.max[0],h.info.max[1],0)}])})}),this._emitProgress(100,"加载完成")}loadBlock(e,t,i,n=0){let s=[0,0,0];i&&(s=e.origin),e.entities.forEach(a=>{const o=a.layer+"||"+a.color;let l=new Map;i?(l=this.totalBlock.get(t),l==null&&(l=new Map,this.totalBlock.set(t,l))):(l=this.model.modelMap.get(o),l==null&&(l=new Map,this.model.modelMap.set(o,l)));let c=[];switch(a.type){case"LINE":c=this.getPoint_line(a,s);break;case"CIRCLE":c=this.getPoint_arc(a,s);break;case"POLYLINE":c=this.getPoint_polyline(a,s);break;case"MTEXT":this.create_text(a);break;case"HATCH":this.create_hatch(a);break;case"INSERT":if(i==!1){this.totalBlock.get(a.blockId)?.forEach(p=>{c.push(...p.map(u=>u.clone()))});const d=this.getMatrix(a.position,a.scale,a.rotation);c.forEach(p=>{p.applyMatrix4(d)})}break;default:return console.warn(`[LoaderModule2d] Unknown entity type: ${a.type}`),null}l.has(a.linkId)?l.get(a.linkId).push(...c):l.set(a.linkId,c)})}getPoint_polyline(e,t){let i=[];for(let n=0;n<e.points.length-1;n++)i.push(new T(e.points[n].x,e.points[n].y,0)),i.push(new T(e.points[n+1].x,e.points[n+1].y,0));return e.closed&&(i.push(new T(e.points[e.points.length-1].x,e.points[e.points.length-1].y,0)),i.push(new T(e.points[0].x,e.points[0].y,0))),i.forEach(n=>{n[0]=n[0]-t[0],n[1]=n[1]-t[1]}),i}create_hatch(e){if(!e.loops||e.loops.length===0)return;const t=e.loops.filter(o=>o.type===!0),i=e.loops.filter(o=>o.type===!1),n=[];for(const o of t){if(!o.points||o.points.length<3)continue;const l=new Ws;l.moveTo(o.points[0][0],o.points[0][1]);for(let c=1;c<o.points.length;c++)l.lineTo(o.points[c][0],o.points[c][1]);l.closePath();for(const c of i){if(!c.points||c.points.length<3)continue;const h=new Gc;h.moveTo(c.points[0][0],c.points[0][1]);for(let d=1;d<c.points.length;d++)h.lineTo(c.points[d][0],c.points[d][1]);h.closePath(),l.holes.push(h)}n.push(new qc(l))}if(n.length===0)return;const s=n.length===1?n[0]:oo(n,!1),a=e.layer+"||"+e.color;this.model.hatchMap.has(a)?this.model.hatchMap.get(a).push({geometry:s,info:e}):this.model.hatchMap.set(a,[{geometry:s,info:e}])}create_text(e){if(!this.font||!e.text)return;const t=new ZU(e.text,{font:this.font,size:e.height??100,depth:0});e.position[1]=e.position[1]-e.height;const i=this.getMatrix(e.position,[1,1,1],e.rotation);t.applyMatrix4(i);const n=e.layer+"||"+e.color;this.model.textMap.has(n)?this.model.textMap.get(n).push({geometry:t,info:e}):this.model.textMap.set(n,[{geometry:t,info:e}]),t.computeBoundingBox();const s=t.boundingBox;if(s){const a=s.max.x-s.min.x,o=s.max.y-s.min.y,l=new jn(a,o);new Rt({visible:!1,side:Vt,depthWrite:!1});let c=[(s.min.x+s.max.x)/2,(s.min.y+s.max.y)/2,0],h=this.getMatrix(c,[1,1,1],0);l.applyMatrix4(h);const d=e.layer+"||"+e.color+"_hitbox";this.model.textMap.has(d)?this.model.textMap.get(d).push({geometry:l,info:e}):this.model.textMap.set(d,[{geometry:l,info:e}])}}getPoint_line(e,t){const i=new T(e.startPoint[0],e.startPoint[1],e.startPoint[2]||0),n=new T(e.endPoint[0],e.endPoint[1],e.endPoint[2]||0);let s=[i,n];return s.forEach(a=>{a[0]=a[0]-t[0],a[1]=a[1]-t[1]}),s}getPoint_arc(e,t){const i=e.center[0],n=e.center[1],s=e.radius,a=new Oc(i,n,s,s,e.startAngle,e.endAngle,!1,0).getPoints(30).map(l=>new T(l.x,l.y,0));let o=[];for(let l=0;l<a.length-1;l++)o.push(a[l].clone()),o.push(a[l+1].clone());return o.forEach(l=>{l[0]=l[0]-t[0],l[1]=l[1]-t[1]}),o}getMatrix(e,t,i){const n=new T(e[0],e[1],e[2]),s=new Di(0,0,i),a=new T(t[0],t[1],t[2]),o=new Tt;o.setFromEuler(s);const l=new Ke;return l.compose(n,o,a),l}getData(){return this.data}getEntitiesByLayer(e){return this.data?this.data.entities.filter(t=>t.layer===e):[]}getLayers(){return this.data?this.data.layers:[]}clear(){this.data=null}dispose(){this.clear()}}class nF{engine;sectionPlaneGroup=null;loaderModule2d;constructor(e){this.engine=e,this.loaderModule2d=new QE(this.engine)}async attachSectionPlane(e,t,i,n){await this.loaderModule2d.loadModel(e+"/"+t,{chunkSize:1e3,enableChunkedLoading:!0,enableValidation:!0});let s=new T(i.x,i.y,i.z),a=new T(n.x,n.y,n.z);const o=new T().copy(a);let l=s.clone().sub(this.engine.modelGroup.position.clone()).dot(a);this.engine.modelGroup.lookAt(o);let c=this.engine.modelGroup.position.clone().add(a.setLength(l));this.engine.modelGroup.position.set(c.x,c.y,c.z),console.log("绘制完成")}removeSectionPlane(){this.engine.scene.remove(this.engine.modelGroup)}getMatrix(e,t){const i=new T(e.x,e.y,e.z),n=new Di(t.x,t.y,t.z),s=new T(1,1,1),a=new Tt;a.setFromEuler(n);const o=new Ke;return o.compose(i,a,s),o}computeMatrixFromOriginAndDirection(e,t){const i=new Ke,n=t.clone().normalize();if(n.length()===0)return console.warn("方向向量长度为零,返回单位矩阵"),i.identity();const s=new T(0,1,0);let a=new T().crossVectors(s,n);if(a.length()<1e-4){const c=new T(0,0,1);a=new T().crossVectors(c,n).normalize()}else a.normalize();const o=new T().crossVectors(a,n).normalize(),l=new Ke;return l.set(a.x,n.x,o.x,0,a.y,n.y,o.y,0,a.z,n.z,o.z,0,0,0,0,1),l.setPosition(e),l}}class sF{options;deviceType;animationId=null;isRenderingPaused=!1;controlsEnabledBeforePause=!0;animate;onWindowResize;_fpsFrameCount=0;_fpsLastCheck=0;_fpsLastSwitch=0;_lowFpsCount=0;_highFpsCount=0;_fpsCheckInterval=100;_fpsSwitchCooldown=100;_fpsThreshold=30;_fpsUpgradeThreshold=60;_lowFpsRequired=5;_highFpsRequired=.1;isMouseDown=!1;isWheeling=!1;scene;camera;renderer;sceneModule;cameraModule;deviceModule;renderModule;controlModule;composerModule;loaderModule;engineStatus;events;lightModule;interactionModule;modelToolModule;worldToScreen;handelBehaved;octreeBox;controls;stats;catchSvg;engineModelModule;viewTree;merge2d;viewCube;rangeScale;setting;measure;clipping;modelTree;engineInfo;modelProperties;modelMapperBatch;modelEdge;ai;pathRoaming;hoverHighLight;minMap;grid;level;issueReport;text;hdr;ground;skyManager;linkElement2d3d;linkView2d3d;oneClickEncoding;models=[];reactBoundingClientRect={left:0,top:0};version="3.4.10";versionEl=null;container;constructor(e){if(window.THREE=bP,this.options=e,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);if(this.engineModelModule=new I6(this),this.engineModelModule.init(),this.ai=new RU(this),this.deviceModule=new xP(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new zr(this),this.sceneModule=new yP(this),this.scene=this.sceneModule.scene,this.renderModule=new DL(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.renderer){const s=this.renderer;s.interactionCullingEnabled=!0,s.interactionActive=!1,s.interactionRenderScene=this.scene,s.interactionFrameBudgetMs=this.options.interactionFrameBudgetMs??6,s.interactionSkipShadows=this.options.interactionSkipShadows??!0}this.controlModule=new JL(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.clipping=new MU(this),this.clipping.init(),this.composerModule=new d8(this),this.composerModule.init(),this.events=new _6,this.engineStatus=new x6(this),this.engineStatus.init(),this.loaderModule=new y6(this),this.lightModule=new E6(this),this.lightModule.init(),this.viewCube=new lU(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=cU(this),this.rangeScale=new hU(this),this.rangeScale.init(),this.setting=new dU(this),this.engineModelModule.init(),this.handelBehaved=k0(this),this.modelMapperBatch=new TU(this),this.measure=new yU(this),this.modelToolModule=new w6(this),this.modelProperties=new CU(this),this.interactionModule=new M6(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new of(this),this.modelEdge=new IU(this),this.modelTree=new wU(this),this.viewTree=new YU(this),this.merge2d=new nF(this),this.engineInfo=new SU(this),this.pathRoaming=new DU(this),this.pathRoaming.init(),this.oneClickEncoding=new XU(this),this.minMap=new BU(this),this.linkElement2d3d=new jU(this),this.linkView2d3d=new qU(this),this.grid=new NU(this),this.level=new OU(this),this.issueReport=new zU(this),this.text=new HU(this),this.hdr=new GU(this),this.ground=new gA(this),this.ground.init(),this.skyManager=new WU(this),this.setting.init(),this.worldToScreen=new zt(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new B6,this.stats.showPanel(0),this.stats.dom.style.position="absolute",this.stats.dom.style.top="0px",this.stats.dom.style.left="0px",this.stats.dom.style.zIndex="1000",this.container.appendChild(this.stats.dom));let t=document.createElement("div");t.className="versionText",this.versionEl=t,this.updateVersionDisplay(),this.container.appendChild(t);let i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.style.position="absolute",i.style.zIndex="1000",i.style.left="0px",i.style.top="0px",i.style.pointerEvents="none",this.container.appendChild(i),this.catchSvg=i,this.onWindowResize=()=>{this.handleWindowResize()},window.addEventListener("resize",this.onWindowResize);let n=this;this.controls.addEventListener("start",()=>{n.renderer&&(n.renderer.interactionActive=!0),n.events.trigger(Ol.EngineBusy),n.container&&(n.container.style.cursor="none")}),this.controls.addEventListener("end",()=>{n.renderer&&(n.renderer.interactionActive=!1),n.events.trigger(Ol.EngineFree),n.container&&(n.container.style.cursor="default")}),this.controls.addEventListener("change",()=>{const s=new T;n.camera.getWorldDirection(s);const a=Math.atan2(s.x,-s.z);let o=new CustomEvent("D3ViewUpdate",{detail:{position:n.camera.position,rotation:a,type:n.camera.type}});window.dispatchEvent(o)}),this.animate=()=>{if(!this.isRenderingPaused)this.animationId=requestAnimationFrame(this.animate);else{this.animationId=null;return}this.stats&&this.stats.begin(),this.composerModule&&this.composerModule.composer.render(),this.viewCube&&this.viewCube.cubeTool.RenderScene(),this.measure.update(),this.ground.update(),this.skyManager.update(),this.hoverHighLight.update(),this.controlModule.update(),this.minMap.update(),this.grid.update(),this.level.update(),this.text&&this.text.update(),this.stats&&this.stats.end(),this._fpsFrameCount++;const s=performance.now();if(s-this._fpsLastCheck>=this._fpsCheckInterval){const a=s-this._fpsLastCheck,o=this._fpsFrameCount/a*1e3;this._fpsFrameCount=0,this._fpsLastCheck=s,o<this._fpsThreshold?(this._lowFpsCount++,this._highFpsCount=0,this._lowFpsCount>=this._lowFpsRequired&&s-this._fpsLastSwitch>this._fpsSwitchCooldown&&(this._adaptiveRenderingDowngrade(),this._fpsLastSwitch=s,this._lowFpsCount=0)):o>this._fpsUpgradeThreshold?(this._highFpsCount++,this._lowFpsCount=0):(this._lowFpsCount=0,this._highFpsCount=0)}if(this.scene){let a=this.scene?.dirLight;a&&this.camera&&this.updateLightPosition(this.camera,a)}},this.animate()}updateVersionDisplay(){if(!this.versionEl)return;const e={simple:"simple",balance:"balance",advanced:"advanced"},t=this.engineModelModule?.getCurrentMode()??"",i=e[t]??t;this.versionEl.innerHTML=`v${this.version} | ${i}`}updateLightPosition(e,t){const i=new T;e.getWorldDirection(i);const n=100,s=new T().copy(i).multiplyScalar(-n),a=new T(0,1,0),o=new T().crossVectors(i,a).normalize();s.addScaledVector(a,n*.5),s.addScaledVector(o,n*.3),t.position.copy(e.position).add(s);const l=new T().copy(e.position).add(i.multiplyScalar(20));t.target.position.copy(l),t.target.updateMatrixWorld()}_adaptiveRenderingDowngrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),i=e.indexOf(t);if(i>0){const n=e[i-1];console.log(`[AdaptiveRendering] FPS低于${this._fpsThreshold},自动降级: ${t} → ${n}`),this.engineModelModule.autoSwitch(n)}}_adaptiveRenderingUpgrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),i=e.indexOf(t);if(i<e.length-1){const n=e[i+1];console.log(`[AdaptiveRendering] FPS高于${this._fpsUpgradeThreshold},自动升级: ${t} → ${n}`),this.engineModelModule.autoSwitch(n)}}pauseRendering(){if(this.isRenderingPaused){console.warn("[BimEngine] Rendering is already paused");return}this.isRenderingPaused=!0,this.controls&&(this.controlsEnabledBeforePause=this.controls.enabled,this.controls.enabled=!1)}resumeRendering(){if(!this.isRenderingPaused){console.warn("[BimEngine] Rendering is not paused");return}this.isRenderingPaused=!1,this.controls&&(this.controls.enabled=this.controlsEnabledBeforePause),this.animationId===null&&this.animate()}isRenderingPausedState(){return this.isRenderingPaused}handleWindowResize(e,t){if(!this.container||!this.renderer||!this.camera)return;if(e===void 0||t===void 0){const n=this.deviceModule.getContainerSize();e=e??n.width,t=t??n.height}if(!e||!t)return;this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t);const i=e/t;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=i,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const n=this.cameraModule.orthographicCamera,s=this.cameraModule.getOrthographicVisibleHeight(n);this.cameraModule.setOrthographicVisibleHeight(s,n),n.updateProjectionMatrix()}if(this.catchSvg){const n=this.container.clientWidth,s=this.container.clientHeight;this.catchSvg.setAttribute("viewBox",`0 0 ${n} ${s}`)}this.events&&this.events.trigger(Ol.ViewportResize,{width:e,height:t})}dispose(){console.log("[BimEngine] Starting engine disposal..."),this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.isRenderingPaused=!0,this.onWindowResize&&window.removeEventListener("resize",this.onWindowResize);try{this.measure&&(this.measure.disActive(),this.measure.clearAll(),this.measure.annotationContainer&&this.measure.annotationContainer.remove()),this.hdr&&this.hdr.dispose(),this.minMap&&this.minMap.dispose(),this.text&&this.text.dispose(),this.issueReport&&this.issueReport.dispose(),this.clipping&&this.clipping.disActive(),this.interactionModule&&this.interactionModule.disActive(),this.viewCube&&this.viewCube.cubeTool&&typeof this.viewCube.cubeTool.dispose=="function"&&this.viewCube.cubeTool.dispose()}catch(e){console.warn("[BimEngine] Error disposing managers:",e)}try{this.controlModule&&(this.controlModule.originDiv&&this.controlModule.originDiv.remove(),this.controlModule.orbitControls&&typeof this.controlModule.orbitControls.dispose=="function"&&this.controlModule.orbitControls.dispose(),this.controlModule.firstPersonControls&&typeof this.controlModule.firstPersonControls.dispose=="function"&&this.controlModule.firstPersonControls.dispose())}catch(e){console.warn("[BimEngine] Error disposing controls:",e)}this.scene&&this.clearScene(this.scene);try{this.composerModule&&this.composerModule.composer&&(this.composerModule.composer.passes&&this.composerModule.composer.passes.forEach(e=>{e.dispose&&e.dispose()}),this.composerModule.composer.renderTarget1&&this.composerModule.composer.renderTarget1.dispose(),this.composerModule.composer.renderTarget2&&this.composerModule.composer.renderTarget2.dispose())}catch(e){console.warn("[BimEngine] Error disposing composer:",e)}try{this.renderModule&&this.renderModule.disposeRenderer(),this.renderer&&(this.renderer.domElement&&this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss())}catch(e){console.warn("[BimEngine] Error disposing renderer:",e)}try{this.stats&&this.stats.dom&&this.stats.dom.parentElement&&this.stats.dom.parentElement.removeChild(this.stats.dom),this.catchSvg&&this.catchSvg.parentElement&&this.catchSvg.parentElement.removeChild(this.catchSvg)}catch(e){console.warn("[BimEngine] Error disposing DOM elements:",e)}try{this.events&&this.events.listeners&&this.events.listeners.clear()}catch(e){console.warn("[BimEngine] Error clearing event listeners:",e)}this.scene=null,this.camera=null,this.renderer=null,this.controls=null,this.models=[],this.container=null,console.log("[BimEngine] Engine disposal completed")}clearScene(e){e&&([...e.children].forEach(t=>{this.clearScene(t)}),e.parent&&e.parent.remove(e),e instanceof Ge&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(t=>this.disposeMaterial(t)):this.disposeMaterial(e.material))),e instanceof di&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof Au&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof ni&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(t=>this.disposeMaterial(t)):this.disposeMaterial(e.material)),e.instanceMatrix&&(e.instanceMatrix=null),e.instanceColor&&(e.instanceColor=null)),e instanceof Rc&&e.material&&this.disposeMaterial(e.material))}disposeMaterial(e){e&&(["map","lightMap","bumpMap","normalMap","specularMap","envMap","alphaMap","aoMap","displacementMap","emissiveMap","gradientMap","metalnessMap","roughnessMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","transmissionMap","thicknessMap","sheenColorMap","sheenRoughnessMap","specularIntensityMap","specularColorMap","iridescenceMap","iridescenceThicknessMap"].forEach(t=>{const i=e[t];i&&i instanceof ii&&i.dispose()}),e.dispose())}}const rF=`
|
||
varying vec2 vWorldPos;
|
||
|
||
void main() {
|
||
vec4 worldPosition = modelMatrix * vec4(position, 1.0);
|
||
vWorldPos = worldPosition.xy;
|
||
gl_Position = projectionMatrix * viewMatrix * worldPosition;
|
||
}
|
||
`,aF=`
|
||
precision highp float;
|
||
|
||
varying vec2 vWorldPos;
|
||
|
||
uniform float minorSpacing;
|
||
uniform float majorStep;
|
||
uniform vec2 worldPerPixel;
|
||
uniform float minorThicknessPx;
|
||
uniform float majorThicknessPx;
|
||
uniform vec3 minorColor;
|
||
uniform vec3 majorColor;
|
||
uniform float minorOpacity;
|
||
uniform float majorOpacity;
|
||
|
||
float distanceToGridLine(float coord, float spacing) {
|
||
float halfSpacing = spacing * 0.5;
|
||
float wrapped = mod(coord + halfSpacing, spacing) - halfSpacing;
|
||
return abs(wrapped);
|
||
}
|
||
|
||
void main() {
|
||
float spacing = max(minorSpacing, 1e-6);
|
||
float stepMultiplier = max(majorStep, 1.0);
|
||
float majorSpacing = spacing * stepMultiplier;
|
||
|
||
float distMinorX = distanceToGridLine(vWorldPos.x, spacing);
|
||
float distMinorY = distanceToGridLine(vWorldPos.y, spacing);
|
||
float distMajorX = distanceToGridLine(vWorldPos.x, majorSpacing);
|
||
float distMajorY = distanceToGridLine(vWorldPos.y, majorSpacing);
|
||
|
||
float minorThicknessX = max(worldPerPixel.x * minorThicknessPx, 1e-7);
|
||
float minorThicknessY = max(worldPerPixel.y * minorThicknessPx, 1e-7);
|
||
float majorThicknessX = max(worldPerPixel.x * majorThicknessPx, 1e-7);
|
||
float majorThicknessY = max(worldPerPixel.y * majorThicknessPx, 1e-7);
|
||
|
||
float minorMaskX = 1.0 - smoothstep(minorThicknessX, minorThicknessX * 1.5, distMinorX);
|
||
float minorMaskY = 1.0 - smoothstep(minorThicknessY, minorThicknessY * 1.5, distMinorY);
|
||
float majorMaskX = 1.0 - smoothstep(majorThicknessX, majorThicknessX * 1.5, distMajorX);
|
||
float majorMaskY = 1.0 - smoothstep(majorThicknessY, majorThicknessY * 1.5, distMajorY);
|
||
|
||
float majorMask = clamp(max(majorMaskX, majorMaskY), 0.0, 1.0);
|
||
float minorMask = clamp(max(minorMaskX, minorMaskY), 0.0, 1.0);
|
||
minorMask *= (1.0 - majorMask); // Prevent overlap so bold lines dominate.
|
||
|
||
vec3 color = minorColor * minorMask * minorOpacity + majorColor * majorMask * majorOpacity;
|
||
float alpha = minorMask * minorOpacity + majorMask * majorOpacity;
|
||
alpha = clamp(alpha, 0.0, 1.0);
|
||
|
||
if (alpha <= 1e-4) {
|
||
discard;
|
||
}
|
||
|
||
gl_FragColor = vec4(color, alpha);
|
||
}
|
||
`;class oF{scene;camera;container;gridGroup;gridGeometry;gridMaterial;gridMesh;animationFrameId=null;resizeObserver;windowResizeHandler;lastState={zoom:-1,centerX:Number.NaN,centerY:Number.NaN,viewWidth:0,viewHeight:0,containerWidth:0,containerHeight:0,minorSpacing:0};largeGridColor=6052956;smallGridColor=3815994;desiredMinorPixelSize=28;coverageMultiplier=1.6;minSpacing=1e-4;minorThicknessPx=.4;majorThicknessPx=.6;minorLineOpacity=.05;majorLineOpacity=.2;baseRenderOrder=-20;gridZOffset=-.001;majorStep=5;gridUniforms={minorSpacing:{value:100},majorStep:{value:this.majorStep},worldPerPixel:{value:new be(1,1)},minorThicknessPx:{value:this.minorThicknessPx},majorThicknessPx:{value:this.majorThicknessPx},minorColor:{value:new We(this.smallGridColor)},majorColor:{value:new We(this.largeGridColor)},minorOpacity:{value:this.minorLineOpacity},majorOpacity:{value:this.majorLineOpacity}};constructor(e,t,i){this.scene=e,this.camera=t,this.container=i,this.gridGroup=new Mi,this.gridGroup.name="AdaptiveGridGroup",this.gridGroup.renderOrder=this.baseRenderOrder,this.gridGroup.visible=!0,this.gridGroup.position.set(0,0,this.gridZOffset),this.scene.add(this.gridGroup),this.createGridMesh(),this.updateGrid(!0),this.startMonitoring(),this.setupResizeObserver()}createGridMesh(){this.gridGeometry=new jn(1,1,1,1),this.gridMaterial=new ei({uniforms:this.gridUniforms,vertexShader:rF,fragmentShader:aF,transparent:!0,depthWrite:!1,depthTest:!1,side:Vt,toneMapped:!1}),this.gridMesh=new Ge(this.gridGeometry,this.gridMaterial),this.gridMesh.frustumCulled=!1,this.gridMesh.renderOrder=this.baseRenderOrder,this.gridGroup.add(this.gridMesh)}startMonitoring(){const e=()=>{this.updateGrid(),this.animationFrameId=requestAnimationFrame(e)};e()}stopMonitoring(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}setupResizeObserver(){typeof ResizeObserver<"u"?(this.resizeObserver=new ResizeObserver(()=>this.updateGrid(!0)),this.resizeObserver.observe(this.container)):(this.windowResizeHandler=()=>this.updateGrid(!0),window.addEventListener("resize",this.windowResizeHandler))}teardownResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=void 0),this.windowResizeHandler&&(window.removeEventListener("resize",this.windowResizeHandler),this.windowResizeHandler=void 0)}normalizeSpacing(e){const t=Math.max(e,this.minSpacing),i=Math.floor(Math.log10(t)),n=Math.pow(10,i),s=[1,2,5,10];for(const a of s){const o=a*n;if(t<=o)return o}return 10*n}updateGrid(e=!1){if(!this.gridMesh)return;const t=Math.max(1,this.container.clientWidth),i=Math.max(1,this.container.clientHeight),n=this.camera.zoom,s=this.camera.right-this.camera.left,a=this.camera.top-this.camera.bottom,o=Math.max(this.minSpacing,s/n),l=Math.max(this.minSpacing,a/n),c=this.camera.position.x,h=this.camera.position.y,d=o/t,p=l/i,u=d*this.desiredMinorPixelSize,A=this.normalizeSpacing(u),m=this.lastState;if(!e){const v=Math.abs(n-m.zoom)/Math.max(1e-4,m.zoom||1)>.02,b=Math.abs(A-m.minorSpacing)>m.minorSpacing*.05,y=Math.abs(c-m.centerX)>Math.max(A*.5,.01),M=Math.abs(h-m.centerY)>Math.max(A*.5,.01),_=Math.abs(o-m.viewWidth)>m.viewWidth*.01,S=Math.abs(l-m.viewHeight)>m.viewHeight*.01,w=t!==m.containerWidth||i!==m.containerHeight;if(!(v||b||y||M||_||S||w))return}const g=o*this.coverageMultiplier,f=l*this.coverageMultiplier;this.gridMesh.scale.set(g,f,1),this.gridMesh.position.set(c,h,0),this.gridUniforms.minorSpacing.value=A,this.gridUniforms.worldPerPixel.value.set(d,p),this.lastState={zoom:n,centerX:c,centerY:h,viewWidth:o,viewHeight:l,containerWidth:t,containerHeight:i,minorSpacing:A}}setVisible(e){this.gridGroup.visible=e}setColors(e,t){this.largeGridColor=e,this.smallGridColor=t,this.gridUniforms.majorColor.value.setHex(e),this.gridUniforms.minorColor.value.setHex(t)}setOpacity(e,t){this.minorLineOpacity=Math.max(0,Math.min(1,e)),this.majorLineOpacity=Math.max(0,Math.min(1,t)),this.gridUniforms.minorOpacity.value=this.minorLineOpacity,this.gridUniforms.majorOpacity.value=this.majorLineOpacity}dispose(){this.stopMonitoring(),this.teardownResizeObserver(),this.gridMesh&&this.gridGroup.remove(this.gridMesh),this.gridGeometry&&(this.gridGeometry.dispose(),this.gridGeometry=void 0),this.gridMaterial&&(this.gridMaterial.dispose(),this.gridMaterial=void 0),this.gridMesh=void 0}}class lF{engine;scene;options;adaptiveGrid;axesHelper;constructor(e,t){this.engine=e,this.options=t,this.scene=this.createScene(),this.initHelpers()}createScene(){const e=new ga,t=this.options.backgroundColor??1710618;return e.background=new We(t),e.is2D=!0,e}initHelpers(){this.options.axesEnabled&&this.createAxes()}initGrid(){this.options.gridEnabled&&this.createGrid()}createGrid(e=1e3,t=50){this.adaptiveGrid&&(this.adaptiveGrid.dispose(),this.adaptiveGrid=void 0),this.adaptiveGrid=new oF(this.scene,this.engine.cameraModule2d.orthographicCamera,this.engine.renderModule2d.container);const i=this.options.backgroundColor??1710618;this.updateGridColorsByBackground(i)}createAxes(e=100){this.axesHelper&&this.scene.remove(this.axesHelper),this.axesHelper=new d1(e),this.axesHelper.rotation.z=0,this.scene.add(this.axesHelper),this.scene.remove(this.axesHelper),this.scene.add(this.axesHelper),this.axesHelper.renderOrder=999}setBackgroundColor(e){this.scene.background=new We(e),this.updateGridColorsByBackground(e)}updateGridColorsByBackground(e){if(!this.adaptiveGrid)return;const t=new We(e);.299*t.r+.587*t.g+.114*t.b<.5?(this.adaptiveGrid.setColors(16777215,16777215),this.adaptiveGrid.setOpacity(.2,.3)):(this.adaptiveGrid.setColors(0,0),this.adaptiveGrid.setOpacity(.05,.2))}addObject(e){this.scene.add(e)}removeObject(e){this.scene.remove(e),e instanceof Ge&&(e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose())}clearScene(){for(let e=this.scene.children.length-1;e>=0;e--){const t=this.scene.children[e];t!==this.axesHelper&&(this.adaptiveGrid||this.removeObject(t))}this.engine.events&&this.engine.events.trigger("scene-cleared")}getObjects(e=!1){const t=[];return this.scene.children.forEach(i=>{(e||i!==this.axesHelper)&&t.push(i)}),t}getSceneStats(){let e=0,t=0,i=0;return this.scene.children.forEach(n=>{n instanceof Ge?e++:n instanceof di?t++:n instanceof Mi&&i++}),{objectCount:this.scene.children.length,meshCount:e,lineCount:t,groupCount:i}}setGridVisible(e){this.adaptiveGrid&&this.adaptiveGrid.setVisible(e)}setAxesVisible(e){this.axesHelper&&(this.axesHelper.visible=e)}dispose(){this.clearScene(),this.adaptiveGrid&&(this.adaptiveGrid.dispose(),this.adaptiveGrid=void 0),this.axesHelper&&(this.scene.remove(this.axesHelper),this.axesHelper=void 0),this.scene.clear()}}class cF{engine;isFree;highlightModels;highlightHoverModels;hideModels;translucentModels;models;constructor(e){this.engine=e,this.isFree=!0,this.highlightModels=[],this.hideModels=[],this.translucentModels=[],this.highlightHoverModels=[],this.models=[]}}class hF{engine;orthographicCamera;container;frustumSize=1e3;near=.1;far=1e4;initialZoom=1;defaultPosition=new T(0,0,1e3);constructor(e,t){this.engine=e,this.container=t,this.orthographicCamera=this.createOrthographicCamera()}createOrthographicCamera(){const e=this.container.clientWidth/this.container.clientHeight,t=this.frustumSize/2,i=t*e,n=new Ki(-i,i,t,-t,this.near,this.far);return n.position.copy(this.defaultPosition),n.lookAt(0,0,0),n.zoom=this.initialZoom,n.updateProjectionMatrix(),n}animationId=null;animationStartTime=0;animationDuration=800;animationStartState={};animationTargetState={};fitToExtents(e,t=1.2,i=!0,n=800){const s=new T(e.min[0],e.min[1]),a=new T(e.max[0],e.max[1]);if(!(s.distanceTo(a)>.001)){console.warn("[CameraModule2d] Invalid extents, using default view"),this.resetView();return}const o=new T;o.addVectors(s,a).multiplyScalar(.5);const l=new T;l.subVectors(a,s);const c=Math.max(l.x,l.y)*t,h=this.container.clientWidth/this.container.clientHeight,d=c/2,p=d*h,u=-p,A=p,m=d,g=-d,f=o.x,v=o.y,b=1;if(!i){this.orthographicCamera.left=u,this.orthographicCamera.right=A,this.orthographicCamera.top=m,this.orthographicCamera.bottom=g,this.orthographicCamera.position.set(f,v,this.defaultPosition.z),this.orthographicCamera.zoom=b,this.orthographicCamera.updateProjectionMatrix(),this.engine.controlModule2d?.panControls&&(this.engine.controlModule2d.panControls.setPosition(f,v),this.engine.controlModule2d.panControls.setZoom(b)),this.engine.events&&this.engine.events.trigger("camera-changed",{type:"fit-to-extents",center:o,size:l});return}this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.animationStartState={left:this.orthographicCamera.left,right:this.orthographicCamera.right,top:this.orthographicCamera.top,bottom:this.orthographicCamera.bottom,x:this.orthographicCamera.position.x,y:this.orthographicCamera.position.y,zoom:this.orthographicCamera.zoom},this.animationTargetState={left:u,right:A,top:m,bottom:g,x:f,y:v,zoom:b},this.animationDuration=n,this.animationStartTime=performance.now(),this.animateFitToExtents(o,l)}easeOutCubic(e){return 1-Math.pow(1-e,3)}animateFitToExtents(e,t){const i=performance.now()-this.animationStartTime,n=Math.min(i/this.animationDuration,1),s=this.easeOutCubic(n),a=this.animationStartState,o=this.animationTargetState;this.orthographicCamera.left=this.lerp(a.left,o.left,s),this.orthographicCamera.right=this.lerp(a.right,o.right,s),this.orthographicCamera.top=this.lerp(a.top,o.top,s),this.orthographicCamera.bottom=this.lerp(a.bottom,o.bottom,s),this.orthographicCamera.position.x=this.lerp(a.x,o.x,s),this.orthographicCamera.position.y=this.lerp(a.y,o.y,s),this.orthographicCamera.zoom=this.lerp(a.zoom,o.zoom,s),this.orthographicCamera.updateProjectionMatrix(),this.engine.controlModule2d?.panControls&&(this.engine.controlModule2d.panControls.setPosition(this.orthographicCamera.position.x,this.orthographicCamera.position.y),this.engine.controlModule2d.panControls.setZoom(this.orthographicCamera.zoom)),this.engine.events&&this.engine.events.trigger("camera-changed",{type:"fit-to-extents",center:e,size:t,progress:s}),n<1?this.animationId=requestAnimationFrame(()=>this.animateFitToExtents(e,t)):this.animationId=null}lerp(e,t,i){return e+(t-e)*i}setZoom(e){this.orthographicCamera.zoom=e,this.orthographicCamera.updateProjectionMatrix(),this.engine.events&&this.engine.events.trigger("view-zoom-changed",{zoom:e})}getZoom(){return this.orthographicCamera.zoom}setPosition(e,t){this.orthographicCamera.position.set(e,t,this.defaultPosition.z),this.engine.events&&this.engine.events.trigger("view-pan-changed",{x:e,y:t})}getPosition(){return this.orthographicCamera.position.clone()}resetView(){this.orthographicCamera.position.copy(this.defaultPosition),this.orthographicCamera.zoom=this.initialZoom,this.orthographicCamera.updateProjectionMatrix(),this.engine.events&&this.engine.events.trigger("camera-reset")}getViewBounds(){const e=this.orthographicCamera,t=e.zoom,i=e.left/t,n=e.right/t,s=e.top/t,a=e.bottom/t,o=e.position.x,l=e.position.y;return{minX:o+i,maxX:o+n,minY:l+a,maxY:l+s,width:n-i,height:s-a}}screenToWorld(e,t){const i=new T(e/this.container.clientWidth*2-1,-(t/this.container.clientHeight)*2+1,.5);return i.unproject(this.orthographicCamera),i}worldToScreen(e,t){const i=new T(e,t,0);return i.project(this.orthographicCamera),{x:(i.x+1)/2*this.container.clientWidth,y:-(i.y-1)/2*this.container.clientHeight}}updateAspectRatio(){const e=this.container.clientWidth/this.container.clientHeight,t=this.frustumSize/2,i=t*e;this.orthographicCamera.left=-i,this.orthographicCamera.right=i,this.orthographicCamera.top=t,this.orthographicCamera.bottom=-t,this.orthographicCamera.updateProjectionMatrix()}setFrustumSize(e){this.frustumSize=e,this.updateAspectRatio()}getFrustumSize(){return this.frustumSize}dispose(){this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.orthographicCamera=null}}class dF{engine;renderer;container;options;antialias=!0;alpha=!1;precision="highp";constructor(e,t,i){this.engine=e,this.container=t,this.options=i,this.renderer=this.createRenderer(),this.handleResize()}createRenderer(){const e=new $c({antialias:this.antialias,alpha:this.alpha,precision:this.precision}),t=this.container.clientWidth,i=this.container.clientHeight;return e.setSize(t,i),e.setPixelRatio(window.devicePixelRatio),e.autoClear=!0,e.sortObjects=!0,e.setClearColor(this.options.backgroundColor??1710618),this.container.appendChild(e.domElement),e}render(e,t){const i=performance.now();this.engine.events&&this.engine.events.trigger("render-start"),this.renderer.render(e,t);const n=performance.now()-i;this.engine.events&&this.engine.events.trigger("render-end",{renderTime:n})}handleResize(){window.addEventListener("resize",()=>{this.onWindowResize()})}onWindowResize(){const e=this.container.clientWidth,t=this.container.clientHeight;this.renderer.setSize(e,t),this.engine.cameraModule2d&&this.engine.cameraModule2d.updateAspectRatio(),this.engine.scene&&this.engine.camera&&this.render(this.engine.scene,this.engine.camera)}setSize(e,t){this.renderer.setSize(e,t),this.engine.cameraModule2d&&this.engine.cameraModule2d.updateAspectRatio()}getSize(){const e=this.renderer.getSize(new be);return{width:e.x,height:e.y}}setBackgroundColor(e){this.renderer.setClearColor(new We(e))}setPixelRatio(e){this.renderer.setPixelRatio(e)}getPixelRatio(){return this.renderer.getPixelRatio()}setAntialias(e){console.warn("Antialias cannot be changed after renderer creation")}clear(e=!0,t=!0,i=!1){this.renderer.clear(e,t,i)}getInfo(){const e=this.renderer.getContext();return{renderer:this.renderer.capabilities.isWebGL2?"WebGL 2.0":"WebGL 1.0",version:this.renderer.capabilities.getVersion(),vendor:this.renderer.capabilities.vendor,capabilities:{maxTextureSize:this.renderer.capabilities.maxTextureSize,maxRenderbufferSize:this.renderer.capabilities.maxRenderbufferSize,maxVertexAttribs:this.renderer.capabilities.maxVertexAttribs,maxVaryingVectors:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS)}}}dispose(){window.removeEventListener("resize",this.onWindowResize.bind(this)),this.renderer.dispose(),this.container.contains(this.renderer.domElement)&&this.container.removeChild(this.renderer.domElement),this.renderer=null}}class uF extends is{object;domElement;enabled=!0;enableZoom=!0;enablePan=!0;enableDamping=!1;dampingFactor=.05;zoomSpeed=1;minZoom=0;maxZoom=1/0;isDragging=!1;mouseButton=-1;previousMousePosition=new be;targetPosition=new T;targetZoom=1;lastClickTime=0;doubleClickDelay=300;constructor(e,t){super(),this.object=e,this.domElement=t||document,this.targetPosition.copy(e.position),this.targetZoom=e.zoom,this.bindEvents()}bindEvents(){this.domElement.addEventListener("mousedown",this.onMouseDown.bind(this)),this.domElement.addEventListener("mousemove",this.onMouseMove.bind(this)),this.domElement.addEventListener("mouseup",this.onMouseUp.bind(this)),this.domElement.addEventListener("mouseleave",this.onMouseUp.bind(this)),this.domElement.addEventListener("wheel",this.onWheel.bind(this),{passive:!1}),this.domElement.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.domElement.addEventListener("click",this.onClick.bind(this)),this.domElement.addEventListener("touchstart",this.onTouchStart.bind(this),{passive:!1}),this.domElement.addEventListener("touchmove",this.onTouchMove.bind(this),{passive:!1}),this.domElement.addEventListener("touchend",this.onTouchEnd.bind(this)),this.domElement.addEventListener("contextmenu",e=>{e.preventDefault()})}onMouseDown(e){this.enabled&&this.enablePan&&(e.button===0||e.button===1)&&(this.isDragging=!0,this.mouseButton=e.button,this.previousMousePosition.set(e.clientX,e.clientY),this.dispatchEvent({type:"start"}))}onMouseMove(e){if(!this.enabled||!this.isDragging)return;const t=e.clientX-this.previousMousePosition.x,i=e.clientY-this.previousMousePosition.y,n=1/this.object.zoom,s=this.object.top-this.object.bottom,a=this.object.right-this.object.left,o=t/this.domElement.clientWidth*a*n,l=i/this.domElement.clientHeight*s*n;this.targetPosition.x-=o,this.targetPosition.y+=l,this.enableDamping||(this.object.position.copy(this.targetPosition),this.object.updateProjectionMatrix()),this.previousMousePosition.set(e.clientX,e.clientY),this.dispatchEvent({type:"change"})}onMouseUp(e){this.isDragging&&(this.isDragging=!1,this.mouseButton=-1,this.dispatchEvent({type:"end"}))}onWheel(e){if(!this.enabled||!this.enableZoom)return;e.preventDefault();const t=Math.pow(1.1,-Math.sign(e.deltaY)*this.zoomSpeed),i=this.targetZoom;this.targetZoom*=t,this.minZoom>0&&(this.targetZoom=Math.max(this.minZoom,this.targetZoom)),this.maxZoom!==1/0&&(this.targetZoom=Math.min(this.targetZoom,this.maxZoom));const n=this.targetZoom,s=(this.object.right-this.object.left)/2,a=(this.object.top-this.object.bottom)/2,o=this.domElement.getBoundingClientRect(),l=(e.clientX-o.left)/o.width*2-1,c=-((e.clientY-o.top)/o.height)*2+1;this.targetPosition.x+=l*s*(1/i-1/n),this.targetPosition.y+=c*a*(1/i-1/n),this.enableDamping||(this.object.zoom=n,this.object.position.copy(this.targetPosition),this.object.updateProjectionMatrix()),this.dispatchEvent({type:"change"})}onDoubleClick(e){this.enabled&&this.dispatchEvent({type:"doubleClick",event:e})}onClick(e){const t=performance.now();t-this.lastClickTime<this.doubleClickDelay||(this.lastClickTime=t)}onTouchStart(e){if(!this.enabled||e.touches.length!==1)return;e.preventDefault();const t=e.touches[0];this.isDragging=!0,this.previousMousePosition.set(t.clientX,t.clientY),this.dispatchEvent({type:"start"})}onTouchMove(e){if(!this.enabled||!this.isDragging)return;e.preventDefault();const t=e.touches[0],i=t.clientX-this.previousMousePosition.x,n=t.clientY-this.previousMousePosition.y,s=1/this.object.zoom,a=this.object.top-this.object.bottom,o=this.object.right-this.object.left,l=i/this.domElement.clientWidth*o*s,c=n/this.domElement.clientHeight*a*s;this.targetPosition.x-=l,this.targetPosition.y+=c,this.enableDamping||this.object.position.copy(this.targetPosition),this.previousMousePosition.set(t.clientX,t.clientY),this.dispatchEvent({type:"change"})}onTouchEnd(e){this.isDragging&&(this.isDragging=!1,this.dispatchEvent({type:"end"}))}update(){if(this.enabled&&this.enableDamping){const e=1-this.dampingFactor;this.object.position.x+=(this.targetPosition.x-this.object.position.x)*e,this.object.position.y+=(this.targetPosition.y-this.object.position.y)*e,this.object.zoom+=(this.targetZoom-this.object.zoom)*e,this.object.updateProjectionMatrix()}}reset(){this.targetPosition.set(0,0,this.object.position.z),this.targetZoom=1,this.enableDamping||(this.object.position.copy(this.targetPosition),this.object.zoom=this.targetZoom,this.object.updateProjectionMatrix()),this.dispatchEvent({type:"reset"})}setPosition(e,t){this.targetPosition.set(e,t,this.object.position.z),this.enableDamping||this.object.position.copy(this.targetPosition),this.dispatchEvent({type:"change"})}setZoom(e){this.targetZoom=e,this.minZoom>0&&(this.targetZoom=Math.max(this.minZoom,this.targetZoom)),this.maxZoom!==1/0&&(this.targetZoom=Math.min(this.targetZoom,this.maxZoom)),this.enableDamping||(this.object.zoom=this.targetZoom,this.object.updateProjectionMatrix()),this.dispatchEvent({type:"change"})}dispose(){this.enabled=!1,this.domElement.removeEventListener("mousedown",this.onMouseDown.bind(this)),this.domElement.removeEventListener("mousemove",this.onMouseMove.bind(this)),this.domElement.removeEventListener("mouseup",this.onMouseUp.bind(this)),this.domElement.removeEventListener("mouseleave",this.onMouseUp.bind(this)),this.domElement.removeEventListener("wheel",this.onWheel.bind(this)),this.domElement.removeEventListener("dblclick",this.onDoubleClick.bind(this)),this.domElement.removeEventListener("click",this.onClick.bind(this)),this.domElement.removeEventListener("touchstart",this.onTouchStart.bind(this)),this.domElement.removeEventListener("touchmove",this.onTouchMove.bind(this)),this.domElement.removeEventListener("touchend",this.onTouchEnd.bind(this))}}class pF{engine;panControls;isActive=!0;constructor(e){this.engine=e,this.panControls=this.createPanControls(),this.init()}init(){this.panControls.addEventListener("doubleClick",this.onDoubleClick.bind(this)),this.panControls.addEventListener("change",this.onChange.bind(this))}createPanControls(){const e=new uF(this.engine.camera,this.engine.renderer.domElement);return e.enableZoom=!0,e.enablePan=!0,e.enableDamping=!0,e.dampingFactor=.05,e.zoomSpeed=1,e.minZoom=0,e.maxZoom=1/0,e}onDoubleClick(e){this.engine.cameraModule2d&&this.engine.cameraModule2d.resetView()}onChange(){this.engine.events&&this.engine.events.trigger("camera-changed",{type:"user-interaction"})}active(){this.isActive=!0,this.panControls.enabled=!0}disActive(){this.isActive=!1,this.panControls.enabled=!1}update(){this.isActive&&this.panControls.update()}reset(){this.panControls.reset()}setPosition(e,t){this.panControls.setPosition(e,t)}setZoom(e){this.panControls.setZoom(e)}getZoom(){return this.panControls.object.zoom}setEnableZoom(e){this.panControls.enableZoom=e}setEnablePan(e){this.panControls.enablePan=e}setEnableDamping(e){this.panControls.enableDamping=e}setDampingFactor(e){this.panControls.dampingFactor=Math.max(0,Math.min(e,1))}setZoomSpeed(e){this.panControls.zoomSpeed=Math.max(.1,e)}setZoomLimits(e,t){this.panControls.minZoom=e,this.panControls.maxZoom=t}dispose(){this.panControls.dispose(),this.panControls=null}}class fF{engine;pickBoxElementIds=[];worldToScreen;constructor(e){this.engine=e,this.pickBoxElementIds=[],this.worldToScreen=new zt(e.camera,e.renderer,e.scene)}init(){this.pickBoxElementIds=[]}pick2d(e,t){let i=[],n=new be(t.offsetX,t.offsetY);this.init(),this.RecurrentIteration(e,this.engine.dwgData.octree);let s=[];this.pickBoxElementIds.forEach(l=>{this.engine.loaderModule2d.model.nodeMap.get(l).forEach(c=>{if(c!=null){let d=this.engine.modelGroup.children[c.indexes[0]];if(d!=null)if(d instanceof vi){let p=new Ft(c.min,c.max),u=e.ray.intersectsBox(p);if(u!=null&&u!=!1){var h=this.engine.modelGroup.children[c.indexes[0]].clonePoints.slice(c.indexes[1],c.indexes[2]);let A=[],m=[];for(let f=0;f<h.length/3;f++)A.push(new T(h[f*3],h[f*3+1],h[f*3+2]));for(let f=0;f<A.length/2;f++)m.push([A[f*2],A[f*2+1]]);m=m.filter(f=>f[0].distanceTo(f[1])>.001);let g=[];A.forEach(f=>{let v=this.worldToScreen.worldToScreen(f);g.push(v)});for(let f=0;f<g.length/2;f++)m.push([g[f*2],g[f*2+1]]);m=m.filter(f=>f[0].distanceTo(f[1])>1),m=m.filter(f=>o(n,f[0],f[1])<10),m.length>0&&m.forEach(f=>{s.push({distance:o(n,f[0],f[1]),linkId:l})})}}else{let p=d.geometrys[c.indexes[1]];const u=new Rt;let A=new Ge(p,u);A.linkId=l,i.push(A)}}})});const a=e.intersectObjects(i,!0);if(a.length>0)return a[0].object.linkId;if(s.length>0)return s[0].linkId;return null;function o(l,c,h){const d=new be().subVectors(h,c),p=d.lengthSq();if(p<1e-10)return l.distanceTo(c);const u=new be().subVectors(l,c),A=Dt.clamp(u.dot(d)/p,0,1),m=new be().copy(d).multiplyScalar(A).add(c);return l.distanceTo(m)}}RecurrentIteration(e,t){if(t==null)return;let i=new T(t.min.X,t.min.Y,0),n=new T(t.max.X,t.max.Y,0),s=new T(Math.min(i.x,n.x),Math.min(i.y,n.y),Math.min(i.z,n.z)),a=new T(Math.max(n.x,i.x),Math.max(n.y,i.y),Math.max(n.z,i.z)),o=new Ft(s,a),l=e.ray.intersectsBox(o);if(!(l==null||l==!1))if(t.children==null||t.children.length==0){if(t.elements!=null)for(var c of t.elements){let h=this.engine.engineStatus2d.hideModels;h!=null&&h.includes(c)||(h=this.engine.engineStatus2d.highlightModels,!(h!=null&&h.includes(c))&&this.pickBoxElementIds.push(c))}}else{if(t.elements!=null)for(var c of t.elements){let d=this.engine.engineStatus2d.hideModels;d!=null&&d.includes(c)||(d=this.engine.engineStatus2d.highlightModels,!(d!=null&&d.includes(c))&&this.pickBoxElementIds.push(c))}for(let h of t.children)this.RecurrentIteration(e,h)}}}class mF{engine;widgetContainer=null;widgetCanvas=null;widgetCtx=null;widgetSize=50;isDragging=!1;isRotating=!1;lastMouseX=0;lastMouseY=0;widgetX=this.widgetSize/2+5;widgetY=this.widgetSize/2+5;widgetRotation=0;rotationStartAngle=null;widgetRotationStart=0;worldToScreen;currentWordPosition=null;currentWordRotation=null;lastCameraWorldPosition=null;enabled=!0;constructor(e){this.engine=e,this.worldToScreen=new zt(e.camera,e.renderer,e.scene),this.initWidget(),this.active();let t=this;this.engine.controlModule2d.panControls.addEventListener("change",()=>{t.updateViewPoint()})}toggle(){return this.enabled=!this.enabled,this.enabled?(this.active(),this.widgetContainer&&(this.widgetContainer.style.display="block")):(this.disActive(),this.widgetContainer&&(this.widgetContainer.style.display="none")),this.enabled}isEnabled(){return this.enabled}initWidget(){const e=window.devicePixelRatio||1;this.widgetContainer=document.createElement("div"),this.widgetContainer.className="MapController",this.widgetContainer.style.position="absolute",this.widgetContainer.style.width=`${this.widgetSize}px`,this.widgetContainer.style.height=`${this.widgetSize}px`,this.widgetContainer.style.border="2px solid rgba(255, 255, 255, 0.4)",this.widgetContainer.style.borderRadius="50%",this.widgetContainer.style.overflow="hidden",this.widgetContainer.style.backgroundColor="rgba(26, 26, 46, 0.85)",this.widgetContainer.style.cursor="crosshair",this.widgetContainer.style.userSelect="none",this.widgetContainer.style.pointerEvents="auto",this.syncWidgetPosition(),this.widgetCanvas=document.createElement("canvas"),this.widgetContainer.className="MapController",this.widgetCanvas.width=this.widgetSize*e,this.widgetCanvas.height=this.widgetSize*e,this.widgetCanvas.style.position="absolute",this.widgetCanvas.style.top="0",this.widgetCanvas.style.left="0",this.widgetCanvas.style.width=`${this.widgetSize}px`,this.widgetCanvas.style.height=`${this.widgetSize}px`,this.widgetCanvas.style.pointerEvents="auto",this.widgetContainer.style.zIndex="1000",this.widgetContainer.appendChild(this.widgetCanvas),this.widgetCtx=this.widgetCanvas.getContext("2d"),this.widgetCtx&&this.widgetCtx.scale(e,e),this.setupWidgetEvents(),this.engine.container&&this.engine.container.appendChild(this.widgetContainer),this.drawWidget()}setupWidgetEvents(){this.widgetContainer&&(this.widgetContainer.addEventListener("mousedown",this.onWidgetCanvasMouseDown),this.widgetCanvas&&this.widgetCanvas.addEventListener("mousedown",this.onWidgetCanvasMouseDown),window.addEventListener("mousemove",this.onWidgetMouseMove),window.addEventListener("mouseup",this.onWidgetMouseUp),this.widgetContainer.addEventListener("contextmenu",e=>{e.preventDefault(),e.stopPropagation()}),this.widgetCanvas&&this.widgetCanvas.addEventListener("contextmenu",e=>{e.preventDefault(),e.stopPropagation()}))}onWidgetCanvasMouseDown=e=>{this.widgetContainer&&(e.button==0?(this.isDragging=!1,this.isRotating=!0):(this.isDragging=!0,this.isRotating=!1),this.captureRotationBaseline(e),this.lastMouseX=e.clientX,this.lastMouseY=e.clientY,this.widgetContainer&&(this.widgetContainer.style.cursor="alias"),e.preventDefault(),e.stopPropagation())};onWidgetMouseMove=e=>{if(!this.isDragging&&!this.isRotating)return;const t=e.clientX-this.lastMouseX,i=e.clientY-this.lastMouseY;if(this.isDragging)this.widgetX+=t,this.widgetY+=i,console.log(`[LinkView2d3d] 拖动位置更新: x=${this.widgetX.toFixed(0)}, y=${this.widgetY.toFixed(0)}`),this.syncWidgetPosition(),this.handleWidgetPositionControl();else if(this.isRotating){const n=this.calculatePointerAngle(e);if(n!==null){this.rotationStartAngle===null&&(this.rotationStartAngle=n,this.widgetRotationStart=this.widgetRotation);const s=n-this.rotationStartAngle;this.widgetRotation=this.widgetRotationStart+s,console.log(`[LinkView2d3d] 旋转角度更新: ${(this.widgetRotation*180/Math.PI).toFixed(1)}°`),this.drawWidget(),this.handleWidgetRotationControl()}}this.lastMouseX=e.clientX,this.lastMouseY=e.clientY};onWidgetMouseUp=()=>{this.isDragging&&console.log(`[LinkView2d3d] 拖动结束,最终位置: x=${this.widgetX.toFixed(0)}, y=${this.widgetY.toFixed(0)}`),this.isRotating&&console.log(`[LinkView2d3d] 旋转结束,最终角度: ${(this.widgetRotation*180/Math.PI).toFixed(1)}°`),this.isDragging=!1,this.isRotating=!1,this.rotationStartAngle=null,this.widgetContainer&&(this.widgetContainer.style.cursor="crosshair")};drawWidget(){const e=this.widgetCtx;if(!e)return;const t=this.widgetSize/2,i=this.widgetSize/2;e.clearRect(0,0,this.widgetSize,this.widgetSize),e.save(),e.translate(t,i),e.rotate(this.widgetRotation);const n=36,s=Math.PI/10,a=e.createRadialGradient(0,0,2,0,0,n);a.addColorStop(0,"rgba(0, 230, 130, 0.9)"),a.addColorStop(1,"rgba(0, 230, 130, 0)");const o=-Math.sin(s)*n,l=-Math.cos(s)*n,c=Math.sin(s)*n,h=-Math.cos(s)*n;e.beginPath(),e.moveTo(0,0),e.lineTo(o,l),e.lineTo(c,h),e.closePath(),e.fillStyle=a,e.fill(),e.fillStyle="rgba(255, 255, 255, 0.95)",e.strokeStyle="rgba(0, 200, 110, 0.9)",e.lineWidth=1.5,e.beginPath(),e.arc(0,0,4,0,Math.PI*2),e.fill(),e.stroke(),e.restore()}active(){window.addEventListener("D3ViewUpdate",this.listenViewUpdate)}disActive(){window.removeEventListener("D3ViewUpdate",this.listenViewUpdate)}disposeWidget(){this.widgetContainer&&this.widgetContainer.removeEventListener("mousedown",this.onWidgetMouseDown),this.widgetCanvas&&this.widgetCanvas.removeEventListener("mousedown",this.onWidgetCanvasMouseDown),window.removeEventListener("mousemove",this.onWidgetMouseMove),window.removeEventListener("mouseup",this.onWidgetMouseUp),this.widgetContainer?.remove(),this.widgetContainer=null,this.widgetCanvas=null,this.widgetCtx=null}listenViewUpdate=e=>{console.log("[LinkView2d3d] 收到视图更新事件",e),e=e.detail,e&&e.position&&(this.lastCameraWorldPosition=new T(e.position.x,e.position.y,e.position.z),this.currentWordPosition=new T(e.position.x,-e.position.z,0)),e&&typeof e.rotation=="number"&&(this.currentWordRotation=e.rotation),this.updateViewPoint()};updateViewPoint(){if(this.currentWordPosition){let e=this.worldToScreen.worldToScreen(this.currentWordPosition);this.widgetX=e.x,this.widgetY=e.y,this.syncWidgetPosition()}this.currentWordRotation!==null&&(this.widgetRotation=this.currentWordRotation,this.drawWidget())}syncWidgetPosition(){if(!this.widgetContainer)return;const e=this.widgetSize/2;this.widgetContainer.style.left=`${this.widgetX-e}px`,this.widgetContainer.style.top=`${this.widgetY-e}px`}handleWidgetPositionControl(){const e=this.getWidgetWorldPosition();e&&(this.currentWordPosition=e,this.dispatchViewControl("move",{position2d:e}))}handleWidgetRotationControl(){this.currentWordRotation=this.widgetRotation,this.dispatchViewControl("rotate",{rotation:this.widgetRotation})}getWidgetWorldPosition(){if(!this.engine?.cameraModule2d?.screenToWorld)return null;const e=this.engine.cameraModule2d.screenToWorld(this.widgetX,this.widgetY);return e?new T(e.x,e.y,0):null}dispatchViewControl(e,t){const i=!!t.position2d,n=typeof t.rotation=="number";if(!i&&!n)return;if(i&&!this.lastCameraWorldPosition){console.warn("[LinkView2d3d] 未获取到 3D 相机位置,暂不推送位置控制");return}const s={source:"LinkView2d3d",mode:e};if(t.position2d&&this.lastCameraWorldPosition){const a=this.lastCameraWorldPosition.y,o=-t.position2d.y;s.position={x:t.position2d.x,y:a,z:o},this.lastCameraWorldPosition=new T(t.position2d.x,a,o)}n&&(s.rotation=t.rotation),window.dispatchEvent(new CustomEvent("D2ViewControl",{detail:s}))}captureRotationBaseline(e){const t=this.calculatePointerAngle(e);if(t===null){this.rotationStartAngle=null;return}this.rotationStartAngle=t,this.widgetRotationStart=this.widgetRotation}calculatePointerAngle(e){if(!this.widgetContainer)return null;const t=this.widgetContainer.getBoundingClientRect(),i=t.left+t.width/2,n=t.top+t.height/2;return Math.atan2(e.clientX-i,n-e.clientY)}}class gF{engine;enabled=!0;constructor(e){this.engine=e,this.active()}toggle(){return this.enabled=!this.enabled,this.enabled?this.active():this.disActive(),this.enabled}isEnabled(){return this.enabled}active(){window.addEventListener("D3ElementClick",this.listenElementClick)}disActive(){window.removeEventListener("D3ElementClick",this.listenElementClick)}listenElementClick=e=>{let t=e.detail.id.toString();var i=this.engine.loaderModule2d.model.nodeMap.get(t);i!=null?(this.engine.modelToolModule2d.highlightModel([t]),this.engine.cameraModule2d.fitToExtents({min:[i[0].min.x,i[0].min.y],max:[i[0].max.x,i[0].max.y]},3)):this.engine.modelToolModule2d.unhighlightAllModels()}}class AF{engine;highlightMaterial;hideMaterial;translucentMaterial;constructor(e){this.engine=e,this.highlightMaterial=new Rt({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:Vt}),this.hideMaterial=new Rt({color:0,transparent:!0,opacity:0,side:Vt}),this.translucentMaterial=new Rt({color:16777215,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:Vt}),this.highlightMaterial.clippingPlanes=this.engine.sectionPlane,this.hideMaterial.clippingPlanes=this.engine.sectionPlane,this.translucentMaterial.clippingPlanes=this.engine.sectionPlane}split_merge_model(e){if(e.isSplit||e instanceof ni)return;let t=e.materialClone.clone(),i=oo(e.geometrys,!0);i.groups.forEach(n=>{n.materialIndex=0}),e.geometry=i,e.material=[t,this.highlightMaterial,this.translucentMaterial],e.needsUpdate=!0,e.isSplit=!0}un_split_merge_model(e){}highlightModelHover(e){this.engine.engineStatus2d.highlightHoverModels=e,this.unHighlightModelHover(),e.forEach(t=>{this.engine.loaderModule2d.model.nodeMap.get(t)?.forEach(n=>{if(n!=null&&n.indexes!=null)if(this.engine.modelGroup.children[n.indexes[0]]instanceof vi){var s=this.engine.modelGroup.children[n.indexes[0]].clonePoints.slice(n.indexes[1],n.indexes[2]);this.highLightRenderLineHover(s)}else{let a=new Ge(this.engine.modelGroup.children[n.indexes[0]].geometrys[n.indexes[1]],this.translucentMaterial);a.name="HighLightHover",a.renderOrder=999,this.engine.modelGroup.add(a)}})})}unHighlightModelHover(){this.engine.engineStatus2d.highlightHoverModels=[],this.unhighLightRenderLineHover()}highlightModel(e){this.engine.engineStatus2d.highlightModels=e,e.forEach(t=>{this.engine.loaderModule2d.model.nodeMap.get(t)?.forEach(n=>{if(n!=null&&n.indexes!=null)if(this.engine.modelGroup.children[n.indexes[0]]instanceof vi){var s=this.engine.modelGroup.children[n.indexes[0]].clonePoints.slice(n.indexes[1],n.indexes[2]);this.highLightRenderLine(s)}else this.split_merge_model(this.engine.modelGroup.children[n.indexes[0]]),this.engine.modelGroup.children[n.indexes[0]].geometry.groups[n.indexes[1]].materialIndex=1})})}unhighlightModel(e){e.forEach(t=>{this.engine.loaderModule2d.model.nodeMap.get(t)?.forEach(n=>{n!=null&&n.indexes!=null&&(this.engine.modelGroup.children[n.indexes[0]]instanceof vi||(this.engine.modelGroup.children[n.indexes[0]].geometry.groups[n.indexes[1]].materialIndex=0))})}),this.unhighLightRenderLine()}unhighlightAllModels(e=!0){this.engine.engineStatus2d.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus2d.highlightModels=[])}hideModel(e){this.unhighlightAllModels(),e.forEach(t=>{this.engine.loaderModule2d.model.nodeMap.get(t)?.forEach(n=>{if(n!=null&&n.indexes!=null)if(this.engine.modelGroup.children[n.indexes[0]]instanceof vi){let s=this.engine.modelGroup.children[n.indexes[0]].geometry.attributes.position.array;for(let a=n.indexes[1];a<n.indexes[2];a++)s[a]=NaN;this.engine.modelGroup.children[n.indexes[0]].geometry.attributes.position.needsUpdate=!0}else this.split_merge_model(this.engine.modelGroup.children[n.indexes[0]]),this.engine.modelGroup.children[n.indexes[0]].geometry.groups[n.indexes[1]].materialIndex=-1})}),this.engine.engineStatus2d.hideModels.push(...e)}showModel(e){e.forEach(t=>{this.engine.loaderModule2d.model.nodeMap.get(t)?.forEach(n=>{if(n!=null&&n.indexes!=null)if(this.engine.modelGroup.children[n.indexes[0]]instanceof vi){let s=this.engine.modelGroup.children[n.indexes[0]].geometry.attributes.position.array;for(let a=n.indexes[1];a<n.indexes[2];a++)s[a]=this.engine.modelGroup.children[n.indexes[0]].clonePoints[a];this.engine.modelGroup.children[n.indexes[0]].geometry.attributes.position.needsUpdate=!0}else this.split_merge_model(this.engine.modelGroup.children[n.indexes[0]]),this.engine.modelGroup.children[n.indexes[0]].geometry.groups[n.indexes[1]].materialIndex=0})}),this.engine.engineStatus2d.hideModels=[]}showAllModels(){this.engine.engineStatus2d.hideModels&&this.engine.engineStatus2d.hideModels.length>0&&this.showModel(this.engine.engineStatus2d.hideModels),this.engine.engineStatus2d.hideModels=[],this.unhighlightAllModels()}highLightRenderLine(e){let t=new ot;t.setAttribute("position",new tt(e,3));const i=new si({color:43775,depthTest:!1,depthWrite:!1}),n=new vi(t,i);n.name="HighLight",n.renderOrder=999,this.engine.modelGroup.add(n)}unhighLightRenderLine(){this.engine.modelGroup.children.filter(e=>e.name=="HighLight").forEach(e=>{this.engine.modelGroup.remove(e)})}highLightRenderLineHover(e){let t=new ot;t.setAttribute("position",new tt(e,3));const i=new si({color:16777215,depthTest:!1,depthWrite:!1}),n=new vi(t,i);n.name="HighLightHover",n.renderOrder=999,this.engine.modelGroup.add(n)}unhighLightRenderLineHover(){this.engine.modelGroup.children.filter(e=>e.name=="HighLightHover").forEach(e=>{this.engine.modelGroup.remove(e)})}}function vF(r){const e={self:null,options:null,mouseDownTime:0,mouseDownPosition:null,lastClickTime:0};e.init=function(m,g){e.self!=null&&e.self.disActive!=null&&e.self.type!=m.type&&e.self.disActive(),e.self=m,g==null&&(g={showCatch:!1}),e.options=g},e.render=function(){e.self&&e.self.render!=null&&e.self.render()},e.active=function(){r.renderer.domElement.addEventListener("mousedown",o),r.renderer.domElement.addEventListener("mouseup",c),r.renderer.domElement.addEventListener("mousemove",l),r.renderer.domElement.addEventListener("touchstart",d,{passive:!1}),r.renderer.domElement.addEventListener("touchend",u,{passive:!1}),r.renderer.domElement.addEventListener("touchmove",p,{passive:!1}),window.addEventListener("keydown",t),window.addEventListener("keyup",i)},e.disActive=function(){r.renderer.domElement.removeEventListener("mousedown",o),r.renderer.domElement.removeEventListener("mouseup",c),r.renderer.domElement.removeEventListener("mousemove",l),r.renderer.domElement.removeEventListener("touchstart",d),r.renderer.domElement.removeEventListener("touchend",u),r.renderer.domElement.removeEventListener("touchmove",p),window.removeEventListener("keydown",t),window.removeEventListener("keyup",i)};function t(m){(m.keyCode===8||m.keyCode===46)&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),m.keyCode===27&&e.self&&e.self.handelKeyEscDown!=null&&e.self.handelKeyEscDown(),m.keyCode===13&&e.self&&e.self.handelKeyEnterDown!=null&&e.self.handelKeyEnterDown(),m.keyCode===32&&e.self&&e.self.handelKeySpaceDown!=null&&e.self.handelKeySpaceDown(),m.key==="Control"&&e.self&&e.self.handelKeyCtrlDown!=null&&e.self.handelKeyCtrlDown(),m.key==="Delete"&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),m.key==="Shift"&&e.self&&e.self.handelKeyShiftDown!=null&&e.self.handelKeyShiftDown(),m.key==="Meta"&&e.self&&e.self.handelKeyMetaDown!=null&&e.self.handelKeyMetaDown()}function i(m){m.key==="Alt"&&e.self&&e.self.handelKeyAltUp!=null&&e.self.handelKeyAltUp(),m.key==="Tab"&&e.self&&e.self.handelKeyTabUp!=null&&e.self.handelKeyTabUp(),m.key==="Control"&&e.self&&e.self.handelKeyCtrlUp!=null&&e.self.handelKeyCtrlUp(),m.key==="Shift"&&e.self&&e.self.handelKeyShiftUp!=null&&e.self.handelKeyShiftUp(),m.key==="Meta"&&e.self&&e.self.handelKeyMetaUp!=null&&e.self.handelKeyMetaUp(),m.key==="Command"&&e.self&&e.self.handelKeyCommandUp!=null&&e.self.handelKeyCommandUp(),m.key==="Windows"&&e.self&&e.self.handelKeyWindowsUp!=null&&e.self.handelKeyWindowsUp()}function n(m){const g=new be,f=r.renderer.domElement.clientWidth,v=r.renderer.domElement.clientHeight;return g.x=m.offsetX/f*2-1,g.y=-(m.offsetY/v)*2+1,g}function s(m){const g=new Ln,f=n(m);return g.setFromCamera(f,r.camera),g}function a(m,g=!1){const f=s(m);if(m.raycaster=f,g){const v=A(f,m);m.catch=v}}function o(m){m.button===0&&(e.mouseDownTime=Date.now(),e.mouseDownPosition=new T(m.offsetX,m.offsetY,0),e.self&&e.self.handleMouseDown!=null&&(r.engineStatus.isFree=!0,a(m,!0),m.catch!=null&&r.controlModule.orbitControls.origin.set(m.catch.point.x,m.catch.point.y,m.catch.point.z),e.self.handleMouseDown(m)))}function l(m){a(m,!0),e.self&&e.self.handleMouseMove!=null&&e.self.handleMouseMove(m)}function c(m){if(m.button!==0)return;const g=Date.now(),f=g-e.mouseDownTime,v=new T(m.offsetX,m.offsetY,0);e.self&&e.self.handleMouseUp!=null&&(a(m,!1),e.self.handleMouseUp(m));const b=v.distanceTo(e.mouseDownPosition);(f<100||b==0)&&e.self&&e.self.handleMouseClick!=null&&(a(m,!0),g-e.lastClickTime<200?e.self.handleMouseDoubleClick!=null&&e.self.handleMouseDoubleClick(m):e.self.handleMouseClick!=null&&e.self.handleMouseClick(m),e.lastClickTime=Date.now())}function h(m){const g=m.touches[0]||m.changedTouches[0];if(!g)return null;const f=r.renderer.domElement.getBoundingClientRect(),v=g.clientX-f.left,b=g.clientY-f.top;return{offsetX:v,offsetY:b,button:0,clientX:g.clientX,clientY:g.clientY,preventDefault:()=>m.preventDefault(),stopPropagation:()=>m.stopPropagation(),originalEvent:m}}function d(m){if(m.preventDefault(),m.touches.length!==1)return;const g=h(m);g&&o(g)}function p(m){if(m.preventDefault(),m.touches.length!==1)return;const g=h(m);g&&l(g)}function u(m){m.preventDefault();const g=h(m);g&&c(g)}function A(m,g){var f=r.octreeBox2d.pick2d(m,g);return f==null?null:{point:null,id:f}}return e}class bF{el;xEl;yEl;constructor(e){this.el=document.createElement("div"),this.el.className="engine-2d-mouse-coord";const t=document.createElement("span");t.className="engine-2d-mouse-coord__label",t.textContent="",this.xEl=document.createElement("span"),this.xEl.className="engine-2d-mouse-coord__value",this.xEl.textContent="X: --",this.yEl=document.createElement("span"),this.yEl.className="engine-2d-mouse-coord__value",this.yEl.textContent="Y: --",this.el.appendChild(t),this.el.appendChild(this.xEl),this.el.appendChild(this.yEl),e.appendChild(this.el)}update(e,t){this.xEl.textContent=`X: ${e.toFixed(0)} mm`,this.yEl.textContent=`Y: ${t.toFixed(0)} mm`}reset(){this.xEl.textContent="X: --",this.yEl.textContent="Y: --"}dispose(){this.el.parentElement?.removeChild(this.el)}}var WE=(r=>(r.ModelLoadStart="model-load-start",r.ModelLoadProgress="model-load-progress",r.ModelLoaded="model-loaded",r.ModelError="model-error",r.SelectionChanged="selection-changed",r.HoverChanged="hover-changed",r.Click="click",r.MouseMove="mouse-move",r.CameraChanged="camera-changed",r.CameraIdle="camera-idle",r.EngineFree="engine-free",r.EngineBusy="engine-busy",r.MeasureChanged="measure-changed",r.MeasureClick="measure-click",r.SectionMove="section-move",r))(WE||{});class yF{engine;behavior;mouseCoordUI=null;constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved2d,this.behavior.init(this);const e=this.engine.container;e&&(this.mouseCoordUI=new bF(e))}active(){this.behavior.active()}disActive(){this.behavior.disActive()}oldId=null;handleMouseMove(e){if(!this.mouseCoordUI||!this.engine.cameraModule2d)return;const t=this.engine.cameraModule2d.screenToWorld(e.offsetX,e.offsetY);if(this.mouseCoordUI.update(t.x*1e3,t.y*1e3),e.catch==null||e.catch.id==null){this.engine.modelToolModule2d.unHighlightModelHover(),this.oldId=null;return}let i=e.catch.id;this.oldId!=i&&this.engine.modelToolModule2d.highlightModelHover([i])}handelKeyEscDown(e){this.engine.modelToolModule2d.unhighlightAllModels()}handleMouseClick(e){if(e.catch!=null){this.engine.modelToolModule2d.highlightModel([e.catch.id]),this.engine.events.trigger(WE.Click,e.catch.id);let t=new CustomEvent("D2ElementClick",{detail:{id:e.catch.id}});window.dispatchEvent(t)}else{this.engine.modelToolModule2d.unhighlightAllModels();let t=new CustomEvent("D2ElementClick",{detail:{id:-1}});window.dispatchEvent(t)}}dispose(){this.mouseCoordUI?.dispose(),this.mouseCoordUI=null}}class xF{overlay;hLine;vLine;box;canvas;constructor(e,t){this.canvas=t,t.style.cursor="none",this.overlay=document.createElement("div"),this.overlay.className="engine-2d-cad-cursor",this.hLine=document.createElement("div"),this.hLine.className="engine-2d-cad-cursor__h",this.vLine=document.createElement("div"),this.vLine.className="engine-2d-cad-cursor__v",this.box=document.createElement("div"),this.box.className="engine-2d-cad-cursor__box",this.overlay.appendChild(this.hLine),this.overlay.appendChild(this.vLine),this.overlay.appendChild(this.box),e.appendChild(this.overlay),this.hide(),this.bindEvents()}bindEvents(){this.canvas.addEventListener("mousemove",this.onMouseMove),this.canvas.addEventListener("mouseenter",this.onMouseEnter),this.canvas.addEventListener("mouseleave",this.onMouseLeave)}onMouseMove=e=>{const t=this.canvas.getBoundingClientRect(),i=e.clientX-t.left,n=e.clientY-t.top;this.hLine.style.top=`${n}px`,this.vLine.style.left=`${i}px`,this.box.style.left=`${i}px`,this.box.style.top=`${n}px`};onMouseEnter=()=>{this.show()};onMouseLeave=()=>{this.hide()};show(){this.overlay.style.visibility="visible"}hide(){this.overlay.style.visibility="hidden"}dispose(){this.canvas.removeEventListener("mousemove",this.onMouseMove),this.canvas.removeEventListener("mouseenter",this.onMouseEnter),this.canvas.removeEventListener("mouseleave",this.onMouseLeave),this.canvas.style.cursor="",this.overlay.parentElement?.removeChild(this.overlay)}}const _F=[{action:"search",label:"搜索"},{action:"hideElement",label:"隐藏元素",dividerBefore:!0},{action:"showAll",label:"显示全部"},{action:"hideLayer",label:"隐藏图层",dividerBefore:!0},{action:"showAllLayers",label:"显示所有图层"},{action:"layerManage",label:"图层管理",dividerBefore:!0},{action:"toggleBg",label:"切换背景"},{action:"linkElement2d3d",label:"模型联动",dividerBefore:!0},{action:"linkView2d3d",label:"视角关联"}];class EF{menu;container;canvas;onAction;menuItemStates=new Map;constructor(e,t,i){this.container=e,this.canvas=t,this.onAction=i,this.menu=this.createMenu(),e.appendChild(this.menu),this.bindEvents()}createMenu(){const e=document.createElement("div");return e.className="engine-2d-context-menu",_F.forEach(t=>{if(t.dividerBefore){const n=document.createElement("div");n.className="engine-2d-context-menu__divider",e.appendChild(n)}const i=document.createElement("div");i.className="engine-2d-context-menu__item",i.textContent=t.label,i.dataset.action=t.action,i.addEventListener("click",()=>{this.hide(),this.onAction(t.action)}),e.appendChild(i)}),e}bindEvents(){this.canvas.addEventListener("contextmenu",this.onContextMenu),document.addEventListener("mousedown",this.onDocMouseDown),document.addEventListener("keydown",this.onEscape)}onContextMenu=e=>{e.preventDefault();const t=this.container.getBoundingClientRect();let i=e.clientX-t.left,n=e.clientY-t.top;this.menu.style.left=`${i}px`,this.menu.style.top=`${n}px`,this.menu.classList.add("engine-2d-context-menu--visible"),this.updateMenuItemStyles();const s=this.menu.offsetWidth,a=this.menu.offsetHeight,o=this.container.clientWidth,l=this.container.clientHeight;i+s>o&&(i=o-s-4),n+a>l&&(n=l-a-4),this.menu.style.left=`${i}px`,this.menu.style.top=`${n}px`};onDocMouseDown=e=>{this.menu.contains(e.target)||this.hide()};onEscape=e=>{e.key==="Escape"&&this.hide()};hide(){this.menu.classList.remove("engine-2d-context-menu--visible")}setMenuItemState(e,t){this.menuItemStates.set(e,t)}setMenuItemStates(e){Object.entries(e).forEach(([t,i])=>{this.menuItemStates.set(t,i)})}updateMenuItemStyles(){this.menu.querySelectorAll(".engine-2d-context-menu__item").forEach(e=>{const t=e.dataset.action;this.menuItemStates.get(t)?(e.style.color="#00e682",e.style.fontWeight="bold"):(e.style.color="",e.style.fontWeight="")})}dispose(){this.canvas.removeEventListener("contextmenu",this.onContextMenu),document.removeEventListener("mousedown",this.onDocMouseDown),document.removeEventListener("keydown",this.onEscape),this.menu.parentElement?.removeChild(this.menu)}}class MF{overlay=null;textEl=null;barEl=null;pctEl=null;constructor(e){this._build(e)}show(e="正在加载...",t=0){this.overlay&&(this.overlay.style.display="flex",this._update(e,t))}update(e,t){this.overlay?.style.display!=="none"&&this._update(e,t)}hide(){this.overlay&&(this.overlay.style.display="none")}_update(e,t){const i=Math.min(100,Math.max(0,Math.round(t)));this.textEl&&(this.textEl.textContent=e),this.barEl&&(this.barEl.style.width=`${i}%`),this.pctEl&&(this.pctEl.textContent=`${i}%`)}_build(e){const t=document.createElement("div");t.style.cssText=`
|
||
position:absolute; inset:0;
|
||
display:none; align-items:center; justify-content:center;
|
||
z-index:200;
|
||
`,this.overlay=t;const i=document.createElement("div");i.style.cssText=`
|
||
display:flex; flex-direction:column; align-items:center; gap:14px;
|
||
padding:28px 36px;
|
||
background:var(--e2d-bg,#1e1f22);
|
||
border:1px solid var(--e2d-border,rgba(255,255,255,0.12));
|
||
border-radius:8px;
|
||
box-shadow:0 8px 32px var(--e2d-shadow-lg,rgba(0,0,0,0.65));
|
||
min-width:200px;
|
||
font-family:system-ui,sans-serif;
|
||
`;const n=document.createElement("div");n.style.cssText="width:48px; height:48px;",n.innerHTML=`
|
||
<svg width="48" height="48" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
|
||
<style>
|
||
@keyframes _e2d_spin { to { transform: rotate(360deg); } }
|
||
._e2d_ring { transform-origin: 24px 24px; animation: _e2d_spin 0.9s linear infinite; }
|
||
</style>
|
||
<circle cx="24" cy="24" r="19" fill="none"
|
||
stroke="var(--e2d-border2,#333)" stroke-width="3"/>
|
||
<g class="_e2d_ring">
|
||
<circle cx="24" cy="24" r="19" fill="none"
|
||
stroke="var(--e2d-accent,#4fc3f7)" stroke-width="3"
|
||
stroke-dasharray="30 90" stroke-linecap="round"/>
|
||
</g>
|
||
</svg>
|
||
`;const s=document.createElement("div");s.style.cssText=`
|
||
font-size:13px; color:var(--e2d-text2,#ccc);
|
||
text-align:center; white-space:nowrap;
|
||
`,s.textContent="正在加载...",this.textEl=s;const a=document.createElement("div");a.style.cssText=`
|
||
width:160px; height:3px; border-radius:2px;
|
||
background:var(--e2d-border2,#333); overflow:hidden;
|
||
`;const o=document.createElement("div");o.style.cssText=`
|
||
height:100%; width:0%; border-radius:2px;
|
||
background:var(--e2d-accent,#4fc3f7);
|
||
transition:width 0.25s ease;
|
||
`,a.appendChild(o),this.barEl=o;const l=document.createElement("div");l.style.cssText=`
|
||
font-size:12px; color:var(--e2d-text3,rgba(255,255,255,0.35));
|
||
`,l.textContent="0%",this.pctEl=l,i.appendChild(n),i.appendChild(s),i.appendChild(a),i.appendChild(l),t.appendChild(i),e.appendChild(t)}dispose(){this.overlay?.remove(),this.overlay=null,this.textEl=null,this.barEl=null,this.pctEl=null}}const wF=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||
<circle cx="6.5" cy="6.5" r="4.5" stroke="currentColor" stroke-width="1.5"/>
|
||
<line x1="10" y1="10" x2="14" y2="14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
||
</svg>`,SF=`<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||
<line x1="1" y1="1" x2="11" y2="11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
||
<line x1="11" y1="1" x2="1" y2="11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
||
</svg>`,CF={房间:"#4fc3f7",门:"#81c784",窗:"#aed581",柱:"#ff8a65",梁:"#ffb74d",楼梯:"#ce93d8",电梯:"#80deea",设备间:"#f48fb1",轴线:"#90a4ae",墙体:"#bcaaa4",室外:"#a5d6a7"};class TF{container;manager;wrapper;input;clearBtn;resultList;statusEl;activeIndex=-1;currentResults=[];debounceTimer=null;constructor(e,t){this.container=e,this.manager=t,this.wrapper=this._buildWrapper(),this.input=this.wrapper.querySelector(".engine-2d-search__input"),this.clearBtn=this.wrapper.querySelector(".engine-2d-search__clear"),this.resultList=this.wrapper.querySelector(".engine-2d-search__list"),this.statusEl=this.wrapper.querySelector(".engine-2d-search__status"),e.appendChild(this.wrapper),this._bindEvents()}_buildWrapper(){const e=document.createElement("div");return e.className="engine-2d-search",e.innerHTML=`
|
||
<div class="engine-2d-search__box">
|
||
<div class="engine-2d-search__input-row">
|
||
<span class="engine-2d-search__icon">${wF}</span>
|
||
<input
|
||
class="engine-2d-search__input"
|
||
type="text"
|
||
placeholder="搜索元素、图层、类型…"
|
||
autocomplete="off"
|
||
spellcheck="false"
|
||
/>
|
||
<button class="engine-2d-search__clear" title="清除">${SF}</button>
|
||
</div>
|
||
<div class="engine-2d-search__divider"></div>
|
||
<div class="engine-2d-search__status"></div>
|
||
<ul class="engine-2d-search__list" role="listbox"></ul>
|
||
</div>
|
||
`,e}_bindEvents(){this.input.addEventListener("input",this._onInput),this.input.addEventListener("keydown",this._onKeyDown),this.clearBtn.addEventListener("click",this._onClear),document.addEventListener("mousedown",this._onDocMouseDown),document.addEventListener("keydown",this._onEscape)}_onInput=()=>{this.debounceTimer!==null&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>this._doSearch(),150);const e=this.input.value.length>0;this.clearBtn.style.opacity=e?"1":"0",this.clearBtn.style.pointerEvents=e?"auto":"none"};_onKeyDown=e=>{const t=this.resultList.querySelectorAll(".engine-2d-search__item");t.length&&(e.key==="ArrowDown"?(e.preventDefault(),this.activeIndex=Math.min(this.activeIndex+1,t.length-1),this._highlightItem(t)):e.key==="ArrowUp"?(e.preventDefault(),this.activeIndex=Math.max(this.activeIndex-1,0),this._highlightItem(t)):e.key==="Enter"&&this.activeIndex>=0&&this.currentResults[this.activeIndex]&&this._selectResult(this.currentResults[this.activeIndex]))};_onClear=()=>{this.input.value="",this.clearBtn.style.opacity="0",this.clearBtn.style.pointerEvents="none",this._clearResults(),this.input.focus()};_onDocMouseDown=e=>{this.wrapper.contains(e.target)||this.hide()};_onEscape=e=>{e.key==="Escape"&&this.hide()};_doSearch(){const e=this.input.value;if(!e.trim()){this._clearResults();return}this.currentResults=this.manager.search(e),this.activeIndex=-1,this._renderResults(this.currentResults,e)}_renderResults(e,t){this.resultList.innerHTML="";const i=this.wrapper.querySelector(".engine-2d-search__divider");if(e.length===0){this.statusEl.textContent=`未找到与 "${t}" 相关的结果`,this.statusEl.style.display="block",i.style.display="none",this.resultList.style.display="none";return}this.statusEl.textContent=`找到 ${e.length} 个结果`,this.statusEl.style.display="block",i.style.display="block",this.resultList.style.display="block",e.forEach((n,s)=>{const a=document.createElement("li");a.className="engine-2d-search__item",a.setAttribute("role","option"),a.dataset.index=String(s);const o=CF[n.type]??"#90a4ae",l=this._highlight(n.name,t);a.innerHTML=`
|
||
<span class="engine-2d-search__item-badge" style="background:${o}20;color:${o};">${n.type}</span>
|
||
<span class="engine-2d-search__item-name">${l}</span>
|
||
${n.layer?`<span class="engine-2d-search__item-layer">${n.layer}</span>`:""}
|
||
${n.description?`<span class="engine-2d-search__item-desc">${n.description}</span>`:""}
|
||
`,a.addEventListener("click",()=>this._selectResult(n)),a.addEventListener("mouseenter",()=>{this.activeIndex=s;const c=this.resultList.querySelectorAll(".engine-2d-search__item");this._highlightItem(c)}),this.resultList.appendChild(a)})}_highlight(e,t){const i=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return e.replace(new RegExp(`(${i})`,"gi"),'<mark class="engine-2d-search__mark">$1</mark>')}_highlightItem(e){e.forEach((t,i)=>{t.classList.toggle("engine-2d-search__item--active",i===this.activeIndex)}),this.activeIndex>=0&&e[this.activeIndex]?.scrollIntoView({block:"nearest"})}_selectResult(e){this.manager.onResultSelect(e),this.hide()}_clearResults(){this.resultList.innerHTML="",this.resultList.style.display="none",this.statusEl.style.display="none";const e=this.wrapper.querySelector(".engine-2d-search__divider");e.style.display="none",this.currentResults=[],this.activeIndex=-1}show(){this.wrapper.classList.add("engine-2d-search--visible"),requestAnimationFrame(()=>this.input.focus())}hide(){this.wrapper.classList.remove("engine-2d-search--visible"),this._clearResults(),this.input.value="",this.clearBtn.style.opacity="0",this.clearBtn.style.pointerEvents="none"}toggle(){this.wrapper.classList.contains("engine-2d-search--visible")?this.hide():this.show()}dispose(){this.input.removeEventListener("input",this._onInput),this.input.removeEventListener("keydown",this._onKeyDown),this.clearBtn.removeEventListener("click",this._onClear),document.removeEventListener("mousedown",this._onDocMouseDown),document.removeEventListener("keydown",this._onEscape),this.wrapper.parentElement?.removeChild(this.wrapper),this.debounceTimer!==null&&clearTimeout(this.debounceTimer)}}const IF=[{id:"1",name:"会议室 A",type:"房间",layer:"建筑-房间",description:"3F 东侧,面积 48㎡"},{id:"2",name:"会议室 B",type:"房间",layer:"建筑-房间",description:"3F 西侧,面积 32㎡"},{id:"3",name:"卫生间-男",type:"房间",layer:"建筑-房间",description:"2F,面积 18㎡"},{id:"4",name:"卫生间-女",type:"房间",layer:"建筑-房间",description:"2F,面积 16㎡"},{id:"5",name:"大厅",type:"房间",layer:"建筑-房间",description:"1F,面积 260㎡"},{id:"6",name:"主入口门",type:"门",layer:"建筑-门窗",description:"宽 2400mm,双开"},{id:"7",name:"次入口门",type:"门",layer:"建筑-门窗",description:"宽 1200mm,单开"},{id:"8",name:"防火门 FD-01",type:"门",layer:"建筑-门窗",description:"甲级防火,宽 900mm"},{id:"9",name:"落地窗 W-101",type:"窗",layer:"建筑-门窗",description:"高 3000mm,南向"},{id:"10",name:"普通窗 W-201",type:"窗",layer:"建筑-门窗",description:"高 1800mm,东向"},{id:"11",name:"承重柱 Z-A1",type:"柱",layer:"结构-柱",description:"600×600,混凝土"},{id:"12",name:"承重柱 Z-A2",type:"柱",layer:"结构-柱",description:"600×600,混凝土"},{id:"13",name:"钢柱 GZ-01",type:"柱",layer:"结构-柱",description:"H 型钢,H300×150"},{id:"14",name:"主梁 L-1",type:"梁",layer:"结构-梁",description:"400×800,跨度 8m"},{id:"15",name:"次梁 L-2",type:"梁",layer:"结构-梁",description:"250×500,跨度 4m"},{id:"16",name:"楼梯间 ST-1",type:"楼梯",layer:"建筑-楼梯",description:"双跑楼梯,净宽 1200mm"},{id:"17",name:"消防楼梯 ST-2",type:"楼梯",layer:"建筑-楼梯",description:"疏散楼梯,净宽 1100mm"},{id:"18",name:"电梯井 EV-1",type:"电梯",layer:"建筑-电梯",description:"客梯,井道 2000×2200"},{id:"19",name:"消防电梯 EV-2",type:"电梯",layer:"建筑-电梯",description:"消防兼客梯"},{id:"20",name:"强电竖井",type:"设备间",layer:"机电-电气",description:"1F~RF,面积 4㎡"},{id:"21",name:"弱电竖井",type:"设备间",layer:"机电-电气",description:"1F~RF,面积 2㎡"},{id:"22",name:"空调机房",type:"设备间",layer:"机电-暖通",description:"BF,面积 80㎡"},{id:"23",name:"消防控制室",type:"设备间",layer:"机电-消防",description:"1F,面积 24㎡"},{id:"24",name:"配电室",type:"设备间",layer:"机电-电气",description:"BF,面积 36㎡"},{id:"25",name:"轴线 A",type:"轴线",layer:"轴网",description:"X 向,间距 8400mm"},{id:"26",name:"轴线 1",type:"轴线",layer:"轴网",description:"Y 向,间距 7200mm"},{id:"27",name:"内墙 Q-001",type:"墙体",layer:"建筑-墙",description:"200mm 砌块"},{id:"28",name:"外墙 Q-101",type:"墙体",layer:"建筑-墙",description:"300mm 保温外墙"},{id:"29",name:"散水 SS-1",type:"室外",layer:"建筑-室外",description:"宽 900mm,坡度 3%"},{id:"30",name:"台阶 TJ-1",type:"室外",layer:"建筑-室外",description:"3 级,踏步 300×150"}];class PF{engine;searchUI=null;constructor(e){this.engine=e;const t=document.getElementById(e?.options?.containerId??"")??e?.container??null;t&&(this.searchUI=new TF(t,this))}search(e){const t=e.trim().toLowerCase();return t?IF.filter(i=>i.name.toLowerCase().includes(t)||i.type.toLowerCase().includes(t)||(i.layer?.toLowerCase().includes(t)??!1)||(i.description?.toLowerCase().includes(t)??!1)):[]}onResultSelect(e){console.log("[SearchManager] 选中结果:",e)}show(){this.searchUI?.show()}hide(){this.searchUI?.hide()}toggle(){this.searchUI?.toggle()}dispose(){this.searchUI?.dispose(),this.searchUI=null}}const jE={dark:{"--e2d-bg":"#1e1f22","--e2d-bg2":"#252526","--e2d-bg3":"#222222","--e2d-bg-hover":"rgba(79,195,247,0.08)","--e2d-bg-accent":"#094771","--e2d-icon-bg":"rgba(255,255,255,0.08)","--e2d-icon-bg-hover":"rgba(255,255,255,0.16)","--e2d-border":"rgba(255,255,255,0.12)","--e2d-border2":"#333333","--e2d-text":"#e0e0e0","--e2d-text2":"#cccccc","--e2d-text3":"rgba(255,255,255,0.35)","--e2d-text4":"#666666","--e2d-text-accent":"#ffffff","--e2d-accent":"#4fc3f7","--e2d-shadow":"rgba(0,0,0,0.50)","--e2d-shadow-lg":"rgba(0,0,0,0.65)","--e2d-cursor":"rgba(255,255,255,0.85)","--e2d-scrollbar":"rgba(255,255,255,0.15)","--e2d-float-bg":"rgba(0,0,0,0.65)","--e2d-float-border":"rgba(255,255,255,0.08)","--e2d-swatch-border":"#444444","--e2d-close":"#aaaaaa","--e2d-close-hover":"#ffffff","--e2d-icon":"rgba(255,255,255,0.4)","--e2d-coord-value":"#76c8ff","--e2d-coord-label":"rgba(255,255,255,0.45)"},light:{"--e2d-bg":"#ffffff","--e2d-bg2":"#f5f5f5","--e2d-bg3":"#eeeeee","--e2d-bg-hover":"rgba(25,118,210,0.06)","--e2d-bg-accent":"#e3f2fd","--e2d-icon-bg":"rgba(0,0,0,0.06)","--e2d-icon-bg-hover":"rgba(0,0,0,0.12)","--e2d-border":"rgba(0,0,0,0.12)","--e2d-border2":"#e0e0e0","--e2d-text":"#1a1a1a","--e2d-text2":"#444444","--e2d-text3":"rgba(0,0,0,0.40)","--e2d-text4":"#aaaaaa","--e2d-text-accent":"#1565c0","--e2d-accent":"#1976d2","--e2d-shadow":"rgba(0,0,0,0.15)","--e2d-shadow-lg":"rgba(0,0,0,0.22)","--e2d-cursor":"rgba(30,30,30,0.70)","--e2d-scrollbar":"rgba(0,0,0,0.18)","--e2d-float-bg":"rgba(245,245,245,0.92)","--e2d-float-border":"rgba(0,0,0,0.10)","--e2d-swatch-border":"#cccccc","--e2d-close":"#777777","--e2d-close-hover":"#1a1a1a","--e2d-icon":"rgba(0,0,0,0.45)","--e2d-coord-value":"#1976d2","--e2d-coord-label":"rgba(0,0,0,0.50)"}};class RF{container;current;constructor(e,t="dark"){this.container=e,this.current=t,this._apply(t)}_apply(e){const t=jE[e];for(const[i,n]of Object.entries(t))this.container.style.setProperty(i,n);this.container.setAttribute("data-e2d-theme",e)}setTheme(e){this.current=e,this._apply(e)}getTheme(){return this.current}toggle(){this.setTheme(this.current==="dark"?"light":"dark")}dispose(){for(const e of Object.keys(jE[this.current]))this.container.style.removeProperty(e);this.container.removeAttribute("data-e2d-theme")}}class DF{options;container=null;animationId=null;isRendering=!1;fpsFrameCount=0;fpsLastCheck=0;currentFps=0;enablePerformanceMonitoring=!1;modelToolModule2d;engineStatus2d;octreeBox2d;events;handelBehaved2d;interactionModule2d;sceneModule2d;cameraModule2d;renderModule2d;controlModule2d;loaderModule2d;layerManager;searchManager;themeManager;cadCursorUI;contextMenuUI;loadingUI;linkView2d3d;linkElement2d3d;scene=null;camera=null;renderer=null;dwgData=null;version="1.0.0";constructor(e){if(this.options=e,this.enablePerformanceMonitoring=e.enablePerformanceMonitoring??!1,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);this.initialize(),this.handelBehaved2d=vF(this),this.interactionModule2d=new yF(this),this.interactionModule2d.init(),this.interactionModule2d.active()}initialize(){this.events=new KU(!1),this.sceneModule2d=new lF(this,this.options),this.scene=this.sceneModule2d.scene,this.cameraModule2d=new hF(this,this.container),this.camera=this.cameraModule2d.orthographicCamera,this.renderModule2d=new dF(this,this.container,this.options),this.renderer=this.renderModule2d.renderer,this.controlModule2d=new pF(this),this.loaderModule2d=new QE(this),this.themeManager=new RF(this.container),this.layerManager=new VE(this),this.searchManager=new PF(this),this.octreeBox2d=new fF(this),this.modelToolModule2d=new AF(this),this.engineStatus2d=new cF(this),this.linkView2d3d=new mF(this),this.linkElement2d3d=new gF(this),this.sceneModule2d.initGrid(),this.cadCursorUI=new xF(this.container,this.renderer.domElement),this.loadingUI=new MF(this.container),this.events.on(On.ModelLoadStart,()=>this.loadingUI.show("正在加载...",0)),this.events.on(On.ModelLoadProgress,e=>this.loadingUI.update(e.text,e.progress)),this.events.on(On.ModelLoaded,()=>this.loadingUI.hide()),this.events.on(On.ModelLoadError,()=>this.loadingUI.hide()),this.contextMenuUI=new EF(this.container,this.renderer.domElement,e=>{if(e==="search"&&this.searchManager.show(),e==="layerManage"&&this.layerManager.toggle(),e==="hideElement"&&this.modelToolModule2d.hideModel(this.engineStatus2d.highlightModels),e==="showAll"&&this.modelToolModule2d.showModel(this.engineStatus2d.hideModels),e==="toggleBg"){this.themeManager.toggle();const t=this.themeManager.getTheme()==="dark"?1710618:15790320;this.setBackgroundColor(t)}if(e==="linkElement2d3d"){const t=this.linkElement2d3d.toggle();this.contextMenuUI.setMenuItemState("linkElement2d3d",t),console.log(`[EngineKernel2d] 二三维图元联动: ${t?"已开启":"已关闭"}`)}if(e==="linkView2d3d"){const t=this.linkView2d3d.toggle();this.contextMenuUI.setMenuItemState("linkView2d3d",t),console.log(`[EngineKernel2d] 图模关联: ${t?"已开启":"已关闭"}`)}}),this.contextMenuUI.setMenuItemStates({linkElement2d3d:this.linkElement2d3d.isEnabled(),linkView2d3d:this.linkView2d3d.isEnabled()}),this.startRendering(),console.log(`[EngineKernel2d] 2D Engine initialized (v${this.version})`)}startRendering(){this.isRendering||(this.isRendering=!0,this.fpsLastCheck=performance.now(),this.animate(),console.log("[EngineKernel2d] Rendering started"))}stopRendering(){this.isRendering=!1,this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),console.log("[EngineKernel2d] Rendering stopped")}animate=()=>{this.isRendering&&(this.animationId=requestAnimationFrame(this.animate),this.controlModule2d.update(),this.scene&&this.camera&&this.renderer&&this.renderer.render(this.scene,this.camera),this.enablePerformanceMonitoring&&this.updatePerformanceStats())};updatePerformanceStats(){this.fpsFrameCount++;const e=performance.now();e-this.fpsLastCheck>=1e3&&(this.currentFps=this.fpsFrameCount,this.fpsFrameCount=0,this.fpsLastCheck=e,this.events.trigger(On.RenderEnd,{fps:this.currentFps}))}async loadModel(e,t){return await this.loaderModule2d.loadModel(e,t),{}}getLayers(){return this.loaderModule2d.getLayers()}getEntitiesByLayer(e){return this.loaderModule2d.getEntitiesByLayer(e)}setLayerVisible(e,t){console.log(`[EngineKernel2d] Set layer ${e} visible: ${t}`)}setTheme(e){this.themeManager.setTheme(e)}resetView(){this.cameraModule2d&&this.cameraModule2d.resetView()}fitToView(){this.dwgData?.metadata.extents&&this.cameraModule2d.fitToExtents(this.dwgData.metadata.extents)}setZoom(e){this.cameraModule2d&&this.cameraModule2d.setZoom(e)}getZoom(){return this.cameraModule2d?this.cameraModule2d.getZoom():1}getPerformanceStats(){const e=this.sceneModule2d.getSceneStats();return{fps:this.currentFps,renderTime:0,entityCount:e.objectCount,visibleEntityCount:e.objectCount}}setBackgroundColor(e){this.sceneModule2d&&this.sceneModule2d.setBackgroundColor(e)}clearScene(){this.sceneModule2d&&this.sceneModule2d.clearScene()}resize(){if(this.renderModule2d){const e=this.container?.clientWidth??0,t=this.container?.clientHeight??0;this.renderModule2d.setSize(e,t)}}captureImage(e){if(!this.renderer||!this.sceneModule2d)return console.error("[EngineKernel2d] Renderer or scene module not initialized"),null;const t=this.renderer.domElement,i=e?.format||"png",n=e?.quality||.92,s=`image/${i==="jpeg"?"jpeg":i}`,a=e?.transparent??!1,o=e?.hideGrid??!0,l=e?.hideAxes??!0,c=this.scene?.background??null;let h=!1,d=!1;this.sceneModule2d.adaptiveGrid&&(h=this.sceneModule2d.adaptiveGrid.gridGroup?.visible??!1,o&&this.sceneModule2d.adaptiveGrid.setVisible(!1)),this.sceneModule2d.axesHelper&&(d=this.sceneModule2d.axesHelper.visible??!1,l&&this.sceneModule2d.setAxesVisible(!1)),a&&this.scene&&(this.scene.background=null),this.scene&&this.camera&&this.renderer.render(this.scene,this.camera);const p=t.toDataURL(s,n);this.scene&&(this.scene.background=c),this.sceneModule2d.adaptiveGrid&&o&&this.sceneModule2d.adaptiveGrid.setVisible(h),this.sceneModule2d.axesHelper&&l&&this.sceneModule2d.setAxesVisible(d),this.scene&&this.camera&&this.renderer.render(this.scene,this.camera);const u={dataURL:p};if(e?.download){const A=e.filename||`capture-${Date.now()}.${i}`,m=document.createElement("a");m.href=p,m.download=A,m.style.display="none",document.body.appendChild(m),m.click(),m.remove(),console.log(`[EngineKernel2d] Image captured and downloaded: ${A}`)}else console.log("[EngineKernel2d] Image captured");return u}async captureImageAsync(e){if(!this.renderer||!this.sceneModule2d)return console.error("[EngineKernel2d] Renderer or scene module not initialized"),null;const t=this.renderer.domElement,i=e?.format||"png",n=e?.quality||.92,s=`image/${i==="jpeg"?"jpeg":i}`,a=e?.transparent??!1,o=e?.hideGrid??!0,l=e?.hideAxes??!0,c=this.scene?.background??null;let h=!1,d=!1;this.sceneModule2d.adaptiveGrid&&(h=this.sceneModule2d.adaptiveGrid.gridGroup?.visible??!1,o&&this.sceneModule2d.adaptiveGrid.setVisible(!1)),this.sceneModule2d.axesHelper&&(d=this.sceneModule2d.axesHelper.visible??!1,l&&this.sceneModule2d.setAxesVisible(!1)),a&&this.scene&&(this.scene.background=null),this.scene&&this.camera&&this.renderer.render(this.scene,this.camera);const p=t.toDataURL(s,n),u=await new Promise(m=>{t.toBlob(g=>{g&&m(g)},s,n)}),A=URL.createObjectURL(u);if(this.scene&&(this.scene.background=c),this.sceneModule2d.adaptiveGrid&&o&&this.sceneModule2d.adaptiveGrid.setVisible(h),this.sceneModule2d.axesHelper&&l&&this.sceneModule2d.setAxesVisible(d),this.scene&&this.camera&&this.renderer.render(this.scene,this.camera),e?.download){const m=e.filename||`capture-${Date.now()}.${i}`,g=document.createElement("a");g.href=A,g.download=m,g.style.display="none",document.body.appendChild(g),g.click(),g.remove(),console.log(`[EngineKernel2d] Image captured and downloaded: ${m}`)}else console.log("[EngineKernel2d] Image captured with Blob URL:",A);return{dataURL:p,blobURL:A,blob:u}}dispose(){console.log("[EngineKernel2d] Disposing engine..."),this.stopRendering(),this.cadCursorUI?.dispose(),this.contextMenuUI?.dispose(),this.loadingUI?.dispose(),this.searchManager?.dispose(),this.themeManager?.dispose(),this.loaderModule2d?.dispose(),this.controlModule2d?.dispose(),this.renderModule2d?.dispose(),this.cameraModule2d?.dispose(),this.sceneModule2d?.dispose(),this.events?.dispose(),this.scene=null,this.camera=null,this.renderer=null,this.dwgData=null,console.log("[EngineKernel2d] Engine disposed")}}class BF{scene;panoramaSphere=null;sphereRadius;constructor(e=500){this.sphereRadius=e,this.scene=new ga,this.init()}init(){this.panoramaSphere=this.createPanoramaSphere(this.sphereRadius),this.scene.add(this.panoramaSphere)}createPanoramaSphere(e=500,t=64){const i=new Br(e,t,t/2);i.scale(-1,1,1);const n=new Rt({map:null,side:Gn,transparent:!0}),s=new Ge(i,n);return s.name="panorama-sphere",s}updatePanoramaTexture(e){if(!this.panoramaSphere){console.warn("SceneModule720: Panorama sphere not initialized");return}const t=this.panoramaSphere.material;t.map&&t.map.dispose(),t.map=e,t.needsUpdate=!0}clearPanoramaTexture(){if(!this.panoramaSphere)return;const e=this.panoramaSphere.material;e.map&&(e.map.dispose(),e.map=null,e.needsUpdate=!0)}getScene(){return this.scene}getPanoramaSphere(){return this.panoramaSphere}setSphereRadius(e){if(this.sphereRadius!==e){if(this.sphereRadius=e,this.panoramaSphere){const t=this.panoramaSphere.material,i=t.map;this.scene.remove(this.panoramaSphere),this.panoramaSphere.geometry.dispose(),t.dispose(),i&&i.dispose()}this.panoramaSphere=this.createPanoramaSphere(e),this.scene.add(this.panoramaSphere)}}getSphereRadius(){return this.sphereRadius}dispose(){if(this.panoramaSphere){const e=this.panoramaSphere.material;e.map&&e.map.dispose(),e.dispose(),this.panoramaSphere.geometry.dispose(),this.scene.remove(this.panoramaSphere),this.panoramaSphere=null}this.scene.clear()}}class LF{camera;minFov;maxFov;container;currentPose;constructor(e,t=75,i=30,n=90){this.container=e,this.minFov=i,this.maxFov=n,this.currentPose={theta:0,phi:0},this.camera=this.createCamera(t),this.init()}createCamera(e){const t=this.container.clientWidth/this.container.clientHeight,i=new pi(e,t,.1,2e3);return i.position.set(0,0,0),i}init(){this.updateCameraRotation()}updateCameraRotation(){const{theta:e,phi:t}=this.currentPose,i=new Di(t,e,0,"YXZ"),n=new Tt;n.setFromEuler(i),this.camera.quaternion.copy(n)}setFov(e){const t=Math.max(this.minFov,Math.min(this.maxFov,e));this.camera.fov=t,this.camera.updateProjectionMatrix()}getFov(){return this.camera.fov}getCameraPose(){return{...this.currentPose}}setCameraPose(e,t){this.currentPose.theta=e,this.currentPose.phi=t,this.updateCameraRotation()}updatePose(e,t){this.currentPose.theta+=e,this.currentPose.phi+=t,this.currentPose.theta<0?this.currentPose.theta+=2*Math.PI:this.currentPose.theta>=2*Math.PI&&(this.currentPose.theta-=2*Math.PI),this.currentPose.phi=Math.max(-Math.PI/2+.01,Math.min(Math.PI/2-.01,this.currentPose.phi)),this.updateCameraRotation()}getCamera(){return this.camera}updateAspectRatio(e,t){const i=e/t;this.camera.aspect=i,this.camera.updateProjectionMatrix()}dispose(){this.camera=null}}class kF{renderer;container;animationId=null;isRenderingPaused=!1;fpsFrameCount=0;fpsLastTime=performance.now();currentFps=60;onBeforeRenderCallback;onAfterRenderCallback;constructor(e,t=!0){this.container=e,this.renderer=this.createRenderer(t),this.init()}createRenderer(e){const t=new $c({antialias:e,alpha:!0,preserveDrawingBuffer:!1}),i=this.container.clientWidth,n=this.container.clientHeight;return t.setSize(i,n),t.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.container.appendChild(t.domElement),t}init(){}setOnBeforeRender(e){this.onBeforeRenderCallback=e}setOnAfterRender(e){this.onAfterRenderCallback=e}render(e,t){this.onBeforeRenderCallback&&this.onBeforeRenderCallback(),this.renderer.render(e,t),this.onAfterRenderCallback&&this.onAfterRenderCallback(),this.updateFps()}startRenderLoop(e,t){if(this.animationId!==null){console.warn("RenderModule720: Render loop already running");return}this.isRenderingPaused=!1,this.animate(e,t)}animate(e,t){this.isRenderingPaused||(this.animationId=requestAnimationFrame(()=>{this.animate(e,t)}),this.render(e,t))}pauseRendering(){this.isRenderingPaused=!0,this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null)}resumeRendering(e,t){this.isRenderingPaused&&(this.isRenderingPaused=!1,this.startRenderLoop(e,t))}isRenderingPausedState(){return this.isRenderingPaused}updateFps(){this.fpsFrameCount++;const e=performance.now();e>=this.fpsLastTime+1e3&&(this.currentFps=Math.round(this.fpsFrameCount*1e3/(e-this.fpsLastTime)),this.fpsFrameCount=0,this.fpsLastTime=e,this.currentFps<30&&console.warn("RenderModule720: Low FPS detected:",this.currentFps))}getCurrentFps(){return this.currentFps}resize(e,t){this.renderer.setSize(e,t),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2))}getDomElement(){return this.renderer.domElement}getRenderer(){return this.renderer}dispose(){this.pauseRendering(),this.container.contains(this.renderer.domElement)&&this.container.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss(),this.onBeforeRenderCallback=void 0,this.onAfterRenderCallback=void 0}}class NF{camera;domElement;cameraModule;enableZoom=!0;enableRotate=!0;minFov=30;maxFov=90;rotateSpeed=.5;zoomSpeed=1;enableDamping=!0;dampingFactor=.05;isDragging=!1;startX=0;startY=0;thetaDelta=0;phiDelta=0;isPinching=!1;pinchStartDistance=null;pinchStartFov=75;_onMouseDown;_onMouseMove;_onMouseUp;_onWheel;_onTouchStart;_onTouchMove;_onTouchEnd;onViewAngleChange;constructor(e,t){this.cameraModule=e,this.camera=e.getCamera(),this.pinchStartFov=this.camera.fov,this.domElement=t,this._onMouseDown=this.onMouseDown.bind(this),this._onMouseMove=this.onMouseMove.bind(this),this._onMouseUp=this.onMouseUp.bind(this),this._onWheel=this.onWheel.bind(this),this._onTouchStart=this.onTouchStart.bind(this),this._onTouchMove=this.onTouchMove.bind(this),this._onTouchEnd=this.onTouchEnd.bind(this),this.init()}init(){this.domElement.addEventListener("mousedown",this._onMouseDown),this.domElement.addEventListener("mousemove",this._onMouseMove),this.domElement.addEventListener("mouseup",this._onMouseUp),this.domElement.addEventListener("mouseleave",this._onMouseUp),this.domElement.addEventListener("wheel",this._onWheel,{passive:!1}),this.domElement.addEventListener("touchstart",this._onTouchStart,{passive:!1}),this.domElement.addEventListener("touchmove",this._onTouchMove,{passive:!1}),this.domElement.addEventListener("touchend",this._onTouchEnd)}onMouseDown(e){e.button===0&&(this.isDragging=!0,this.startX=e.clientX,this.startY=e.clientY)}onMouseMove(e){if(!this.isDragging||!this.enableRotate)return;const t=e.clientX-this.startX,i=e.clientY-this.startY,{horizontal:n,vertical:s}=this.getRotationFactors();this.thetaDelta+=t*n*this.rotateSpeed*.06,this.phiDelta+=i*s*this.rotateSpeed*.06,this.startX=e.clientX,this.startY=e.clientY,this.applyRotation()}onMouseUp(){this.isDragging=!1}onWheel(e){if(!this.enableZoom)return;e.preventDefault();const t=(e.deltaY>0?1:-1)*this.zoomSpeed*2;this.applyZoom(t)}onTouchStart(e){e.touches.length===1?(this.isDragging=!0,this.isPinching=!1,this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY):e.touches.length===2&&(e.preventDefault(),this.isDragging=!1,this.isPinching=!0,this.pinchStartDistance=this.getTouchDistance(e.touches),this.pinchStartFov=this.cameraModule.getFov())}onTouchMove(e){if(e.touches.length===1&&this.isDragging&&this.enableRotate){const t=e.touches[0].clientX-this.startX,i=e.touches[0].clientY-this.startY,{horizontal:n,vertical:s}=this.getRotationFactors();this.thetaDelta-=t*n*this.rotateSpeed,this.phiDelta-=i*s*this.rotateSpeed,this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY,this.applyRotation()}else if(e.touches.length===2&&this.enableZoom){e.preventDefault(),this.isPinching||(this.isPinching=!0,this.pinchStartDistance=this.getTouchDistance(e.touches),this.pinchStartFov=this.cameraModule.getFov());const t=this.getTouchDistance(e.touches);if(this.pinchStartDistance&&t>0){const i=this.pinchStartDistance/t,n=Dt.clamp(this.pinchStartFov*i,this.minFov,this.maxFov);this.cameraModule.setFov(n)}}}onTouchEnd(e){e.touches&&e.touches.length>0?this.isDragging=e.touches.length===1:this.isDragging=!1,e.touches.length<2&&(this.isPinching=!1,this.pinchStartDistance=null)}applyRotation(){if(this.cameraModule.updatePose(this.thetaDelta,this.phiDelta),this.enableDamping?(this.thetaDelta*=1-this.dampingFactor,this.phiDelta*=1-this.dampingFactor):(this.thetaDelta=0,this.phiDelta=0),this.onViewAngleChange){const e=this.cameraModule.getCameraPose();this.onViewAngleChange(e.theta,e.phi)}}getRotationFactors(){const e=Math.max(1,this.domElement.clientWidth),t=Math.max(1,this.domElement.clientHeight);return{horizontal:Math.PI*2/e,vertical:Math.PI/t}}applyZoom(e){const t=this.cameraModule.getFov(),i=Dt.clamp(t+e,this.minFov,this.maxFov);this.cameraModule.setFov(i)}getTouchDistance(e){if(e.length<2)return 0;const t=e[0].clientX-e[1].clientX,i=e[0].clientY-e[1].clientY;return Math.sqrt(t*t+i*i)}update(){this.enableDamping&&(Math.abs(this.thetaDelta)>1e-4||Math.abs(this.phiDelta)>1e-4)&&this.applyRotation()}lookAt(e,t){this.thetaDelta=e,this.phiDelta=Math.max(-Math.PI/2+.01,Math.min(Math.PI/2-.01,t)),this.cameraModule.setCameraPose(e,t),this.thetaDelta=0,this.phiDelta=0}getViewAngle(){return this.cameraModule.getCameraPose()}setOnViewAngleChange(e){this.onViewAngleChange=e}reset(){this.thetaDelta=0,this.phiDelta=0,this.lookAt(0,0)}setRotateSpeed(e){this.rotateSpeed=Math.max(.05,e)}setZoomSpeed(e){this.zoomSpeed=Math.max(.1,e)}setEnableDamping(e){this.enableDamping=e}setDampingFactor(e){this.dampingFactor=Math.max(0,Math.min(1,e))}setZoomLimits(e,t){this.minFov=e,this.maxFov=t}dispose(){this.domElement.removeEventListener("mousedown",this._onMouseDown),this.domElement.removeEventListener("mousemove",this._onMouseMove),this.domElement.removeEventListener("mouseup",this._onMouseUp),this.domElement.removeEventListener("mouseleave",this._onMouseUp),this.domElement.removeEventListener("wheel",this._onWheel),this.domElement.removeEventListener("touchstart",this._onTouchStart),this.domElement.removeEventListener("touchmove",this._onTouchMove),this.domElement.removeEventListener("touchend",this._onTouchEnd),this.onViewAngleChange=void 0}}class UF{controls;domElement;cameraModule;constructor(e,t){this.cameraModule=e,this.domElement=t,this.controls=new NF(e,t)}init(){}active(){}disActive(){this.controls.enableRotate=!1,this.controls.enableZoom=!1}enable(){this.controls.enableRotate=!0,this.controls.enableZoom=!0}update(){this.controls.update()}lookAt(e,t){this.controls.lookAt(e,t)}getViewAngle(){return this.controls.getViewAngle()}setOnViewAngleChange(e){this.controls.setOnViewAngleChange(e)}reset(){this.controls.reset()}getControls(){return this.controls}updateInteractionOptions(e){if(e.rotateSpeed!==void 0&&this.controls.setRotateSpeed(e.rotateSpeed),e.zoomSpeed!==void 0&&this.controls.setZoomSpeed(e.zoomSpeed),e.enableDamping!==void 0&&this.controls.setEnableDamping(e.enableDamping),e.dampingFactor!==void 0&&this.controls.setDampingFactor(e.dampingFactor),e.enableRotate!==void 0&&(this.controls.enableRotate=e.enableRotate),e.enableZoom!==void 0&&(this.controls.enableZoom=e.enableZoom),e.minFov!==void 0||e.maxFov!==void 0){const t=e.minFov??this.controls.minFov,i=e.maxFov??this.controls.maxFov;this.controls.setZoomLimits(t,i)}}dispose(){this.controls.dispose()}}class FF{cache=new Map;loadingPromises=new Map;loadTexture(e){if(this.cache.has(e))return Promise.resolve(this.cache.get(e));if(this.loadingPromises.has(e))return this.loadingPromises.get(e);const t=new Promise((i,n)=>{new Da().load(e,s=>{s.colorSpace=Jt,s.minFilter=_t,s.magFilter=_t,this.cache.set(e,s),this.loadingPromises.delete(e),i(s)},void 0,s=>{this.loadingPromises.delete(e),n(s)})});return this.loadingPromises.set(e,t),t}async preloadTextures(e){const t=e.map(i=>this.loadTexture(i));return Promise.all(t)}has(e){return this.cache.has(e)}get(e){return this.cache.get(e)}remove(e){const t=this.cache.get(e);t&&(t.dispose(),this.cache.delete(e))}clear(){this.cache.forEach(e=>e.dispose()),this.cache.clear(),this.loadingPromises.clear()}size(){return this.cache.size}dispose(){this.clear()}}class OF{textureCache;currentUrl=null;loadProgress=0;onProgressCallback;constructor(){this.textureCache=new FF}async loadTexture(e){this.currentUrl=e,this.loadProgress=0,this.onProgressCallback&&this.onProgressCallback(0);try{const t=await this.loadTextureInternal(e);return this.loadProgress=100,this.onProgressCallback&&this.onProgressCallback(100),t}catch(t){throw console.error("PanoramaLoader: Failed to load texture:",t),t}}loadTextureInternal(e){return new Promise((t,i)=>{if(this.textureCache.has(e)){const n=this.textureCache.get(e);if(n){t(n);return}}new Da().load(e,n=>{n.colorSpace=Jt,n.minFilter=_t,n.magFilter=_t,this.textureCache.cache.set(e,n),t(n)},n=>{n.total>0&&(this.loadProgress=n.loaded/n.total*100,this.onProgressCallback&&this.onProgressCallback(this.loadProgress))},n=>{i(n)})})}async preloadPanoramas(e){try{await this.textureCache.preloadTextures(e)}catch(t){throw console.error("PanoramaLoader: Failed to preload panoramas:",t),t}}getLoadProgress(){return this.loadProgress}setOnProgress(e){this.onProgressCallback=e}getCurrentUrl(){return this.currentUrl}isCached(e){return this.textureCache.has(e)}getCachedTexture(e){return this.textureCache.get(e)}clearCache(){this.textureCache.clear()}removeCachedTexture(e){this.textureCache.remove(e)}dispose(){this.textureCache.dispose(),this.onProgressCallback=void 0,this.currentUrl=null}}class qE{static sphericalToCartesian(e){const t=e.radius||500,{theta:i,phi:n}=e,s=t*Math.cos(n)*Math.cos(i),a=t*Math.sin(n),o=t*Math.cos(n)*Math.sin(i);return{x:s,y:a,z:o}}static cartesianToSpherical(e,t,i){const n=Math.sqrt(e*e+t*t+i*i),s=Math.asin(t/n);let a=Math.atan2(i,e);return a<0&&(a+=2*Math.PI),{theta:a,phi:s,radius:n}}static normalizeAngle(e,t=-Math.PI,i=Math.PI){const n=i-t;let s=e;for(;s<t;)s+=n;for(;s>i;)s-=n;return s}static clampPhi(e,t=-Math.PI/2+.01,i=Math.PI/2-.01){return Math.max(t,Math.min(i,e))}static sphericalDistance(e,t){const i=Math.sin(e.phi)*Math.sin(t.phi)+Math.cos(e.phi)*Math.cos(t.phi)*Math.cos(e.theta-t.theta);return Math.acos(Math.max(-1,Math.min(1,i)))}static lerpSpherical(e,t,i){let n=t.theta-e.theta;n>Math.PI?n-=2*Math.PI:n<-Math.PI&&(n+=2*Math.PI);const s=e.theta+n*i,a=e.phi+(t.phi-e.phi)*i,o=e.radius||500,l=t.radius||500,c=o+(l-o)*i;return{theta:s,phi:a,radius:c}}}var Lh=(r=>(r.ICON="icon",r.TEXT="text",r.LINK="link",r))(Lh||{});class zF{annotations=new Map;container;annotationContainer;worldToScreen;sphereRadius;camera;renderer;onClickAnnotation;onHoverAnnotation;constructor(e,t,i,n){this.container=e,this.camera=t,this.renderer=i,this.sphereRadius=n,this.worldToScreen=new zt(t,i),this.createAnnotationContainer()}createAnnotationContainer(){this.annotationContainer=document.createElement("div"),this.annotationContainer.className="panorama-annotation-container",this.annotationContainer.style.cssText=`
|
||
position: absolute;
|
||
top: 0;
|
||
left: 0;
|
||
width: 100%;
|
||
height: 100%;
|
||
pointer-events: none;
|
||
z-index: 1000;
|
||
overflow: hidden;
|
||
`,this.container.appendChild(this.annotationContainer)}addAnnotation(e){const t=this.generateId(),i=this.sphericalToCartesian(e.position),n=this.createAnnotationElement(e,t),s={id:t,config:e,element:n,worldPosition:i,screenPosition:{x:0,y:0},visible:!1};return this.annotationContainer.appendChild(n),this.annotations.set(t,s),this.updateAnnotationPosition(s),t}addAnnotations(e){return e.map(t=>this.addAnnotation(t))}createAnnotationElement(e,t){const i=document.createElement("div");switch(i.className=`panorama-annotation panorama-annotation-${e.type}`,i.dataset.annotationId=t,i.style.cssText=`
|
||
position: absolute;
|
||
pointer-events: auto;
|
||
cursor: pointer;
|
||
transform: translate(-50%, -50%);
|
||
transition: opacity 0.2s ease;
|
||
`,e.type){case Lh.ICON:this.createIconAnnotation(i,e);break;case Lh.TEXT:this.createTextAnnotation(i,e);break;case Lh.LINK:this.createLinkAnnotation(i,e);break}return this.attachAnnotationEvents(i,t),i}createIconAnnotation(e,t){const i=t.size||{width:40,height:40};e.style.width=`${i.width}px`,e.style.height=`${i.height}px`;const n=document.createElement("img");n.src=t.iconUrl,n.style.cssText=`
|
||
width: 100%;
|
||
height: 100%;
|
||
object-fit: contain;
|
||
display: block;
|
||
`,n.onerror=()=>{console.error(`Failed to load annotation icon: ${t.iconUrl}`)},e.appendChild(n),t.tooltip&&(e.title=t.tooltip)}createTextAnnotation(e,t){const i=t.style||{};e.style.cssText+=`
|
||
padding: ${i.padding||"8px 12px"};
|
||
background-color: ${i.backgroundColor||"rgba(0, 0, 0, 0.7)"};
|
||
color: ${i.color||"#ffffff"};
|
||
font-size: ${i.fontSize||14}px';
|
||
border-radius: 4px;
|
||
white-space: nowrap;
|
||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||
`,e.textContent=t.text,t.tooltip&&(e.title=t.tooltip)}createLinkAnnotation(e,t){const i=t.style||{};if(e.style.cssText+=`
|
||
padding: 8px 12px;
|
||
background-color: rgba(59, 130, 246, 0.9);
|
||
color: ${i.color||"#ffffff"};
|
||
font-size: ${i.fontSize||14}px';
|
||
border-radius: 4px;
|
||
text-decoration: ${i.textDecoration||"none"};
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 8px;
|
||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||
transition: background-color 0.2s ease;
|
||
`,e.addEventListener("mouseenter",()=>{e.style.backgroundColor="rgba(37, 99, 235, 0.95)"}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor="rgba(59, 130, 246, 0.9)"}),t.iconUrl){const s=document.createElement("img");s.src=t.iconUrl,s.style.cssText=`
|
||
width: 16px;
|
||
height: 16px;
|
||
display: block;
|
||
`,e.appendChild(s)}const n=document.createElement("span");n.textContent=t.text||t.url,e.appendChild(n),t.tooltip&&(e.title=t.tooltip)}attachAnnotationEvents(e,t){e.addEventListener("click",i=>{i.stopPropagation();const n=this.annotations.get(t);n&&this.handleClickAnnotation(n)}),e.addEventListener("mouseenter",()=>{const i=this.annotations.get(t);i&&this.handleHoverAnnotation(i)}),e.addEventListener("mouseleave",()=>{this.onHoverAnnotation&&this.onHoverAnnotation(null)})}sphericalToCartesian(e){const t=e.radius??this.sphereRadius;return qE.sphericalToCartesian({...e,radius:t})}updateAnnotationPosition(e){const t=new T(e.worldPosition.x,e.worldPosition.y,e.worldPosition.z),i=this.worldToScreen.worldToScreen(t);e.screenPosition={x:i.x,y:i.y};const n=this.isPositionInFront(t),s=this.isPositionInView(i);e.visible=n&&s,e.visible?(e.element.style.display="block",e.element.style.left=`${i.x}px`,e.element.style.top=`${i.y}px`):e.element.style.display="none"}isPositionInFront(e){const t=new T;return this.camera.getWorldDirection(t),e.clone().normalize().dot(t)>0}isPositionInView(e){const t=this.renderer.domElement.clientWidth,i=this.renderer.domElement.clientHeight;return e.x>=0&&e.x<=t&&e.y>=0&&e.y<=i}update(){this.annotations.forEach(e=>{this.updateAnnotationPosition(e)})}handleClickAnnotation(e){if(e.config.type===Lh.LINK){const t=e.config;window.open(t.url,"_blank")}this.onClickAnnotation&&this.onClickAnnotation(e)}handleHoverAnnotation(e){this.onHoverAnnotation&&this.onHoverAnnotation(e)}setOnClickAnnotation(e){this.onClickAnnotation=e}setOnHoverAnnotation(e){this.onHoverAnnotation=e}removeAnnotation(e){const t=this.annotations.get(e);t&&(t.element.remove(),this.annotations.delete(e))}clearAll(){this.annotations.forEach(e=>{e.element.remove()}),this.annotations.clear()}getAnnotations(){return Array.from(this.annotations.values())}getAnnotation(e){return this.annotations.get(e)}updateCamera(e){this.camera=e,this.worldToScreen.updateCamera(e)}dispose(){this.clearAll(),this.annotationContainer.remove(),this.onClickAnnotation=void 0,this.onHoverAnnotation=void 0}generateId(){return`annotation-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}}class HF{listeners=new Map;on(e,t){const i=String(e);this.listeners.has(i)||this.listeners.set(i,[]),this.listeners.get(i).push(t)}off(e,t){const i=String(e),n=this.listeners.get(i);if(n){const s=n.indexOf(t);s!==-1&&n.splice(s,1),n.length===0&&this.listeners.delete(i)}}trigger(e,t){const i=String(e),n=this.listeners.get(i);if(n&&n.length>0){const s=[...n];for(const a of s)try{a(t)}catch(o){console.error(`EventModule: Error in event handler for "${i}":`,o)}}}removeAllListeners(e){const t=String(e);this.listeners.delete(t)}clear(){this.listeners.clear()}listenerCount(e){const t=String(e),i=this.listeners.get(t);return i?i.length:0}dispose(){this.clear()}}var Ns=(r=>(r.PanoramaLoadStart="panorama-load-start",r.PanoramaLoadProgress="panorama-load-progress",r.PanoramaLoaded="panorama-loaded",r.PanoramaLoadError="panorama-load-error",r.AnnotationClick="annotation-click",r.AnnotationHover="annotation-hover",r.AnnotationAdd="annotation-add",r.AnnotationRemove="annotation-remove",r.ViewAngleChanged="view-angle-changed",r))(Ns||{});class GF{sceneModule;cameraModule;renderModule;controlModule;eventModule;panoramaLoader;annotationManager;worldToScreen;isInitialized=!1;version="1.0.0";constructor(e){this.initialize(e)}initialize(e){const t={fov:75,enableZoom:!0,enableRotate:!0,minFov:30,maxFov:90,sphereRadius:500,rotateSpeed:.35,zoomSpeed:.8,enableDamping:!0,dampingFactor:.08,...e},i=document.getElementById(t.containerId);if(!i)throw new Error(`Container with id "${t.containerId}" not found`);try{this.eventModule=new HF,this.sceneModule=new BF(t.sphereRadius),this.cameraModule=new LF(i,t.fov,t.minFov,t.maxFov),this.renderModule=new kF(i,!0),this.controlModule=new UF(this.cameraModule,this.renderModule.getDomElement());const n=this.controlModule.getControls();n.enableZoom=t.enableZoom,n.enableRotate=t.enableRotate,n.setRotateSpeed(t.rotateSpeed),n.setZoomSpeed(t.zoomSpeed),n.setEnableDamping(t.enableDamping),n.setDampingFactor(t.dampingFactor),n.setZoomLimits(t.minFov,t.maxFov),n.setOnViewAngleChange((s,a)=>{this.eventModule.trigger(Ns.ViewAngleChanged,{theta:s,phi:a})}),this.panoramaLoader=new OF,this.worldToScreen=new zt(this.cameraModule.getCamera(),this.renderModule.getRenderer(),this.sceneModule.getScene()),this.annotationManager=new zF(i,this.cameraModule.getCamera(),this.renderModule.getRenderer(),t.sphereRadius),this.annotationManager.setOnClickAnnotation(s=>{this.eventModule.trigger(Ns.AnnotationClick,{id:s.id,config:s.config,metadata:s.config.metadata})}),this.annotationManager.setOnHoverAnnotation(s=>{this.eventModule.trigger(Ns.AnnotationHover,{annotation:s?{id:s.id,config:s.config,metadata:s.config.metadata}:null})}),this.setupRenderLoop(),this.isInitialized=!0,console.log("EngineKernel720: Initialized successfully")}catch(n){throw console.error("EngineKernel720: Initialization failed",n),n}}setupRenderLoop(){this.renderModule.setOnBeforeRender(()=>{this.controlModule.update(),this.annotationManager.update()}),this.renderModule.startRenderLoop(this.sceneModule.getScene(),this.cameraModule.getCamera())}async loadPanorama(e){this.checkInitialized(),this.eventModule.trigger(Ns.PanoramaLoadStart,{url:e});try{this.panoramaLoader.setOnProgress(i=>{this.eventModule.trigger(Ns.PanoramaLoadProgress,{url:e,progress:i})});const t=await this.panoramaLoader.loadTexture(e);this.sceneModule.updatePanoramaTexture(t),this.eventModule.trigger(Ns.PanoramaLoaded,{url:e,progress:100}),console.log("EngineKernel720: Panorama loaded successfully")}catch(t){throw console.error("EngineKernel720: Failed to load panorama",t),this.eventModule.trigger(Ns.PanoramaLoadError,{url:e,error:t}),t}}async preloadPanoramas(e){this.checkInitialized();try{await this.panoramaLoader.preloadPanoramas(e),console.log(`EngineKernel720: Preloaded ${e.length} panoramas`)}catch(t){throw console.error("EngineKernel720: Failed to preload panoramas",t),t}}addAnnotation(e){this.checkInitialized();const t=this.annotationManager.addAnnotation(e);return this.eventModule.trigger(Ns.AnnotationAdd,{id:t,config:e}),t}addAnnotations(e){return this.checkInitialized(),e.map(t=>this.addAnnotation(t))}removeAnnotation(e){this.checkInitialized(),this.annotationManager.removeAnnotation(e),this.eventModule.trigger(Ns.AnnotationRemove,{id:e})}clearAnnotations(){this.checkInitialized(),this.annotationManager.clearAll()}getAnnotations(){return this.checkInitialized(),this.annotationManager.getAnnotations()}updateInteractionOptions(e){this.checkInitialized(),this.controlModule.updateInteractionOptions(e)}pickPanoramaPoint(e,t){this.checkInitialized();const i=this.renderModule.getRenderer().domElement,n=i.clientWidth,s=i.clientHeight;if(n===0||s===0)return null;const a=new be(e/n*2-1,-(t/s*2-1)),o=this.cameraModule.getCamera(),l=new T(a.x,a.y,.5);l.unproject(o),l.sub(o.position).normalize();const c=this.sceneModule.getSphereRadius(),h=o.position.clone().add(l.multiplyScalar(c)),d=qE.cartesianToSpherical(h.x,h.y,h.z);return{theta:d.theta,phi:d.phi,radius:c}}lookAt(e,t,i){this.checkInitialized(),i&&console.warn("EngineKernel720: Animated lookAt not implemented yet"),this.controlModule.lookAt(e,t)}getViewAngle(){return this.checkInitialized(),this.controlModule.getViewAngle()}setFov(e){this.checkInitialized(),this.cameraModule.setFov(e)}getFov(){return this.checkInitialized(),this.cameraModule.getFov()}on(e,t){this.checkInitialized(),this.eventModule.on(e,t)}off(e,t){this.checkInitialized(),this.eventModule.off(e,t)}resize(e,t){this.checkInitialized();const i=e??this.renderModule.getRenderer().domElement.clientWidth,n=t??this.renderModule.getRenderer().domElement.clientHeight;this.renderModule.resize(i,n),this.cameraModule.updateAspectRatio(i,n),console.log("EngineKernel720: Resized to",i,"x",n)}pauseRendering(){this.checkInitialized(),this.renderModule.pauseRendering()}resumeRendering(){this.checkInitialized(),this.renderModule.resumeRendering(this.sceneModule.getScene(),this.cameraModule.getCamera())}isRenderingPausedState(){return this.isInitialized?this.renderModule.isRenderingPausedState():!0}getVersion(){return this.version}dispose(){if(this.isInitialized)try{this.renderModule.pauseRendering(),this.annotationManager.dispose(),this.panoramaLoader.dispose(),this.controlModule.dispose(),this.cameraModule.dispose(),this.renderModule.dispose(),this.sceneModule.dispose(),this.eventModule.dispose(),this.isInitialized=!1,console.log("EngineKernel720: Disposed successfully")}catch(e){console.error("EngineKernel720: Error during dispose",e)}}checkInitialized(){if(!this.isInitialized)throw new Error("EngineKernel720: Not initialized")}}function VF(r){return new sF(r)}function QF(r){return new DF(r)}function WF(r){return new GF(r)}class ta{engine=null;registry;container;containerId;options;_isInitialized=!1;_isDestroyed=!1;unsubscribeTheme=null;currentMeasureType=null;isMeasureActive=!1;currentSectionMode=null;selectedComponent=null;constructor(e,t){this.registry=t,this.container=e.container,this.container.id?this.containerId=this.container.id:(this.containerId=`engine-container-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,this.container.id=this.containerId),this.options={backgroundColor:"linear-gradient(to bottom, rgb(214, 224, 235), rgb(246, 250, 255))",version:e.version??"v2",showStats:e.showStats??!1,showViewCube:e.showViewCube??!0}}init(){if(this._isInitialized){console.warn("[Engine] Engine already initialized.");return}if(this._isDestroyed){console.error("[Engine] Cannot initialize destroyed engine.");return}try{typeof this.options.backgroundColor=="string"&&(this.container.style.background=this.options.backgroundColor);const e={containerId:this.containerId,backgroundColor:this.options.backgroundColor,version:this.options.version,showStats:this.options.showStats,showViewCube:this.options.showViewCube};if(console.log("引擎配置信息:",e),this.engine=VF(e),!this.engine)throw new Error("Failed to create engine instance");this._isInitialized=!0,this.resize(this.container.clientWidth,this.container.clientHeight),this.unsubscribeTheme=ht.subscribe(t=>{this.setTheme(t)}),this.setTheme(ht.getTheme()),this.engine?.events?.on?(this.engine.events.on("click",t=>{const i=this.registry;console.log("[Engine] 底层 click 事件触发:",t),t&&Array.isArray(t)&&t.length>0&&t[0].url?(this.selectedComponent={url:t[0].url,id:t[0].ids?.[0]},console.log("[Engine] 触发 component:selected:",this.selectedComponent),i.emit("component:selected",this.selectedComponent)):(this.selectedComponent=null,console.log("[Engine] 触发 component:deselected"),i.emit("component:deselected",{}))}),this.engine.events.on("loading_completed",()=>{console.log("[Engine] 底层 LoadingCompleted 事件触发"),this.registry.emit("engine:model-loading-completed",{})})):console.warn("[Engine] 底层引擎不支持 events.on 方法,无法监听点击事件")}catch(e){throw console.error("[Engine] Failed to initialize engine:",e),this._isInitialized=!1,e}}setTheme(e){}setLocales(){}isInitialized(){return this._isInitialized}loadModel(e,t){if(!this._isInitialized||!this.engine){console.error("[Engine] Engine not initialized. Please call init() first.");return}if(!e||e.length===0){console.error("[Engine] Model URLs are required.");return}this.engine.loaderModule.loadModels(e,t)}CameraGoHome(){this.engine.viewCube.CameraGoHome()}onRawEvent(e,t){this.engine?.events?.on(e,t)}offRawEvent(e,t){this.engine?.events?.off(e,t)}pauseRendering(){if(!this._isInitialized||!this.engine){console.warn("[Engine] Engine not initialized.");return}this.engine.pauseRendering()}resumeRendering(){if(!this._isInitialized||!this.engine){console.warn("[Engine] Engine not initialized.");return}this.engine.resumeRendering()}dispose(){if(!this._isInitialized||!this.engine){console.warn("[Engine] Engine not initialized.");return}this.engine.dispose()}resize(e,t){if(!this._isInitialized||!this.engine)return;const i=typeof e=="number"?Math.floor(e):this.container.clientWidth,n=typeof t=="number"?Math.floor(t):this.container.clientHeight;i<=0||n<=0||typeof this.engine.handleWindowResize=="function"&&this.engine.handleWindowResize(i,n)}activateMeasure(e){if(!this._isInitialized||!this.engine?.measure){console.error("[Engine] Cannot activate measure: engine not initialized.");return}if(this.currentMeasureType===e){console.log(`[Engine] Measure ${e} already active, skipping.`);return}this.isMeasureActive||(console.log("[Engine] Activating measure module"),this.engine.measure.active(),this.isMeasureActive=!0),console.log(`[Engine] Activating measure: ${e}`);const t=this.engine.measure;switch(e){case"clearHeight":t.clearHeightMeasure.active();break;case"clearDistance":t.clearDistanceMeasure.active();break;case"distance":t.distanceMeasure.active();break;case"elevation":t.elevationMeasure.active();break;case"point":t.pointMeasure.active();break;case"angle":t.angleMeasure.active();break;case"area":t.areaMeasure.active();break;case"slope":t.slopeMeasure.active();break;default:console.error(`[Engine] Unknown measure type: ${e}`);return}this.currentMeasureType=e}getCurrentMeasureType(){return this.currentMeasureType}deactivateMeasure(){!this._isInitialized||!this.engine?.measure||(console.log("[Engine] Deactivating measure"),this.engine.measure.disActive(),this.engine.measure.clearAll(),this.isMeasureActive=!1,this.currentMeasureType=null)}clearAllMeasures(){!this._isInitialized||!this.engine?.measure||(console.log("[Engine] Clearing all measures"),this.engine.measure.clearAll())}saveMeasureSetting(e){!this._isInitialized||!this.engine?.measure||this.engine.measure.saveSetting?.(e)}setClearHeightDirection(e){!this._isInitialized||!this.engine?.measure||(console.log(`[Engine] Setting clearHeight direction: ${e}`),this.engine.measure.clearHeightMeasure.setDirection(e))}setClearHeightSelectType(e){!this._isInitialized||!this.engine?.measure||(console.log(`[Engine] Setting clearHeight selectType: ${e}`),this.engine.measure.clearHeightMeasure.setSelectType(e))}activeSection(e){if(!this._isInitialized||!this.engine?.clipping){console.error("[Engine] Cannot activate section: engine not initialized.");return}if(this.currentSectionMode===e){console.log(`[Engine] Section ${e} already active, skipping.`);return}console.log(`[Engine] Activating section: ${e}`),this.engine.clipping.active(e),this.currentSectionMode=e}getCurrentSectionMode(){return this.currentSectionMode}setSectionBoxRange(e){if(!this._isInitialized||!this.engine?.clipping){console.error("[Engine] Cannot set section box range: engine not initialized.");return}this.engine.clipping.updateClippingValue(e)}deactivateSection(){!this._isInitialized||!this.engine?.clipping||(console.log("[Engine] Deactivating all sections"),this.engine.clipping.disActive(),this.currentSectionMode=null)}hideSection(){if(!this._isInitialized||!this.engine?.clipping){console.error("[Engine] Cannot hide section: engine not initialized.");return}console.log("[Engine] Hiding section"),this.engine.clipping.disabled()}recoverSection(){if(!this._isInitialized||!this.engine?.clipping){console.error("[Engine] Cannot recover section: engine not initialized.");return}console.log("[Engine] Recovering section"),this.engine.clipping.recover()}fitSectionBoxToModel(){if(!this._isInitialized||!this.engine){console.error("[Engine] Cannot fit section box: engine not initialized.");return}const e=this.engine.engineStatus?.highlightModels;e&&(console.log("[Engine] Fitting section box to model"),this.engine.clipping?.clippingModel(e))}scaleSectionBox(){if(!this._isInitialized||!this.engine?.clipping){console.error("[Engine] Cannot scale section box: engine not initialized.");return}this.engine.clipping.scaleBox()}reverseSection(){if(!this._isInitialized||!this.engine?.clipping){console.error("[Engine] Cannot reverse section: engine not initialized.");return}this.engine.clipping.reverse()}switchCamera(){if(!this._isInitialized||!this.engine?.cameraModule){console.warn("[Engine] Cannot switch camera: engine not initialized.");return}this.engine.cameraModule.switchCurrentCamera()}getCameraType(){return!this._isInitialized||!this.engine?.cameraModule?"perspective":this.engine.cameraModule.getCameraType()===1?"orthographic":"perspective"}getRenderMode(){return!this._isInitialized||!this.engine?.engineModelModule?"balance":this.engine.engineModelModule.getCurrentMode()}setRenderMode(e){if(!this._isInitialized||!this.engine?.engineModelModule){console.warn("[Engine] Cannot set render mode: engine not initialized.");return}try{this.engine.engineModelModule.setMode(e)}catch(t){console.warn("[Engine] Failed to set render mode:",t)}}normalizePercent(e,t){return Number.isFinite(e)?Math.min(100,Math.max(0,Math.round(e))):t}getSettingApi(){return!this._isInitialized||!this.engine?.setting?null:this.engine.setting}callSettingMethod(e,...t){const i=this.getSettingApi();if(!i)return;const n=i[e];if(typeof n=="function")return n.apply(this.engine.setting,t)}hasSettingMethod(e){const t=this.getSettingApi();return t?typeof t[e]=="function":!1}mergeSettingsWithDefaults(e){const t=e.display?.groundId??"0",i=typeof e.display?.showGround=="boolean"?e.display.showGround:t!=="0"&&t!=="";return{render:{mode:e.render?.mode??"advanced",contrast:this.normalizePercent(e.render?.contrast??50,50),saturation:this.normalizePercent(e.render?.saturation??50,50),shadowIntensity:this.normalizePercent(e.render?.shadowIntensity??50,50),lightIntensity:this.normalizePercent(e.render?.lightIntensity??50,50),gtaoIntensity:this.normalizePercent(e.render?.gtaoIntensity??50,50)},display:{showEdge:!!e.display?.showEdge,edgeOpacity:this.normalizePercent(e.display?.edgeOpacity??30,30),showGrid:!!e.display?.showGrid,showLevel:!!e.display?.showLevel,showGround:i,groundId:t,groundHeight:Number.isFinite(e.display?.groundHeight)?Number(e.display?.groundHeight):0},environment:{type:e.environment?.type??"none",hdrId:e.environment?.hdrId??"0",hdrIntensity:this.normalizePercent(e.environment?.hdrIntensity??20,20),skyPreset:e.environment?.skyPreset??"sunrise_clear",skyParams:e.environment?.skyParams??{},skyIntensity:this.normalizePercent(e.environment?.skyIntensity??20,20)}}}getPresetLists(){const e={ground:[],hdr:[],sky:[]},t=this.getSettingApi();if(!t)return e;const i=t.getPresetLists,n=typeof i=="function"?i.call(this.engine.setting):null,s=this.getGroundList().map(o=>({id:o.id,names:[o.name,o.name,o.name]})),a=this.getHDRBackgroundList().map(o=>({id:o.id,names:[o.name,o.name,o.name]}));return{ground:Array.isArray(n?.ground)&&n.ground.length>0?n.ground:s,hdr:Array.isArray(n?.hdr)&&n.hdr.length>0?n.hdr:a,sky:Array.isArray(n?.sky)?n.sky:[]}}getSettings(){const e=this.callSettingMethod("getSettings");return e&&typeof e=="object"?this.mergeSettingsWithDefaults(e):{render:{mode:this.getRenderMode(),contrast:this.normalizePercent(this.getSceneContrast(),50),saturation:this.normalizePercent(this.getSceneSaturation(),50),shadowIntensity:50,lightIntensity:this.normalizePercent(this.getAmbientLightIntensity(),50),gtaoIntensity:50},display:{showEdge:this.getModelEdgeActive(),edgeOpacity:30,showGrid:!1,showLevel:!1,showGround:this.getGroundId()!=="0"&&this.getGroundId()!=="",groundId:this.getGroundId()||"0",groundHeight:this.getGroundElevation()},environment:{type:this.getHDRBackgroundId()&&this.getHDRBackgroundId()!=="0"?"hdr":"none",hdrId:this.getHDRBackgroundId()||"0",hdrIntensity:20,skyPreset:"sunrise_clear",skyParams:{},skyIntensity:20}}}async setSettings(e){if(!this._isInitialized||!this.engine?.setting){console.warn("[Engine] Cannot set settings: engine not initialized.");return}if(this.hasSettingMethod("setSettings"))try{const t=this.callSettingMethod("setSettings",e);await Promise.resolve(t);return}catch(t){console.warn("[Engine] Native setSettings failed, fallback to compatibility mode.",t)}if(e.render?.mode&&this.setRenderMode(e.render.mode),typeof e.render?.lightIntensity=="number"&&this.setAmbientLightIntensity(e.render.lightIntensity),typeof e.render?.contrast=="number"&&this.setSceneContrast(e.render.contrast),typeof e.render?.saturation=="number"&&this.setSceneSaturation(e.render.saturation),typeof e.display?.showEdge=="boolean"&&(e.display.showEdge?this.activeModelEdge():this.disActiveModelEdge()),typeof e.display?.edgeOpacity=="number"&&this.callSettingMethod("setEdgeOpacity",e.display.edgeOpacity),typeof e.display?.showGrid=="boolean"&&this.callSettingMethod("setShowGrid",e.display.showGrid),typeof e.display?.showLevel=="boolean"&&this.callSettingMethod("setShowLevel",e.display.showLevel),typeof e.display?.groundId=="string"&&this.setGroundId(e.display.groundId),typeof e.display?.groundHeight=="number"&&this.setGroundElevation(e.display.groundHeight),typeof e.environment?.type=="string"){const t=this.callSettingMethod("setEnvironmentType",e.environment.type);t!==void 0?await Promise.resolve(t):e.environment.type==="none"&&this.setHDRBackgroundId("0")}if(typeof e.environment?.hdrId=="string"){const t=this.callSettingMethod("setHdrId",e.environment.hdrId);t!==void 0?await Promise.resolve(t):this.setHDRBackgroundId(e.environment.hdrId)}typeof e.environment?.hdrIntensity=="number"&&this.callSettingMethod("setHdrIntensity",e.environment.hdrIntensity),typeof e.environment?.skyPreset=="string"&&this.callSettingMethod("setSkyPreset",e.environment.skyPreset),typeof e.environment?.skyIntensity=="number"&&this.callSettingMethod("setSkyIntensity",e.environment.skyIntensity),e.environment?.skyParams&&typeof e.environment.skyParams=="object"&&this.callSettingMethod("setSkyParams",e.environment.skyParams),typeof e.render?.shadowIntensity=="number"&&this.callSettingMethod("setShadowIntensity",e.render.shadowIntensity),typeof e.render?.gtaoIntensity=="number"&&this.callSettingMethod("setGtaoIntensity",e.render.gtaoIntensity)}async resetToDefault(){const t=this.getSettingApi()?.resetToDefault;if(typeof t=="function"){await Promise.resolve(t.call(this.engine.setting));return}await this.setSettings({render:{mode:"advanced",contrast:50,saturation:50,shadowIntensity:50,lightIntensity:50,gtaoIntensity:50},display:{showEdge:!1,edgeOpacity:30,showGrid:!1,showLevel:!1,showGround:!1,groundId:"0",groundHeight:0},environment:{type:"none",hdrId:"0",hdrIntensity:20,skyPreset:"sunrise_clear",skyParams:{},skyIntensity:20}})}activeModelEdge(){if(!this._isInitialized||!this.engine?.modelEdge){console.warn("[Engine] Cannot active model edge: engine not initialized.");return}this.engine.modelEdge.active()}disActiveModelEdge(){!this._isInitialized||!this.engine?.modelEdge||this.engine.modelEdge.disActive()}getModelEdgeActive(){return!this._isInitialized||!this.engine?.modelEdge?!1:this.engine.modelEdge.getActive?.()??!1}setAmbientLightIntensity(e){if(!this._isInitialized||!this.engine?.setting){console.warn("[Engine] Cannot set ambient light intensity: engine not initialized.");return}this.engine.setting.setAmbientLightIntensity(e)}getAmbientLightIntensity(){return!this._isInitialized||!this.engine?.setting?50:this.engine.setting.getAmbientLightIntensity?.()??50}setSceneContrast(e){if(!this._isInitialized||!this.engine?.setting){console.warn("[Engine] Cannot set scene contrast: engine not initialized.");return}this.engine.setting.setSceneContrast(e)}getSceneContrast(){return!this._isInitialized||!this.engine?.setting?50:this.engine.setting.getSceneContrast?.()??50}setSceneSaturation(e){if(!this._isInitialized||!this.engine?.setting){console.warn("[Engine] Cannot set scene saturation: engine not initialized.");return}this.engine.setting.setSceneSaturation(e)}getSceneSaturation(){return!this._isInitialized||!this.engine?.setting?50:this.engine.setting.getSceneSaturation?.()??50}getHDRBackgroundList(){return!this._isInitialized||!this.engine?.setting?[]:this.engine.setting.getHDRBackground?.()??[]}setHDRBackgroundId(e){if(!this._isInitialized||!this.engine?.setting){console.warn("[Engine] Cannot set HDR background: engine not initialized.");return}this.engine.setting.setHDRBackgroundId(e)}getHDRBackgroundId(){return!this._isInitialized||!this.engine?.setting?"":this.engine.setting.getHDRBackgroundId?.()??""}setHDRBackgroundVisibility(e){if(!this._isInitialized||!this.engine?.setting){console.warn("[Engine] Cannot set HDR background visibility: engine not initialized.");return}this.engine.setting.setHDRBackgroundVisibility(e)}getHDRBackgroundVisibility(){return!this._isInitialized||!this.engine?.setting?!0:this.engine.setting.getHDRBackgroundVisibility?.()??!0}getGroundList(){return!this._isInitialized||!this.engine?.setting?[]:this.engine.setting.getGroundList?.()??[]}setGroundId(e){if(!this._isInitialized||!this.engine?.setting){console.warn("[Engine] Cannot set ground: engine not initialized.");return}this.engine.setting.setGroundId(e)}getGroundId(){return!this._isInitialized||!this.engine?.setting?"":this.engine.setting.getGroundId?.()??""}setGroundElevation(e){if(!this._isInitialized||!this.engine?.setting){console.warn("[Engine] Cannot set ground elevation: engine not initialized.");return}this.engine.setting.setGroundElevation(e)}getGroundElevation(){return!this._isInitialized||!this.engine?.setting?0:this.engine.setting.getGroundElevation?.()??0}isWalkModeActive=!1;activateFirstPersonMode(){if(!this._isInitialized||!this.engine){console.error("[Engine] Cannot activate first person mode: engine not initialized.");return}if(!this.engine.controlModule){console.error("[Engine] Control module not available.");return}if(this.isWalkModeActive){console.log("[Engine] First person mode already active, skipping.");return}console.log("[Engine] Activating first person mode"),this.engine.controlModule.switchFirstPersonMode(),this.loadWalkSettings(),this.isWalkModeActive=!0}deactivateFirstPersonMode(){!this._isInitialized||!this.engine?.controlModule||this.isWalkModeActive&&(console.log("[Engine] Deactivating first person mode"),this.engine.controlModule.switchDefaultMode(),this.isWalkModeActive=!1)}static WALK_SPEED_KEY="bim-walk-speed";static WALK_GRAVITY_KEY="bim-walk-gravity";static WALK_COLLISION_KEY="bim-walk-collision";setWalkSpeed(e){if(!this._isInitialized||!this.engine?.controlModule){console.error("[Engine] Cannot set walk speed: engine not initialized.");return}localStorage.setItem(ta.WALK_SPEED_KEY,String(e)),this.engine.controlModule.setMoveSpeed(e)}setWalkGravity(e){if(!this._isInitialized||!this.engine?.controlModule){console.error("[Engine] Cannot set walk gravity: engine not initialized.");return}localStorage.setItem(ta.WALK_GRAVITY_KEY,String(e)),this.engine.controlModule.setApplyGravity(e)}setWalkCollision(e){if(!this._isInitialized||!this.engine?.controlModule){console.error("[Engine] Cannot set walk collision: engine not initialized.");return}localStorage.setItem(ta.WALK_COLLISION_KEY,String(e)),this.engine.controlModule.setApplyCollision(e)}loadWalkSettings(){if(!this.engine?.controlModule)return;const e=localStorage.getItem(ta.WALK_SPEED_KEY),t=localStorage.getItem(ta.WALK_GRAVITY_KEY),i=localStorage.getItem(ta.WALK_COLLISION_KEY);this.engine.controlModule.setMoveSpeed(e?Number(e):1),this.engine.controlModule.setApplyGravity(t==="true"),this.engine.controlModule.setApplyCollision(i==="true")}toggleMiniMap(){if(!this._isInitialized||!this.engine){console.error("[Engine] Cannot toggle mini map: engine not initialized.");return}this.engine.minMap?.toggle()}getMiniMapState(){return!this._isInitialized||!this.engine?!1:this.engine.minMap?.getstate()??!1}isFirstPersonModeActive(){return this.isWalkModeActive}getSelectedComponent(){return this.selectedComponent}getComponentProperties(e,t,i){if(!this._isInitialized||!this.engine){console.error("[Engine] Cannot get component properties: engine not initialized.");return}if(!this.engine.modelProperties){console.error("[Engine] modelProperties not available");return}console.log("[Engine] Getting component properties:",{url:e,id:t}),this.engine.modelProperties.getModelProperties(e,t,i)}getModelPosition(e){return!this._isInitialized||!this.engine?(console.error("[Engine] Cannot get model position: engine not initialized."),null):this.engine.issueReport?.getMoldePosition?(console.log("[Engine] Getting model position:",e),this.engine.issueReport.getMoldePosition(e)):(console.error("[Engine] getMoldePosition method not available in issueReport"),null)}jumpToCamera(e){if(!this._isInitialized||!this.engine)return console.error("[Engine] Cannot jump to camera: engine not initialized."),!1;if(!this.engine.issueReport?.jumptoCamera)return console.error("[Engine] jumptoCamera method not available in issueReport"),!1;console.log("[Engine] Jumping to camera:",e);try{return this.engine.issueReport.jumptoCamera(e),!0}catch(t){return console.error("[Engine] Failed to jump to camera:",t),!1}}getTypeTreeData(){return!this._isInitialized||!this.engine?.modelTree?[]:this.engine.modelTree.getTypeTreeData()}getLevelTreeData(){return!this._isInitialized||!this.engine?.modelTree?[]:this.engine.modelTree.getLevelTreeData()}getMajorTreeData(){return!this._isInitialized||!this.engine?.modelTree?[]:this.engine.modelTree.getMajorTreeData()}activateZoomBox(){if(!this._isInitialized||!this.engine){console.warn("[Engine] Engine not initialized.");return}this.engine.rangeScale?.active()}getEngineInfo(){return!this._isInitialized||!this.engine?(console.warn("[Engine] Engine not initialized."),null):this.engine.engineInfo.getEngineInfo()}pathRoamingAddPoint(){if(!this._isInitialized||!this.engine?.pathRoaming){console.warn("[Engine] pathRoaming not available");return}this.engine.pathRoaming.addPoint(0)}pathRoamingRemovePoint(e){if(!this._isInitialized||!this.engine?.pathRoaming){console.warn("[Engine] pathRoaming not available");return}this.engine.pathRoaming.removePoint(e)}pathRoamingClearPoints(){if(!this._isInitialized||!this.engine?.pathRoaming){console.warn("[Engine] pathRoaming not available");return}this.engine.pathRoaming.clearPoints()}pathRoamingGetPoints(){return!this._isInitialized||!this.engine?.pathRoaming?(console.warn("[Engine] pathRoaming not available"),[]):this.engine.pathRoaming.getPoints()??[]}pathRoamingJumpToPoint(e){if(!this._isInitialized||!this.engine?.pathRoaming){console.warn("[Engine] pathRoaming not available");return}this.engine.pathRoaming.jumpToPoint(e)}pathRoamingPlay(e){if(!this._isInitialized||!this.engine?.pathRoaming){console.warn("[Engine] pathRoaming not available");return}this.engine.pathRoaming.play(e)}pathRoamingStop(){if(!this._isInitialized||!this.engine?.pathRoaming){console.warn("[Engine] pathRoaming not available");return}this.engine.pathRoaming.stop()}getHighlightModels(){return!this._isInitialized||!this.engine?null:this.engine.engineStatus?.highlightModels??null}highlightModel(e){if(!this._isInitialized||!this.engine?.modelToolModule){console.warn("[Engine] Cannot highlight model: engine not initialized.");return}const t=this.sanitizeModelParams(e);if(t.length)try{this.engine.modelToolModule.highlightModel(t)}catch(i){console.warn("[Engine] highlightModel failed:",i)}}unhighlightAllModels(){if(!this._isInitialized||!this.engine?.modelToolModule){console.warn("[Engine] Cannot unhighlight models: engine not initialized.");return}this.engine.modelToolModule.unhighlightAllModels()}viewScaleToModel(e){if(!this._isInitialized||!this.engine?.modelToolModule){console.warn("[Engine] Cannot view scale to model: engine not initialized.");return}const t=this.sanitizeModelParams(e);if(t.length)try{this.engine.modelToolModule.viewScaleToModel(t)}catch(i){console.warn("[Engine] viewScaleToModel failed:",i)}}hideModels(e){if(!this._isInitialized||!this.engine?.modelToolModule){console.warn("[Engine] Cannot hide models: engine not initialized.");return}const t=this.sanitizeModelParams(e);if(t.length)try{this.engine.modelToolModule.hideModel(t)}catch(i){console.warn("[Engine] hideModels failed:",i)}}showModel(e){if(!this._isInitialized||!this.engine?.modelToolModule){console.warn("[Engine] Cannot show model: engine not initialized.");return}const t=this.sanitizeModelParams(e);if(t.length)try{this.engine.modelToolModule.showModel(t)}catch(i){console.warn("[Engine] showModel failed:",i)}}sanitizeModelParams(e){if(!Array.isArray(e))return[];const t=a=>a.replace(/\/+$/,""),i=Array.isArray(this.engine?.models)?this.engine.models:[],n=new Map;for(const a of i)a?.url&&n.set(t(a.url),a);const s=[];for(const a of e){if(!a||typeof a.url!="string"||!a.url||!Array.isArray(a.ids))continue;const o=n.get(t(a.url));if(!o||!(o.nodesMap instanceof Map))continue;const l=new Set;for(const h of a.ids){if(!Number.isFinite(h))continue;const d=Number(h);if(!Number.isInteger(d))continue;const p=o.nodesMap.get(d);!p||!Array.isArray(p.indexes)||p.indexes.length===0||l.add(d)}const c=Array.from(l);c.length&&s.push({url:a.url,ids:c})}return s}translucentModels(e){if(!this._isInitialized||!this.engine?.modelToolModule){console.warn("[Engine] Cannot translucent models: engine not initialized.");return}e&&this.engine.modelToolModule.translucentModel(e)}unTranslucentModel(){if(!this._isInitialized||!this.engine?.modelToolModule){console.warn("[Engine] Cannot cancel translucent: engine not initialized.");return}this.engine.modelToolModule.unTranslucentModel()}isolateModels(e){if(!this._isInitialized||!this.engine?.modelToolModule){console.warn("[Engine] Cannot isolate models: engine not initialized.");return}e&&this.engine.modelToolModule.isolateModel(e)}translucentOtherModels(e){if(!this._isInitialized||!this.engine?.modelToolModule){console.warn("[Engine] Cannot translucent other models: engine not initialized.");return}e&&this.engine.modelToolModule.translucentOtherModel(e)}showAllModels(){if(!this._isInitialized||!this.engine?.modelToolModule){console.warn("[Engine] Cannot show all models: engine not initialized.");return}this.deactivateSection(),this.engine.modelToolModule.showAllModels()}batchSelectSameTypeModel(e){if(!this._isInitialized||!this.engine?.modelToolModule){console.warn("[Engine] Cannot batch select: engine not initialized.");return}e&&this.engine.modelToolModule.batchSelectSameTypeModel(e)}batchSelectSameLevelModel(e){if(!this._isInitialized||!this.engine?.modelToolModule){console.warn("[Engine] Cannot batch select: engine not initialized.");return}e&&this.engine.modelToolModule.batchSelectSameLevelModel(e)}batchSelectSameLevelTypeModel(e){if(!this._isInitialized||!this.engine?.modelToolModule){console.warn("[Engine] Cannot batch select: engine not initialized.");return}e&&this.engine.modelToolModule.batchSelectSameLevelTypeModel(e)}destroy(){this._isDestroyed||(this.deactivateMeasure(),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.engine&&(this.engine.dispose(),this.engine=null),this.container.innerHTML="",this.currentMeasureType=null,this.isMeasureActive=!1,this._isDestroyed=!0,this._isInitialized=!1)}}class jF{element;content=null;isVisible=!1;onCloseCallback;options;mouseDownTime=0;mouseDownX=0;mouseDownY=0;CLICK_THRESHOLD=200;MOVE_THRESHOLD=5;constructor(e){this.options=e,this.element=document.createElement("div"),this.element.className=`bim-right-key ${e?.className||""}`,e?.zIndex&&(this.element.style.zIndex=e.zIndex.toString()),document.body.appendChild(this.element)}init(){document.addEventListener("mousedown",this.handleGlobalClick),this.element.addEventListener("contextmenu",e=>{e.preventDefault(),e.stopPropagation()}),this.options?.container&&(this.options.container.addEventListener("mousedown",this.handleContainerMouseDown),this.options.container.addEventListener("mouseup",this.handleContainerMouseUp),this.options.container.addEventListener("contextmenu",this.handleContainerContextMenu))}setTheme(e){}setLocales(){}destroy(){document.removeEventListener("mousedown",this.handleGlobalClick),this.options?.container&&(this.options.container.removeEventListener("mousedown",this.handleContainerMouseDown),this.options.container.removeEventListener("mouseup",this.handleContainerMouseUp),this.options.container.removeEventListener("contextmenu",this.handleContainerContextMenu)),this.unmountContent(),this.element.remove()}handleContainerMouseDown=e=>{e.button===2&&(this.mouseDownTime=Date.now(),this.mouseDownX=e.clientX,this.mouseDownY=e.clientY)};handleContainerMouseUp=e=>{if(e.button!==2||Date.now()-this.mouseDownTime>this.CLICK_THRESHOLD)return;const i=e.clientX-this.mouseDownX,n=e.clientY-this.mouseDownY;i*i+n*n>this.MOVE_THRESHOLD*this.MOVE_THRESHOLD||this.options?.onContext&&this.options.onContext(e)};handleContainerContextMenu=e=>{e.preventDefault()};setOnClose(e){this.onCloseCallback=e}mount(e){this.unmountContent(),this.content=e,this.element.appendChild(e.getElement())}unmountContent(){this.content&&(this.content.destroy(),this.element.innerHTML="",this.content=null)}show(e,t){this.element.classList.add("visible"),this.isVisible=!0,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`;const i=this.element.getBoundingClientRect(),n=window.innerWidth,s=window.innerHeight;let a=e,o=t;e+i.width>n&&(a=e-i.width),t+i.height>s&&(o=t-i.height),this.element.style.left=`${a}px`,this.element.style.top=`${o}px`}hide(){this.element.classList.remove("visible"),this.isVisible=!1,this.unmountContent(),this.onCloseCallback&&this.onCloseCallback()}handleGlobalClick=e=>{this.isVisible&&(this.element.contains(e.target)||this.hide())}}class vA{element;options;unsubscribeLocale=null;unsubscribeTheme=null;activeSubMenu=null;constructor(e){this.options=e,this.element=document.createElement("ul"),this.element.className="bim-menu"}init(){this.render(),this.unsubscribeLocale=Kt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ht.subscribe(e=>{this.setTheme(e)})}setTheme(e){const t=this.element.style;t.setProperty("--bim-bg-elevated",e.bgElevated),t.setProperty("--bim-text-primary",e.textPrimary),t.setProperty("--bim-divider",e.divider),t.setProperty("--bim-component-bg-hover",e.componentBgHover),t.setProperty("--bim-shadow-lg",e.shadowLg)}setLocales(){this.element.innerHTML="",this.render()}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.closeSubMenu(),this.element.remove()}getElement(){return this.element}hasAnyIcon(e){return e.some(t=>t.icon?!0:t.children?this.hasAnyIcon(t.children):!1)}render(){const{items:e,groupOrder:t}=this.options;this.hasAnyIcon(e)?this.element.classList.add("has-icons"):this.element.classList.remove("has-icons");const i=new Map,n="default";e.forEach(a=>{const o=a.group||n;i.has(o)||i.set(o,[]),i.get(o).push(a)});let s=[];if(t){s=t.filter(a=>i.has(a));for(const a of i.keys())s.includes(a)||s.push(a)}else s=Array.from(i.keys());s.forEach((a,o)=>{if(o>0){const c=document.createElement("li");c.className="bim-menu-divider",this.element.appendChild(c)}const l=i.get(a);l.sort((c,h)=>(c.order||0)-(h.order||0)),l.forEach(c=>{if(c.visible!==!1&&(this.element.appendChild(this.createItemElement(c)),c.divider)){const h=document.createElement("li");h.className="bim-menu-divider",this.element.appendChild(h)}})})}createItemElement(e){const t=document.createElement("li"),i=!e.disabled;t.className=`bim-menu-item ${i?"":"disabled"}`;const n=document.createElement("div");n.className="bim-menu-item-icon",e.icon&&(n.innerHTML=e.icon),t.appendChild(n);const s=document.createElement("div");s.className="bim-menu-item-label",s.textContent=Ee(e.label),t.appendChild(s);const a=e.children,o=a&&a.length>0;if(o){const l=document.createElement("div");l.className="bim-menu-item-arrow",l.innerHTML='<svg viewBox="0 0 24 24"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>',t.appendChild(l),t.addEventListener("mouseenter",()=>this.openSubMenu(e,t))}else t.addEventListener("mouseenter",()=>this.closeSubMenu());return i&&t.addEventListener("click",l=>{l.stopPropagation(),console.log(`[BimMenu] Clicked item: ${e.id}`),o||(e.onClick?(console.log(`[BimMenu] Executing onClick for ${e.id}`),e.onClick()):console.warn(`[BimMenu] No onClick handler for ${e.id}`))}),t}openSubMenu(e,t){const i=e.children;if(!i||i.length===0)return;this.closeSubMenu();const n=document.createElement("div");n.style.position="fixed",n.style.zIndex="10001";const s=t.getBoundingClientRect();n.style.top=`${s.top}px`,n.style.left=`${s.right}px`,n.addEventListener("mousedown",l=>l.stopPropagation());const a=new vA({items:i});a.init(),n.appendChild(a.element),document.body.appendChild(n),this.activeSubMenu={menu:a,container:n};const o=n.getBoundingClientRect();o.right>window.innerWidth&&(n.style.left=`${s.left-o.width}px`)}closeSubMenu(){this.activeSubMenu&&(this.activeSubMenu.menu.destroy(),this.activeSubMenu.container.remove(),this.activeSubMenu=null)}}class bA extends Hn{container;rightKeyPanel;contextHandlers=[];constructor(e,t){super(t),this.container=e,this.rightKeyPanel=new jF({zIndex:9e3,container:this.container,onContext:this.handleContextMenu}),this.rightKeyPanel.init()}destroy(){this.rightKeyPanel.destroy(),super.destroy()}registerHandler(e){this.contextHandlers.push(e)}unregisterHandler(e){this.contextHandlers=this.contextHandlers.filter(t=>t!==e)}clearHandlers(e=!0){if(!e){this.contextHandlers=[];return}this.contextHandlers.length!==0&&(this.contextHandlers=[this.contextHandlers[0]])}showMenu(e,t,i,n){if(!i||i.length===0)return;const s=new vA({items:i,groupOrder:n});s.init(),this.rightKeyPanel.mount(s),this.rightKeyPanel.show(e,t)}hide(){this.rightKeyPanel.hide()}handleContextMenu=e=>{let t=null;for(const i of this.contextHandlers){const n=i(e);n&&n.length>0&&(t||(t=[]),t=t.concat(n))}t&&t.length>0?this.showMenu(e.clientX,e.clientY,t):this.hide()}}class XE extends Hn{container;engineInstance=null;rightKey=null;constructor(e,t){super(t),this.container=e}getEngineComponent(){return this.engineInstance}initialize(e){this.engineInstance&&this.engineInstance.isInitialized()&&(console.warn("[EngineManager] 3D Engine already initialized. Destroying old instance..."),this.engineInstance.destroy(),this.engineInstance=null);try{return this.engineInstance=new ta({container:this.container,...e},this.registry),this.engineInstance.init(),this.rightKey=new bA(this.container,this.registry),this.rightKey.registerHandler(t=>{const i=this.engineInstance?.getSelectedComponent(),n=[];return i&&(n.push({id:"componentDetail",label:"menu.componentDetail",group:"component",order:1,divider:!0,onClick:()=>{this.registry.componentDetail?.show(),this.rightKey?.hide()}}),n.push({id:"hideSelected",label:"menu.hideSelected",group:"component",order:2,onClick:()=>{const s=this.engineInstance?.getHighlightModels();s&&this.engineInstance?.hideModels(s),this.rightKey?.hide()}}),n.push({id:"transparentSelected",label:"menu.transparentSelected",group:"component",order:3,onClick:()=>{const s=this.engineInstance?.getHighlightModels();s&&this.engineInstance?.translucentModels(s),this.rightKey?.hide()}}),n.push({id:"cancelTranslucent",label:"menu.cancelTranslucent",group:"component",order:4,onClick:()=>{this.engineInstance?.unTranslucentModel(),this.rightKey?.hide()}}),n.push({id:"isolateSelected",label:"menu.isolateSelected",group:"component",order:5,divider:!0,children:[{id:"hideOthers",label:"menu.hideOthers",onClick:()=>{const s=this.engineInstance?.getHighlightModels();s&&this.engineInstance?.isolateModels(s),this.rightKey?.hide()}},{id:"transparentOthers",label:"menu.transparentOthers",onClick:()=>{const s=this.engineInstance?.getHighlightModels();s&&this.engineInstance?.translucentOtherModels(s),this.rightKey?.hide()}}]}),n.push({id:"quickSelect",label:"menu.quickSelect",group:"component",order:6,children:[{id:"selectSameType",label:"menu.selectSameType",onClick:()=>{const s=this.engineInstance?.getHighlightModels();s&&this.engineInstance?.batchSelectSameTypeModel(s),this.rightKey?.hide()}},{id:"selectSameLevel",label:"menu.selectSameLevel",onClick:()=>{const s=this.engineInstance?.getHighlightModels();s&&this.engineInstance?.batchSelectSameLevelModel(s),this.rightKey?.hide()}},{id:"selectSameLevelType",label:"menu.selectSameLevelType",onClick:()=>{const s=this.engineInstance?.getHighlightModels();s&&this.engineInstance?.batchSelectSameLevelTypeModel(s),this.rightKey?.hide()}}]}),n.push({id:"fitSectionBox",label:"menu.fitSectionBox",group:"component",order:7,onClick:()=>{this.engineInstance?.fitSectionBoxToModel(),this.rightKey?.hide()}})),n.push({id:"showAll",label:"menu.showAll",group:"component",order:8,onClick:()=>{this.engineInstance?.showAllModels(),this.emit("menu:show-all",{}),this.rightKey?.hide()}}),n}),this.engineInstance.isInitialized()}catch(t){return console.error("[EngineManager] Failed to initialize 3D engine:",t),this.engineInstance=null,!1}}isInitialized(){return this.engineInstance!==null&&this.engineInstance.isInitialized()}loadModel(e,t){if(!this.engineInstance){console.warn("[EngineManager] 3D Engine not initialized.");return}this.engineInstance.loadModel(e,t)}pauseRendering(){if(!this.engineInstance){console.warn("[EngineManager] 3D Engine not initialized.");return}this.engineInstance.pauseRendering()}resumeRendering(){if(!this.engineInstance){console.warn("[EngineManager] 3D Engine not initialized.");return}this.engineInstance.resumeRendering()}getModelPosition(e){return this.engineInstance?this.engineInstance.getModelPosition(e):(console.warn("[EngineManager] 3D Engine not initialized."),null)}jumpToCamera(e){return this.engineInstance?this.engineInstance.jumpToCamera(e):(console.warn("[EngineManager] 3D Engine not initialized."),!1)}getConstructTreeData(){return this.engineInstance?{level:this.engineInstance.getLevelTreeData(),type:this.engineInstance.getTypeTreeData(),major:this.engineInstance.getMajorTreeData()}:(console.warn("[EngineManager] 3D Engine not initialized."),{level:[],type:[],major:[]})}getComponentProperties(e,t,i){if(!this.engineInstance){console.warn("[EngineManager] 3D Engine not initialized.");return}this.engineInstance.getComponentProperties(e,t,i)}registerRightKeyHandler(e){if(!this.rightKey){console.warn("[EngineManager] RightKey manager not initialized.");return}this.rightKey.registerHandler(e)}unregisterRightKeyHandler(e){if(!this.rightKey){console.warn("[EngineManager] RightKey manager not initialized.");return}this.rightKey.unregisterHandler(e)}clearRightKeyHandlers(e=!0){if(!this.rightKey){console.warn("[EngineManager] RightKey manager not initialized.");return}this.rightKey.clearHandlers(e)}showRightKeyMenu(e,t,i,n){if(!this.rightKey){console.warn("[EngineManager] RightKey manager not initialized.");return}this.rightKey.showMenu(e,t,i,n)}hideRightKeyMenu(){if(!this.rightKey){console.warn("[EngineManager] RightKey manager not initialized.");return}this.rightKey.hide()}destroy(){this.engineInstance&&(this.engineInstance.destroy(),this.engineInstance=null),this.rightKey&&(this.rightKey.destroy(),this.rightKey=null),super.destroy()}}const YE={测量:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M0,28.207H3.429v3.526H44.571V28.207H48v7.052H0ZM0,3.526v14.1a3.478,3.478,0,0,0,3.429,3.526H6.857V17.629h3.429v3.526h3.429V17.629h3.429v3.526h3.429V10.578H24V21.155h3.429V17.629h3.429v3.526h3.429V17.629h3.429v3.526h3.429V10.578h3.429V21.155A3.478,3.478,0,0,0,48,17.629V3.526A3.478,3.478,0,0,0,44.571,0H3.429A3.478,3.478,0,0,0,0,3.526Z" transform="translate(0 5.456)"/></svg>',地图:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M32.984,563.2H26.329a66.982,66.982,0,0,1-5.471,7.121l-1.455,1.61-1.455-1.61a66.978,66.978,0,0,1-5.471-7.121H5.821L0,580.662H38.8Z" transform="translate(4.598 -537.259)"/><path fill="currentColor" d="M275.4,9.7a9.7,9.7,0,1,0-19.4,0c0,6.636,9.7,17.462,9.7,17.462S275.4,16.337,275.4,9.7Zm-13.582,0a3.88,3.88,0,1,1,3.88,3.88,3.88,3.88,0,0,1-3.88-3.88Z" transform="translate(-241.701 4.598)"/></svg>',框选放大:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M336.351,336.158l-5.5.037-.037-5.5-3.665.025.037,5.5-5.491.037.025,3.665,5.491-.037.041,5.491,3.661-.025-.037-5.491,5.5-.041Z" transform="translate(-305.467 -314.477)"/><path fill="currentColor" d="M41.88,40.861l-.227-.223-7.167-7.068a14.787,14.787,0,1,0-2.832,2.4l7.4,7.3.227.223.021-.021a1.821,1.821,0,0,0,1.065.33,1.849,1.849,0,0,0,1.837-1.862,1.868,1.868,0,0,0-.343-1.061l.017-.021ZM23.648,34.668A11.1,11.1,0,1,1,34.675,23.487,11.106,11.106,0,0,1,23.648,34.668ZM3,41.492H6.241v3.241H3ZM3,15.564H6.241v3.241H3ZM3,2.6H6.241V5.841H3Zm12.964,0h3.241V5.841H15.964Zm-6.482,0h3.241V5.841H9.482Zm12.964,0h3.241V5.841H22.446Zm6.482,0h3.241V5.841H28.928Zm6.482,0h3.241V5.841H35.41Zm6.482,0h3.241V5.841H41.892Zm0,6.482h3.241v3.241H41.892Zm0,6.482h3.241v3.241H41.892Zm0,6.482h3.241v3.241H41.892ZM9.482,41.492h3.241v3.241H9.482Zm6.482,0h3.241v3.241H15.964Zm6.482,0h3.241v3.241H22.446ZM3,9.082H6.241v3.241H3ZM3,22.046H6.241v3.241H3Zm38.892,6.482h3.241v3.241H41.892ZM3,28.528H6.241v3.241H3ZM3,35.01H6.241v3.241H3Z" transform="translate(-0.067 0.333)"/></svg>',漫游:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M327.239,38.548a6.01,6.01,0,1,0-6.358-6A6.144,6.144,0,0,0,327.239,38.548Zm8.006,5.76a3.082,3.082,0,0,0-3.061-2.64h-1.648c-.471,0-.706.24-1.177.48l-2.119,1.68-2.119-1.92a1.781,1.781,0,0,0-1.177-.48h-1.648a2.914,2.914,0,0,0-3.061,2.64l-1.413,10.8c0,.48,0,.96.471,1.2a1.781,1.781,0,0,0,1.177.48h1.648l1.413,15.36a3.082,3.082,0,0,0,3.061,2.64h3.532a2.914,2.914,0,0,0,3.061-2.64l1.413-15.36h1.648a1.781,1.781,0,0,0,1.177-.48,2.2,2.2,0,0,0,.235-1.2Z" transform="translate(-303.239 -26.548)"/></svg>',目录树:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M116.8,153.474h12a1.2,1.2,0,0,0,1.2-1.185v-7.111a1.2,1.2,0,0,0-1.2-1.184h-12a1.2,1.2,0,0,0-1.2,1.184v1.629H93.553v-7.554H100a1.2,1.2,0,0,0,1.2-1.185v-7.112a1.2,1.2,0,0,0-1.2-1.185H83.2a1.2,1.2,0,0,0-1.2,1.185v7.112a1.2,1.2,0,0,0,1.2,1.185h6.45v28a2.383,2.383,0,0,0,2.4,2.37H115.6v1.63a1.2,1.2,0,0,0,1.2,1.185h12a1.2,1.2,0,0,0,1.2-1.185v-7.112a1.2,1.2,0,0,0-1.2-1.185h-12a1.2,1.2,0,0,0-1.2,1.185v1.63H93.553V150.657H115.6v1.629a1.2,1.2,0,0,0,1.2,1.185Z" transform="translate(-82 -126.874)"/></svg>',剖切:'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><g transform="translate(-176.967 -101.068)"><path d="M306.33,364.55h14.737v19.115H306.33Z" transform="translate(-118.068 -248.554)"/><path d="M487.114,140.356a1.6,1.6,0,0,1-1.744-1.393V99.573a1.787,1.787,0,0,1,3.487,0v39.389A1.6,1.6,0,0,1,487.114,140.356Z" transform="translate(-285.677 6.11)"/><path d="M508.34,274.031H487.114a1.743,1.743,0,1,1,0-3.487h17.739V242.767H487.114a1.744,1.744,0,1,1,0-3.487H508.34Z" transform="translate(-285.677 -131.282)"/><path d="M201.437,274.031h-3.278a1.743,1.743,0,1,1,0-3.487h3.278a1.743,1.743,0,1,1,0,3.487Zm-8.858,0H187a1.743,1.743,0,1,1,0-3.487h5.579a1.743,1.743,0,1,1,0,3.487Zm-10.626-.532a1.743,1.743,0,0,1-1.743-1.744v-5.579a1.743,1.743,0,1,1,3.487,0v5.579A1.743,1.743,0,0,1,181.953,273.5Zm0-11.159a1.743,1.743,0,0,1-1.743-1.743v-5.579a1.743,1.743,0,1,1,3.487,0V260.6A1.743,1.743,0,0,1,181.953,262.34Zm0-11.158a1.744,1.744,0,0,1-1.743-1.744v-5.579a1.743,1.743,0,1,1,3.487,0v5.579A1.744,1.744,0,0,1,181.953,251.181Zm19.484-8.414h-5.579a1.744,1.744,0,1,1,0-3.487h5.579a1.744,1.744,0,0,1,0,3.487Zm-11.159,0H184.7a1.744,1.744,0,1,1,0-3.487h5.579a1.744,1.744,0,1,1,0,3.487Z" transform="translate(0 -131.282)"/></g></svg>',剖切盒:'<svg width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><g transform="translate(-56.83 2.793)"><path d="M194.963,19.168a1.69,1.69,0,0,1-.607-.119l-19.027-8.292a1.253,1.253,0,0,1,0-2.35L191.289.112a1.592,1.592,0,0,1,1.24,0l18.663,8.294a1.267,1.267,0,0,1,.791,1.175,1.308,1.308,0,0,1-.791,1.175l-15.6,8.278a1.519,1.519,0,0,1-.633.143Zm-15.7-9.586,15.7,6.832,12.331-6.832L191.9,2.749Z" transform="translate(-109.947 0)"/><path d="M195.008,417.821a1.691,1.691,0,0,1-.607-.119l-19.025-8.294a1.253,1.253,0,0,1,0-2.35l15.958-8.294a1.592,1.592,0,0,1,1.24,0l18.657,8.294a1.267,1.267,0,0,1,.791,1.175,1.308,1.308,0,0,1-.791,1.175l-15.6,8.278c-.211.095-3.483.143-3.694.143Zm-15.6-9.588,15.6,6.832,12.329-6.832L191.948,401.4Z" transform="translate(-109.992 -382.638)"/><path d="M200.046,603.93a1.976,1.976,0,0,1-.634-.119l-18.774-8.3a1.257,1.257,0,0,1-.655-1.754,1.512,1.512,0,0,1,1.931-.595l18.131,8.013,14.971-8.007a1.51,1.51,0,0,1,1.928.6,1.256,1.256,0,0,1-.661,1.75l-15.6,8.282a1.489,1.489,0,0,1-.634.119Z" transform="translate(-115.041 -568.787)"/><path d="M101.029,216.82a1.467,1.467,0,0,1-1-.377,1.237,1.237,0,0,1-.41-.917V198.817a1.413,1.413,0,0,1,2.816,0V215.5a1.241,1.241,0,0,1-.4.931A1.472,1.472,0,0,1,101.029,216.82Zm-34.377.143a1.467,1.467,0,0,1-1-.377,1.237,1.237,0,0,1-.41-.917V198.817a1.413,1.413,0,0,1,2.816,0v16.852a1.237,1.237,0,0,1-.41.917A1.467,1.467,0,0,1,66.652,216.964Zm-5.215,2.8a1.467,1.467,0,0,1-1-.377,1.237,1.237,0,0,1-.41-.917V201.621a1.413,1.413,0,0,1,2.816,0v16.852a1.237,1.237,0,0,1-.41.917A1.467,1.467,0,0,1,61.436,219.768Z" transform="translate(-0.4 -189.683)"/><path d="M60.922,37.617A1.32,1.32,0,0,1,60,37.258a1.2,1.2,0,0,1-.378-.876V20.295a1.3,1.3,0,0,1,2.588,0V36.382a1.276,1.276,0,0,1-1.294,1.235Zm-1.175,8.411a1.341,1.341,0,0,1,1.75-.578l15.126,7.071a1.224,1.224,0,0,1,.6,1.671,1.337,1.337,0,0,1-1.75.572L60.347,47.708a1.228,1.228,0,0,1-.606-1.671Z" transform="translate(0 -18.25)"/><path d="M71.756,44.947a1.337,1.337,0,0,1,1.75-.582l15.126,7.118a1.235,1.235,0,0,1,.6,1.682,1.333,1.333,0,0,1-1.75.576L72.356,46.629a1.239,1.239,0,0,1-.606-1.682ZM59.915,12.652a1.337,1.337,0,0,1,1.75-.582L76.79,19.194a1.235,1.235,0,0,1,.6,1.682,1.333,1.333,0,0,1-1.75.576L60.515,14.334A1.247,1.247,0,0,1,59.915,12.652Z" transform="translate(-0.168 -11.442)"/><path d="M334.418,146.671a1.341,1.341,0,0,1,1.75-.578l15.126,7.073a1.224,1.224,0,0,1,.6,1.671,1.337,1.337,0,0,1-1.75.573l-15.126-7.09a1.25,1.25,0,0,1-.663-.7,1.177,1.177,0,0,1,.058-.945Zm16.3,35.276a1.32,1.32,0,0,1-.917-.36,1.2,1.2,0,0,1-.377-.875v-16.1a1.3,1.3,0,0,1,2.588,0V180.7a1.2,1.2,0,0,1-.38.878,1.321,1.321,0,0,1-.922.357Z" transform="translate(-260.918 -139.687)"/><path d="M576.438,360.4a1.288,1.288,0,0,1-1.294-1.294V342.253a1.294,1.294,0,1,1,2.588,0v16.852A1.3,1.3,0,0,1,576.438,360.4ZM572.8,344.248,573,361.1l-2.613.024-.2-16.857Z" transform="translate(-486.154 -327.316)"/><path d="M508.543,26.833l.192,16.852-2.613.024-.192-16.852Z" transform="translate(-425.253 -25.689)"/></g></svg>',全屏:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M6.241,3.671H12.85a1.734,1.734,0,0,0,1.836-1.836A1.734,1.734,0,0,0,12.85,0H1.469C1.1,0,.734.367.367.734A1.349,1.349,0,0,0,0,1.836V12.85a1.734,1.734,0,0,0,1.836,1.836A1.734,1.734,0,0,0,3.671,12.85V6.241l9.913,9.913a1.817,1.817,0,1,0,2.57-2.57ZM13.584,27.9,6.975,34.51l-3.3,3.3V31.206a1.734,1.734,0,0,0-1.836-1.836A1.734,1.734,0,0,0,0,31.206V42.22a1.734,1.734,0,0,0,1.836,1.836H12.85a1.836,1.836,0,0,0,0-3.671H6.241l3.3-3.3,6.608-6.608a1.817,1.817,0,1,0-2.57-2.57ZM42.22,29.371a1.734,1.734,0,0,0-1.836,1.836v6.608l-3.3-3.3L30.472,27.9a1.817,1.817,0,1,0-2.57,2.57L34.51,37.08l3.3,3.3H31.206a1.836,1.836,0,1,0,0,3.671H42.22a1.734,1.734,0,0,0,1.836-1.836V31.206a1.734,1.734,0,0,0-1.836-1.836ZM42.22,0H31.206a1.734,1.734,0,0,0-1.836,1.836,1.734,1.734,0,0,0,1.836,1.836h6.608l-3.3,3.3L27.9,13.584a1.817,1.817,0,1,0,2.57,2.57L37.08,9.545l3.3-3.3V12.85a1.836,1.836,0,0,0,3.671,0V1.836A1.734,1.734,0,0,0,42.22,0Z" transform="translate(1.972 1.972)"/></svg>',设置:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M112.388,106.443l-2.668-.373a1.687,1.687,0,0,1-1.306-1.031,16.337,16.337,0,0,0-2-3.475,1.681,1.681,0,0,1-.243-1.646l1.012-2.5a1.652,1.652,0,0,0-.709-2.057l-5.769-3.335a1.654,1.654,0,0,0-2.136.415L96.919,94.56a1.693,1.693,0,0,1-1.562.62,15.32,15.32,0,0,0-3.992,0,1.693,1.693,0,0,1-1.562-.62l-1.651-2.113a1.654,1.654,0,0,0-2.136-.415l-5.769,3.33a1.659,1.659,0,0,0-.709,2.057l1.012,2.5a1.679,1.679,0,0,1-.243,1.646,16.141,16.141,0,0,0-2,3.475A1.669,1.669,0,0,1,77,106.066l-2.668.373a1.663,1.663,0,0,0-1.432,1.646v6.665a1.662,1.662,0,0,0,1.427,1.642l2.668.373a1.687,1.687,0,0,1,1.306,1.031,16.338,16.338,0,0,0,2,3.475,1.681,1.681,0,0,1,.243,1.646l-1.012,2.5a1.652,1.652,0,0,0,.709,2.057l5.769,3.33a1.654,1.654,0,0,0,2.136-.415L89.8,128.27a1.693,1.693,0,0,1,1.562-.62,15.321,15.321,0,0,0,3.992,0,1.693,1.693,0,0,1,1.562.62l1.651,2.113a1.654,1.654,0,0,0,2.136.415l5.769-3.33a1.659,1.659,0,0,0,.709-2.057l-1.012-2.5a1.681,1.681,0,0,1,.243-1.646,16.141,16.141,0,0,0,2-3.475,1.669,1.669,0,0,1,1.306-1.031l2.668-.373a1.658,1.658,0,0,0,1.427-1.642v-6.665A1.639,1.639,0,0,0,112.388,106.443ZM93.36,117.893a6.478,6.478,0,1,1,6.478-6.478A6.479,6.479,0,0,1,93.36,117.893Z" transform="translate(-69.355 -87.415)"/></svg>',拾曲面剖切:'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><g transform="translate(-59.63 -21.333)"><path d="M302.465,495.393l2.363-4.363a.842.842,0,0,1,1.091-.273.914.914,0,0,1,.454,1l-1.636,3,11.453-3.454c.091,0,.091,0,.182-.091a.785.785,0,1,1,.273,1.545l-11.453,3.454,3,1.545h.091a.645.645,0,0,1,.182,1,.842.842,0,0,1-1.091.273l-4.545-2.363c-.091,0-.182-.091-.273-.182A.742.742,0,0,1,302.465,495.393Z" transform="translate(205.84 -520.136) rotate(43)"/><path d="M88.23,54.014v2.86l-21.123,8.17V34l21.123-8.17V47.069h2.9l-.207-25.736L64,31.75V69.333L91.129,58.916v-4.9Z"/><path d="M199,255.9l-15.532,6.268v-21.23L199,234.667Z" transform="translate(-113.668 -202.979)"/></g></svg>',轴向剖切:'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><g transform="translate(-59.63 -21.333)"><path d="M.194,3.727,2.558,8.089a.842.842,0,0,0,1.091.273.914.914,0,0,0,.454-1l-1.636-3L13.919,7.817c.091,0,.091,0,.182.091a.785.785,0,1,0,.273-1.545L2.921,2.909l3-1.545h.091a.645.645,0,0,0,.182-1A.842.842,0,0,0,5.1.091L.558,2.454c-.091,0-.182.091-.273.182A.742.742,0,0,0,.194,3.727Z" transform="translate(102.244 57.563) rotate(-178)"/><path d="M88.23,54.014v2.86l-21.123,8.17V34l21.123-8.17V47.069h2.9l-.207-25.736L64,31.75V69.333L91.129,58.916v-4.9Z"/><path d="M199,255.9l-15.532,6.268v-21.23L199,234.667Z" transform="translate(-113.668 -202.979)"/></g></svg>',主视角:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M122.32,181.835v-13.16h-9.87V163.74h19.74v18.095Zm-19.74,0V163.74h9.87v18.095ZM96,163.74,117.385,144l21.385,19.74Z" transform="translate(-93.385 -138.917)"/></svg>',文档:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M64,128h1.714v41.143H64Zm46.286,0H112v41.143h-1.714Zm-44.571,0h44.571v3.429H65.714Zm0,6.857h44.571v3.429H65.714Zm0-3.429h3.429v3.429H65.714Zm8.571,0h3.429v3.429H74.286Zm8.571,0h27.429v3.429H82.857Zm-17.143,36h44.571v1.714H65.714Zm5.143-24H76v1.714H70.857Zm10.286,0h24v1.714h-24Zm-10.286,6.857H76V152H70.857Zm10.286,0h24V152h-24Zm-10.286,6.857H76v1.714H70.857Zm10.286,0h24v1.714h-24Z" transform="translate(-64 -124.571)"/></svg>',第一人称漫游:'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><path d="M178.325,132.27a6.411,6.411,0,0,0,0-9.429,7.359,7.359,0,0,0-9.984,0,6.411,6.411,0,0,0,0,9.429,7.359,7.359,0,0,0,9.984,0Zm-2-7.543a3.845,3.845,0,0,1,0,5.657,4.414,4.414,0,0,1-5.99,0,3.847,3.847,0,0,1,0-5.657,4.414,4.414,0,0,1,5.99,0Zm6.618,31.639q4.975,1.006,4.975,3.189t-4.975,3.189a57.4,57.4,0,0,1-19.226,0q-4.973-1.006-4.973-3.189t4.975-3.189q.777-.156,1.613-.284v-2.521a4.488,4.488,0,0,1-1.412.217,4.761,4.761,0,0,1-.587-.036l-.038,0a29.007,29.007,0,0,0-7.657,2.332q-3.482,1.712-3.482,3.484a2.944,2.944,0,0,0,1.3,2.116,14.359,14.359,0,0,0,4.4,2.293,46.614,46.614,0,0,0,15.477,2.258,46.614,46.614,0,0,0,15.477-2.258,14.362,14.362,0,0,0,4.4-2.293,2.943,2.943,0,0,0,1.3-2.116q0-1.772-3.482-3.484a29.007,29.007,0,0,0-7.657-2.332,4.908,4.908,0,0,1-.625.039,4.488,4.488,0,0,1-1.412-.217v2.521q.836.128,1.613.284Zm-14.788-6.588v5.979q2.391-.2,5.176-.2t5.176.2v-12.2h2.824v6.222a1.25,1.25,0,0,0,.414.942v0l.081.071q.744.1,1.457.22a1.41,1.41,0,0,0,.457-.293,1.25,1.25,0,0,0,.414-.942v-8a3.75,3.75,0,0,0-1.24-2.828,4.2,4.2,0,0,0-2.995-1.172H166.745a4.2,4.2,0,0,0-2.995,1.172,3.75,3.75,0,0,0-1.24,2.828v8a1.268,1.268,0,0,0,.414.942,1.415,1.415,0,0,0,.456.293q.715-.119,1.459-.222.041-.034.081-.071a1.25,1.25,0,0,0,.414-.942v-6.222h2.824Zm-8.471-6.222v-1.778a6.253,6.253,0,0,1,2.067-4.715,7.013,7.013,0,0,1,4.992-1.952h13.176a7.013,7.013,0,0,1,4.992,1.952,6.253,6.253,0,0,1,2.067,4.715v8a3.722,3.722,0,0,1-.484,1.881l0,.005a28.526,28.526,0,0,1,5.841,2.041q5,2.462,5,5.851,0,4.238-7.531,6.9a49.5,49.5,0,0,1-16.469,2.428,49.5,49.5,0,0,1-16.469-2.428q-7.531-2.667-7.531-6.9,0-3.388,5-5.849a28.381,28.381,0,0,1,5.841-2.044,3.707,3.707,0,0,1-.488-1.884Zm24.8,16a13.145,13.145,0,0,0-2.129-.581,54.5,54.5,0,0,0-18.044,0,13.079,13.079,0,0,0-2.127.581,13.078,13.078,0,0,0,2.127.581,54.5,54.5,0,0,0,18.044,0,13.078,13.078,0,0,0,2.127-.581Z" transform="translate(-149.333 -120.889)"/></svg>',反向:'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><g transform="translate(0.364 4.658)"><path d="M0,287.1m0-.817v-2.042a.722.722,0,0,1,.817-.817H44.509a.722.722,0,0,1,.817.817v2.042a.722.722,0,0,1-.817.817H.817A.722.722,0,0,1,0,286.28Z" transform="translate(-0.001 -272.164)"/><path d="M829.7,13.238l-1.443,1.444a.817.817,0,0,1-1.155,0L815.263,2.844a.817.817,0,0,1,0-1.156L816.706.244a.817.817,0,0,1,1.155,0L829.7,12.083a.817.817,0,0,1,0,1.155Z" transform="translate(-782.667)"/><path d="M94.367,648m0,.817v2.042a.722.722,0,0,1-.817.817H49.858a.722.722,0,0,1-.817-.817v-2.042a.722.722,0,0,1,.817-.817H93.55A.722.722,0,0,1,94.367,648.816Z" transform="translate(-47.095 -622.268)"/><path d="M.239,649.97l1.443-1.444a.817.817,0,0,1,1.155,0l11.838,11.838a.817.817,0,0,1,0,1.156l-1.443,1.443a.817.817,0,0,1-1.155,0L.239,651.124a.817.817,0,0,1,0-1.155Z" transform="translate(0 -622.544)"/></g></svg>',路径漫游:'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><g transform="translate(0 -4.9)"><path d="M43.755,35.8a23.352,23.352,0,0,1-8.074-3.095c-1.131-.912-2.263-1.819-2.263-3.458,0-.364-.164-.548-.486-.548-1.776-.364-2.263,0-1.935,2.183a5,5,0,0,0,1.776,3.095,14.337,14.337,0,0,0,4.521,2.551c2.1.912,4.521,1.276,6.461,2.551,1.935,1.091,2.1,2.551.809,4.37A12.572,12.572,0,0,1,37.3,48.187a30.594,30.594,0,0,1-17.115-1.455c-2.585-.912-4.2-.364-5.488,2,0,.184-.164.184-.323.548,2.1.728,3.876,1.455,5.811,2,5.811,1.639,11.786,2.367,17.76.548A14.453,14.453,0,0,0,46.663,45.1c2.422-4.2,1.613-8.381-2.908-9.293Zm-19.7-7.97a11.943,11.943,0,0,0-7.382-10.952A12.17,12.17,0,0,0,3.457,19.546a10.951,10.951,0,0,0-2.3,12.879c2.459,5.329,6.456,9.77,10.453,14.06.463.444.617.444,1.075,0,3.689-4.143,7.382-8.287,10-13.172A11.6,11.6,0,0,0,24.059,27.833Zm-4.151,3.255c-1.692,3.851-4.614,6.955-7.382,10.215-.463.444-.617.3-.921,0A44.891,44.891,0,0,1,4.228,31.088a7.684,7.684,0,0,1-.767-3.109A8.664,8.664,0,0,1,18.22,21.909a8.155,8.155,0,0,1,1.688,9.18ZM33.007,4.9c-5.685,0-9.785,6.416-7.274,11.76,1.454,3.34,4.1,5.745,6.746,8.15a.492.492,0,0,0,.795,0c2.908-2.537,5.554-5.211,7.008-8.821A8.117,8.117,0,0,0,33.007,4.9Zm4.366,10.422A16.825,16.825,0,0,1,33.4,20c-.4.269-.659.269-.926,0a16.342,16.342,0,0,1-3.969-4.545,5.033,5.033,0,1,1,8.864-.132Z"/><path d="M183.031,141.935a2.136,2.136,0,0,0,2.053-2.18,2.084,2.084,0,0,0-2.18-2.18,2.171,2.171,0,0,0-2.053,2.307A2.058,2.058,0,0,0,183.031,141.935Zm-20.094,7.854a4.7,4.7,0,0,0-4.6,4.881,4.913,4.913,0,0,0,4.74,4.881,4.882,4.882,0,0,0-.14-9.762Zm0,6.417a1.77,1.77,0,0,1-1.532-1.532A1.79,1.79,0,0,1,162.937,153a1.611,1.611,0,0,1,1.672,1.672A1.578,1.578,0,0,1,162.937,156.206Z" transform="translate(-150.629 -126.653)"/></g></svg>',适应到模型:'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><g transform="translate(-84.667 -84.667)"><path d="M87.667,97V87.667H97V85.333H86.733a1.4,1.4,0,0,0-1.4,1.4V97Zm0,23.333H85.333V130.6a1.4,1.4,0,0,0,1.4,1.4H97v-2.333H87.667v-9.333Zm32.667,9.333V132H130.6a1.4,1.4,0,0,0,1.4-1.4V120.333h-2.333v9.333h-9.333ZM129.667,97H132V86.733a1.4,1.4,0,0,0-1.4-1.4H120.333v2.333h9.333Z"/><path d="M270.857,243.5l11.3-6.652V223.387l-11.3,6.361V243.5Zm-1.8,0v-13.75l-11.3-6.361v13.456l11.3,6.652Zm-10.278-21.621,11.177,6.284,11.177-6.284L269.958,215.3l-11.177,6.573Zm11.622-8.426,13.1,7.709a.919.919,0,0,1,.448.793v15.419a.926.926,0,0,1-.448.793l-13.1,7.709a.887.887,0,0,1-.9,0l-13.1-7.709a.905.905,0,0,1-.448-.793V221.954a.919.919,0,0,1,.448-.793l13.1-7.709A.887.887,0,0,1,270.4,213.452Z" transform="translate(-161.292 -120.997)"/></g></svg>',隐藏:'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><path d="M61.274,76.178l0-.007-.007,0a32.458,32.458,0,0,0-7.014-9.981L51.53,68.91a28.382,28.382,0,0,1,6.124,8.635c-4.472,9.25-10.809,13.636-19.472,13.636A20.615,20.615,0,0,1,30.6,89.838l-2.937,2.933a23.916,23.916,0,0,0,10.514,2.277q15.472,0,23.088-16.116a3.229,3.229,0,0,0,0-2.755ZM57.839,58.351l-2.274-2.277a.429.429,0,0,0-.608,0l-6.265,6.262a23.775,23.775,0,0,0-10.51-2.281q-15.472,0-23.088,16.116v.007a3.236,3.236,0,0,0,0,2.765,32.617,32.617,0,0,0,7.014,9.985L16.7,94.32a.429.429,0,0,0,0,.608l2.274,2.277a.429.429,0,0,0,.608,0L57.839,58.949a.426.426,0,0,0,0-.6ZM32.113,78.915a6.011,6.011,0,0,1,7.22-7.22l-7.223,7.22Zm9.9-9.9A9.452,9.452,0,0,0,29.43,81.6l-4.6,4.6a28.424,28.424,0,0,1-6.124-8.635c4.475-9.25,10.816-13.636,19.472-13.636a20.615,20.615,0,0,1,7.577,1.343Zm-4.046,14.55a5.752,5.752,0,0,1-1.01-.086l-2.744,2.741A9.446,9.446,0,0,0,46.638,73.794L43.9,76.538a6.018,6.018,0,0,1-5.932,7.024Z" transform="translate(-14.182 -52.64)"/></svg>',重置:'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><path d="M32.936,32.658a15.914,15.914,0,0,1-9.6,3.064c-.451-.006-.9-.042-1.342-.077-.182-.018-.357-.047-.539-.077-.352-.047-.7-.089-1.037-.164-.211-.036-.422-.1-.621-.148-.334-.077-.668-.154-.99-.254-.153-.059-.3-.11-.457-.177-.381-.124-.755-.26-1.113-.414-.082-.036-.162-.071-.24-.1-.422-.2-.844-.408-1.248-.627-.017-.012-.035-.018-.054-.03a16.485,16.485,0,0,1-3.732-2.9c-.017-.018-.035-.042-.054-.059-.34-.355-.668-.721-.979-1.118-.065-.083-.123-.16-.194-.254A17.286,17.286,0,0,1,7.149,18.751h3.98L6.318,9.076,0,18.874H3.942a20.809,20.809,0,0,0,3.5,11.57.871.871,0,0,0,.075.14c.225.34.486.648.724.961.1.113.177.232.274.362.354.443.746.869,1.133,1.285.043.043.075.076.108.113a19.778,19.778,0,0,0,4.436,3.446c.043.027.08.043.128.076.467.259.949.5,1.432.719.124.055.242.113.359.164.419.184.847.335,1.277.493.2.076.4.14.611.21.378.113.762.21,1.153.3.257.065.509.129.772.184a2.252,2.252,0,0,0,.316.076c.37.07.735.1,1.1.151.134.027.27.049.4.065.66.065,1.314.11,1.974.11,4.006,0,8.852-1.3,11.85-4.177a1.908,1.908,0,0,0,.333-2.484,2.228,2.228,0,0,0-2.952.023ZM44.053,20.424a20.728,20.728,0,0,0-3.47-11.537c-.032-.055-.054-.113-.08-.164-.284-.405-.574-.778-.869-1.161a1.289,1.289,0,0,1-.1-.14A19.86,19.86,0,0,0,32.168,1.7c-.086-.032-.155-.076-.242-.11-.456-.195-.922-.362-1.394-.53C30.37,1,30.2.937,30.033.883,29.62.754,29.212.651,28.792.548c-.231-.055-.467-.113-.7-.164-.113-.022-.22-.055-.338-.081-.311-.055-.617-.081-.933-.124C26.6.151,26.392.119,26.18.1,25.655.042,25.135.021,24.616.016c-.1,0-.188-.016-.284-.016-.016,0-.032.005-.049.005A19.124,19.124,0,0,0,13.02,3.695a1.682,1.682,0,0,0-.466,2.515,1.777,1.777,0,0,0,2.309.3A15.251,15.251,0,0,1,24.374,3.45c.486.006.971.03,1.441.077.147.012.287.036.432.059a11.3,11.3,0,0,1,1.16.189c.162.03.334.077.493.11.381.089.744.178,1.107.3a2.577,2.577,0,0,1,.34.124c.422.142.832.29,1.23.467.047.012.082.047.123.059a16.492,16.492,0,0,1,6.182,4.8.367.367,0,0,0,.024.036A17.308,17.308,0,0,1,40.629,20.43H36.645l5.048,9.787L48,20.424Zm0,0" transform="translate(0 4.349)"/></svg>',标高:'<svg width="32" height="32" viewBox="0 0 32 32"><path fill="currentColor" d="M84.131,193.119a1.056,1.056,0,0,1,1.116.982v7.857a1.056,1.056,0,0,1-1.116.982H54.367a1.056,1.056,0,0,1-1.116-.982V194.1a1.056,1.056,0,0,1,1.116-.982Zm-1.116,1.964H55.483v5.893H83.015Zm1.116-13.749a1.064,1.064,0,0,1,1.114.935,1.032,1.032,0,0,1-1.007,1.025l-.107,0H71.2l-7.858,6.914a1.227,1.227,0,0,1-1.578,0l-8.185-7.2-.018-.016-.032-.031.049.047a1.107,1.107,0,0,1-.092-.092l-.011-.014a.869.869,0,0,1-.182-.857l0-.008L53.31,182l.012-.029.02-.045.019-.035a1.1,1.1,0,0,1,.891-.552h.007q.053,0,.107,0ZM68.043,183.3H57.06l5.492,4.831Z" transform="translate(-53.247 -176.136)"/></svg>',距离:'<svg width="32" height="32" viewBox="0 0 32 32"><path fill="currentColor" d="M29.692,3.03,27.55.919a.529.529,0,0,1-.014-.756A.549.549,0,0,1,28.3.15l.014.013,3.067,3.023a.529.529,0,0,1,0,.756L28.317,6.966a.549.549,0,0,1-.767.013.529.529,0,0,1-.014-.756l.014-.013L29.692,4.1H2.31L4.452,6.21a.528.528,0,0,1,.013.756.547.547,0,0,1-.766.013l-.014-.013L.616,3.942a.531.531,0,0,1,0-.756L3.685.163a.548.548,0,0,1,.767.014.528.528,0,0,1,0,.742L2.31,3.03ZM24.136,15.055H23.051V18H21.966v-2.94H20.882V18H19.8v-2.94H18.712V18H17.627v-2.94H16.543v5.078H15.458V15.055H14.373V18H13.288v-2.94H12.2V18H11.119v-2.94H10.034V18H8.949v-2.94H7.865V18H6.78v-2.94H5.7v5.078H4.61V15.055H1.9a.27.27,0,0,0-.272.268v6.413A.269.269,0,0,0,1.9,22H30.1a.268.268,0,0,0,.271-.267V15.323a.269.269,0,0,0-.271-.268H27.39v5.078H26.305V15.055H25.221V18H24.136Zm5.966-1.6A1.884,1.884,0,0,1,32,15.323v6.413a1.885,1.885,0,0,1-1.9,1.871H1.9A1.885,1.885,0,0,1,0,21.736V15.323a1.885,1.885,0,0,1,1.9-1.871Z" transform="translate(0 4.197)"/></svg>',最小距离:'<svg width="32" height="32" viewBox="0 0 32 32"><path fill="currentColor" d="M-5.839,24.8H-34.16A1.875,1.875,0,0,1-36,22.933V16.52a1.887,1.887,0,0,1,1.9-1.871H-5.9A1.887,1.887,0,0,1-4,16.52v6.412A1.875,1.875,0,0,1-5.839,24.8ZM-34.1,16.252a.27.27,0,0,0-.272.268v6.412a.27.27,0,0,0,.272.267H-5.9a.269.269,0,0,0,.271-.267V16.52a.27.27,0,0,0-.271-.268H-8.61V21.33H-9.695V16.252h-1.085v2.939h-1.085V16.252h-1.085v2.939h-1.085V16.252h-1.084v2.939H-16.2V16.252h-1.085v2.939h-1.085V16.252h-1.084V21.33h-1.084V16.252h-1.085v2.939h-1.085V16.252H-23.8v2.939h-1.085V16.252h-1.085v2.939h-1.085V16.252h-1.084v2.939H-29.22V16.252H-30.3V21.33H-31.39V16.252Z" transform="translate(36 2)"/><path fill="currentColor" d="M23.716,7.947V4.875c0-.8-.232-1.085-.765-1.085a1.573,1.573,0,0,0-1.133.585V7.947H20.4V2.75h1.163l.1.687H21.7a2.547,2.547,0,0,1,1.763-.817c1.172,0,1.676.78,1.676,2.089V7.947Zm-7.26,0V2.62h1.58V7.947Zm-3.8,0V4.875c0-.8-.243-1.085-.76-1.085a1.606,1.606,0,0,0-1.049.585V7.947H9.421V4.875c0-.8-.243-1.085-.758-1.085a1.608,1.608,0,0,0-1.05.585V7.947H6.194V2.75H7.36l.1.7H7.5A2.326,2.326,0,0,1,9.169,2.62a1.486,1.486,0,0,1,1.5.91A2.445,2.445,0,0,1,12.4,2.62c1.156,0,1.691.78,1.691,2.089V7.947Zm3.8-6.849a.79.79,0,0,1,1.58,0,.79.79,0,0,1-1.58,0Z" transform="translate(0.333 3.053)"/></svg>',激光边距:'<svg width="32" height="32" viewBox="0 0 32 32"><path fill="currentColor" d="M0,1.293v31.96H32V1.293ZM30.97,32.182H1.03V2.323H30.97Z"/><path fill="currentColor" d="M160.026,291.9l1.6,1.6,7.305-7.305-7.305-7.305-1.6,1.6,4.794,4.566h-6.392v2.283h6.392Zm-5.251,0-4.566-4.566h6.164v-2.283H150.21l4.566-4.566-1.37-1.6L146.1,286.19l7.305,7.305Z" transform="translate(-141.535 -268.917)"/></svg>',角度:'<svg width="32" height="32" viewBox="0 0 32 32"><path fill="currentColor" d="M39.587,50.766h13.7a1,1,0,0,1,0,2H23.171a1,1,0,0,1,0-2h1.418l6.582-7.006v-.006a.517.517,0,0,1,.14-.357.456.456,0,0,1,.337-.144l12.1-12.876a.451.451,0,0,1,.665,0,.524.524,0,0,1,0,.708L32.883,43.355a8.3,8.3,0,0,1,6.7,7.411Zm-.949,0a7.254,7.254,0,0,0-6.611-6.5l-6.108,6.5Z" transform="translate(-22.229 -26.489)"/></svg>',坡度:'<svg width="32" height="32" viewBox="0 0 32 32"><path fill="currentColor" d="M202.1,188.337l2.629-2.191-8.447-3.106,1.533,8.871,2.629-2.194,9.341,11.209,1.656-1.379Zm-13.726-.435a1.075,1.075,0,0,0-1.07-.341,1.057,1.057,0,0,0-.5.277l-5.11,4.08a1.08,1.08,0,0,0-.406.84l-.007,17.386a1.079,1.079,0,0,0,1.077,1.077L205.7,211.2a1.078,1.078,0,0,0,.822-1.774Zm-4.934,21.164.007-15.788,3.968-3.171,15.974,18.941Z" transform="translate(-180.36 -181.131)"/></svg>',体积:'<svg width="32" height="32" viewBox="0 0 32 32"><path fill="currentColor" d="M94.74,86.658V71.189a.371.371,0,0,1,.2-.329l13.869-7.22a.371.371,0,0,1,.344,0l13.053,6.891h0l.819.431a.371.371,0,0,1,.2.328v15.3a.371.371,0,0,1-.2.328l-13.872,7.255a.371.371,0,0,1-.342,0L94.94,86.987a.371.371,0,0,1-.2-.329Zm2.119-.837,11.2,5.8a.024.024,0,0,0,.035-.022V79.483a.371.371,0,0,0-.2-.328l-11.2-5.909a.024.024,0,0,0-.035.021V85.492A.371.371,0,0,0,96.859,85.821Zm13.151-6.459v12a.12.12,0,0,0,.176.106L114,89.474l3.334-1.745,3.771-1.978a.371.371,0,0,0,.2-.328V73.5a.193.193,0,0,0-.284-.171l-10.812,5.708A.371.371,0,0,0,110.01,79.362ZM97.925,71.725l10.839,5.72a.371.371,0,0,0,.346,0L119.8,71.808a.214.214,0,0,0,0-.378l-10.649-5.621a.371.371,0,0,0-.344,0L97.925,71.47A.144.144,0,0,0,97.925,71.725Z" transform="translate(-92.982 -62.907)"/></svg>',空间体积:'<svg width="32" height="32" viewBox="0 0 32 32"><path fill="currentColor" d="M125.977,128.829l13.076-7.363v-13.6l-13.076,6.8Zm-3.126-15.655a.565.565,0,0,1-.258-.064L109.3,106.323a.567.567,0,0,1-.011-1L122.578,98a.567.567,0,0,1,.55,0l13.288,7.325a.567.567,0,0,1-.011,1l-13.292,6.79A.63.63,0,0,1,122.851,113.174ZM110.773,105.8l12.078,6.172,12.078-6.172-12.078-6.657Z" transform="translate(-1.922)"/><path fill="currentColor" d="M120.649,322.52a.58.58,0,0,1-.262-.064l-13.08-6.8a.573.573,0,0,1-.307-.5V301a.566.566,0,0,1,.273-.486.573.573,0,0,1,.558-.019l13.076,6.8a.573.573,0,0,1,.307.5v14.161a.57.57,0,0,1-.565.569Zm-12.511-7.708,11.942,6.206V308.136l-11.942-6.206Zm15.917,9.408a.585.585,0,0,1-.288-.076.567.567,0,0,1-.281-.489V309.49a.562.562,0,0,1,.307-.5l13.076-6.8a.573.573,0,0,1,.558.019.562.562,0,0,1,.273.486v13.6a.568.568,0,0,1-.288.493l-13.076,7.359A.557.557,0,0,1,124.055,324.22Zm.569-14.385V322.68l11.942-6.722V303.629Z" transform="translate(0 -194.822)"/></svg>',close:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12z"/></svg>',check:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M9 16.17L4.83 12l-1.42 1.41L9 19L21 7l-1.41-1.41z"/></svg>',warning:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M1 21h22L12 2L1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"/></svg>',error:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10s10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"/></svg>',success:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10s10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5l1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>',plus:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>',minus:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M19 13H5v-2h14v2z"/></svg>',arrowUp:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6l-6 6z"/></svg>',arrowUpBold:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8l-8 8z"/></svg>',arrowDown:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6l-6-6z"/></svg>',arrowLeft:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M15.41 7.41L14 6l-6 6l6 6l1.41-1.41L10.83 12z"/></svg>',arrowRight:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M10 6L8.59 7.41L13.17 12l-4.58 4.59L10 18l6-6z"/></svg>',search:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5A6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5S14 7.01 14 9.5S11.99 14 9.5 14z"/></svg>',refresh:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M17.65 6.35A7.958 7.958 0 0 0 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08A5.99 5.99 0 0 1 12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"/></svg>',delete:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg>',edit:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a.996.996 0 0 0 0-1.41l-2.34-2.34a.996.996 0 0 0-1.41 0l-1.83 1.83l3.75 3.75l1.83-1.83z"/></svg>',save:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M17 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2V7l-4-4zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3s3 1.34 3 3s-1.34 3-3 3zm3-10H5V5h10v4z"/></svg>',expand:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M16.59 8.59L12 13.17L7.41 8.59L6 10l6 6l6-6z"/></svg>',collapse:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12 8l-6 6l1.41 1.41L12 10.83l4.59 4.58L18 14z"/></svg>',bot:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2M7.5 13A2.5 2.5 0 0 0 5 15.5A2.5 2.5 0 0 0 7.5 18a2.5 2.5 0 0 0 2.5-2.5A2.5 2.5 0 0 0 7.5 13m9 0a2.5 2.5 0 0 0-2.5 2.5a2.5 2.5 0 0 0 2.5 2.5a2.5 2.5 0 0 0 2.5-2.5a2.5 2.5 0 0 0-2.5-2.5Z"/></svg>',history:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M13 3a9 9 0 0 0-9 9H1l3.89 3.89l.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7s-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42A8.954 8.954 0 0 0 13 21a9 9 0 0 0 0-18zm-1 5v5l4.28 2.54l.72-1.21l-3.5-2.08V8H12z"/></svg>',settings:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12 15.5A3.5 3.5 0 0 1 8.5 12A3.5 3.5 0 0 1 12 8.5a3.5 3.5 0 0 1 3.5 3.5a3.5 3.5 0 0 1-3.5 3.5m7.43-2.53c.04-.32.07-.64.07-.97c0-.33-.03-.66-.07-1l2.11-1.63c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.31-.61-.22l-2.49 1c-.52-.39-1.06-.73-1.69-.98l-.37-2.65A.506.506 0 0 0 14 2h-4c-.25 0-.46.18-.5.42l-.37 2.65c-.63.25-1.17.59-1.69.98l-2.49-1c-.22-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64L4.57 11c-.04.34-.07.67-.07 1c0 .33.03.65.07.97l-2.11 1.66c-.19.15-.25.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1.01c.52.4 1.06.74 1.69.99l.37 2.65c.04.24.25.42.5.42h4c.25 0 .46-.18.5-.42l.37-2.65c.63-.26 1.17-.59 1.69-.99l2.49 1.01c.22.08.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.66Z"/></svg>',loader:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12 4V2A10 10 0 0 0 2 12h2a8 8 0 0 1 8-8Z"><animateTransform attributeName="transform" dur="0.75s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12"/></path></svg>',send:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M2 21l21-9L2 3v7l15 2l-15 2v7z"/></svg>',透视相机:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M24 4L4 14v20l20 10l20-10V14L24 4zm0 4.5l14 7v14l-14 7l-14-7v-14l14-7zM24 18a6 6 0 100 12a6 6 0 000-12z"/></svg>',正交相机:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M6 6h36v36H6V6zm4 4v28h28V10H10zm4 4h20v20H14V14z"/></svg>',default:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10s10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8s8 3.59 8 8s-3.59 8-8 8zm-1-13h2v6h-2zm0 8h2v2h-2z"/></svg>'};function It(r){const e=YE[r];return e||(console.warn(`[IconManager] Icon "${r}" not found, using default icon`),YE.default)}class qF{container;wrapper;mainButton;items=[];itemElements=[];itemButtonMap=new Map;toggleStateMap=new Map;isActive=!1;timer=null;unsubscribeTheme=null;unsubscribeLocale=null;mainButtonLabel;onMainButtonClick;pointerX=Number.NaN;pointerY=Number.NaN;maxInteractiveRadius=220;closeDelay;itemsPerRing;MAIN_BUTTON_SIZE=60;SUB_BUTTON_SIZE=46;BASE_RADIUS=80;RING_GAP=40;FAN_START_DEG=170;FAN_END_DEG=280;CANVAS_PADDING=28;constructor(e){this.container=e.container,this.items=e.items===void 0?this.createDefaultItems():[...e.items],this.mainButtonLabel=e.mainButtonLabel??"toolbar.home",this.onMainButtonClick=e.onMainButtonClick,this.itemsPerRing=Math.max(3,e.itemsPerRing??5),this.closeDelay=Math.max(100,e.closeDelay??260),this.wrapper=this.createWrapper(),this.mainButton=this.createMainButton(e.mainButtonIcon),this.wrapper.appendChild(this.mainButton),this.container.appendChild(this.wrapper),this.renderItems(),this.updateLayoutMetrics(),this.bindEvents(),this.setTheme(ht.getTheme()),this.updateLocales(),this.unsubscribeTheme=ht.subscribe(t=>{this.setTheme(t)}),this.unsubscribeLocale=Kt.subscribe(()=>{this.updateLocales()})}createDefaultItems(){return[{id:"zoom",label:"toolbar.zoomBox",icon:It("框选放大")},{id:"measure",label:"toolbar.measure",icon:It("测量")},{id:"section",label:"toolbar.section",icon:It("剖切")},{id:"walk",label:"toolbar.walk",icon:It("漫游")},{id:"setting",label:"toolbar.setting",icon:It("设置")}]}createWrapper(){const e=document.createElement("div");return e.className="radial-toolbar-wrapper",e}createMainButton(e){const t=document.createElement("button");return t.className="radial-main-btn",t.type="button",t.innerHTML=e??It("主视角"),t}bindEvents(){this.mainButton.addEventListener("mouseenter",this.handlePointerEnter),this.mainButton.addEventListener("mouseleave",this.handlePointerLeave),this.mainButton.addEventListener("click",this.handleMainButtonClick),this.mainButton.addEventListener("dblclick",this.handleMainButtonDoubleClick),document.addEventListener("click",this.handleDocumentClick),document.addEventListener("mousemove",this.handleDocumentMouseMove),document.addEventListener("mouseleave",this.handleDocumentMouseLeave),document.addEventListener("visibilitychange",this.handleVisibilityChange),window.addEventListener("blur",this.handleWindowBlur)}handleDocumentMouseMove=e=>{this.pointerX=e.clientX,this.pointerY=e.clientY};handleDocumentMouseLeave=()=>{this.pointerX=Number.NaN,this.pointerY=Number.NaN,this.collapse()};handleVisibilityChange=()=>{document.hidden&&(this.pointerX=Number.NaN,this.pointerY=Number.NaN,this.collapse())};handleWindowBlur=()=>{this.pointerX=Number.NaN,this.pointerY=Number.NaN,this.collapse()};handlePointerEnter=()=>{this.timer&&(clearTimeout(this.timer),this.timer=null),this.expand()};handlePointerLeave=e=>{const t=e.relatedTarget;t instanceof Node&&this.wrapper.contains(t)||this.scheduleCollapse()};handleMainButtonClick=e=>{e.stopPropagation()};handleMainButtonDoubleClick=e=>{if(e.stopPropagation(),this.onMainButtonClick){this.onMainButtonClick();return}};handleDocumentClick=e=>{const t=e.target;t instanceof Node&&(this.wrapper.contains(t)||this.collapse())};renderItems(){this.itemElements.forEach(e=>e.remove()),this.itemElements=[],this.itemButtonMap.clear(),this.toggleStateMap.clear(),this.items.forEach((e,t)=>{this.toggleStateMap.set(e.id,!!e.isActive);const i=this.createSubButton(e,t);this.wrapper.insertBefore(i,this.mainButton),this.itemElements.push(i),this.itemButtonMap.set(e.id,i)}),this.updateItemPositions()}createSubButton(e,t){const i=document.createElement("button");i.className="radial-sub-btn",i.type="button",i.dataset.index=String(t),this.applyItemActiveClass(i,e);const n=document.createElement("span");return n.className="radial-sub-btn-icon",e.icon?n.innerHTML=e.icon:n.textContent=this.getFallbackLabel(e.label),i.appendChild(n),i.addEventListener("mouseenter",this.handlePointerEnter),i.addEventListener("mouseleave",this.handlePointerLeave),i.addEventListener("click",s=>{if(s.stopPropagation(),e.isToggle){const o=!(this.toggleStateMap.get(e.id)??!1);this.toggleStateMap.set(e.id,o),e.isActive=o,this.applyItemActiveClass(i,e),e.onToggle?.(o,e),this.collapse();return}e.onClick?.(e),this.collapse()}),i}updateItemPositions(){const e=this.itemElements.length,t=this.FAN_END_DEG-this.FAN_START_DEG;this.itemElements.forEach((i,n)=>{const s=Math.floor(n/this.itemsPerRing),a=s*this.itemsPerRing,o=Math.min(this.itemsPerRing,e-a),l=n-a,c=o===1?.5:l/(o-1),d=(this.FAN_START_DEG+t*c)*Math.PI/180,p=this.getBaseRadius(o)+s*this.RING_GAP,u=Math.cos(d)*p,A=Math.sin(d)*p,m=(l+s*.5)*.045,g=(o-1-l+s*.4)*.032;i.style.setProperty("--rt-x",`${u.toFixed(2)}px`),i.style.setProperty("--rt-y",`${A.toFixed(2)}px`),i.style.setProperty("--rt-open-delay",`${m.toFixed(3)}s`),i.style.setProperty("--rt-close-delay",`${g.toFixed(3)}s`)})}updateLayoutMetrics(){const e=this.items.length,t=Math.max(1,Math.ceil(e/this.itemsPerRing)),i=Math.max(1,Math.min(e,this.itemsPerRing)),n=this.getBaseRadius(i)+(t-1)*this.RING_GAP,s=Math.ceil(n+this.MAIN_BUTTON_SIZE+this.SUB_BUTTON_SIZE+this.CANVAS_PADDING*2);this.maxInteractiveRadius=n+this.SUB_BUTTON_SIZE*.7,this.wrapper.style.width=`${s}px`,this.wrapper.style.height=`${s}px`,this.wrapper.style.setProperty("--rt-main-size",`${this.MAIN_BUTTON_SIZE}px`),this.wrapper.style.setProperty("--rt-sub-size",`${this.SUB_BUTTON_SIZE}px`),this.wrapper.style.setProperty("--rt-main-offset",`${(this.MAIN_BUTTON_SIZE-this.SUB_BUTTON_SIZE)/2}px`)}getBaseRadius(e){return this.BASE_RADIUS}scheduleCollapse(){this.timer&&clearTimeout(this.timer),this.timer=window.setTimeout(()=>{if(this.timer=null,this.isPointerInsideToolbar()){this.isActive&&this.scheduleCollapse();return}this.collapse()},this.closeDelay)}isPointerInsideToolbar(){return this.mainButton.matches(":hover")||this.itemElements.some(e=>e.matches(":hover"))?!0:this.isPointerInsideFanRegion()}isPointerInsideFanRegion(){if(!Number.isFinite(this.pointerX)||!Number.isFinite(this.pointerY))return!1;const e=this.mainButton.getBoundingClientRect(),t=e.left+e.width/2,i=e.top+e.height/2,n=this.pointerX-t,s=this.pointerY-i,a=Math.hypot(n,s);if(a<=this.MAIN_BUTTON_SIZE/2)return!0;if(a>this.maxInteractiveRadius)return!1;let o=Math.atan2(s,n)*180/Math.PI;return o<0&&(o+=360),this.FAN_START_DEG<=this.FAN_END_DEG?o>=this.FAN_START_DEG&&o<=this.FAN_END_DEG:o>=this.FAN_START_DEG||o<=this.FAN_END_DEG}expand(){this.isActive||this.items.length===0||(this.isActive=!0,this.wrapper.classList.add("is-active"))}collapse(){this.isActive&&(this.isActive=!1,this.wrapper.classList.remove("is-active"))}updateLocales(){const e=Ee(this.mainButtonLabel);this.mainButton.title=e,this.mainButton.setAttribute("aria-label",e),this.itemElements.forEach((t,i)=>{const n=this.items[i];if(!n)return;const s=Ee(n.label);if(t.title=s,t.setAttribute("aria-label",s),this.applyItemActiveClass(t,n),!n.icon){const a=t.querySelector(".radial-sub-btn-icon");a&&(a.textContent=this.getFallbackLabel(n.label))}})}applyItemActiveClass(e,t){if(!t.isToggle){e.classList.remove("is-active"),e.dataset.active="false";return}const i=this.toggleStateMap.get(t.id)??!!t.isActive;e.classList.toggle("is-active",i),e.dataset.active=i?"true":"false"}getFallbackLabel(e){const t=Ee(e).trim();return t?t.charAt(0).toUpperCase():"?"}setTheme(e){this.wrapper.classList.remove("theme-light","theme-dark"),this.wrapper.classList.add(`theme-${e.name}`);const t=this.wrapper.style;t.setProperty("--bim-primary",e.primary),t.setProperty("--bim-primary-hover",e.primaryHover),t.setProperty("--bim-primary-active",e.primaryActive),t.setProperty("--bim-text-inverse",e.textInverse),t.setProperty("--bim-icon-inverse",e.iconInverse),t.setProperty("--bim-shadow-glow",e.shadowGlow),t.setProperty("--rt-main-bg",e.bgBase),t.setProperty("--rt-main-bg-hover",e.bgBase),t.setProperty("--rt-main-border",e.floatingBtnBorder),t.setProperty("--rt-main-shadow",e.floatingBtnShadow),t.setProperty("--rt-main-shadow-hover",e.floatingBtnShadowHover),t.setProperty("--rt-main-icon",e.floatingIconColor),t.setProperty("--rt-main-icon-hover",e.floatingIconColorHover),t.setProperty("--rt-sub-bg",e.bgBase),t.setProperty("--rt-sub-bg-hover",e.primaryHover),t.setProperty("--rt-sub-border",e.floatingBtnBorder),t.setProperty("--rt-sub-shadow",e.floatingBtnShadow),t.setProperty("--rt-sub-shadow-hover",e.floatingBtnShadowHover),t.setProperty("--rt-sub-icon",e.floatingIconColor),t.setProperty("--rt-sub-icon-hover",e.iconHover)}setItemActive(e,t){const i=this.items.find(s=>s.id===e);if(!i||!i.isToggle)return;i.isActive=t,this.toggleStateMap.set(e,t);const n=this.itemButtonMap.get(e);n&&this.applyItemActiveClass(n,i)}init(){}setLocales(){this.updateLocales()}destroy(){this.timer&&(clearTimeout(this.timer),this.timer=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),document.removeEventListener("click",this.handleDocumentClick),document.removeEventListener("mousemove",this.handleDocumentMouseMove),document.removeEventListener("mouseleave",this.handleDocumentMouseLeave),document.removeEventListener("visibilitychange",this.handleVisibilityChange),window.removeEventListener("blur",this.handleWindowBlur),this.mainButton.removeEventListener("mouseenter",this.handlePointerEnter),this.mainButton.removeEventListener("mouseleave",this.handlePointerLeave),this.mainButton.removeEventListener("click",this.handleMainButtonClick),this.itemElements.forEach(e=>{e.removeEventListener("mouseenter",this.handlePointerEnter),e.removeEventListener("mouseleave",this.handlePointerLeave)}),this.wrapper.parentNode&&this.wrapper.parentNode.removeChild(this.wrapper)}}const XF=r=>({id:"measure",label:"toolbar.measure",icon:It("测量"),isToggle:!0,isActive:r.bottomDock?.isOpen("measure")??!1,onToggle:e=>{const t=r.bottomDock;if(!t){console.warn("[RadialToolbar] bottom dock not initialized: measure");return}e?t.open("measure"):t.close("measure"),console.log(`[RadialToolbar] 测量${e?"已打开":"已关闭"}`)}}),YF=r=>({id:"section",label:"toolbar.section",icon:It("剖切"),isToggle:!0,isActive:r.bottomDock?.isOpen("section")??!1,onToggle:e=>{const t=r.bottomDock;if(!t){console.warn("[RadialToolbar] bottom dock not initialized: section");return}e?t.open("section"):t.close("section"),console.log(`[RadialToolbar] 剖切${e?"已打开":"已关闭"}`)}}),KF=r=>({id:"setting",label:"toolbar.setting",icon:It("设置"),onClick:()=>{r.setting?.toggle(),console.log(`[RadialToolbar] 设置${r.setting?.isOpen()?"已打开":"已关闭"}`)}}),ZF=r=>({id:"walk",label:"toolbar.walk",icon:It("漫游"),isToggle:!0,isActive:r.bottomDock?.isOpen("walk")??!1,onToggle:e=>{const t=r.bottomDock;if(!t){console.warn("[RadialToolbar] bottom dock not initialized: walk");return}e?t.open("walk"):t.close("walk"),console.log(`[RadialToolbar] 漫游${e?"已打开":"已关闭"}`)}});class KE extends Hn{toolbar=null;unsubscribeDockState=null;constructor(e,t,i){super(t),this.toolbar=new qF({container:e,items:i?.items??this.createDefaultItems(),itemsPerRing:i?.itemsPerRing??4,mainButtonIcon:It("主视角"),mainButtonLabel:"toolbar.home",onMainButtonClick:()=>{console.log("[RadialToolbar] main: home"),this.registry.engine3d?.getEngineComponent()?.CameraGoHome()}}),this.toolbar.setTheme(ht.getTheme()),this.unsubscribeDockState=this.registry.bottomDock?.onStateChange(({id:n,open:s})=>{this.toolbar?.setItemActive(n,s)})??null,this.syncInitialToggleStates()}createDefaultItems(){return[KF(this.registry),XF(this.registry),YF(this.registry),ZF(this.registry)]}syncInitialToggleStates(){const e=this.registry.bottomDock;!e||!this.toolbar||(this.toolbar.setItemActive("measure",e.isOpen("measure")),this.toolbar.setItemActive("section",e.isOpen("section")),this.toolbar.setItemActive("walk",e.isOpen("walk")))}destroy(){this.unsubscribeDockState&&(this.unsubscribeDockState(),this.unsubscribeDockState=null),this.toolbar?.destroy(),this.toolbar=null,super.destroy()}}class JF{container;root;panelGap=10;panelMap=new Map;panelOrder=[];resizeObserver;handleWindowResize=()=>{this.reflow()};constructor(e){this.container=e,this.root=document.createElement("div"),this.root.className="bottom-dock-stack",this.container.appendChild(this.root),this.resizeObserver=typeof ResizeObserver<"u"?new ResizeObserver(()=>{this.reflow()}):null,this.resizeObserver||window.addEventListener("resize",this.handleWindowResize)}setTheme(e){const t=this.root.style;t.setProperty("--bd-bg",e.floatingBtnBg),t.setProperty("--bd-border",e.floatingBtnBorder),t.setProperty("--bd-shadow",e.floatingBtnShadow),t.setProperty("--bd-close-color",e.floatingIconColor),t.setProperty("--bd-close-color-hover",e.floatingIconColorHover),t.setProperty("--bd-close-bg-hover",e.floatingBtnBgHover),t.setProperty("--bd-close-border-hover",e.floatingBtnBorder),t.setProperty("--bd-body-bg",e.floatingBtnBg),t.setProperty("--bd-placeholder-border",e.borderSubtle),t.setProperty("--bd-placeholder-text",e.textSecondary)}hasPanel(e){return this.panelMap.has(e)}addPanel(e){const t=this.panelMap.get(e.id);if(t&&t.leaving){t.leaving=!1,t.element.classList.remove("is-leaving"),t.removeTimer&&(clearTimeout(t.removeTimer),t.removeTimer=null),t.bodyElement.replaceChildren(e.content),this.panelOrder.includes(e.id)||this.panelOrder.push(e.id),this.reflow();return}if(t)return;const i=document.createElement("section");i.className="bottom-dock-panel is-entering",i.dataset.panelId=e.id;let n=null;e.closable!==!1&&(n=document.createElement("button"),n.className="bottom-dock-panel-close",n.type="button",n.setAttribute("aria-label","close-panel"),n.textContent="×",n.addEventListener("click",a=>{a.stopPropagation(),e.onClose(e.id)}),i.appendChild(n));const s=document.createElement("div");s.className="bottom-dock-panel-body",s.appendChild(e.content),i.appendChild(s),this.root.appendChild(i),this.panelOrder.push(e.id),this.panelMap.set(e.id,{id:e.id,element:i,bodyElement:s,closeButton:n,leaving:!1,removeTimer:null}),this.resizeObserver?.observe(i),this.reflow(),requestAnimationFrame(()=>{i.classList.remove("is-entering")})}removePanel(e){const t=this.panelMap.get(e);if(!t||t.leaving)return;t.leaving=!0,t.element.classList.add("is-leaving");const i=this.panelOrder.indexOf(e);i>=0&&this.panelOrder.splice(i,1),this.reflow(),t.removeTimer=window.setTimeout(()=>{this.resizeObserver?.unobserve(t.element),t.element.remove(),this.panelMap.delete(e),t.removeTimer=null},220)}createPlaceholderContent(e){const t=document.createElement("div");return t.className="bottom-dock-placeholder",t.textContent=e,t}destroy(){this.resizeObserver?.disconnect(),window.removeEventListener("resize",this.handleWindowResize),this.panelMap.clear(),this.panelOrder.length=0,this.root.remove()}reflow(){let e=0,t=0;this.panelOrder.forEach(s=>{const a=this.panelMap.get(s);a&&(a.element.style.transform=`translateX(-50%) translateY(-${e}px)`,e+=a.element.offsetHeight+this.panelGap,t=Math.max(t,a.element.offsetWidth))});const i=this.panelOrder.length,n=i>0?e-this.panelGap:0;this.root.style.height=`${n}px`,this.root.style.width=i>0?`${t}px`:"0px"}}class ZE extends Hn{stack;definitions=new Map;openStates=new Map;listeners=new Set;unsubscribeTheme=null;constructor(e,t){super(t),this.stack=new JF(e),this.stack.setTheme(ht.getTheme()),this.unsubscribeTheme=ht.subscribe(i=>{this.stack.setTheme(i)}),this.registerDefaultPanels()}register(e){this.definitions.set(e.id,e),this.openStates.has(e.id)||this.openStates.set(e.id,!1)}unregister(e){this.isOpen(e)&&this.close(e),this.definitions.delete(e),this.openStates.delete(e)}toggle(e){if(this.isOpen(e)){this.close(e);return}this.open(e)}open(e){const t=this.definitions.get(e);if(!t){console.warn(`[BottomDock] Unknown panel id: ${e}`);return}if(this.isOpen(e))return;const i=t.createContent?t.createContent():this.stack.createPlaceholderContent(`${t.title} 面板内容占位`);this.stack.addPanel({id:e,content:i,closable:t.closable!==!1,onClose:()=>{this.close(e)}}),this.openStates.set(e,!0),this.emitState({id:e,open:!0})}close(e){this.isOpen(e)&&(this.stack.removePanel(e),this.openStates.set(e,!1),this.emitState({id:e,open:!1}))}isOpen(e){return this.openStates.get(e)??!1}createPlaceholderContent(e){return this.stack.createPlaceholderContent(e)}onStateChange(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}destroy(){this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.listeners.clear(),this.definitions.clear(),this.openStates.clear(),this.stack.destroy(),super.destroy()}emitState(e){this.listeners.forEach(t=>{t(e)})}registerDefaultPanels(){this.register({id:"measure",title:"测量",createContent:()=>{const e=this.registry.measureDock?.getPanelElement();return e||this.stack.createPlaceholderContent("测量面板占位")}}),this.register({id:"section",title:"剖切",createContent:()=>{const e=this.registry.sectionDock?.getPanelElement();return e||this.stack.createPlaceholderContent("剖切面板占位")}}),this.register({id:"walk",title:"漫游",createContent:()=>{const e=this.registry.walkDock?.getPanelElement();return e||this.stack.createPlaceholderContent("漫游面板占位")}})}}const ia={clearHeight:'<svg aria-hidden="true" viewBox="0 0 48 48"><path d="M19.0032 32.1184C18.712 32.1184 18.4032 32.1184 18.112 32.4096C17.512 32.6992 17.8224 33.5904 18.112 33.8816L23.1472 38.6256C23.7472 38.9152 24.6192 38.9152 24.928 38.6256L29.9632 33.8816C30.2528 33.5904 30.2528 33.2816 30.2528 32.9904C30.2528 32.3904 29.6528 32.1008 29.072 32.1008L25.7856 32.1008L25.7856 16.2192L29.0256 16.2192C29.3152 16.2192 29.6256 16.2192 29.9152 15.928C30.5152 15.6368 30.2064 14.7472 29.9152 14.456L24.8816 9.7072C24.2816 9.4176 23.4096 9.4176 23.0992 9.7072L18.0656 14.4512C17.7744 14.7424 17.7744 15.0512 17.7744 15.3424C17.7744 15.9424 18.3744 16.232 18.9568 16.232L22.24 16.232L22.24 32.1328L19.0016 32.1328L19.0016 32.1184L19.0032 32.1184ZM4.75842 6.80639L43.2384 6.80639C44.128 6.80639 44.7104 6.20639 44.7104 5.33442C44.7104 4.1536 44.1088 3.2624 43.2384 3.2624L4.75678 3.2624C4.1568 3.2624 3.5744 3.8624 3.2848 4.73442C3.2848 5.62561 3.8848 6.5152 4.75678 6.80639L4.75842 6.80639ZM43.256 41.1936L4.75842 41.1936C4.1584 41.1936 3.576 41.7936 3.2864 42.6656C3.2864 43.5568 3.8864 44.4464 4.75842 44.7376L43.2384 44.7376C44.128 44.7376 44.7104 44.1376 44.7104 43.2656C44.728 42.08 44.1328 41.1936 43.256 41.1936Z" fill="currentColor"/></svg>',clearDistance:'<svg aria-hidden="true" viewBox="0 0 48 48"><path d="M15.2619 20.2135C15.2619 20.8776 14.5628 21.2125 14.0415 21.0436L4.13531 16.0541C4.10363 16.0394 4.07281 16.023 4.04285 16.005C4.0129 15.987 3.98397 15.9675 3.95607 15.9464C3.92817 15.9254 3.90144 15.9029 3.87591 15.879C3.85037 15.8552 3.82615 15.83 3.80326 15.8036L3.80909 35.8838C3.80909 36.8159 3.18577 37.4393 2.2537 37.4393C1.32163 37.4393 0.701223 36.8159 0.701223 35.8838L0.701223 9.16557C0.698312 8.2335 1.31872 7.61016 2.25079 7.61016C3.18286 7.61016 3.80618 8.2335 3.80618 9.16557L3.80035 14.8075C3.82324 14.7811 3.84746 14.7559 3.873 14.7321C3.89853 14.7082 3.92525 14.6858 3.95315 14.6647C3.98106 14.6437 4.00999 14.6242 4.03994 14.6062C4.0699 14.5881 4.10072 14.5718 4.1324 14.557L14.0444 9.56752C14.5687 9.23546 15.2619 9.56752 15.2619 10.2316L15.2619 13.9074L32.9566 13.9074C33.3644 13.9074 33.6557 13.6628 33.7314 13.2725L33.7488 13.0686L33.7488 10.2142C33.7488 9.71316 34.3838 9.20925 34.8557 9.54422L43.8938 14.5803C44.0132 14.6415 44.1181 14.7259 44.2026 14.8337L44.1968 8.07624C44.1968 7.14413 44.8201 6.52374 45.7521 6.52374C46.6842 6.52374 47.3044 7.14413 47.3044 8.07624L47.3044 36.0383C47.3044 36.0637 47.3038 36.0891 47.3025 36.1145C47.3016 36.1399 47.2998 36.1652 47.2974 36.1905C47.2948 36.2158 47.2917 36.241 47.288 36.2662C47.2842 36.2914 47.2798 36.3164 47.2749 36.3413C47.2698 36.3663 47.2642 36.3911 47.258 36.4157C47.252 36.4404 47.2453 36.4649 47.2378 36.4892C47.2303 36.5136 47.2224 36.5377 47.2139 36.5617C47.2055 36.5856 47.1964 36.6093 47.1867 36.6328C47.1767 36.6563 47.1664 36.6795 47.1558 36.7025C47.1448 36.7255 47.1334 36.7482 47.1216 36.7707C47.1094 36.7931 47.0969 36.8152 47.0841 36.837C47.0709 36.8588 47.0574 36.8803 47.0433 36.9015C47.0289 36.9226 47.0142 36.9434 46.9992 36.9638C46.9842 36.9843 46.9686 37.0043 46.9524 37.024C46.9361 37.0436 46.9195 37.0629 46.9027 37.0818C46.8855 37.1006 46.8679 37.119 46.8501 37.137C46.8321 37.155 46.8137 37.1726 46.7949 37.1897C46.7761 37.2068 46.7569 37.2234 46.7372 37.2395C46.7176 37.2557 46.6975 37.2713 46.6772 37.2865C46.6568 37.3017 46.636 37.3163 46.6149 37.3305C46.5937 37.3447 46.5723 37.3583 46.5505 37.3714C46.5287 37.3845 46.5066 37.397 46.4842 37.409C46.4618 37.4211 46.4391 37.4325 46.4161 37.4434C46.3932 37.4543 46.3699 37.4646 46.3464 37.4744C46.323 37.4842 46.2993 37.4933 46.2754 37.5019C46.2514 37.5105 46.2273 37.5186 46.203 37.526C46.1786 37.5334 46.1542 37.5402 46.1296 37.5464C46.1049 37.5526 46.0801 37.5582 46.0552 37.5632C46.0302 37.5683 46.0052 37.5726 45.9801 37.5764C45.9549 37.5802 45.9297 37.5833 45.9044 37.5859C45.8791 37.5884 45.8537 37.5903 45.8284 37.5916C45.803 37.5929 45.7775 37.5936 45.7521 37.5936C44.8201 37.5936 44.1968 36.9732 44.1968 36.0412L44.1997 15.8357C44.1783 15.8546 44.1554 15.8715 44.1309 15.8861C44.1064 15.9008 44.0807 15.9131 44.054 15.9231L35.0188 20.9562C34.544 21.2912 33.9091 20.9562 33.9091 20.2863L33.9091 17.4318C33.9091 16.9279 33.5887 16.593 33.1168 16.593L15.2619 16.59L15.2619 20.2135L15.2619 20.2135ZM41.0889 24.2796L41.0889 36.0412C41.0889 36.8975 40.3899 37.5936 39.5335 37.5936C38.6014 37.5936 37.981 36.9732 37.981 36.0412L37.981 24.2796C37.981 23.3475 38.6014 22.7243 39.5335 22.7243C40.4656 22.7243 41.0889 23.3475 41.0889 24.2796ZM28.6604 24.2796L28.6604 36.0412C28.6603 36.0665 28.6596 36.0919 28.6584 36.1173C28.657 36.1426 28.6551 36.168 28.6526 36.1932C28.6501 36.2185 28.6469 36.2437 28.6432 36.2688C28.6394 36.2939 28.6351 36.3189 28.63 36.3438C28.625 36.3687 28.6194 36.3935 28.6133 36.4181C28.607 36.4427 28.6002 36.4672 28.5929 36.4915C28.5855 36.5158 28.5774 36.5399 28.5689 36.5638C28.5603 36.5877 28.5512 36.6113 28.5414 36.6348C28.5317 36.6583 28.5213 36.6815 28.5105 36.7044C28.4996 36.7274 28.4881 36.75 28.4762 36.7724C28.4642 36.7948 28.4517 36.8168 28.4386 36.8386C28.4255 36.8604 28.4119 36.8819 28.3978 36.903C28.3837 36.9241 28.369 36.9448 28.3539 36.9652C28.3388 36.9856 28.3232 37.0056 28.3071 37.0253C28.2909 37.0449 28.2744 37.0641 28.2573 37.0829C28.2402 37.1017 28.2227 37.1201 28.2048 37.1381C28.1868 37.156 28.1684 37.1735 28.1496 37.1906C28.1308 37.2076 28.1116 37.2242 28.092 37.2404C28.0723 37.2564 28.0523 37.2721 28.032 37.2872C28.0115 37.3024 27.9908 37.317 27.9697 37.3311C27.9486 37.3452 27.9272 37.3588 27.9054 37.3719C27.8836 37.385 27.8615 37.3975 27.8391 37.4094C27.8167 37.4214 27.7941 37.4329 27.7712 37.4438C27.7482 37.4546 27.725 37.4649 27.7015 37.4747C27.6781 37.4844 27.6544 37.4936 27.6305 37.5022C27.6066 37.5107 27.5825 37.5187 27.5582 37.5261C27.5339 37.5335 27.5094 37.5403 27.4848 37.5465C27.4602 37.5527 27.4354 37.5583 27.4105 37.5633C27.3857 37.5683 27.3606 37.5727 27.3355 37.5765C27.3104 37.5802 27.2852 37.5833 27.2599 37.5859C27.2347 37.5884 27.2094 37.5903 27.184 37.5916C27.1586 37.5929 27.1333 37.5936 27.1079 37.5936C26.1758 37.5936 25.5525 36.9732 25.5525 36.0412L25.5525 24.2796C25.5525 23.3475 26.1758 22.7243 27.1079 22.7243C28.0399 22.7243 28.6604 23.3475 28.6604 24.2796ZM10.019 24.2796L10.019 36.0412C10.0189 36.0666 10.0183 36.092 10.017 36.1174C10.0156 36.1428 10.0138 36.1681 10.0112 36.1934C10.0087 36.2187 10.0055 36.2439 10.0018 36.2691C9.99798 36.2942 9.99357 36.3193 9.9886 36.3442C9.98359 36.3691 9.97796 36.3939 9.97178 36.4185C9.96554 36.4432 9.95874 36.4677 9.95134 36.492C9.94393 36.5163 9.93592 36.5404 9.92729 36.5644C9.91867 36.5883 9.90952 36.612 9.89978 36.6355C9.88998 36.659 9.87967 36.6822 9.86879 36.7051C9.85787 36.7281 9.84638 36.7508 9.83438 36.7732C9.82238 36.7956 9.80982 36.8177 9.79674 36.8395C9.78362 36.8613 9.77003 36.8828 9.75587 36.9039C9.74171 36.925 9.72704 36.9458 9.7119 36.9662C9.69671 36.9866 9.68101 37.0066 9.66488 37.0262C9.64876 37.0459 9.63212 37.0651 9.61506 37.0839C9.59795 37.1027 9.58042 37.1212 9.56242 37.1391C9.54442 37.1571 9.52599 37.1745 9.50715 37.1916C9.48826 37.2087 9.46899 37.2253 9.44935 37.2414C9.42967 37.2575 9.40965 37.2731 9.38921 37.2883C9.36878 37.3034 9.34796 37.318 9.32682 37.3321C9.30563 37.3462 9.28417 37.3598 9.26237 37.3729C9.24053 37.3859 9.2184 37.3984 9.19599 37.4104C9.17359 37.4224 9.15085 37.4338 9.12788 37.4446C9.10487 37.4555 9.08162 37.4658 9.05818 37.4755C9.03465 37.4852 9.01093 37.4944 8.98703 37.5029C8.96303 37.5115 8.93888 37.5195 8.9146 37.5268C8.89023 37.5342 8.86576 37.541 8.8411 37.5471C8.81645 37.5533 8.79165 37.5589 8.76671 37.5638C8.74178 37.5688 8.7167 37.5731 8.69157 37.5768C8.6664 37.5805 8.64118 37.5837 8.61587 37.5862C8.59056 37.5886 8.56524 37.5905 8.53984 37.5917C8.51443 37.593 8.48903 37.5936 8.46362 37.5936C7.53156 37.5936 6.90821 36.9732 6.90821 36.0412L6.90821 24.2796C6.90821 23.3475 7.53156 22.7243 8.46362 22.7243C9.39568 22.7243 10.0161 23.3475 10.0161 24.2796L10.019 24.2796ZM33.3207 29.7147C34.2527 29.7147 34.8732 30.3381 34.8732 31.2701L34.8732 36.0412C34.8731 36.0665 34.8724 36.0919 34.8712 36.1173C34.8699 36.1426 34.8679 36.168 34.8654 36.1932C34.8629 36.2185 34.8597 36.2437 34.856 36.2688C34.8522 36.2939 34.8478 36.3189 34.8429 36.3438C34.8378 36.3687 34.8323 36.3935 34.8261 36.4181C34.8198 36.4427 34.813 36.4672 34.8057 36.4915C34.7983 36.5158 34.7903 36.5399 34.7817 36.5638C34.7731 36.5877 34.7639 36.6113 34.7542 36.6348C34.7445 36.6583 34.7341 36.6815 34.7233 36.7044C34.7124 36.7274 34.701 36.75 34.689 36.7724C34.677 36.7948 34.6644 36.8168 34.6514 36.8386C34.6383 36.8604 34.6247 36.8819 34.6106 36.903C34.5965 36.9241 34.5819 36.9448 34.5668 36.9652C34.5516 36.9856 34.536 37.0056 34.5199 37.0253C34.5038 37.0449 34.4872 37.0641 34.4701 37.0829C34.453 37.1017 34.4356 37.1201 34.4176 37.1381C34.3996 37.156 34.3812 37.1735 34.3624 37.1906C34.3436 37.2076 34.3244 37.2242 34.3048 37.2404C34.2851 37.2564 34.2652 37.2721 34.2448 37.2872C34.2244 37.3024 34.2036 37.317 34.1825 37.3311C34.1614 37.3452 34.1399 37.3588 34.1182 37.3719C34.0964 37.385 34.0743 37.3975 34.0519 37.4094C34.0296 37.4214 34.0069 37.4329 33.9839 37.4438C33.961 37.4546 33.9378 37.4649 33.9144 37.4747C33.8909 37.4844 33.8672 37.4936 33.8433 37.5022C33.8194 37.5107 33.7953 37.5187 33.771 37.5261C33.7467 37.5335 33.7223 37.5403 33.6977 37.5465C33.673 37.5527 33.6482 37.5583 33.6234 37.5633C33.5984 37.5683 33.5734 37.5727 33.5484 37.5765C33.5232 37.5802 33.498 37.5833 33.4727 37.5859C33.4475 37.5884 33.4222 37.5903 33.3968 37.5916C33.3714 37.5929 33.3461 37.5936 33.3207 37.5936C32.3886 37.5936 31.7682 36.9732 31.7682 36.0412L31.7682 31.2701C31.7682 30.3381 32.3886 29.7147 33.3207 29.7147ZM22.4446 31.2701L22.4446 36.0412C22.4446 36.8975 21.7485 37.5936 20.8892 37.5936C19.9572 37.5936 19.3367 36.9732 19.3367 36.0412L19.3367 31.2701C19.3367 30.3381 19.9572 29.7147 20.8892 29.7147C21.8213 29.7147 22.4446 30.3381 22.4446 31.2701ZM16.2289 31.2701L16.2289 36.0412C16.2288 36.0665 16.2282 36.0919 16.2269 36.1173C16.2256 36.1426 16.2237 36.168 16.2211 36.1932C16.2186 36.2185 16.2155 36.2437 16.2117 36.2688C16.2079 36.2939 16.2036 36.3189 16.1986 36.3438C16.1936 36.3687 16.188 36.3935 16.1818 36.4181C16.1756 36.4427 16.1688 36.4672 16.1614 36.4915C16.154 36.5158 16.146 36.5399 16.1374 36.5638C16.1288 36.5877 16.1197 36.6113 16.11 36.6348C16.1002 36.6583 16.0899 36.6815 16.079 36.7044C16.0681 36.7274 16.0567 36.75 16.0447 36.7724C16.0328 36.7948 16.0202 36.8168 16.0072 36.8386C15.994 36.8604 15.9804 36.8819 15.9664 36.903C15.9522 36.9241 15.9376 36.9448 15.9225 36.9652C15.9073 36.9856 15.8917 37.0056 15.8756 37.0253C15.8595 37.0449 15.8429 37.0641 15.8259 37.0829C15.8088 37.1017 15.7913 37.1201 15.7734 37.1381C15.7554 37.156 15.737 37.1735 15.7182 37.1906C15.6994 37.2076 15.6801 37.2242 15.6605 37.2404C15.6409 37.2564 15.6209 37.2721 15.6005 37.2872C15.5801 37.3024 15.5594 37.317 15.5382 37.3311C15.5171 37.3452 15.4957 37.3588 15.4739 37.3719C15.4521 37.385 15.43 37.3975 15.4077 37.4094C15.3853 37.4214 15.3626 37.4329 15.3397 37.4438C15.3167 37.4546 15.2935 37.4649 15.2701 37.4747C15.2466 37.4844 15.2229 37.4936 15.199 37.5022C15.1751 37.5107 15.151 37.5187 15.1268 37.5261C15.1025 37.5335 15.078 37.5403 15.0534 37.5465C15.0287 37.5527 15.0039 37.5583 14.9791 37.5633C14.9542 37.5683 14.9292 37.5727 14.9041 37.5765C14.8789 37.5802 14.8538 37.5833 14.8285 37.5859C14.8032 37.5884 14.7779 37.5903 14.7526 37.5916C14.7271 37.5929 14.7018 37.5936 14.6764 37.5936C13.7444 37.5936 13.1239 36.9732 13.1239 36.0412L13.1239 31.2701C13.1239 30.3381 13.7444 29.7147 14.6764 29.7147C15.6085 29.7147 16.2289 30.3381 16.2289 31.2701Z" fill="currentColor"/></svg>',distance:'<svg viewBox="0 0 32 32" aria-hidden="true"><g transform="translate(0 4.197)"><path fill="currentColor" d="M29.692,3.03,27.55.919a.529.529,0,0,1-.014-.756A.549.549,0,0,1,28.3.15l.014.013,3.067,3.023a.529.529,0,0,1,0,.756L28.317,6.966a.549.549,0,0,1-.767.013.529.529,0,0,1-.014-.756l.014-.013L29.692,4.1H2.31L4.452,6.21a.528.528,0,0,1,.013.756.547.547,0,0,1-.766.013l-.014-.013L.616,3.942a.531.531,0,0,1,0-.756L3.685.163a.548.548,0,0,1,.767.014.528.528,0,0,1,0,.742L2.31,3.03ZM24.136,15.055H23.051V18H21.966v-2.94H20.882V18H19.8v-2.94H18.712V18H17.627v-2.94H16.543v5.078H15.458V15.055H14.373V18H13.288v-2.94H12.2V18H11.119v-2.94H10.034V18H8.949v-2.94H7.865V18H6.78v-2.94H5.7v5.078H4.61V15.055H1.9a.27.27,0,0,0-.272.268v6.413A.269.269,0,0,0,1.9,22H30.1a.268.268,0,0,0,.271-.267V15.323a.269.269,0,0,0-.271-.268H27.39v5.078H26.305V15.055H25.221V18H24.136Zm5.966-1.6A1.884,1.884,0,0,1,32,15.323v6.413a1.885,1.885,0,0,1-1.9,1.871H1.9A1.885,1.885,0,0,1,0,21.736V15.323a1.885,1.885,0,0,1,1.9-1.871Z"/></g></svg>',elevation:'<svg viewBox="0 0 32 32" aria-hidden="true"><path fill="currentColor" d="M84.131,193.119a1.056,1.056,0,0,1,1.116.982v7.857a1.056,1.056,0,0,1-1.116.982H54.367a1.056,1.056,0,0,1-1.116-.982V194.1a1.056,1.056,0,0,1,1.116-.982Zm-1.116,1.964H55.483v5.893H83.015Zm1.116-13.749a1.064,1.064,0,0,1,1.114.935,1.032,1.032,0,0,1-1.007,1.025l-.107,0H71.2l-7.858,6.914a1.227,1.227,0,0,1-1.578,0l-8.185-7.2-.018-.016-.032-.031.049.047a1.107,1.107,0,0,1-.092-.092l-.011-.014a.869.869,0,0,1-.182-.857l0-.008L53.31,182l.012-.029.02-.045.019-.035a1.1,1.1,0,0,1,.891-.552h.007q.053,0,.107,0ZM68.043,183.3H57.06l5.492,4.831Z" transform="translate(-53.247 -176.136)"/></svg>',point:'<svg aria-hidden="true" viewBox="0 0 48 48"><path d="M40.1698 18.0929C40.1428 20.5301 39.3645 22.7586 38.3131 24.9092C36.7378 28.1319 34.6461 31.0118 32.3727 33.7664C30.2564 36.3308 27.9853 38.7519 25.5613 41.0284C24.7143 41.8237 23.9413 41.8481 23.073 41.0687C18.5767 37.0334 14.5359 32.6092 11.4515 27.3755C10.9495 26.5238 10.4945 25.6458 10.1025 24.7372C9.73107 23.8761 10.0514 22.9753 10.8534 22.6034C11.6577 22.2304 12.582 22.5576 12.9732 23.4086C14.8167 27.4176 17.5132 30.8241 20.4598 34.0548C21.596 35.3006 22.7863 36.4939 24.0184 37.6454C24.1708 37.7877 24.2667 37.9033 24.4831 37.6853C28.5664 33.5709 32.3892 29.2509 35.1723 24.1156C35.9836 22.6186 36.66 21.0543 36.8866 19.3498C37.2281 16.7802 36.712 14.3356 35.493 12.0807C33.1715 7.78618 29.5679 5.33714 24.6496 5.16445C19.0467 4.96786 14.0685 8.58606 12.3051 13.9294C11.8621 15.2717 11.6275 16.6474 11.6092 18.061C11.5962 19.0717 10.9335 19.7853 10.0201 19.783C9.10383 19.7808 8.43479 19.0505 8.43746 18.056C8.45818 10.5393 13.6357 4.02759 20.9324 2.34148C26.9693 0.946299 33.4364 3.45514 37.0904 8.60424C39.1088 11.4483 40.1115 14.6187 40.1698 18.0929ZM6.42075 43.1971C18.363 43.1971 30.2366 43.1971 42.1204 43.1971C42.1186 42.9919 41.9834 42.8579 41.8977 42.7076C40.3484 39.9866 38.7956 37.2673 37.2401 34.5498C36.9062 33.9668 36.8856 33.3861 37.257 32.8222C37.5915 32.314 38.0819 32.0681 38.6918 32.1099C39.2399 32.1477 39.6712 32.4169 39.9425 32.8899C42.0656 36.5932 44.1915 40.2948 46.2926 44.0105C46.9411 45.1576 46.1392 46.3818 44.7752 46.3821C37.6695 46.3845 30.564 46.3832 23.4585 46.3832C16.9643 46.3832 10.4699 46.3507 3.97625 46.4082C2.51885 46.4212 1.62531 45.0904 2.42647 43.7424C4.52293 40.2152 6.51577 36.6264 8.55216 33.0634C8.99072 32.2962 9.67627 31.9592 10.3942 32.1457C11.456 32.4219 11.9181 33.5491 11.3553 34.5444C10.2685 36.467 9.16594 38.3807 8.07099 40.2987C7.53258 41.2418 6.99643 42.1859 6.42075 43.1971ZM30.6461 17.8271C30.6465 21.3322 27.7864 24.1813 24.2754 24.1734C20.7946 24.1656 17.9554 21.3147 17.9555 17.8276C17.9557 14.3185 20.8087 11.4763 24.3244 11.4829C27.8051 11.4893 30.6458 14.3402 30.6461 17.8271ZM24.3201 14.6556C22.5583 14.656 21.1314 16.0714 21.1285 17.8213C21.1256 19.591 22.5741 21.0173 24.3575 21.0005C26.0699 20.9844 27.4807 19.5391 27.4733 17.8085C27.4659 16.0808 26.0403 14.6552 24.3201 14.6556Z" fill="currentColor"/></svg>',angle:'<svg viewBox="0 0 32 32" aria-hidden="true"><path fill="currentColor" d="M39.587,50.766h13.7a1,1,0,0,1,0,2H23.171a1,1,0,0,1,0-2h1.418l6.582-7.006v-.006a.517.517,0,0,1,.14-.357.456.456,0,0,1,.337-.144l12.1-12.876a.451.451,0,0,1,.665,0,.524.524,0,0,1,0,.708L32.883,43.355a8.3,8.3,0,0,1,6.7,7.411Zm-.949,0a7.254,7.254,0,0,0-6.611-6.5l-6.108,6.5Z" transform="translate(-22.229 -26.489)"/></svg>',area:'<svg aria-hidden="true" viewBox="0 0 48 48"><path d="M28.7725 16.8582L16.6882 28.9801C16.0335 29.6368 16.0335 30.7313 16.6882 31.3881C17.0156 31.7164 17.452 31.8806 17.8885 31.8806C18.3249 31.8806 18.7614 31.7164 19.0887 31.3881L31.173 19.2662C31.8277 18.6094 31.8277 17.5149 31.173 16.8582C30.5183 16.2015 29.4272 16.2015 28.7725 16.8582Z" fill="currentColor"/><path d="M44.5667 11.9055C45.385 11.9055 46.0397 11.2488 46.0397 10.4552L46.0397 3.47761C46.0397 2.65672 45.385 2 44.5667 2L37.6107 2C36.7924 2 36.1377 2.65672 36.1377 3.47761L36.1377 5.06468L11.9418 5.06468L11.9418 3.47761C11.9418 2.65672 11.2871 2 10.4688 2L3.51277 2C2.69442 2 2.03974 2.65672 2.03974 3.47761L2.03974 10.4279C2.03974 11.2488 2.69442 11.9055 3.51277 11.9055L5.20403 11.9055L5.20403 36.0671L3.51277 36.0671C2.69442 36.0671 2.03974 36.7239 2.03974 37.5448L2.03974 44.5224C2.03974 45.3433 2.69442 46 3.51277 46L10.4688 46C11.2598 46 11.9145 45.3433 11.9418 44.5224L11.9418 42.7438L36.1377 42.7438L36.1377 44.5224C36.1377 45.3433 36.7924 46 37.6107 46L44.5667 46C45.385 46 46.0397 45.3433 46.0397 44.5224L46.0397 37.5448C46.0397 36.7239 45.385 36.0671 44.5667 36.0671L42.7936 36.0671L42.7936 11.9055L44.5667 11.9055ZM39.0837 4.92786L43.0937 4.92786L43.0937 8.95024L39.0837 8.95024L39.0837 4.92786ZM4.9858 4.92786L8.99572 4.92786L8.99572 8.95024L4.9858 8.95024L4.9858 4.92786ZM8.99572 43.0448L4.9858 43.0448L4.9858 39.0224L8.99572 39.0224L8.99572 43.0448ZM43.0937 43.0448L39.0837 43.0448L39.0837 39.0224L43.0937 39.0224L43.0937 43.0448ZM39.3838 36.0671L37.6107 36.0671C36.7924 36.0671 36.1377 36.7239 36.1377 37.5448L36.1377 39.3234L11.9418 39.3234L11.9418 37.5448C11.9418 36.7239 11.2871 36.0671 10.4688 36.0671L8.61382 36.0671L8.61382 11.9055L10.4688 11.9055C11.2598 11.9055 11.9145 11.2488 11.9418 10.4552L11.9418 8.48507L36.1377 8.48507L36.1377 10.4279C36.1377 11.2488 36.7924 11.9055 37.6107 11.9055L39.3838 11.9055L39.3838 36.0671Z" fill="currentColor"/></svg>',slope:'<svg viewBox="0 0 32 32" aria-hidden="true"><path fill="currentColor" d="M202.1,188.337l2.629-2.191-8.447-3.106,1.533,8.871,2.629-2.194,9.341,11.209,1.656-1.379Zm-13.726-.435a1.075,1.075,0,0,0-1.07-.341,1.057,1.057,0,0,0-.5.277l-5.11,4.08a1.08,1.08,0,0,0-.406.84l-.007,17.386a1.079,1.079,0,0,0,1.077,1.077L205.7,211.2a1.078,1.078,0,0,0,.822-1.774Zm-4.934,21.164.007-15.788,3.968-3.171,15.974,18.941Z" transform="translate(-180.36 -181.131)"/></svg>'},Hl={distance:{key:"distance",callBackType:"distance",icon:ia.distance,order:0},clearHeight:{key:"clearHeight",callBackType:"clear-height",icon:ia.clearHeight,order:1},clearDistance:{key:"clearDistance",callBackType:"clear-distance",icon:ia.clearDistance,order:2},elevation:{key:"elevation",callBackType:"elevation",icon:ia.elevation,order:3},point:{key:"point",callBackType:"point",icon:ia.point,order:4},angle:{key:"angle",callBackType:"angle",icon:ia.angle,order:5},area:{key:"area",callBackType:"area",icon:ia.area,order:6},slope:{key:"slope",callBackType:"slope",icon:ia.slope,order:7}},JE=Object.values(Hl).sort((r,e)=>r.order-e.order).map(r=>r.key);function $E(r){switch(r){case"clearHeight":case"clearDistance":case"distance":case"elevation":return"length";case"area":return"area";case"angle":return"angle";case"slope":return"percent";default:return"point"}}function eM(r){return Object.values(Hl).find(e=>e.callBackType===r)?.key}const $F=["distance","clearHeight","clearDistance","elevation"],e9=["point","angle","area","slope"],tM="bim-engine:measure:config",t9={unit:"mm",precision:2};class i9{element;options;modeButtons=new Map;clearBtn;expandBtn;settingsBtn;secondaryRow;clearHeightOptions;clearHeightDirectionLabel;clearHeightSelectTypeLabel;directionButtons=new Map;selectTypeButtons=new Map;mainView;settingsView;settingsUnitLabel;settingsPrecisionLabel;settingsUnitSelect;settingsPrecisionSelect;settingsSaveBtn;settingsBackBtn;activeMode;isExpanded;clearHeightDirection;clearHeightSelectType;view="main";config;lockedWidthPx=null;constructor(e={}){this.options=e,this.activeMode=e.defaultMode??"distance",this.isExpanded=e.defaultExpanded??!1,this.clearHeightDirection=e.defaultClearHeightDirection??1,this.clearHeightSelectType=e.defaultClearHeightSelectType??"point",this.config=this.loadConfigFromCache()??{...t9};const{root:t,clearBtn:i,expandBtn:n,settingsBtn:s,secondaryRow:a,clearHeightOptions:o,clearHeightDirectionLabel:l,clearHeightSelectTypeLabel:c,mainView:h,settingsView:d,settingsUnitLabel:p,settingsPrecisionLabel:u,settingsUnitSelect:A,settingsPrecisionSelect:m,settingsSaveBtn:g,settingsBackBtn:f}=this.createDom();this.element=t,this.clearBtn=i,this.expandBtn=n,this.settingsBtn=s,this.secondaryRow=a,this.clearHeightOptions=o,this.clearHeightDirectionLabel=l,this.clearHeightSelectTypeLabel=c,this.mainView=h,this.settingsView=d,this.settingsUnitLabel=p,this.settingsPrecisionLabel=u,this.settingsUnitSelect=A,this.settingsPrecisionSelect=m,this.settingsSaveBtn=g,this.settingsBackBtn=f}init(){this.setLocales(),this.syncSettingsFormFromConfig(),this.applyExpandedState(),this.applyClearHeightOptionsState(),this.applyViewState(),this.syncActiveMode(this.activeMode)}setTheme(e){const t=this.element.style;t.setProperty("--bim-text-primary",e.textPrimary),t.setProperty("--bim-text-secondary",e.textSecondary),t.setProperty("--bim-text-tertiary",e.textTertiary),t.setProperty("--bim-border-default",e.borderDefault),t.setProperty("--bim-border-strong",e.borderStrong),t.setProperty("--bim-bg-inset",e.bgInset),t.setProperty("--bim-bg-elevated",e.bgElevated),t.setProperty("--bim-primary",e.primary),t.setProperty("--bim-primary-subtle",e.primarySubtle),t.setProperty("--bim-danger",e.danger),t.setProperty("--bim-component-bg-hover",e.componentBgHover)}setLocales(){for(const[n,s]of this.modeButtons.entries()){const a=Ee(`measure.modes.${n}`);s.dataset.tooltip=a,s.setAttribute("aria-label",a)}const e=Ee("measure.actions.clearAll");this.clearBtn.dataset.tooltip=e,this.clearBtn.setAttribute("aria-label",e);const t=this.isExpanded?Ee("measure.actions.collapse"):Ee("measure.actions.expand");delete this.expandBtn.dataset.tooltip,this.expandBtn.setAttribute("aria-label",t);const i=Ee("measure.actions.settings");this.settingsBtn.dataset.tooltip=i,this.settingsBtn.setAttribute("aria-label",i),this.clearHeightDirectionLabel.textContent=Ee("measure.clearHeight.direction"),this.clearHeightSelectTypeLabel.textContent=Ee("measure.clearHeight.selectType"),this.directionButtons.get(0).textContent=Ee("measure.clearHeight.directionDown"),this.directionButtons.get(1).textContent=Ee("measure.clearHeight.directionUp"),this.selectTypeButtons.get("point").textContent=Ee("measure.clearHeight.selectPoint"),this.selectTypeButtons.get("element").textContent=Ee("measure.clearHeight.selectElement"),this.settingsUnitLabel.textContent=Ee("measure.settings.unit"),this.settingsPrecisionLabel.textContent=Ee("measure.settings.precision"),this.settingsSaveBtn.textContent=Ee("measure.settings.save"),this.settingsBackBtn.textContent=Ee("measure.settings.cancel")}switchMode(e,t=!0){this.activeMode=e,this.syncActiveMode(e),this.applyClearHeightOptionsState(),this.closeSettingsView(),t&&this.options.onModeChange?.(e),e==="clearHeight"&&(this.options.onClearHeightDirectionChange?.(this.clearHeightDirection),this.options.onClearHeightSelectTypeChange?.(this.clearHeightSelectType))}destroy(){this.element.remove()}getConfig(){return{...this.config}}createDom(){const e=document.createElement("div");e.className="measure-dock-panel";const t=document.createElement("div");t.className="measure-dock-panel-main";const i=document.createElement("div");i.className="measure-dock-clearheight-options";const n=document.createElement("div");n.className="measure-dock-clearheight-group";const s=document.createElement("span");s.className="measure-dock-clearheight-label";const a=document.createElement("div");a.className="measure-dock-clearheight-buttons";const o=this.createClearHeightOptionButton(()=>{this.setClearHeightDirection(0)}),l=this.createClearHeightOptionButton(()=>{this.setClearHeightDirection(1)});this.directionButtons.set(0,o),this.directionButtons.set(1,l),a.appendChild(o),a.appendChild(l),n.appendChild(s),n.appendChild(a);const c=document.createElement("div");c.className="measure-dock-clearheight-group";const h=document.createElement("span");h.className="measure-dock-clearheight-label";const d=document.createElement("div");d.className="measure-dock-clearheight-buttons";const p=this.createClearHeightOptionButton(()=>{this.setClearHeightSelectType("point")}),u=this.createClearHeightOptionButton(()=>{this.setClearHeightSelectType("element")});this.selectTypeButtons.set("point",p),this.selectTypeButtons.set("element",u),d.appendChild(p),d.appendChild(u),c.appendChild(h),c.appendChild(d),i.appendChild(n),i.appendChild(c);const A=document.createElement("div");A.className="measure-dock-panel-top";const m=document.createElement("div");m.className="measure-dock-panel-mode-zone";const g=document.createElement("div");g.className="measure-dock-panel-mode-row",$F.forEach(U=>{g.appendChild(this.createModeButton(U))});const f=document.createElement("div");f.className="measure-dock-panel-mode-row measure-dock-panel-mode-row-secondary",e9.forEach(U=>{f.appendChild(this.createModeButton(U))});const v=this.createIconButton("measure-dock-panel-action-clear",It("delete"));v.addEventListener("click",()=>{this.options.onClearAll?.()});const b=this.createIconButton("measure-dock-panel-action-settings",It("settings"));b.addEventListener("click",()=>{this.openSettingsView(),this.options.onSettings?.()}),g.appendChild(v),f.appendChild(b),m.appendChild(g),m.appendChild(f);const y=document.createElement("div");y.className="measure-dock-panel-actions";const M=this.createIconButton("measure-dock-panel-action-expand",It("expand"));M.addEventListener("click",()=>{this.isExpanded=!this.isExpanded,this.applyExpandedState(),this.setLocales()}),y.appendChild(M),A.appendChild(m),A.appendChild(y),t.appendChild(i),t.appendChild(A);const{settingsView:_,settingsUnitLabel:S,settingsPrecisionLabel:w,settingsUnitSelect:E,settingsPrecisionSelect:I,settingsSaveBtn:B,settingsBackBtn:R}=this.createSettingsView();return e.appendChild(t),e.appendChild(_),{root:e,clearBtn:v,expandBtn:M,settingsBtn:b,secondaryRow:f,clearHeightOptions:i,clearHeightDirectionLabel:s,clearHeightSelectTypeLabel:h,mainView:t,settingsView:_,settingsUnitLabel:S,settingsPrecisionLabel:w,settingsUnitSelect:E,settingsPrecisionSelect:I,settingsSaveBtn:B,settingsBackBtn:R}}createSettingsView(){const e=document.createElement("div");e.className="measure-dock-panel-settings";const t=document.createElement("div");t.className="measure-dock-settings-row";const i=document.createElement("span");i.className="measure-dock-settings-label";const n=document.createElement("select");n.className="measure-dock-settings-select",["m","cm","mm","km"].forEach(d=>{const p=document.createElement("option");p.value=d,p.textContent=d,n.appendChild(p)}),t.appendChild(i),t.appendChild(n);const s=document.createElement("div");s.className="measure-dock-settings-row";const a=document.createElement("span");a.className="measure-dock-settings-label";const o=document.createElement("select");o.className="measure-dock-settings-select",[0,1,2,3].forEach(d=>{const p=document.createElement("option");p.value=String(d),p.textContent=d===0?"0":`0.${"0".repeat(d)}`,o.appendChild(p)}),s.appendChild(a),s.appendChild(o);const l=document.createElement("div");l.className="measure-dock-settings-actions";const c=document.createElement("button");c.type="button",c.className="measure-dock-settings-btn is-save",c.addEventListener("click",()=>{this.saveSettings()});const h=document.createElement("button");return h.type="button",h.className="measure-dock-settings-btn is-back",h.addEventListener("click",()=>{this.closeSettingsView()}),l.appendChild(c),l.appendChild(h),e.appendChild(t),e.appendChild(s),e.appendChild(l),{settingsView:e,settingsUnitLabel:i,settingsPrecisionLabel:a,settingsUnitSelect:n,settingsPrecisionSelect:o,settingsSaveBtn:c,settingsBackBtn:h}}createClearHeightOptionButton(e){const t=document.createElement("button");return t.type="button",t.className="measure-dock-clearheight-btn",t.addEventListener("click",e),t}createModeButton(e){const t=document.createElement("button");return t.type="button",t.className="measure-dock-panel-mode-btn",t.dataset.mode=e,t.innerHTML=`<span class="measure-dock-panel-mode-icon">${Hl[e].icon}</span>`,t.addEventListener("click",()=>{this.switchMode(e)}),this.modeButtons.set(e,t),t}createIconButton(e,t){const i=document.createElement("button");return i.type="button",i.className=`measure-dock-panel-action-btn ${e}`,i.innerHTML=t,i}applyExpandedState(){this.secondaryRow.style.display=this.isExpanded?"grid":"none",this.expandBtn.classList.toggle("is-expanded",this.isExpanded),this.expandBtn.classList.toggle("is-collapsed",!this.isExpanded)}openSettingsView(){this.lockPanelWidth(),this.view="settings",this.syncSettingsFormFromConfig(),this.applyViewState()}closeSettingsView(){this.view==="settings"&&(this.view="main",this.unlockPanelWidth(),this.applyViewState())}saveSettings(){const e=this.settingsUnitSelect.value,t=Number(this.settingsPrecisionSelect.value);!this.isValidUnit(e)||!this.isValidPrecision(t)||(this.config={unit:e,precision:t},this.saveConfigToCache(this.config),this.options.onConfigSave?.(this.getConfig()),this.view="main",this.unlockPanelWidth(),this.applyViewState())}lockPanelWidth(){const e=this.element.getBoundingClientRect().width;e<=0||(this.lockedWidthPx=Math.ceil(e),this.element.style.width=`${this.lockedWidthPx}px`)}unlockPanelWidth(){this.lockedWidthPx=null,this.element.style.removeProperty("width")}syncSettingsFormFromConfig(){this.settingsUnitSelect.value=this.config.unit,this.settingsPrecisionSelect.value=String(this.config.precision)}applyViewState(){const e=this.view==="main";this.mainView.style.display=e?"block":"none",this.settingsView.style.display=e?"none":"flex"}applyClearHeightOptionsState(){this.clearHeightOptions.classList.remove("is-visible");for(const[e,t]of this.directionButtons.entries())t.classList.toggle("is-active",e===this.clearHeightDirection);for(const[e,t]of this.selectTypeButtons.entries())t.classList.toggle("is-active",e===this.clearHeightSelectType)}setClearHeightDirection(e){this.clearHeightDirection!==e&&(this.clearHeightDirection=e,this.applyClearHeightOptionsState(),this.options.onClearHeightDirectionChange?.(e))}setClearHeightSelectType(e){this.clearHeightSelectType!==e&&(this.clearHeightSelectType=e,this.applyClearHeightOptionsState(),this.options.onClearHeightSelectTypeChange?.(e))}loadConfigFromCache(){try{const e=localStorage.getItem(tM);if(!e)return null;const t=JSON.parse(e);return!t||typeof t!="object"||!this.isValidUnit(t.unit)||!this.isValidPrecision(t.precision)?null:{unit:t.unit,precision:t.precision}}catch{return null}}saveConfigToCache(e){try{localStorage.setItem(tM,JSON.stringify(e))}catch{return}}isValidUnit(e){return e==="m"||e==="cm"||e==="mm"||e==="km"}isValidPrecision(e){return e===0||e===1||e===2||e===3}syncActiveMode(e){for(const[t,i]of this.modeButtons.entries())i.classList.toggle("is-active",t===e)}}class iM extends Hn{panel=null;unsubscribeTheme=null;unsubscribeLocale=null;unsubscribeDockState=null;unsubscribeMeasureEvents=null;constructor(e){super(e)}init(){this.unsubscribeTheme||(this.unsubscribeTheme=ht.subscribe(()=>{this.applyPresentation()})),this.unsubscribeLocale||(this.unsubscribeLocale=Kt.subscribe(()=>{this.applyPresentation()})),this.unsubscribeDockState||(this.unsubscribeDockState=this.registry.bottomDock?.onStateChange(e=>{if(e.id!=="measure"||e.open){e.id==="measure"&&e.open&&this.ensureMeasureEventSubscription();return}this.engineComponent?.deactivateMeasure()})??null),this.ensureMeasureEventSubscription()}destroy(){this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeDockState&&(this.unsubscribeDockState(),this.unsubscribeDockState=null),this.unsubscribeMeasureEvents&&(this.unsubscribeMeasureEvents(),this.unsubscribeMeasureEvents=null),this.panel?.destroy(),this.panel=null,super.destroy()}getPanelElement(){if(this.ensureMeasureEventSubscription(),this.panel)this.panel.switchMode("distance");else{this.panel=new i9({defaultMode:"distance",defaultExpanded:!1,defaultClearHeightDirection:1,defaultClearHeightSelectType:"point",onModeChange:t=>{this.engineComponent?.activateMeasure(t)},onClearAll:()=>{this.engineComponent?.clearAllMeasures()},onConfigSave:t=>{this.engineComponent?.saveMeasureSetting({unit:t.unit,precision:t.precision})},onClearHeightDirectionChange:t=>{this.engineComponent?.setClearHeightDirection(t)},onClearHeightSelectTypeChange:t=>{this.engineComponent?.setClearHeightSelectType(t)}}),this.panel.init(),this.panel.switchMode("distance"),this.engineComponent?.setClearHeightDirection(1),this.engineComponent?.setClearHeightSelectType("point");const e=this.panel.getConfig();this.engineComponent?.saveMeasureSetting({unit:e.unit,precision:e.precision})}return this.applyPresentation(),this.panel.element}ensureMeasureEventSubscription(){if(this.unsubscribeMeasureEvents)return;const e=this.engineComponent;if(!e){console.warn("[MeasureDockManager] skip callback binding: engine component not ready yet");return}const t=n=>{this.handleMeasureCallback("measure-changed",n)},i=n=>{this.handleMeasureCallback("measure-click",n)};e.onRawEvent("measure-changed",t),e.onRawEvent("measure-click",i),this.unsubscribeMeasureEvents=()=>{e.offRawEvent("measure-changed",t),e.offRawEvent("measure-click",i)},console.log("[MeasureDockManager] raw event callbacks bound")}applyPresentation(){this.panel&&(this.panel.setTheme(ht.getTheme()),this.panel.setLocales())}handleMeasureCallback(e,t){const i=this.registry.bottomDock?.isOpen("measure")??!1,n=eM(t.type);if(console.log("[MeasureDockManager] callback received",{event:e,type:t.type,mode:n,dockOpen:i,hasPanel:!!this.panel}),!i){console.log("[MeasureDockManager] skip mode switch: measure dock is closed");return}if(!n||!this.panel){console.log("[MeasureDockManager] skip mode switch: invalid mode or panel not ready");return}this.panel.switchMode(n,!1),this.engineComponent?.activateMeasure(n),console.log("[MeasureDockManager] switched mode by callback",{event:e,mode:n})}}class n9{element;options;typeButtons=new Map;axisButtons=new Map;toolContainer;axisPanel;divider;activeType;activeAxis;isHidden;constructor(e={}){this.options=e,this.activeType=e.defaultType??null,this.activeAxis=e.defaultAxis??"x",this.isHidden=e.defaultHidden??!1;const{root:t,toolContainer:i,axisPanel:n,divider:s}=this.createDom();this.element=t,this.toolContainer=i,this.axisPanel=n,this.divider=s}init(){this.applyTypeState(),this.applyAxisState(),this.renderTools(),this.setLocales()}setTheme(e){const t=this.element.style;t.setProperty("--bim-text-primary",e.textPrimary),t.setProperty("--bim-text-secondary",e.textSecondary),t.setProperty("--bim-border-default",e.borderDefault),t.setProperty("--bim-border-strong",e.borderStrong),t.setProperty("--bim-bg-inset",e.bgInset),t.setProperty("--bim-bg-elevated",e.bgElevated),t.setProperty("--bim-primary",e.primary),t.setProperty("--bim-primary-subtle",e.primarySubtle),t.setProperty("--bim-component-bg-hover",e.componentBgHover)}setLocales(){this.typeButtons.get("face").dataset.tooltip=Ee("toolbar.sectionPlane"),this.typeButtons.get("axis").dataset.tooltip=Ee("toolbar.sectionAxis"),this.typeButtons.get("box").dataset.tooltip=Ee("toolbar.sectionBox"),this.axisButtons.get("x").dataset.label="X",this.axisButtons.get("y").dataset.label="Y",this.axisButtons.get("z").dataset.label="Z",this.typeButtons.forEach(e=>{e.setAttribute("aria-label",e.dataset.tooltip??"")}),this.axisButtons.forEach(e=>{e.setAttribute("aria-label",e.dataset.label??"")}),this.renderTools()}destroy(){this.element.remove()}resetForOpen(){this.activeType=null,this.isHidden=!1,this.applyTypeState(),this.renderTools()}getActiveType(){return this.activeType}getActiveAxis(){return this.activeAxis}createDom(){const e=document.createElement("div");e.className="section-dock-panel";const t=document.createElement("div");t.className="section-dock-axis-panel",["x","y","z"].forEach(h=>{const d=document.createElement("button");d.type="button",d.className="section-dock-axis-btn",d.textContent=h.toUpperCase(),d.addEventListener("click",()=>{this.handleAxisChange(h)}),this.axisButtons.set(h,d),t.appendChild(d)});const i=document.createElement("div");i.className="section-dock-main";const n=document.createElement("div");n.className="section-dock-types";const s=this.createTypeButton("face",It("拾曲面剖切")),a=this.createTypeButton("axis",It("轴向剖切")),o=this.createTypeButton("box",It("剖切盒"));n.appendChild(s),n.appendChild(a),n.appendChild(o);const l=document.createElement("div");l.className="section-dock-divider";const c=document.createElement("div");return c.className="section-dock-tools",i.appendChild(n),i.appendChild(l),i.appendChild(c),e.appendChild(t),e.appendChild(i),{root:e,toolContainer:c,axisPanel:t,divider:l}}createTypeButton(e,t){const i=document.createElement("button");i.type="button",i.className="section-dock-type-btn";const n=document.createElement("span");return n.className="section-dock-type-icon",n.innerHTML=t,i.appendChild(n),i.addEventListener("click",()=>{this.handleTypeChange(e)}),this.typeButtons.set(e,i),i}handleTypeChange(e){this.activeType!==e&&(this.activeType=e,this.applyTypeState(),this.renderTools(),this.isHidden&&(this.isHidden=!1,this.options.onHideToggle?.(!1)),this.options.onTypeChange?.(e,this.activeAxis))}handleAxisChange(e){this.activeAxis!==e&&(this.activeAxis=e,this.applyAxisState(),this.activeType==="axis"&&this.options.onAxisChange?.(e))}applyTypeState(){this.typeButtons.forEach((t,i)=>{t.classList.toggle("is-active",i===this.activeType)});const e=this.activeType==="axis";this.axisPanel.classList.toggle("is-visible",e)}applyAxisState(){this.axisButtons.forEach((e,t)=>{e.classList.toggle("is-active",t===this.activeAxis)})}renderTools(){if(this.toolContainer.innerHTML="",!this.activeType){this.divider.classList.add("is-hidden");return}this.divider.classList.remove("is-hidden"),this.getToolsForType(this.activeType).forEach(e=>{const t=document.createElement("button");t.type="button",t.className="section-dock-tool-btn",e.isActive&&t.classList.add("is-active");const i=document.createElement("span");i.className="section-dock-tool-icon",i.innerHTML=It(e.iconName),t.appendChild(i);const n=Ee(e.textKey);t.dataset.tooltip=n,t.setAttribute("aria-label",n),t.addEventListener("click",e.onClick),this.toolContainer.appendChild(t)})}getToolsForType(e){const t={key:"hide",iconName:"隐藏",textKey:e==="box"?"sectionBox.actions.hide":e==="axis"?"sectionAxis.actions.hide":"sectionPlane.actions.hide",isActive:this.isHidden,onClick:()=>{this.isHidden=!this.isHidden,this.options.onHideToggle?.(this.isHidden),this.renderTools()}},i={key:"reverse",iconName:"反向",textKey:e==="axis"?"sectionAxis.actions.reverse":e==="box"?"sectionBox.actions.reverse":"sectionPlane.actions.reverse",onClick:()=>{this.options.onReverse?.()}};return e==="axis"?[t,i,{key:"reset",iconName:"重置",textKey:"sectionAxis.actions.reset",onClick:()=>{this.isHidden=!1,this.options.onReset?.(e,this.activeAxis),this.renderTools()}}]:e==="box"?[t,{key:"fit",iconName:"适应到模型",textKey:"sectionBox.actions.fitToModel",onClick:()=>{this.options.onFitToModel?.()}},{key:"reset",iconName:"重置",textKey:"sectionBox.actions.reset",onClick:()=>{this.isHidden=!1,this.options.onReset?.(e,this.activeAxis),this.renderTools()}}]:[t,i,{key:"reset",iconName:"重置",textKey:"sectionPlane.actions.reset",onClick:()=>{this.isHidden=!1,this.options.onReset?.(e,this.activeAxis),this.renderTools()}}]}}class nM extends Hn{panel=null;unsubscribeTheme=null;unsubscribeLocale=null;unsubscribeDockState=null;constructor(e){super(e)}init(){this.unsubscribeTheme||(this.unsubscribeTheme=ht.subscribe(()=>{this.applyPresentation()})),this.unsubscribeLocale||(this.unsubscribeLocale=Kt.subscribe(()=>{this.applyPresentation()})),this.unsubscribeDockState||(this.unsubscribeDockState=this.registry.bottomDock?.onStateChange(e=>{if(e.id==="section"){if(!e.open){console.log("deactivateSection"),this.engineComponent?.deactivateSection();return}this.panel?.resetForOpen()}})??null)}destroy(){this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeDockState&&(this.unsubscribeDockState(),this.unsubscribeDockState=null),this.panel?.destroy(),this.panel=null,super.destroy()}getPanelElement(){return this.panel||(this.panel=new n9({defaultType:null,defaultAxis:"x",defaultHidden:!1,onTypeChange:(e,t)=>{this.activateByType(e,t)},onAxisChange:e=>{this.panel?.getActiveType()==="axis"&&this.engineComponent?.activeSection(e)},onHideToggle:e=>{if(e){this.engineComponent?.hideSection();return}this.engineComponent?.recoverSection()},onReverse:()=>{this.engineComponent?.reverseSection()},onReset:(e,t)=>{this.engineComponent?.deactivateSection(),this.activateByType(e,t)},onFitToModel:()=>{this.engineComponent?.scaleSectionBox()}}),this.panel.init()),this.panel.resetForOpen(),this.applyPresentation(),this.panel.element}activateByType(e,t){if(e==="face"){this.engineComponent?.activeSection("face");return}if(e==="box"){this.engineComponent?.activeSection("box");return}this.engineComponent?.activeSection(t)}applyPresentation(){this.panel&&(this.panel.setTheme(ht.getTheme()),this.panel.setLocales())}}class sM{element;options;state={mode:"none",isPlanViewActive:!1,speed:1,gravity:!1,collision:!1,characterModel:"construction-worker",walkMode:"walk"};planViewBtn;pathModeBtn;settingsContainer;speedControl;speedDecreaseBtn;speedIncreaseBtn;speedDisplay;gravityCheckbox;gravityLabel;collisionCheckbox;collisionLabel;characterModelSelect;characterModelLabel;walkModeSelect;walkModeLabel;exitBtn;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.state.speed=e.defaultSpeed??1,this.state.gravity=e.defaultGravity??!1,this.state.collision=e.defaultCollision??!1,this.state.characterModel=e.defaultCharacterModel??"construction-worker",this.state.walkMode=e.defaultWalkMode??"walk"}init(){this.element=this.createPanel(),this.updateSettingsView(),this.unsubscribeLocale=Kt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ht.subscribe(e=>this.setTheme(e)),this.setLocales(),this.setTheme(ht.getTheme())}setPlanViewActive(e){this.state.isPlanViewActive=e,this.updateButtonStates()}setPathModeActive(e){if(!e&&this.state.mode!=="path")return;const t=e?"path":"none";this.setMode(t)}getState(){return{...this.state}}createPanel(){const e=document.createElement("div");e.className="walk-control-panel";const t=this.createLeftButtons(),i=document.createElement("div");i.className="walk-divider",this.settingsContainer=this.createSettingsContainer();const n=document.createElement("div");n.className="walk-divider";const s=this.createExitButton();return e.appendChild(t),e.appendChild(i),e.appendChild(this.settingsContainer),e.appendChild(n),e.appendChild(s),e}createLeftButtons(){const e=document.createElement("div");return e.className="walk-control-left",this.planViewBtn=this.createIconButton("plan-view",()=>{this.state.isPlanViewActive=!this.state.isPlanViewActive,this.updateButtonStates(),this.options.onPlanViewToggle?.(this.state.isPlanViewActive)}),this.pathModeBtn=this.createIconButton("path",()=>{const t=this.state.mode==="path"?"none":"path";this.setMode(t),this.options.onPathModeToggle?.(t==="path")}),e.appendChild(this.planViewBtn),e.appendChild(this.pathModeBtn),e}createSettingsContainer(){const e=document.createElement("div");e.className="walk-control-settings",this.speedControl=this.createSpeedControl();const t=document.createElement("label");t.className="walk-checkbox-wrapper walk-checkbox-gravity",this.gravityCheckbox=document.createElement("input"),this.gravityCheckbox.type="checkbox",this.gravityCheckbox.className="walk-checkbox",this.gravityCheckbox.checked=this.state.gravity,this.gravityCheckbox.addEventListener("change",()=>{this.state.gravity=this.gravityCheckbox.checked,this.options.onGravityToggle?.(this.state.gravity)}),this.gravityLabel=document.createElement("span"),this.gravityLabel.className="walk-checkbox-label",t.appendChild(this.gravityCheckbox),t.appendChild(this.gravityLabel);const i=document.createElement("label");i.className="walk-checkbox-wrapper walk-checkbox-collision",this.collisionCheckbox=document.createElement("input"),this.collisionCheckbox.type="checkbox",this.collisionCheckbox.className="walk-checkbox",this.collisionCheckbox.checked=this.state.collision,this.collisionCheckbox.addEventListener("change",()=>{this.state.collision=this.collisionCheckbox.checked,this.options.onCollisionToggle?.(this.state.collision)}),this.collisionLabel=document.createElement("span"),this.collisionLabel.className="walk-checkbox-label",i.appendChild(this.collisionCheckbox),i.appendChild(this.collisionLabel);const n=document.createElement("div");n.className="walk-select-wrapper walk-select-wrapper-character-model",this.characterModelLabel=document.createElement("label"),this.characterModelLabel.className="walk-select-label",this.characterModelSelect=document.createElement("select"),this.characterModelSelect.className="walk-select walk-select-character-model",this.characterModelSelect.addEventListener("change",()=>{this.state.characterModel=this.characterModelSelect.value,this.options.onCharacterModelChange?.(this.state.characterModel)}),n.appendChild(this.characterModelLabel),n.appendChild(this.characterModelSelect);const s=document.createElement("div");return s.className="walk-select-wrapper walk-select-wrapper-walk-mode",this.walkModeLabel=document.createElement("label"),this.walkModeLabel.className="walk-select-label",this.walkModeSelect=document.createElement("select"),this.walkModeSelect.className="walk-select walk-select-walk-mode",this.walkModeSelect.addEventListener("change",()=>{this.state.walkMode=this.walkModeSelect.value,this.options.onWalkModeChange?.(this.state.walkMode)}),s.appendChild(this.walkModeLabel),s.appendChild(this.walkModeSelect),e.appendChild(this.speedControl),e.appendChild(n),e.appendChild(s),e.appendChild(t),e.appendChild(i),e}createSpeedControl(){const e=document.createElement("div");e.className="walk-speed-control";const t=document.createElement("label");t.className="walk-speed-label",t.textContent=Ee("walkControl.speed");const i=document.createElement("div");return i.className="walk-speed-group",this.speedDecreaseBtn=document.createElement("button"),this.speedDecreaseBtn.className="walk-speed-btn",this.speedDecreaseBtn.textContent="-",this.speedDecreaseBtn.addEventListener("click",()=>{this.state.speed>1&&(this.state.speed--,this.updateSpeedDisplay(),this.options.onSpeedChange?.(this.state.speed))}),this.speedDisplay=document.createElement("div"),this.speedDisplay.className="walk-speed-display",this.speedDisplay.textContent=`${this.state.speed}X`,this.speedIncreaseBtn=document.createElement("button"),this.speedIncreaseBtn.className="walk-speed-btn",this.speedIncreaseBtn.textContent="+",this.speedIncreaseBtn.addEventListener("click",()=>{this.state.speed<10&&(this.state.speed++,this.updateSpeedDisplay(),this.options.onSpeedChange?.(this.state.speed))}),i.appendChild(this.speedDecreaseBtn),i.appendChild(this.speedDisplay),i.appendChild(this.speedIncreaseBtn),e.appendChild(t),e.appendChild(i),e}createIconButton(e,t){const i=document.createElement("button");return i.className=`walk-icon-btn walk-icon-btn-${e}`,i.innerHTML=this.getIconSVG(e),i.addEventListener("click",t),i}createExitButton(){const e=document.createElement("button");return e.className="walk-exit-btn",e.addEventListener("click",()=>{this.options.onExit?.()}),this.exitBtn=e,e}setMode(e){const t=this.state.mode;t==="walk"&&e!=="walk"&&this.options.onWalkModeToggle?.(!1),t==="path"&&e!=="path"&&this.options.onPathModeToggle?.(!1),this.state.mode=e,e==="path"?(this.state.gravity=!1,this.state.collision=!1,this.gravityCheckbox.checked=!1,this.gravityCheckbox.disabled=!0,this.collisionCheckbox.checked=!1,this.collisionCheckbox.disabled=!0):(this.gravityCheckbox.disabled=!1,this.collisionCheckbox.disabled=!1),this.updateButtonStates(),this.updateSettingsView(),this.updateSpeedButtonStates()}updateButtonStates(){this.planViewBtn.classList.toggle("active",this.state.isPlanViewActive),this.pathModeBtn.classList.toggle("active",this.state.mode==="path")}updateSettingsView(){const e=this.speedControl,t=this.gravityCheckbox.parentElement,i=this.collisionCheckbox.parentElement,n=this.characterModelSelect.parentElement,s=this.walkModeSelect.parentElement;this.state.mode==="walk"?(e.style.display="none",t.style.display="flex",i.style.display="flex",n.style.display="flex",s.style.display="flex"):(e.style.display="flex",t.style.display="flex",i.style.display="flex",n.style.display="none",s.style.display="none")}updateSpeedDisplay(){this.speedDisplay.textContent=`${this.state.speed}X`,this.updateSpeedButtonStates()}updateSpeedButtonStates(){this.speedDecreaseBtn.disabled=this.state.speed<=1,this.speedIncreaseBtn.disabled=this.state.speed>=10}getIconSVG(e){return{"plan-view":It("地图"),path:It("路径漫游"),walk:It("第一人称漫游")}[e]||""}setLocales(){const e=this.speedControl.querySelector(".walk-speed-label");e&&(e.textContent=Ee("walkControl.speed")),this.gravityLabel.textContent=Ee("walkControl.gravity"),this.collisionLabel.textContent=Ee("walkControl.collision"),this.characterModelLabel.textContent=Ee("walkControl.characterModel.label"),this.characterModelSelect.innerHTML="";const t=document.createElement("option");t.value="construction-worker",t.textContent=Ee("walkControl.characterModel.constructionWorker"),t.selected=this.state.characterModel==="construction-worker",this.characterModelSelect.appendChild(t);const i=document.createElement("option");i.value="office-male",i.textContent=Ee("walkControl.characterModel.officeMale"),i.selected=this.state.characterModel==="office-male",this.characterModelSelect.appendChild(i),this.walkModeLabel.textContent=Ee("walkControl.walkMode.label"),this.walkModeSelect.innerHTML="";const n=document.createElement("option");n.value="walk",n.textContent=Ee("walkControl.walkMode.walk"),n.selected=this.state.walkMode==="walk",this.walkModeSelect.appendChild(n);const s=document.createElement("option");s.value="run",s.textContent=Ee("walkControl.walkMode.run"),s.selected=this.state.walkMode==="run",this.walkModeSelect.appendChild(s),this.exitBtn.textContent=Ee("walkControl.exit")}setTheme(e){if(!this.element)return;const t=this.element.style;t.setProperty("--bim-bg-base",e.bgBase??"#152232"),t.setProperty("--bim-bg-elevated",e.bgElevated??"#1f2d3e"),t.setProperty("--bim-bg-inset",e.bgInset??"#152232"),t.setProperty("--bim-border-default",e.borderDefault??"#334155"),t.setProperty("--bim-border-strong",e.borderStrong??"#475569"),t.setProperty("--bim-border-subtle",e.borderSubtle??"#1e293b"),t.setProperty("--bim-divider",e.divider??"#334155"),t.setProperty("--bim-shadow-xl",e.shadowXl??"0 20px 40px rgba(0, 0, 0, 0.3)"),t.setProperty("--bim-primary",e.primary??"#3b82f6"),t.setProperty("--bim-primary-hover",e.primaryHover??"#60a5fa"),t.setProperty("--bim-primary-subtle",e.primarySubtle??"rgba(59, 130, 246, 0.15)"),t.setProperty("--bim-text-primary",e.textPrimary??"#ffffff"),t.setProperty("--bim-text-inverse",e.textInverse??"#152232"),t.setProperty("--bim-icon-default",e.iconDefault??"#ffffff"),t.setProperty("--bim-component-bg-hover",e.componentBgHover??"rgba(248, 250, 252, 0.06)"),t.setProperty("--bim-component-bg-active",e.componentBgActive??"rgba(248, 250, 252, 0.1)")}destroy(){this.unsubscribeLocale?.(),this.unsubscribeTheme?.(),this.element&&this.element.parentElement&&this.element.parentElement.removeChild(this.element)}}class s9{element;panel;constructor(e={}){this.panel=new sM(e),this.panel.init(),this.element=this.panel.element,this.element.classList.add("walk-dock-panel")}init(){}setPlanViewActive(e){this.panel.setPlanViewActive(e)}setLocales(){this.panel.setLocales()}setTheme(e){this.panel.setTheme(e)}getState(){return this.panel.getState()}destroy(){this.panel.destroy()}}class uo extends Hn{dialog=null;isVisible=!1;constructor(e){super(e)}get dialogWidth(){return 300}get dialogHeight(){return"auto"}get dialogOptions(){return{draggable:!0,resizable:!1}}onDialogClose(){}onDialogCreated(){}onBeforeDestroy(){}getDialogPosition(){const e=this.registry.container;if(!e)return{x:100,y:100};const t=e.clientWidth,i=e.clientHeight,n=this.dialogWidth,s=typeof this.dialogHeight=="number"?this.dialogHeight:300;return{x:t-n-20,y:(i-s)/2}}show(){if(!this.registry.dialog||!this.registry.container){console.warn(`[${this.dialogId}] Dialog manager or container is not initialized`);return}this.dialog&&this.destroyDialog();const e=this.getDialogPosition(),t=this.createContent(),i=this.dialogOptions;this.dialog=this.registry.dialog.create({id:this.dialogId,title:this.dialogTitle,content:t,width:this.dialogWidth,height:this.dialogHeight,position:e,draggable:i.draggable,resizable:i.resizable,onClose:()=>{this.onDialogClose(),this.destroyDialog()}}),this.dialog.init(),this.isVisible=!0,this.onDialogCreated()}hide(){this.destroyDialog()}toggle(){this.isVisible?this.hide():this.show()}isOpen(){return this.isVisible}destroyDialog(){this.onBeforeDestroy(),this.dialog&&(this.dialog.destroy(),this.dialog=null),this.isVisible=!1}destroy(){this.destroyDialog(),super.destroy()}}class r9{element;registry;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e){this.registry=e}points=[];duration=1e4;loop=!1;playingPointIndex=-1;isPlaying=!1;init(){this.element=document.createElement("div"),this.element.className="walk-path-panel",this.unsubscribeLocale=Kt.subscribe(()=>this.render()),this.unsubscribeTheme=ht.subscribe(e=>this.setTheme(e)),this.loadPointsFromEngine(),this.render(),this.setTheme(ht.getTheme())}loadPointsFromEngine(){const e=this.registry.engine3d?.getEngineComponent()?.pathRoamingGetPoints()??[];this.points=e.map((t,i)=>({index:i}))}render(){this.element.innerHTML="";const e=this.createSettingsSection();this.element.appendChild(e);const t=this.createPointsSection();this.element.appendChild(t);const i=this.createPlayButton();this.element.appendChild(i)}createSettingsSection(){const e=document.createElement("div");e.className="walk-path-settings";const t=document.createElement("div");t.className="walk-path-form-group";const i=document.createElement("label");i.textContent=Ee("walkControl.path.duration");const n=document.createElement("div");n.className="walk-path-input-wrapper";const s=document.createElement("input");s.type="number",s.className="walk-path-input",s.value=String(this.duration/1e3),s.min="1",s.oninput=h=>{const d=parseInt(h.target.value)||1;this.duration=d*1e3};const a=document.createElement("span");a.className="walk-path-unit",a.textContent=Ee("walkControl.path.durationUnit"),n.appendChild(s),n.appendChild(a),t.appendChild(i),t.appendChild(n);const o=document.createElement("div");o.className="walk-path-form-group walk-path-form-group-inline";const l=document.createElement("input");l.type="checkbox",l.id="walk-path-loop-checkbox",l.className="walk-path-checkbox",l.checked=this.loop,l.onchange=h=>{this.loop=h.target.checked};const c=document.createElement("label");return c.htmlFor="walk-path-loop-checkbox",c.textContent=Ee("walkControl.path.loop"),o.appendChild(l),o.appendChild(c),e.appendChild(t),e.appendChild(o),e}createPointsSection(){const e=document.createElement("div");e.className="walk-path-points-section";const t=document.createElement("div");t.className="walk-path-points-toolbar";const i=document.createElement("button");i.className="walk-path-btn walk-path-btn-small",i.textContent=`+ ${Ee("walkControl.path.addPoint")}`,i.onclick=()=>this.addPoint();const n=document.createElement("button");n.className="walk-path-btn walk-path-btn-small walk-path-btn-danger",n.textContent=Ee("walkControl.path.deleteAll"),n.onclick=()=>this.deleteAllPoints(),t.appendChild(i),t.appendChild(n),e.appendChild(t);const s=document.createElement("div");if(s.className="walk-path-points-list",this.points.length===0){const a=document.createElement("div");a.className="walk-path-empty",a.textContent=Ee("walkControl.path.noPoints"),s.appendChild(a)}else this.points.forEach((a,o)=>{const l=this.createPointItem(o);s.appendChild(l)});return e.appendChild(s),e}createPointItem(e){const t=document.createElement("div");t.className="walk-path-point-item",this.playingPointIndex===e&&t.classList.add("walk-path-point-item-active");const i=document.createElement("span");i.className="walk-path-point-name",i.textContent=`${Ee("walkControl.path.point")}${e}`;const n=document.createElement("div");n.className="walk-path-point-actions";const s=document.createElement("button");s.className="walk-path-btn-icon",s.innerHTML="▶",s.title=Ee("walkControl.path.play"),s.onclick=o=>{o.stopPropagation(),this.jumpToPoint(e)};const a=document.createElement("button");return a.className="walk-path-btn-icon walk-path-btn-icon-danger",a.innerHTML="×",a.onclick=o=>{o.stopPropagation(),this.deletePoint(e)},n.appendChild(s),n.appendChild(a),t.appendChild(i),t.appendChild(n),t}createPlayButton(){const e=document.createElement("div");e.className="walk-path-btn-group";const t=document.createElement("button");t.className="walk-path-btn walk-path-btn-play",t.textContent=`▶ ${Ee("walkControl.path.play")}`,t.disabled=this.points.length===0||this.isPlaying,t.onclick=()=>this.playPath();const i=document.createElement("button");return i.className="walk-path-btn walk-path-btn-stop",i.textContent=`■ ${Ee("walkControl.path.stop")}`,i.disabled=!this.isPlaying,i.onclick=()=>this.stopPath(),e.appendChild(t),e.appendChild(i),e}addPoint(){this.registry.engine3d?.getEngineComponent()?.pathRoamingAddPoint();const e=this.points.length;this.points.push({index:e}),this.render()}deletePoint(e){this.registry.engine3d?.getEngineComponent()?.pathRoamingRemovePoint(e),this.points.splice(e,1),this.points.forEach((t,i)=>t.index=i),this.render()}deleteAllPoints(){this.registry.engine3d?.getEngineComponent()?.pathRoamingClearPoints(),this.points=[],this.render()}jumpToPoint(e){this.registry.engine3d?.getEngineComponent()?.pathRoamingJumpToPoint(e)}playPath(){this.points.length!==0&&(this.isPlaying=!0,this.render(),console.log("[WalkPathPanel] 开始播放漫游",{duration:this.duration,loop:this.loop,pointsCount:this.points.length}),this.registry.engine3d?.getEngineComponent()?.pathRoamingPlay({duration:this.duration,loop:this.loop,onPointComplete:e=>{console.log("[WalkPathPanel] onPointComplete",{pointIndex:e}),this.playingPointIndex=e,this.render()},onComplete:()=>{console.log("[WalkPathPanel] onComplete 播放完成"),this.isPlaying=!1,this.playingPointIndex=-1,this.render()}}))}stopPath(){console.log("[WalkPathPanel] 停止漫游"),this.registry.engine3d?.getEngineComponent()?.pathRoamingStop(),this.isPlaying=!1,this.playingPointIndex=-1,this.render()}setLocales(){this.render()}setTheme(e){this.element&&(this.element.style.setProperty("--bim-text-primary",e.textPrimary??"#fff"),this.element.style.setProperty("--bim-text-secondary",e.textPrimary??"#fff"),this.element.style.setProperty("--bim-bg-elevated",e.bgElevated??"#1f2d3e"),this.element.style.setProperty("--bim-border-default",e.borderDefault??"#334155"),this.element.style.setProperty("--bim-primary",e.primary??"#3b82f6"))}destroy(){this.isPlaying&&this.stopPath(),this.unsubscribeLocale?.(),this.unsubscribeTheme?.(),this.element?.parentElement&&this.element.parentElement.removeChild(this.element)}}class rM extends uo{panel=null;constructor(e){super(e)}get dialogId(){return"walk-path-dialog"}get dialogTitle(){return"walkControl.path.dialogTitle"}get dialogWidth(){return 300}get dialogHeight(){return 450}init(){}getDialogPosition(){const e=this.registry.container;return e?{x:e.clientWidth-this.dialogWidth-20,y:20}:{x:100,y:100}}createContent(){return this.panel=new r9(this.registry),this.panel.init(),this.panel.element}onDialogClose(){this.registry.walkControl&&this.registry.walkControl.panel&&this.registry.walkControl.panel.setPathModeActive(!1)}onBeforeDestroy(){this.panel&&(this.panel.destroy(),this.panel=null)}}class aM extends Hn{panel=null;pathManager=null;unsubscribeDockState=null;constructor(e){super(e)}init(){this.pathManager=new rM(this.registry),this.pathManager.init(),this.unsubscribeDockState||(this.unsubscribeDockState=this.registry.bottomDock?.onStateChange(e=>{if(e.id==="walk"){if(e.open){this.onOpen();return}this.onClose()}})??null)}destroy(){this.unsubscribeDockState&&(this.unsubscribeDockState(),this.unsubscribeDockState=null),this.onClose(),this.pathManager?.destroy(),this.pathManager=null,super.destroy()}getPanelElement(){return this.panel||(this.panel=new s9({onPlanViewToggle:e=>{this.engineComponent?.toggleMiniMap(),this.registry.toolbar?.setBtnActive("map",e),this.emit("walk:plan-view-toggle",{isActive:e})},onPathModeToggle:e=>{e?this.pathManager?.show():this.pathManager?.hide(),this.emit("walk:path-mode-toggle",{isActive:e})},onWalkModeToggle:e=>{e&&this.pathManager?.hide(),this.emit("walk:walk-mode-toggle",{isActive:e})},onSpeedChange:e=>{const t=e*.1;this.engineComponent?.setWalkSpeed(t),this.emit("walk:speed-change",{speed:e})},onGravityToggle:e=>{this.engineComponent?.setWalkGravity(e),this.emit("walk:gravity-toggle",{enabled:e})},onCollisionToggle:e=>{this.engineComponent?.setWalkCollision(e),this.emit("walk:collision-toggle",{enabled:e})},onCharacterModelChange:e=>{},onWalkModeChange:e=>{},onExit:()=>{this.registry.bottomDock?.close("walk")}}),this.panel.init()),this.syncMapState(),this.panel.element}onOpen(){this.engineComponent?.activateFirstPersonMode(),this.syncMapState()}onClose(){this.pathManager?.hide(),this.engineComponent?.getMiniMapState()&&this.engineComponent.toggleMiniMap(),this.engineComponent?.deactivateFirstPersonMode(),this.panel&&(this.panel.destroy(),this.panel=null),this.registry.toolbar?.setBtnActive("map",!1)}syncMapState(){const e=this.engineComponent?.getMiniMapState()??!1;this.panel?.setPlanViewActive(e)}}class kh{element;options;activeMode;isExpanded;result=null;clearHeightDirection=0;clearHeightSelectType="point";config;draftConfig=null;view="main";static CONFIG_CACHE_KEY="bim-engine:measure:config";static DEFAULT_CONFIG={unit:"mm",precision:2};toolButtons=new Map;toggleBtn;toggleTextEl;mainValueRowEl;mainValueValueEl;mainValueLabelEl;mainNumberEl;mainUnitEl;xyzBoxEl;xyzXEl;xyzYEl;xyzZEl;clearBtn;settingsBtn;modeOptionsEl;directionBtns=new Map;selectTypeBtns=new Map;mainViewEl;settingsViewEl;unitSelectEl;precisionSelectEl;saveSettingsBtn;cancelSettingsBtn;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.activeMode=e.defaultMode??"distance",this.isExpanded=e.defaultExpanded??!1,this.config=this.loadConfigFromCache()??{...kh.DEFAULT_CONFIG},this.element=this.createDom()}init(){this.unsubscribeLocale=Kt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ht.subscribe(e=>{this.setTheme(e)}),this.setLocales(),this.setTheme(ht.getTheme()),this.applyExpandedState(),this.applyActiveModeState(),this.applyClearHeightOptionsState(),this.applyViewState(),this.renderResult(),this.options.onModeChange&&this.options.onModeChange(this.activeMode)}setTheme(e){const t=this.element.style;t.setProperty("--bim-bg-inset",e.bgInset??"#152232"),t.setProperty("--bim-bg-elevated",e.bgElevated??"#1f2d3e"),t.setProperty("--bim-border-default",e.borderDefault??"#334155"),t.setProperty("--bim-border-strong",e.borderStrong??"#475569"),t.setProperty("--bim-divider",e.divider??"#334155"),t.setProperty("--bim-primary",e.primary??"#3b82f6"),t.setProperty("--bim-primary-hover",e.primaryHover??"#60a5fa"),t.setProperty("--bim-primary-subtle",e.primarySubtle??"rgba(59, 130, 246, 0.15)"),t.setProperty("--bim-danger",e.danger??"#ef4444"),t.setProperty("--bim-text-primary",e.textPrimary??"#ffffff"),t.setProperty("--bim-text-secondary",e.textSecondary??"#94a3b8"),t.setProperty("--bim-text-tertiary",e.textTertiary??"#64748b"),t.setProperty("--bim-text-inverse",e.textInverse??"#152232"),t.setProperty("--bim-icon-default",e.iconDefault??"#ffffff"),t.setProperty("--bim-component-bg-hover",e.componentBgHover??"rgba(248, 250, 252, 0.06)")}setLocales(){for(const[t,i]of this.toolButtons.entries())i.title=Ee(this.getModeI18nKey(t)),i.setAttribute("aria-label",i.title);this.toggleBtn.title=this.isExpanded?Ee("measure.actions.collapse"):Ee("measure.actions.expand"),this.toggleBtn.setAttribute("aria-label",this.toggleBtn.title),this.toggleTextEl&&(this.toggleTextEl.textContent=this.toggleBtn.title),this.clearBtn.textContent=Ee("measure.actions.clearAll"),this.settingsBtn.title=Ee("measure.actions.settings"),this.settingsBtn.setAttribute("aria-label",this.settingsBtn.title),this.mainValueLabelEl.textContent=Ee(this.getModeValueLabelI18nKey(this.activeMode)),this.element.querySelectorAll("[data-i18n-key]").forEach(t=>{const i=t.dataset.i18nKey;i&&(t.textContent=Ee(i))}),this.saveSettingsBtn.textContent=Ee("measure.settings.save"),this.cancelSettingsBtn.textContent=Ee("measure.settings.cancel")}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove()}getActiveMode(){return this.activeMode}switchMode(e,t=!0){this.setActiveMode(e,t)}setActiveMode(e,t=!0){this.activeMode!==e&&(this.activeMode=e,this.applyActiveModeState(),this.applyClearHeightOptionsState(),this.mainValueLabelEl.textContent=Ee(this.getModeValueLabelI18nKey(this.activeMode)),t&&this.options.onModeChange&&this.options.onModeChange(e),this.renderResult(),this.options.onExpandedChange&&this.options.onExpandedChange(this.isExpanded))}setResult(e){this.result=e,this.renderResult()}clearAll(){this.result=null,this.renderResult(),this.options.onClearAll&&this.options.onClearAll()}openSettings(){this.enterSettingsView(),this.options.onSettings&&this.options.onSettings()}getConfig(){return{...this.config}}setConfig(e,t=!1){const i={unit:e.unit??this.config.unit,precision:e.precision??this.config.precision};this.config=i,t&&this.saveConfigToCache(i),this.renderResult(),this.view==="settings"&&this.syncSettingsFormFromConfig(i)}setExpanded(e){this.isExpanded!==e&&(this.isExpanded=e,this.applyExpandedState(),this.setLocales(),this.options.onExpandedChange&&this.options.onExpandedChange(this.isExpanded))}getExpanded(){return this.isExpanded}createDom(){const e=document.createElement("div");e.className="bim-measure-panel",this.mainViewEl=document.createElement("div"),this.mainViewEl.className="bim-measure-main";const t=document.createElement("div");t.className="bim-measure-tools";const i=document.createElement("div");i.className="bim-measure-tool-grid";const n=`
|
||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||
<circle cx="12" cy="12" r="9"></circle>
|
||
</svg>
|
||
`;for(let A=0;A<JE.length;A++){const m=JE[A],g=Hl[m],f=document.createElement("button");f.type="button",f.className="bim-measure-tool-btn",f.dataset.mode=m;const v=document.createElement("span");v.className="bim-measure-tool-icon",v.innerHTML=g.icon||n,f.appendChild(v),f.addEventListener("click",()=>{this.setActiveMode(m)}),this.toolButtons.set(m,f),i.appendChild(f)}t.appendChild(i);const s=document.createElement("div");s.className="bim-measure-toggle",this.toggleBtn=document.createElement("button"),this.toggleBtn.type="button",this.toggleBtn.className="bim-measure-toggle-btn",this.toggleTextEl=document.createElement("span"),this.toggleTextEl.className="bim-measure-toggle-text";const a=document.createElement("span");a.className="bim-measure-toggle-icon",a.innerHTML=`
|
||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||
<path d="M7 10l5 5 5-5z"></path>
|
||
</svg>
|
||
`,this.toggleBtn.appendChild(this.toggleTextEl),this.toggleBtn.appendChild(a),this.toggleBtn.addEventListener("click",()=>{this.isExpanded=!this.isExpanded,this.applyExpandedState(),this.setLocales(),this.options.onExpandedChange&&this.options.onExpandedChange(this.isExpanded)}),s.appendChild(this.toggleBtn),t.appendChild(s),this.mainViewEl.appendChild(t),this.modeOptionsEl=this.createModeOptionsDom(),this.mainViewEl.appendChild(this.modeOptionsEl);const o=document.createElement("div");o.className="bim-measure-result";const l=document.createElement("div");l.className="bim-measure-row",this.mainValueRowEl=l;const c=document.createElement("span");c.className="label",this.mainValueLabelEl=c;const h=document.createElement("span");h.className="value",this.mainValueValueEl=h,this.mainNumberEl=document.createElement("span"),this.mainNumberEl.className="bim-measure-main-number",this.mainUnitEl=document.createElement("span"),this.mainUnitEl.className="bim-measure-main-unit",this.mainValueValueEl.appendChild(this.mainNumberEl),this.mainValueValueEl.appendChild(document.createTextNode(" ")),this.mainValueValueEl.appendChild(this.mainUnitEl),l.appendChild(c),l.appendChild(h),o.appendChild(l);const d=document.createElement("div");d.className="bim-measure-xyz",this.xyzBoxEl=d;const p=(A,m,g)=>{const f=document.createElement("div");f.className="bim-measure-row";const v=document.createElement("span");v.className="label",v.dataset.i18nKey=A;const b=document.createElement("span");return b.className=`value ${m}`,g(b),f.appendChild(v),f.appendChild(b),f};d.appendChild(p("measure.labels.x","bim-measure-xyz-x",A=>this.xyzXEl=A)),d.appendChild(p("measure.labels.y","bim-measure-xyz-y",A=>this.xyzYEl=A)),d.appendChild(p("measure.labels.z","bim-measure-xyz-z",A=>this.xyzZEl=A)),o.appendChild(d),this.mainViewEl.appendChild(o);const u=document.createElement("div");return u.className="bim-measure-footer",this.clearBtn=document.createElement("button"),this.clearBtn.type="button",this.clearBtn.className="bim-measure-clear-btn",this.clearBtn.addEventListener("click",()=>{this.clearAll()}),this.settingsBtn=document.createElement("button"),this.settingsBtn.type="button",this.settingsBtn.className="bim-measure-settings-btn",this.settingsBtn.innerHTML=`
|
||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||
<path d="M19.14 12.94c.04-.31.06-.63.06-.94s-.02-.63-.06-.94l2.03-1.58a.5.5 0 0 0 .12-.64l-1.92-3.32a.5.5 0 0 0-.6-.22l-2.39.96a7.27 7.27 0 0 0-1.63-.94l-.36-2.54A.5.5 0 0 0 13.9 1h-3.8a.5.5 0 0 0-.49.42l-.36 2.54c-.58.23-1.12.54-1.63.94l-2.39-.96a.5.5 0 0 0-.6.22L2.71 7.48a.5.5 0 0 0 .12.64l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94L2.83 14.52a.5.5 0 0 0-.12.64l1.92 3.32c.13.22.39.3.6.22l2.39-.96c.5.4 1.05.71 1.63.94l.36 2.54c.04.24.25.42.49.42h3.8c.24 0 .45-.18.49-.42l.36-2.54c.58-.23 1.12-.54 1.63-.94l2.39.96c.22.09.47 0 .6-.22l1.92-3.32a.5.5 0 0 0-.12-.64l-2.03-1.58zM12 15.5A3.5 3.5 0 1 1 12 8a3.5 3.5 0 0 1 0 7.5z"></path>
|
||
</svg>
|
||
`,this.settingsBtn.addEventListener("click",()=>{this.openSettings()}),u.appendChild(this.clearBtn),u.appendChild(this.settingsBtn),this.mainViewEl.appendChild(u),this.settingsViewEl=this.createSettingsDom(),e.appendChild(this.mainViewEl),e.appendChild(this.settingsViewEl),e}createSettingsDom(){const e=document.createElement("div");e.className="bim-measure-settings";const t=document.createElement("div");t.className="bim-measure-settings-title",t.dataset.i18nKey="measure.settings.title",e.appendChild(t);const i=document.createElement("div");i.className="bim-measure-settings-row";const n=document.createElement("div");n.className="label",n.dataset.i18nKey="measure.settings.unit",this.unitSelectEl=document.createElement("select"),this.unitSelectEl.className="bim-measure-settings-select",this.unitSelectEl.appendChild(this.makeOption("m")),this.unitSelectEl.appendChild(this.makeOption("cm")),this.unitSelectEl.appendChild(this.makeOption("mm")),this.unitSelectEl.appendChild(this.makeOption("km")),i.appendChild(n),i.appendChild(this.unitSelectEl),e.appendChild(i);const s=document.createElement("div");s.className="bim-measure-settings-hint",s.dataset.i18nKey="measure.settings.hint",e.appendChild(s);const a=document.createElement("div");a.className="bim-measure-settings-row";const o=document.createElement("div");o.className="label",o.dataset.i18nKey="measure.settings.precision",this.precisionSelectEl=document.createElement("select"),this.precisionSelectEl.className="bim-measure-settings-select",this.precisionSelectEl.appendChild(this.makePrecisionOption(0)),this.precisionSelectEl.appendChild(this.makePrecisionOption(1)),this.precisionSelectEl.appendChild(this.makePrecisionOption(2)),this.precisionSelectEl.appendChild(this.makePrecisionOption(3)),a.appendChild(o),a.appendChild(this.precisionSelectEl),e.appendChild(a);const l=document.createElement("div");return l.className="bim-measure-settings-actions",this.saveSettingsBtn=document.createElement("button"),this.saveSettingsBtn.type="button",this.saveSettingsBtn.className="bim-measure-settings-save",this.saveSettingsBtn.addEventListener("click",()=>{this.saveSettings()}),this.cancelSettingsBtn=document.createElement("button"),this.cancelSettingsBtn.type="button",this.cancelSettingsBtn.className="bim-measure-settings-cancel",this.cancelSettingsBtn.addEventListener("click",()=>{this.cancelSettings()}),l.appendChild(this.saveSettingsBtn),l.appendChild(this.cancelSettingsBtn),e.appendChild(l),this.syncSettingsFormFromConfig(this.config),e}createModeOptionsDom(){const e=document.createElement("div");e.className="bim-measure-mode-options";const t=document.createElement("div");t.className="bim-measure-radio-group";const i=document.createElement("span");i.className="bim-measure-radio-label",i.dataset.i18nKey="measure.clearHeight.direction";const n=document.createElement("div");n.className="bim-measure-radio-items";const s=this.createRadioItem("measure.clearHeight.directionDown",()=>{this.setClearHeightDirection(0)}),a=this.createRadioItem("measure.clearHeight.directionUp",()=>{this.setClearHeightDirection(1)});this.directionBtns.set(0,s),this.directionBtns.set(1,a),n.appendChild(s),n.appendChild(a),t.appendChild(i),t.appendChild(n),e.appendChild(t);const o=document.createElement("div");o.className="bim-measure-radio-group";const l=document.createElement("span");l.className="bim-measure-radio-label",l.dataset.i18nKey="measure.clearHeight.selectType";const c=document.createElement("div");c.className="bim-measure-radio-items";const h=this.createRadioItem("measure.clearHeight.selectPoint",()=>{this.setClearHeightSelectType("point")}),d=this.createRadioItem("measure.clearHeight.selectElement",()=>{this.setClearHeightSelectType("element")});return this.selectTypeBtns.set("point",h),this.selectTypeBtns.set("element",d),c.appendChild(h),c.appendChild(d),o.appendChild(l),o.appendChild(c),e.appendChild(o),e}createRadioItem(e,t){const i=document.createElement("button");return i.type="button",i.className="bim-measure-radio-item",i.dataset.i18nKey=e,i.textContent=Ee(e),i.addEventListener("click",t),i}setClearHeightDirection(e){this.clearHeightDirection!==e&&(this.clearHeightDirection=e,this.applyClearHeightOptionsState(),this.options.onClearHeightDirectionChange?.(e))}setClearHeightSelectType(e){this.clearHeightSelectType!==e&&(this.clearHeightSelectType=e,this.applyClearHeightOptionsState(),this.options.onClearHeightSelectTypeChange?.(e))}applyClearHeightOptionsState(){this.activeMode==="clearHeight"?this.modeOptionsEl.classList.add("is-visible"):this.modeOptionsEl.classList.remove("is-visible");for(const[e,t]of this.directionBtns.entries())e===this.clearHeightDirection?t.classList.add("is-active"):t.classList.remove("is-active");for(const[e,t]of this.selectTypeBtns.entries())e===this.clearHeightSelectType?t.classList.add("is-active"):t.classList.remove("is-active")}makeOption(e){const t=document.createElement("option");return t.value=e,t.textContent=e,t}makePrecisionOption(e){const t=document.createElement("option");return t.value=String(e),t.textContent=e===0?"0":`0.${"0".repeat(e)}`,t}enterSettingsView(){this.draftConfig={...this.config},this.view="settings",this.syncSettingsFormFromConfig(this.config),this.applyViewState()}saveSettings(){const e=this.unitSelectEl.value||this.config.unit,t=Number(this.precisionSelectEl.value),i={unit:e,precision:this.isValidPrecision(t)?t:this.config.precision};this.config=i,this.saveConfigToCache(i),this.draftConfig=null,this.view="main",this.applyViewState(),this.renderResult(),this.options.onConfigSave?.(i),this.options.onExpandedChange?.(this.isExpanded)}cancelSettings(){this.draftConfig&&(this.config={...this.draftConfig}),this.draftConfig=null,this.view="main",this.applyViewState(),this.renderResult(),this.options.onExpandedChange&&this.options.onExpandedChange(this.isExpanded)}syncSettingsFormFromConfig(e){this.unitSelectEl.value=e.unit,this.precisionSelectEl.value=String(e.precision)}applyViewState(){this.view==="settings"?(this.mainViewEl.style.display="none",this.settingsViewEl.style.display="block"):(this.mainViewEl.style.display="block",this.settingsViewEl.style.display="none")}loadConfigFromCache(){try{const e=localStorage.getItem(kh.CONFIG_CACHE_KEY);if(!e)return null;const t=JSON.parse(e);if(!t||typeof t!="object")return null;const i=t.unit,n=t.precision;return!this.isValidUnit(i)||!this.isValidPrecision(n)?null:{unit:i,precision:n}}catch{return null}}saveConfigToCache(e){try{localStorage.setItem(kh.CONFIG_CACHE_KEY,JSON.stringify(e))}catch{}}isValidUnit(e){return e==="m"||e==="cm"||e==="mm"||e==="km"}isValidPrecision(e){return e===0||e===1||e===2||e===3}applyExpandedState(){let e=0;for(const t of this.toolButtons.values())e>=4?t.style.display=this.isExpanded?"":"none":t.style.display="",e++;this.isExpanded?this.toggleBtn.classList.add("is-expanded"):this.toggleBtn.classList.remove("is-expanded")}applyActiveModeState(){for(const[e,t]of this.toolButtons.entries())e===this.activeMode?t.classList.add("is-active"):t.classList.remove("is-active")}renderResult(){if(this.activeMode==="point"){this.mainValueRowEl.style.display="none",this.xyzBoxEl.style.display="";const i=this.result?.xyz;if(!i){this.xyzXEl.textContent="--",this.xyzYEl.textContent="--",this.xyzZEl.textContent="--";return}this.xyzXEl.textContent=this.convertValue("length",i.x)+" "+this.getUnitText("length"),this.xyzYEl.textContent=this.convertValue("length",i.y)+" "+this.getUnitText("length"),this.xyzZEl.textContent=this.convertValue("length",i.z)+" "+this.getUnitText("length");return}this.mainValueRowEl.style.display="",this.mainValueLabelEl.textContent=Ee(this.getModeValueLabelI18nKey(this.activeMode));const t=this.result?this.result[Hl[this.activeMode].callBackType]:void 0;if(this.activeMode==="slope"||this.activeMode==="angle")this.mainNumberEl.textContent=t??"--",this.mainUnitEl.textContent="";else{const i=$E(this.activeMode);this.mainNumberEl.textContent=this.convertValue(i,t),this.mainUnitEl.textContent=this.getUnitText(i)}this.xyzBoxEl.style.display="none"}getModeI18nKey(e){return`measure.modes.${e}`}getModeValueLabelI18nKey(e){return`measure.labels.value.${e}`}convertValue(e,t){if(t==null||Number.isNaN(t))return"--";const i=this.config.unit,n=this.config.precision;let s;switch(e){case"length":switch(i){case"mm":s=t*1e3;break;case"cm":s=t*100;break;case"km":s=t/1e3;break;default:s=t}break;case"area":switch(i){case"mm":s=t*1e3*1e3;break;case"cm":s=t*100*100;break;case"km":s=t/1e3/1e3;break;default:s=t}break;default:s=t}return s.toFixed(n)}getUnitText(e){const t=this.config.unit;switch(e){case"length":case"point":return t;case"area":return`${t}²`;case"angle":case"percent":return"°";default:return""}}}class oM extends uo{panel=null;config=null;unsubscribeMeasureChanged=null;constructor(e){super(e)}get dialogId(){return"measure-dialog"}get dialogTitle(){return"measure.dialogTitle"}get dialogWidth(){return 250}createContent(){this.panel=new kh({defaultMode:"distance",defaultExpanded:!1,onModeChange:t=>{console.log("[MeasureDialogManager] 当前测量方式已切换:",t),this.engineComponent?.activateMeasure(t)},onClearAll:()=>{console.log("[MeasureDialogManager] 删除全部"),this.engineComponent?.clearAllMeasures()},onSettings:()=>{console.log("[MeasureDialogManager] 打开设置")},onExpandedChange:()=>{this.dialog?.fitHeight(!1)},onConfigSave:t=>{console.log("[MeasureDialogManager] 保存设置:",t),this.engineComponent?.saveMeasureSetting({unit:t.unit,precision:t.precision})},onClearHeightDirectionChange:t=>{console.log("[MeasureDialogManager] 净高朝向切换:",t),this.engineComponent?.setClearHeightDirection(t)},onClearHeightSelectTypeChange:t=>{console.log("[MeasureDialogManager] 净高选择对象切换:",t),this.engineComponent?.setClearHeightSelectType(t)}}),this.panel.init(),this.config=this.panel.getConfig(),this.config&&(console.log("[MeasureDialogManager] 同步缓存设置到引擎:",this.config),this.engineComponent?.saveMeasureSetting({unit:this.config.unit,precision:this.config.precision}));const e=document.createElement("div");return e.style.padding="12px",e.appendChild(this.panel.element),e}onDialogCreated(){this.dialog?.fitHeight(!1),this.engineComponent?.setClearHeightDirection(0),this.engineComponent?.setClearHeightSelectType("point");const e=this.engineComponent;if(e){const t=i=>{console.log("[MeasureDialogManager] 测量值回调:",i),i&&this.panel&&this.handleMeasureChanged(i)};e.onRawEvent("measure-changed",t),e.onRawEvent("measure-click",t),this.unsubscribeMeasureChanged=()=>{e.offRawEvent("measure-changed",t),e.offRawEvent("measure-click",t)}}}handleMeasureChanged(e){if(!this.panel)return;const t=eM(e.type);if(!t){console.warn("[MeasureDialogManager] 未知测量类型:",e.type);return}this.panel.getActiveMode()!==t&&this.panel.switchMode(t,!1);const n=this.convertToMeasureResult(e,t);this.panel.setResult(n)}convertToMeasureResult(e,t){const i=Hl[t],n={};return $E(t)==="point"?e.textX!==void 0&&e.textY!==void 0&&e.textZ!==void 0&&(n.xyz={x:e.textX,y:e.textY,z:e.textZ}):n[i.callBackType]=e.text,n}onDialogClose(){this.unsubscribeMeasureChanged&&(this.unsubscribeMeasureChanged(),this.unsubscribeMeasureChanged=null),this.registry.toolbar?.setBtnActive("measure",!1)}onBeforeDestroy(){this.unsubscribeMeasureChanged&&(this.unsubscribeMeasureChanged(),this.unsubscribeMeasureChanged=null),this.engineComponent?.deactivateMeasure(),this.panel&&(this.panel.destroy(),this.panel=null)}getActiveMode(){return this.panel?this.panel.getActiveMode():null}switchMode(e){this.panel&&this.panel.switchMode(e)}setMeasureResult(e){this.panel&&this.panel.setResult(e)}getConfig(){return this.panel&&(this.config=this.panel.getConfig()),this.config?{...this.config}:null}setConfig(e,t=!0){if(this.panel){this.panel.setConfig(e,t),this.config=this.panel.getConfig(),this.dialog?.fitHeight(!1);return}const i=this.config,n={unit:e.unit??i?.unit??"mm",precision:e.precision??i?.precision??2};this.config=n}clearAll(){this.panel&&this.panel.clearAll()}openSettings(){this.panel&&this.panel.openSettings()}}class a9{element;options;isHidden=!1;hideBtn;reverseBtn;resetBtn;hideLabelEl;reverseLabelEl;resetLabelEl;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.isHidden=e.defaultHidden??!1,this.element=this.createDom()}setHiddenState(e){this.isHidden=e,this.updateButtonStates()}getHiddenState(){return this.isHidden}updateButtonStates(){this.hideBtn?.classList.toggle("active",this.isHidden)}init(){this.unsubscribeLocale=Kt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ht.subscribe(e=>{this.setTheme(e)}),this.setLocales(),this.setTheme(ht.getTheme())}setTheme(e){const t=this.element.style;t.setProperty("--bim-bg-inset",e.bgInset??"#152232"),t.setProperty("--bim-border-default",e.borderDefault??"#334155"),t.setProperty("--bim-border-strong",e.borderStrong??"#475569"),t.setProperty("--bim-primary",e.primary??"#3b82f6"),t.setProperty("--bim-primary-subtle",e.primarySubtle??"rgba(59, 130, 246, 0.15)"),t.setProperty("--bim-icon-default",e.iconDefault??"#ffffff"),t.setProperty("--bim-text-primary",e.textPrimary??"#ffffff"),t.setProperty("--bim-component-bg-hover",e.componentBgHover??"rgba(248, 250, 252, 0.06)")}setLocales(){this.hideLabelEl.textContent=Ee("sectionPlane.actions.hide"),this.reverseLabelEl.textContent=Ee("sectionPlane.actions.reverse"),this.resetLabelEl.textContent=Ee("sectionPlane.actions.reset"),this.hideBtn.title=Ee("sectionPlane.actions.hide"),this.reverseBtn.title=Ee("sectionPlane.actions.reverse"),this.resetBtn.title=Ee("sectionPlane.actions.reset")}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove()}createDom(){const e=document.createElement("div");return e.className="section-plane-panel",this.hideBtn=this.createButton("hide",It("隐藏"),()=>{this.isHidden=!this.isHidden,this.updateButtonStates(),this.options.onHideToggle?.(this.isHidden)}),this.reverseBtn=this.createButton("reverse",It("反向"),()=>{this.options.onReverse&&this.options.onReverse()}),this.resetBtn=this.createButton("reset",It("重置"),()=>{this.options.onReset&&this.options.onReset()}),e.appendChild(this.hideBtn),e.appendChild(this.reverseBtn),e.appendChild(this.resetBtn),e}createButton(e,t,i){const n=document.createElement("button");n.type="button",n.className="section-plane-btn";const s=document.createElement("div");s.className="section-plane-btn-icon",s.innerHTML=t,n.appendChild(s);const a=document.createElement("div");return a.className="section-plane-btn-label",n.appendChild(a),e==="hide"?this.hideLabelEl=a:e==="reverse"?this.reverseLabelEl=a:this.resetLabelEl=a,n.addEventListener("click",i),n}}class lM extends uo{panel=null;constructor(e){super(e)}get dialogId(){return"section-plane-dialog"}get dialogTitle(){return"sectionPlane.dialogTitle"}get dialogWidth(){return 240}get dialogHeight(){return 120}init(){}getDialogPosition(){const e=this.registry.container;if(!e)return{x:100,y:100};const t=20,i=50,n=e.clientWidth,s=e.clientHeight;return{x:n-this.dialogWidth-t,y:s-this.dialogHeight-i}}createContent(){return this.panel=new a9({defaultHidden:!1,onHideToggle:e=>{console.log("[SectionPlaneDialogManager] 隐藏切换:",e),e?this.engineComponent?.hideSection():this.engineComponent?.recoverSection()},onReverse:()=>{this.engineComponent?.reverseSection()},onReset:()=>{this.engineComponent?.deactivateSection(),this.engineComponent?.activeSection("face")}}),this.panel.init(),this.panel.element}onDialogCreated(){this.engineComponent?.activeSection("face"),this.dialog?.fitHeight(!1)}onDialogClose(){this.registry.toolbar?.setBtnActive("section-plane",!1)}onBeforeDestroy(){this.engineComponent?.deactivateSection(),this.panel&&(this.panel.destroy(),this.panel=null)}}class o9{element;options;isHidden=!1;activeAxis="x";hideBtn;reverseBtn;hideLabelEl;reverseLabelEl;axisXBtn;axisYBtn;axisZBtn;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.isHidden=e.defaultHidden??!1,this.activeAxis=e.defaultAxis??"x",this.element=this.createDom()}init(){this.unsubscribeLocale=Kt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ht.subscribe(e=>{this.setTheme(e)}),this.setLocales(),this.setTheme(ht.getTheme()),this.updateHideButtonState(),this.updateAxisButtonsState()}setTheme(e){const t=this.element.style;t.setProperty("--bim-bg-inset",e.bgInset??"#152232"),t.setProperty("--bim-border-default",e.borderDefault??"#334155"),t.setProperty("--bim-border-strong",e.borderStrong??"#475569"),t.setProperty("--bim-divider",e.divider??"#334155"),t.setProperty("--bim-primary",e.primary??"#3b82f6"),t.setProperty("--bim-primary-subtle",e.primarySubtle??"rgba(59, 130, 246, 0.15)"),t.setProperty("--bim-icon-default",e.iconDefault??"#ffffff"),t.setProperty("--bim-text-primary",e.textPrimary??"#ffffff"),t.setProperty("--bim-component-bg-hover",e.componentBgHover??"rgba(248, 250, 252, 0.06)")}setLocales(){this.hideLabelEl.textContent=Ee("sectionAxis.actions.hide"),this.reverseLabelEl.textContent=Ee("sectionAxis.actions.reverse"),this.hideBtn.title=Ee("sectionAxis.actions.hide"),this.reverseBtn.title=Ee("sectionAxis.actions.reverse"),this.axisXBtn.title=Ee("sectionAxis.actions.axisX"),this.axisYBtn.title=Ee("sectionAxis.actions.axisY"),this.axisZBtn.title=Ee("sectionAxis.actions.axisZ")}setHiddenState(e){this.isHidden=e,this.updateHideButtonState()}getHiddenState(){return this.isHidden}setActiveAxis(e){this.activeAxis=e,this.updateAxisButtonsState()}getActiveAxis(){return this.activeAxis}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove()}createDom(){const e=document.createElement("div");e.className="section-axis-panel";const t=document.createElement("div");t.className="section-axis-row-1",this.hideBtn=this.createButton("hide",It("隐藏"),()=>this.handleHideToggle()),this.reverseBtn=this.createButton("reverse",It("反向"),()=>this.handleReverse()),t.appendChild(this.hideBtn),t.appendChild(this.reverseBtn);const i=document.createElement("div");return i.className="section-axis-row-2",this.axisXBtn=this.createAxisButton("axisX","X",()=>this.handleAxisChange("x")),this.axisYBtn=this.createAxisButton("axisY","Y",()=>this.handleAxisChange("y")),this.axisZBtn=this.createAxisButton("axisZ","Z",()=>this.handleAxisChange("z")),i.appendChild(this.axisXBtn),i.appendChild(this.axisYBtn),i.appendChild(this.axisZBtn),e.appendChild(t),e.appendChild(i),e}createButton(e,t,i){const n=document.createElement("button");n.type="button",n.className="section-axis-btn";const s=document.createElement("div");s.className="section-axis-btn-icon",s.innerHTML=t,n.appendChild(s);const a=document.createElement("div");return a.className="section-axis-btn-label",n.appendChild(a),e==="hide"?this.hideLabelEl=a:e==="reverse"&&(this.reverseLabelEl=a),n.addEventListener("click",i),n}createAxisButton(e,t,i){const n=document.createElement("button");n.type="button",n.className="section-axis-btn section-axis-btn-text";const s=document.createElement("div");return s.className="section-axis-btn-label",s.textContent=t,n.appendChild(s),n.addEventListener("click",i),n}handleHideToggle(){this.isHidden=!this.isHidden,this.updateHideButtonState(),this.options.onHideToggle&&this.options.onHideToggle(this.isHidden)}handleReverse(){this.options.onReverse&&this.options.onReverse()}handleAxisChange(e){this.activeAxis!==e&&(this.activeAxis=e,this.updateAxisButtonsState(),this.options.onAxisChange&&this.options.onAxisChange(e))}updateHideButtonState(){this.isHidden?this.hideBtn.classList.add("active"):this.hideBtn.classList.remove("active")}updateAxisButtonsState(){this.axisXBtn.classList.toggle("active",this.activeAxis==="x"),this.axisYBtn.classList.toggle("active",this.activeAxis==="y"),this.axisZBtn.classList.toggle("active",this.activeAxis==="z")}}class cM extends uo{panel=null;constructor(e){super(e)}get dialogId(){return"section-axis-dialog"}get dialogTitle(){return"sectionAxis.dialogTitle"}get dialogWidth(){return 240}getDialogPosition(){const e=this.registry.container;if(!e)return{x:100,y:100};const t=e.clientWidth,i=e.clientHeight;return{x:t-this.dialogWidth-20,y:i-50-200}}createContent(){return this.panel=new o9({defaultAxis:"x",defaultHidden:!1,onHideToggle:e=>{console.log("[SectionAxisDialogManager] 隐藏切换:",e),e?this.engineComponent?.hideSection():this.engineComponent?.recoverSection()},onReverse:()=>{this.engineComponent?.reverseSection()},onAxisChange:e=>{console.log("[SectionAxisDialogManager] 切换轴向:",e),this.engineComponent?.activeSection(e)}}),this.panel.init(),this.panel.element}onDialogCreated(){if(this.dialog?.fitHeight(!1),!this.engineComponent){console.error("[SectionAxisDialogManager] Engine not initialized. Call initEngine() first.");return}this.engineComponent.activeSection("x")}onDialogClose(){this.registry.toolbar?.setBtnActive("section-axis",!1)}onBeforeDestroy(){this.engineComponent?.deactivateSection(),this.panel&&(this.panel.destroy(),this.panel=null)}getHiddenState(){return this.panel?.getHiddenState()??!1}setHiddenState(e){this.panel?.setHiddenState(e)}getActiveAxis(){return this.panel?.getActiveAxis()??"x"}setActiveAxis(e){this.panel?.setActiveAxis(e)}}const hM={x:{min:0,max:100},y:{min:0,max:100},z:{min:0,max:100}};class l9{element;options;isHidden=!1;isReversed=!1;range;hideBtn;fitBtn;resetBtn;hideLabelEl;fitLabelEl;resetLabelEl;xLabelEl;yLabelEl;zLabelEl;unsubscribeLocale=null;unsubscribeTheme=null;xSlider;ySlider;zSlider;xMinHandle;xMaxHandle;yMinHandle;yMaxHandle;zMinHandle;zMaxHandle;dragState={isDragging:!1,axis:null,handleType:null,pointerId:null};constructor(e={}){this.options=e,this.isHidden=e.defaultHidden??!1,this.isReversed=e.defaultReversed??!1,this.range=JSON.parse(JSON.stringify(e.defaultRange??hM))}init(){this.element=this.createPanel(),this.unsubscribeLocale=Kt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ht.subscribe(e=>this.setTheme(e)),this.setLocales(),this.setTheme(ht.getTheme()),this.updateButtonStates(),this.updateAllSlidersUI(),this.setupDragListeners()}setHiddenState(e){this.isHidden=e,this.updateButtonStates()}getHiddenState(){return this.isHidden}setReversedState(e){this.isReversed=e,this.updateButtonStates()}getReversedState(){return this.isReversed}setRange(e){e.x&&(this.range.x={...this.range.x,...e.x}),e.y&&(this.range.y={...this.range.y,...e.y}),e.z&&(this.range.z={...this.range.z,...e.z}),this.updateAllSlidersUI()}getRange(){return JSON.parse(JSON.stringify(this.range))}reset(){this.isHidden=this.options.defaultHidden??!1,this.isReversed=this.options.defaultReversed??!1,this.range=JSON.parse(JSON.stringify(this.options.defaultRange??hM)),this.updateButtonStates(),this.updateAllSlidersUI(),this.options.onReset?.(),this.options.onRangeChange?.(this.range)}createPanel(){const e=document.createElement("div");e.className="section-box-panel";const t=document.createElement("div");t.className="section-box-row-buttons",this.hideBtn=this.createButton("hide",Ee("sectionBox.actions.hide"),()=>{this.isHidden=!this.isHidden,this.updateButtonStates(),this.options.onHideToggle?.(this.isHidden)},"hide"),this.fitBtn=this.createButton("fit",Ee("sectionBox.actions.fitToModel"),()=>{this.options.onFitToModel?.()},"fit"),this.resetBtn=this.createButton("reset",Ee("sectionBox.actions.reset"),()=>this.reset(),"reset"),[this.hideBtn,this.fitBtn,this.resetBtn].forEach(n=>t.appendChild(n));const i=document.createElement("div");return i.className="section-box-sliders",i.addEventListener("pointerdown",n=>n.stopPropagation()),this.xSlider=this.createSlider("x",Ee("sectionBox.axes.x")),this.ySlider=this.createSlider("y",Ee("sectionBox.axes.y")),this.zSlider=this.createSlider("z",Ee("sectionBox.axes.z")),[this.xSlider,this.ySlider,this.zSlider].forEach(n=>i.appendChild(n)),e.appendChild(t),e.appendChild(i),e}createButton(e,t,i,n){const s=document.createElement("button");s.className="section-box-btn",s.title=t;const a={hide:"隐藏",reverse:"反向",fit:"适应到模型",reset:"重置"},o=document.createElement("div");o.className="section-box-btn-icon",o.innerHTML=It(a[e]||e);const l=document.createElement("div");return l.className="section-box-btn-label",l.textContent=t,n==="hide"?this.hideLabelEl=l:n==="fit"?this.fitLabelEl=l:n==="reset"&&(this.resetLabelEl=l),s.appendChild(o),s.appendChild(l),s.addEventListener("click",i),s}createSlider(e,t){const i=document.createElement("div");i.className="section-box-slider";const n=document.createElement("div");n.className="section-box-slider-label",n.textContent=t,e==="x"?this.xLabelEl=n:e==="y"?this.yLabelEl=n:this.zLabelEl=n;const s=document.createElement("div");s.className="section-box-slider-track";const a=document.createElement("div");a.className="section-box-slider-range";const o=document.createElement("div");o.className="section-box-slider-handle",o.setAttribute("data-axis",e),o.setAttribute("data-handle","min");const l=document.createElement("div");return l.className="section-box-slider-handle",l.setAttribute("data-axis",e),l.setAttribute("data-handle","max"),s.append(a,o,l),i.append(n,s),e==="x"?(this.xMinHandle=o,this.xMaxHandle=l):e==="y"?(this.yMinHandle=o,this.yMaxHandle=l):(this.zMinHandle=o,this.zMaxHandle=l),i}setupDragListeners(){[this.xMinHandle,this.xMaxHandle,this.yMinHandle,this.yMaxHandle,this.zMinHandle,this.zMaxHandle].forEach(t=>{t.addEventListener("pointerdown",n=>{n.preventDefault(),n.stopPropagation(),t.setPointerCapture(n.pointerId),this.dragState={isDragging:!0,axis:t.getAttribute("data-axis"),handleType:t.getAttribute("data-handle"),pointerId:n.pointerId},t.classList.add("dragging"),t.closest(".section-box-slider").style.zIndex="100"}),t.addEventListener("pointermove",n=>{this.dragState.isDragging&&this.dragState.pointerId===n.pointerId&&this.onDragging(n)});const i=n=>{this.dragState.isDragging&&this.dragState.pointerId===n.pointerId&&(t.hasPointerCapture(n.pointerId)&&t.releasePointerCapture(n.pointerId),t.closest(".section-box-slider").style.zIndex="",t.classList.remove("dragging"),this.dragState={isDragging:!1,axis:null,handleType:null,pointerId:null})};t.addEventListener("pointerup",i),t.addEventListener("pointercancel",i),t.addEventListener("lostpointercapture",i)})}onDragging(e){const{axis:t,handleType:i}=this.dragState;if(!t||!i)return;const a=(t==="x"?this.xSlider:t==="y"?this.ySlider:this.zSlider).querySelector(".section-box-slider-track").getBoundingClientRect();let o=(e.clientX-a.left)/a.width*100;o=Math.max(0,Math.min(100,o));const l=this.range[t];i==="min"?l.min=Math.min(o,l.max):l.max=Math.max(o,l.min),this.updateSliderUI(t),this.options.onRangeChange?.(this.range)}updateSliderUI(e){const t=this.range[e],i=e==="x"?this.xMinHandle:e==="y"?this.yMinHandle:this.zMinHandle,n=e==="x"?this.xMaxHandle:e==="y"?this.yMaxHandle:this.zMaxHandle,a=(e==="x"?this.xSlider:e==="y"?this.ySlider:this.zSlider).querySelector(".section-box-slider-range");i.style.left=`${t.min}%`,n.style.left=`${t.max}%`,a.style.left=`${t.min}%`,a.style.width=`${t.max-t.min}%`,i.setAttribute("data-value",Math.round(t.min).toString()),n.setAttribute("data-value",Math.round(t.max).toString())}updateAllSlidersUI(){["x","y","z"].forEach(e=>this.updateSliderUI(e))}updateButtonStates(){this.hideBtn&&this.hideBtn.classList.toggle("active",this.isHidden)}setLocales(){this.hideLabelEl&&(this.hideLabelEl.textContent=Ee("sectionBox.actions.hide"),this.fitLabelEl.textContent=Ee("sectionBox.actions.fitToModel"),this.resetLabelEl.textContent=Ee("sectionBox.actions.reset"),this.xLabelEl.textContent=Ee("sectionBox.axes.x"),this.yLabelEl.textContent=Ee("sectionBox.axes.y"),this.zLabelEl.textContent=Ee("sectionBox.axes.z"),this.hideBtn.title=Ee("sectionBox.actions.hide"),this.fitBtn.title=Ee("sectionBox.actions.fitToModel"),this.resetBtn.title=Ee("sectionBox.actions.reset"))}setTheme(e){if(!this.element)return;const t=this.element.style;t.setProperty("--bim-bg-inset",e.bgInset??"#152232"),t.setProperty("--bim-bg-elevated",e.bgElevated??"#1f2d3e"),t.setProperty("--bim-border-default",e.borderDefault??"#334155"),t.setProperty("--bim-border-strong",e.borderStrong??"#475569"),t.setProperty("--bim-divider",e.divider??"#334155"),t.setProperty("--bim-primary",e.primary??"#3b82f6"),t.setProperty("--bim-primary-subtle",e.primarySubtle??"rgba(59, 130, 246, 0.15)"),t.setProperty("--bim-icon-default",e.iconDefault??"#ffffff"),t.setProperty("--bim-text-primary",e.textPrimary??"#ffffff"),t.setProperty("--bim-component-bg-hover",e.componentBgHover??"rgba(248, 250, 252, 0.06)")}destroy(){this.unsubscribeLocale?.(),this.unsubscribeTheme?.(),this.element&&this.element.parentElement&&this.element.parentElement.removeChild(this.element)}}class dM extends uo{panel=null;unsubscribeSectionMove=null;constructor(e){super(e)}get dialogId(){return"section-box-dialog"}get dialogTitle(){return"sectionBox.dialogTitle"}get dialogWidth(){return 280}getDialogPosition(){const e=this.registry.container;if(!e)return{x:100,y:100};const t=e.clientWidth,i=e.clientHeight;return{x:t-this.dialogWidth-20,y:i-50-300}}createContent(){return this.panel=new l9({defaultHidden:!1,defaultReversed:!1,onHideToggle:e=>{console.log("[SectionBoxDialogManager] 隐藏切换:",e),e?this.engineComponent?.hideSection():this.engineComponent?.recoverSection()},onFitToModel:()=>{this.engineComponent?.scaleSectionBox()},onReset:()=>{this.engineComponent?.deactivateSection(),this.engineComponent?.activeSection("box"),this.engineComponent?.recoverSection()},onRangeChange:e=>{this.engineComponent?.setSectionBoxRange(e)}}),this.panel.init(),this.panel.element}onDialogCreated(){this.engineComponent?.activeSection("box"),this.dialog?.fitHeight(!1);const e=this.engineComponent;if(e){const t=i=>{i&&this.panel&&this.panel.setRange(i)};e.onRawEvent("section-move",t),this.unsubscribeSectionMove=()=>e.offRawEvent("section-move",t)}}onDialogClose(){this.unsubscribeSectionMove&&(this.unsubscribeSectionMove(),this.unsubscribeSectionMove=null),this.registry.toolbar?.setBtnActive("section-box",!1)}onBeforeDestroy(){this.unsubscribeSectionMove&&(this.unsubscribeSectionMove(),this.unsubscribeSectionMove=null),this.engineComponent?.deactivateSection(),this.panel&&(this.panel.destroy(),this.panel=null)}getHiddenState(){return this.panel?.getHiddenState()??!1}setHiddenState(e){this.panel?.setHiddenState(e)}getReversedState(){return this.panel?.getReversedState()??!1}setReversedState(e){this.panel?.setReversedState(e)}getRange(){return this.panel?.getRange()??null}setRange(e){this.panel?.setRange(e)}}class uM extends Hn{panel=null;pathManager=null;constructor(e){super(e)}init(){this.pathManager=new rM(this.registry),this.pathManager.init()}show(){this.registry.toolbar?.hide(),console.log("[WalkControl] 打开漫游面板,激活第一人称模式"),this.engineComponent?.activateFirstPersonMode(),this.panel=new sM({onPlanViewToggle:t=>{console.log("[WalkControl] 小地图:",t),this.engineComponent?.toggleMiniMap(),this.registry.toolbar?.setBtnActive("map",t),this.emit("walk:plan-view-toggle",{isActive:t})},onPathModeToggle:t=>{console.log("[WalkControl] 路径漫游:",t),t?this.pathManager?.show():this.pathManager?.hide(),this.emit("walk:path-mode-toggle",{isActive:t})},onWalkModeToggle:t=>{console.log("[WalkControl] 第三人称漫游按钮点击:",t),t&&(this.pathManager?.hide(),alert("第三人称功能开发中")),this.emit("walk:walk-mode-toggle",{isActive:t})},onSpeedChange:t=>{console.log("[WalkControl] 速度变化:",t);const i=t*.1;this.engineComponent?.setWalkSpeed(i),this.emit("walk:speed-change",{speed:t})},onGravityToggle:t=>{console.log("[WalkControl] 重力:",t),this.engineComponent?.setWalkGravity(t),this.emit("walk:gravity-toggle",{enabled:t})},onCollisionToggle:t=>{console.log("[WalkControl] 碰撞:",t),this.engineComponent?.setWalkCollision(t),this.emit("walk:collision-toggle",{enabled:t})},onCharacterModelChange:t=>{console.log("[WalkControl] 角色模型:",t)},onWalkModeChange:t=>{console.log("[WalkControl] 行走模式:",t)},onExit:()=>{this.hide()}}),this.panel.init();const e=this.engineComponent?.getMiniMapState()??!1;this.panel.setPlanViewActive(e),this.registry.container?(this.panel.element.style.position="absolute",this.panel.element.style.bottom="20px",this.panel.element.style.left="50%",this.panel.element.style.transform="translateX(-50%)",this.panel.element.style.zIndex="1000",this.registry.container.appendChild(this.panel.element)):console.warn("[WalkControlManager] Container not found")}hide(){this.pathManager?.hide(),this.engineComponent?.getMiniMapState()&&this.engineComponent.toggleMiniMap(),console.log("[WalkControl] 关闭漫游面板,退出第一人称模式"),this.engineComponent?.deactivateFirstPersonMode(),this.panel&&(this.panel.destroy(),this.panel=null),this.registry.toolbar?.setBtnActive("map",!1),this.registry.toolbar&&this.registry.toolbar.show()}destroy(){this.hide(),this.pathManager?.destroy(),this.pathManager=null,super.destroy()}}class pM extends uo{get dialogId(){return"engine-info-dialog"}get dialogTitle(){return"info.dialogTitle"}get dialogWidth(){return 280}constructor(e){super(e)}init(){}getDialogPosition(){const e=this.registry.container;if(!e)return{x:100,y:100};const t=e.clientWidth,i=e.clientHeight;return{x:(t-this.dialogWidth)/2,y:(i-150)/2}}createContent(){const e=this.engineComponent?.getEngineInfo()??null,t=document.createElement("div");t.className="engine-info-content",t.style.cssText="padding: 16px;";const i=(n,s)=>{const a=document.createElement("div");a.style.cssText="display: flex; justify-content: space-between; margin-bottom: 12px; font-size: 14px;";const o=document.createElement("span");o.style.cssText="color: var(--bim-text-secondary, #94a3b8);",o.textContent=n;const l=document.createElement("span");return l.style.cssText="color: var(--bim-text-primary, #fff); font-weight: 500;",l.textContent=String(s),a.appendChild(o),a.appendChild(l),a};return t.appendChild(i(Ee("info.meshCount"),e?.meshCount??"-")),t.appendChild(i(Ee("info.totalTriangles"),e?.totalTriangles??"-")),t.appendChild(i(Ee("info.totalVertices"),e?.totalVertices??"-")),t}}const yA="font-size: 15px; font-weight: 600; color: var(--bim-text-primary, #0f172a); margin-bottom: 4px;",c9="height: 1px; background: var(--bim-divider, #e2e8f0); margin: 8px 0;",xA="display: flex; align-items: center; justify-content: space-between; gap: 12px;",_A="display: flex; flex-direction: column; gap: 6px;",h9="font-size: 12px; color: var(--bim-text-secondary, #475569); min-width: 32px; text-align: right;",zn="var(--bim-border-default, #e2e8f0)",EA="var(--bim-bg-inset, #f1f5f9)",po="var(--bim-primary, #3b82f6)",fo="var(--bim-text-primary, #0f172a)",Gl="var(--bim-text-inverse, #ffffff)",d9="var(--bim-component-bg-hover, rgba(0,0,0,0.04))",fM={render:{mode:"advanced",contrast:50,saturation:50,shadowIntensity:50,lightIntensity:50,gtaoIntensity:50},display:{showEdge:!1,edgeOpacity:30,showGrid:!1,showLevel:!1,showGround:!1,groundId:"0",groundHeight:0},environment:{type:"none",hdrId:"0",hdrIntensity:20,skyPreset:"sunrise_clear",skyParams:{},skyIntensity:20}},u9={ground:[],hdr:[],sky:[]};class fr extends uo{get dialogId(){return"setting-dialog"}get dialogTitle(){return"setting.dialogTitle"}get dialogWidth(){return 420}settings=structuredClone(fM);presetList=[];selectedPresetId=null;presetLists=structuredClone(u9);savedPosition=null;savedScrollTop=null;isDirty=!1;saveAsModalEl=null;deleteConfirmModalEl=null;unsubscribeLocale=null;static INTERNAL_DEFAULT_PRESET_ID="__internal-default-preset__";constructor(e){super(e)}init(){this.ensurePresetListWithInternalDefault(),this.applySelectedPresetFromList(),this.unsubscribeLocale=Kt.subscribe(()=>{this.updateInternalDefaultPresetLabel(),this.isOpen()&&this.reopenAtSamePosition()})}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.closeSaveAsPresetModal(),this.closeDeletePresetConfirmModal(),super.destroy()}ensurePresetListWithInternalDefault(){const e=this.presetList.filter(n=>n.id!==fr.INTERNAL_DEFAULT_PRESET_ID),t=e.some(n=>n.isDefault),i=this.createInternalDefaultPreset(!t);this.presetList=[...e,i],(!this.selectedPresetId||!this.presetList.some(n=>n.id===this.selectedPresetId))&&(this.selectedPresetId=i.id)}updateInternalDefaultPresetLabel(){const e=this.presetList.findIndex(t=>t.id===fr.INTERNAL_DEFAULT_PRESET_ID);e<0||(this.presetList[e]={...this.presetList[e],presetName:Ee("setting.defaultPresetLabel")},this.ensurePresetListWithInternalDefault())}createInternalDefaultPreset(e=!0){return{id:fr.INTERNAL_DEFAULT_PRESET_ID,presetName:Ee("setting.defaultPresetLabel"),isDefault:e,settings:structuredClone(fM),source:"sdk-default",readonly:!1,allowModify:!1}}setPresetList(e){this.presetList=this.normalizePresetList(e),this.ensurePresetListWithInternalDefault(),this.selectedPresetId=this.resolveDefaultPresetId(this.presetList),!this.selectedPresetId&&this.presetList.length>0&&(this.selectedPresetId=this.presetList[0].id),this.applySelectedPresetFromList(),this.isDirty=!1,this.updateUndoRestoreVisibility(),this.isOpen()&&this.reopenAtSamePosition()}getDialogPosition(){if(this.savedPosition){const n=this.savedPosition;return this.savedPosition=null,n}const e=this.registry.container;if(!e)return{x:100,y:100};const t=e.clientWidth,i=e.clientHeight;return{x:(t-this.dialogWidth)/2,y:Math.max(20,(i-560)/2)}}createContent(){this.syncFromEngine(),this.ensureSliderStyle();const e=document.createElement("div");e.style.cssText="height: 600px; display: flex; flex-direction: column;";const t=document.createElement("div");t.className="setting-scroll-body",t.style.cssText="padding: 14px 16px 12px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0;",t.appendChild(this.createRenderModeSection()),t.appendChild(this.createSliderSection(Ee("setting.lightIntensity"),this.settings.render.lightIntensity,0,100,n=>this.updateSettings({render:{lightIntensity:n}}))),this.settings.render.mode==="advanced"&&(t.appendChild(this.createSliderSection(Ee("setting.contrast"),this.settings.render.contrast,0,100,n=>this.updateSettings({render:{contrast:n}}))),t.appendChild(this.createSliderSection(Ee("setting.saturation"),this.settings.render.saturation,0,100,n=>this.updateSettings({render:{saturation:n}})))),t.appendChild(this.createDivider()),t.appendChild(this.createDisplaySection()),t.appendChild(this.createDivider()),t.appendChild(this.createEnvironmentSection());const i=document.createElement("div");return i.style.cssText=`
|
||
padding: 12px 16px 14px 16px;
|
||
border-top: 1px solid ${zn};
|
||
background: var(--bim-bg-elevated, #fff);
|
||
position: sticky;
|
||
bottom: 0;
|
||
z-index: 1;
|
||
`,i.appendChild(this.createBottomActionBar()),e.appendChild(t),e.appendChild(i),e}syncFromEngine(){const e=this.engineComponent;if(!e)return;const t=this.selectedPresetId;this.ensurePresetListWithInternalDefault(),t&&this.presetList.some(i=>i.id===t)&&(this.selectedPresetId=t),this.presetLists=e.getPresetLists(),this.settings=e.getSettings(),this.isDirty=this.getCurrentSettingsDirtyState(this.settings),this.selectedPresetId===null&&(this.selectedPresetId=this.resolveDefaultPresetId(this.presetList),!this.selectedPresetId&&this.presetList.length>0&&(this.selectedPresetId=this.presetList[0].id))}applySelectedPresetFromList(){const e=this.presetList.find(t=>t.id===this.selectedPresetId)??this.presetList.find(t=>t.isDefault)??this.presetList[0];e&&(this.selectedPresetId=e.id,this.settings=structuredClone(e.settings),this.isDirty=!1,this.engineComponent?.setSettings(e.settings),this.updateUndoRestoreVisibility())}normalizePresetList(e){const t=new Set,i=[];for(const n of e){if(!n||typeof n.id!="string")continue;const s=n.id.trim();s!==fr.INTERNAL_DEFAULT_PRESET_ID&&(!s||t.has(s)||(t.add(s),i.push({id:s,presetName:n.presetName?.trim()||s,isDefault:!!n.isDefault,settings:structuredClone(n.settings),readonly:!!n.readonly,source:n.source})))}return i}resolveDefaultPresetId(e){return e.length===0?null:e.find(i=>i.isDefault)?.id??null}createDivider(){const e=document.createElement("div");return e.style.cssText=c9,e}createBottomActionBar(){const e=document.createElement("div");e.style.cssText="display: flex; flex-direction: column; gap: 8px;";const t=document.createElement("button");t.id=`${this.dialogId}-undo-btn`,t.type="button",t.textContent=Ee("setting.undoChanges"),t.style.cssText=`
|
||
border: none; background: transparent; color: #ef4444;
|
||
text-align: left; cursor: pointer; font-size: 13px; padding: 0;
|
||
text-decoration: underline;
|
||
display: ${this.isDirty&&this.selectedPresetId?"block":"none"};
|
||
`,t.addEventListener("click",()=>{this.selectedPresetId&&this.applyPresetById(this.selectedPresetId)}),e.appendChild(t);const i=document.createElement("div"),n=this.isSelectedPresetDeletable(),s=this.isSelectedPresetAllowModify();if(i.style.cssText="display: grid; grid-template-columns: minmax(0, 1.55fr) 40px minmax(0, 0.7fr) minmax(0, 0.95fr); gap: 8px; align-items: center;",i.appendChild(this.createBottomPresetSelect()),s&&n)i.appendChild(this.createDeleteIconButton());else{const a=document.createElement("div");a.style.cssText="width: 40px; height: 36px;",i.appendChild(a)}if(s)i.appendChild(this.createFooterActionButton(Ee("setting.savePreset"),{background:po,color:Gl,border:"none",onClick:()=>this.handleSaveCurrentPreset(),compact:!0}));else{const a=document.createElement("div");i.appendChild(a)}return i.appendChild(this.createFooterActionButton(Ee("setting.saveAsNewPreset"),{background:po,color:Gl,border:"none",onClick:()=>this.openSaveAsPresetModal(),compact:!0})),e.appendChild(i),e}createDeleteIconButton(){const e=document.createElement("button");return e.type="button",e.title=Ee("setting.deletePreset"),e.setAttribute("aria-label",Ee("setting.deletePreset")),e.innerHTML=`
|
||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||
<polyline points="3 6 5 6 21 6"></polyline>
|
||
<path d="M8 6V4a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v2"></path>
|
||
<path d="M19 6l-1 14a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1L5 6"></path>
|
||
<line x1="10" y1="11" x2="10" y2="17"></line>
|
||
<line x1="14" y1="11" x2="14" y2="17"></line>
|
||
</svg>
|
||
`,e.style.cssText=`
|
||
width: 40px; height: 36px; border-radius: 6px;
|
||
border: 1px solid #fca5a5; background: var(--bim-danger-soft, #fecaca);
|
||
color: #991b1b; cursor: pointer; display: inline-flex;
|
||
align-items: center; justify-content: center;
|
||
`,e.addEventListener("click",()=>this.openDeletePresetConfirmModal()),e}isSelectedPresetDeletable(){return!this.selectedPresetId||this.selectedPresetId===fr.INTERNAL_DEFAULT_PRESET_ID||this.presetList.find(t=>t.id===this.selectedPresetId)?.allowModify===!1?!1:this.presetList.some(t=>t.id===this.selectedPresetId)}isSelectedPresetAllowModify(){return this.selectedPresetId?this.presetList.find(t=>t.id===this.selectedPresetId)?.allowModify!==!1:!0}createBottomPresetSelect(){const e=[];if(this.presetList.length===0)e.push({value:"",label:Ee("setting.presetSelectPlaceholder")});else for(const i of this.presetList)e.push({value:i.id,label:i.presetName});return this.selectedPresetId&&this.presetList.some(i=>i.id===this.selectedPresetId)||(this.selectedPresetId=this.resolveDefaultPresetId(this.presetList)??this.presetList[0]?.id??null),this.createSelect(e,this.selectedPresetId??"",i=>{i&&this.applyPresetById(i)})}createFooterActionButton(e,t){const i=document.createElement("button");return i.type="button",i.textContent=e,i.style.cssText=`
|
||
height: ${t.compact?"36px":"40px"}; border-radius: 6px; cursor: pointer;
|
||
font-size: ${t.compact?"13px":"14px"}; font-weight: 600;
|
||
padding: 0 8px; white-space: nowrap;
|
||
background: ${t.background}; color: ${t.color}; border: ${t.border};
|
||
`,i.addEventListener("click",t.onClick),i}createRenderModeSection(){const e=document.createElement("div");e.style.cssText=_A;const t=document.createElement("div");t.style.cssText=yA,t.textContent=Ee("setting.renderMode"),e.appendChild(t);const i=document.createElement("div");i.style.cssText=`
|
||
display: flex; gap: 0; border-radius: 6px; overflow: hidden;
|
||
border: 1px solid ${zn};
|
||
`;const n=[{key:"simple",labelKey:"setting.modes.simple"},{key:"balance",labelKey:"setting.modes.balance"},{key:"advanced",labelKey:"setting.modes.advanced"}];for(let s=0;s<n.length;s++){const a=n[s],o=a.key===this.settings.render.mode,l=document.createElement("button");l.type="button",l.style.cssText=`
|
||
flex: 1; text-align: center; padding: 7px 0; cursor: pointer;
|
||
font-size: 13px; font-weight: 500; transition: all 0.15s;
|
||
background: ${o?po:"transparent"};
|
||
color: ${o?Gl:fo};
|
||
border: none;
|
||
${s<n.length-1?`border-right: 1px solid ${zn};`:""}
|
||
`,l.textContent=Ee(a.labelKey),l.addEventListener("mouseenter",()=>{o||(l.style.background=d9)}),l.addEventListener("mouseleave",()=>{o||(l.style.background="transparent")}),l.addEventListener("click",()=>{this.updateSettings({render:{mode:a.key}},!0)}),i.appendChild(l)}return e.appendChild(i),e}createDisplaySection(){const e=document.createElement("div");e.style.cssText=_A;const t=document.createElement("div");if(t.style.cssText=yA,t.textContent=Ee("setting.displaySection"),e.appendChild(t),e.appendChild(this.createToggleRow(Ee("setting.edgeLine"),this.settings.display.showEdge,i=>{this.updateSettings({display:{showEdge:i}},!0)})),this.settings.display.showEdge&&e.appendChild(this.createSliderSection(Ee("setting.edgeOpacity"),this.settings.display.edgeOpacity,0,100,i=>this.updateSettings({display:{edgeOpacity:i}}))),e.appendChild(this.createToggleRow(Ee("setting.showGrid"),this.settings.display.showGrid,i=>{this.updateSettings({display:{showGrid:i}})})),e.appendChild(this.createToggleRow(Ee("setting.showLevel"),this.settings.display.showLevel,i=>{this.updateSettings({display:{showLevel:i}})})),e.appendChild(this.createToggleRow(Ee("setting.ground"),this.settings.display.showGround,i=>{const n=i?this.settings.display.groundId&&this.settings.display.groundId!=="0"?this.settings.display.groundId:this.presetLists.ground[0]?.id||"1":"0";this.updateSettings({display:{showGround:i,groundId:n}}),this.reopenAtSamePosition()})),this.settings.display.showGround){const i=this.presetLists.ground.map(c=>({value:c.id,label:this.getLocalizedPresetName(c.names,c.id)}));e.appendChild(this.createSelect(i,this.settings.display.groundId,c=>{this.updateSettings({display:{groundId:c}})}));const n=document.createElement("div");n.style.cssText=`${xA} margin-top: 10px;`;const s=document.createElement("span");s.style.cssText="font-size: 13px; color: var(--bim-text-secondary, #475569);",s.textContent=Ee("setting.groundElevation"),n.appendChild(s);const a=document.createElement("div");a.style.cssText="display: flex; align-items: center; gap: 4px;";const o=document.createElement("input");o.type="number",o.value=String(this.settings.display.groundHeight),o.style.cssText=`
|
||
width: 72px; padding: 4px 8px; border-radius: 4px;
|
||
border: 1px solid ${zn};
|
||
background: ${EA};
|
||
color: ${fo};
|
||
font-size: 13px; outline: none; text-align: right;
|
||
`,o.addEventListener("input",()=>{const c=Number(o.value);Number.isNaN(c)||this.updateSettings({display:{groundHeight:c}})});const l=document.createElement("span");l.style.cssText="font-size: 13px; color: var(--bim-text-secondary, #475569);",l.textContent=Ee("setting.groundElevationUnit"),a.appendChild(o),a.appendChild(l),n.appendChild(a),e.appendChild(n)}return e}createEnvironmentSection(){const e=document.createElement("div");e.style.cssText=_A;const t=document.createElement("div");t.style.cssText=yA,t.textContent=Ee("setting.environment"),e.appendChild(t);const i=document.createElement("div");i.style.cssText=`
|
||
display: flex; gap: 0; border-radius: 6px; overflow: hidden;
|
||
border: 1px solid ${zn};
|
||
margin-bottom: 10px;
|
||
`;const n=[{key:"none",labelKey:"setting.environmentType.none"},{key:"hdr",labelKey:"setting.environmentType.hdr"},{key:"sky",labelKey:"setting.environmentType.sky"}];for(let s=0;s<n.length;s++){const a=n[s],o=this.settings.environment.type===a.key,l=document.createElement("button");l.type="button",l.style.cssText=`
|
||
flex: 1; text-align: center; padding: 7px 0; cursor: pointer;
|
||
font-size: 13px; font-weight: 500; transition: all 0.15s;
|
||
background: ${o?po:"transparent"};
|
||
color: ${o?Gl:fo};
|
||
border: none;
|
||
${s<n.length-1?`border-right: 1px solid ${zn};`:""}
|
||
`,l.textContent=Ee(a.labelKey),l.addEventListener("click",()=>{this.updateSettings({environment:{type:a.key}},!0)}),i.appendChild(l)}if(e.appendChild(i),this.settings.environment.type==="hdr"){const s=this.presetLists.hdr.map(a=>({value:a.id,label:this.getLocalizedPresetName(a.names,a.id)}));e.appendChild(this.createSelect(s,this.settings.environment.hdrId,a=>{this.updateSettings({environment:{type:"hdr",hdrId:a}})}))}if(this.settings.environment.type==="sky"){const s=this.presetLists.sky.map(a=>({value:a.id,label:this.getLocalizedPresetName(a.names,a.id)}));e.appendChild(this.createSelect(s,this.settings.environment.skyPreset,a=>{this.updateSettings({environment:{type:"sky",skyPreset:a}})}))}return e}createSliderSection(e,t,i,n,s){const a=document.createElement("div");a.style.cssText="margin-bottom: 4px;";const o=document.createElement("div");o.style.cssText=`${xA} margin-bottom: 6px;`;const l=document.createElement("span");l.style.cssText="font-size: 13px; color: var(--bim-text-secondary, #475569);",l.textContent=e,o.appendChild(l);const c=document.createElement("span");c.style.cssText=h9,c.textContent=String(t),o.appendChild(c),a.appendChild(o);const h=document.createElement("input");return h.type="range",h.min=String(i),h.max=String(n),h.value=String(t),h.className="bim-setting-slider",h.style.cssText=`
|
||
width: 100%; height: 4px; -webkit-appearance: none; appearance: none;
|
||
background: var(--bim-border-strong, #cbd5e1); border-radius: 2px;
|
||
outline: none; cursor: pointer;
|
||
`,h.addEventListener("input",()=>{const d=Number(h.value);c.textContent=String(d),s(d)}),a.appendChild(h),a}createToggleRow(e,t,i){const n=document.createElement("div");n.style.cssText=xA;const s=document.createElement("span");s.style.cssText="font-size: 13px; color: var(--bim-text-secondary, #475569);",s.textContent=e,n.appendChild(s);const a="var(--bim-border-strong, #cbd5e1)",o=po;let l=t;const c=document.createElement("div");c.style.cssText=`
|
||
width: 40px; height: 22px; border-radius: 11px; cursor: pointer;
|
||
position: relative; transition: background 0.2s;
|
||
background: ${l?o:a};
|
||
`;const h=document.createElement("div");return h.style.cssText=`
|
||
width: 18px; height: 18px; border-radius: 50%;
|
||
background: #fff; position: absolute; top: 2px;
|
||
transition: left 0.2s;
|
||
box-shadow: 0 1px 3px rgba(0,0,0,0.2);
|
||
left: ${l?"20px":"2px"};
|
||
`,c.appendChild(h),c.addEventListener("click",()=>{l=!l,c.style.background=l?o:a,h.style.left=l?"20px":"2px",i(l)}),n.appendChild(c),n}createSelect(e,t,i){const n=document.createElement("select");n.style.cssText=`
|
||
width: 100%; padding: 7px 10px; border-radius: 6px;
|
||
border: 1px solid ${zn};
|
||
background: ${EA};
|
||
color: ${fo};
|
||
font-size: 13px; outline: none; cursor: pointer;
|
||
-webkit-appearance: none; appearance: none;
|
||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
|
||
background-repeat: no-repeat;
|
||
background-position: right 10px center;
|
||
padding-right: 28px;
|
||
`;for(const s of e){const a=document.createElement("option");a.value=s.value,a.textContent=s.label,s.value===t&&(a.selected=!0),n.appendChild(a)}return n.addEventListener("change",()=>i(n.value)),n.addEventListener("focus",()=>{n.style.borderColor=po}),n.addEventListener("blur",()=>{n.style.borderColor=zn}),n}async applyPresetById(e){const t=this.presetList.find(i=>i.id===e);t&&(this.selectedPresetId=e,await this.engineComponent?.setSettings(t.settings),this.settings=structuredClone(t.settings),this.isDirty=!1,this.logCurrentSettings("apply-preset"),this.updateUndoRestoreVisibility(),this.emit("setting:preset-changed",{preset:structuredClone(t),timestamp:Date.now()}),this.reopenAtSamePosition())}async updateSettings(e,t=!1){const i=this.mergeSettings(this.settings,e);try{await this.engineComponent?.setSettings(e)}catch(n){console.warn("[SettingDialogManager] Failed to apply settings patch, keep local state in sync.",n)}this.settings=i,this.isDirty=this.getCurrentSettingsDirtyState(i),this.logCurrentSettings("update-settings"),this.updateUndoRestoreVisibility(),t&&this.reopenAtSamePosition()}logCurrentSettings(e){console.log("[SettingDialogManager] current settings",{source:e,settings:structuredClone(this.settings)})}mergeSettings(e,t){return{render:{...e.render,...t.render},display:{...e.display,...t.display},environment:{...e.environment,...t.environment,skyParams:{...e.environment.skyParams,...t.environment?.skyParams}}}}getCurrentSettingsDirtyState(e){const t=this.presetList.find(i=>i.id===this.selectedPresetId);return t?JSON.stringify(t.settings)!==JSON.stringify(e):!1}getLocalizedPresetName(e,t){if(!Array.isArray(e)||e.length===0)return t;const i=Kt.getLocale();return i==="zh-CN"?e[0]||e[1]||e[2]||t:i==="zh-TW"?e[1]||e[0]||e[2]||t:e[2]||e[0]||e[1]||t}updateUndoRestoreVisibility(){const e=document.getElementById(this.dialogId);if(!e)return;const t=e.querySelector(`#${this.dialogId}-undo-btn`);t instanceof HTMLElement&&(t.style.display=this.isDirty&&this.selectedPresetId?"block":"none")}handleSaveCurrentPreset(){if(!this.isSelectedPresetAllowModify())return;if(!this.selectedPresetId){window.alert(Ee("setting.selectPresetFirst"));return}const e=this.presetList.findIndex(s=>s.id===this.selectedPresetId);if(e<0){window.alert(Ee("setting.selectPresetFirst"));return}const t=this.selectedPresetId,i=this.engineComponent?.getSettings()??structuredClone(this.settings),n={...this.presetList[e],settings:structuredClone(i),isDefault:!0};this.presetList=this.presetList.map((s,a)=>({...a===e?n:s,isDefault:a===e})),this.ensurePresetListWithInternalDefault(),this.selectedPresetId=t,this.settings=structuredClone(i),this.isDirty=!1,this.updateUndoRestoreVisibility(),this.emit("setting:preset-saved",{preset:structuredClone(n),currentSettings:structuredClone(i),timestamp:Date.now()}),this.reopenAtSamePosition()}saveAsPresetWithName(e){const t=e.trim();if(!t)return window.alert(Ee("setting.presetNameRequired")),!1;if(this.presetList.some(o=>o.presetName.toLowerCase()===t.toLowerCase()))return window.alert(Ee("setting.presetNameDuplicate")),!1;const n=this.engineComponent?.getSettings()??structuredClone(this.settings),s={id:`user-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,presetName:t,isDefault:!0,settings:structuredClone(n),source:"user",readonly:!1},a=this.presetList.filter(o=>o.id!==fr.INTERNAL_DEFAULT_PRESET_ID);return this.presetList=[...a.map(o=>({...o,isDefault:!1})),s],this.ensurePresetListWithInternalDefault(),this.selectedPresetId=s.id,this.settings=structuredClone(n),this.isDirty=!1,this.updateUndoRestoreVisibility(),this.emit("setting:preset-saved",{preset:structuredClone(s),currentSettings:structuredClone(n),timestamp:Date.now()}),this.reopenAtSamePosition(),!0}openDeletePresetConfirmModal(){if(!this.isSelectedPresetAllowModify()||!this.isSelectedPresetDeletable())return;this.closeDeletePresetConfirmModal();const e=document.getElementById(this.dialogId);if(!e)return;const t=document.createElement("div");t.style.cssText=`
|
||
position: absolute; inset: 0;
|
||
background: rgba(15, 23, 42, 0.35);
|
||
display: flex; align-items: center; justify-content: center;
|
||
z-index: 21;
|
||
`;const i=document.createElement("div");i.style.cssText=`
|
||
width: min(320px, calc(100% - 24px));
|
||
border-radius: 8px;
|
||
background: var(--bim-bg-elevated, #fff);
|
||
border: 1px solid ${zn};
|
||
padding: 12px;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 10px;
|
||
`;const n=document.createElement("div");n.textContent=Ee("setting.deleteDialogTitle"),n.style.cssText="font-size: 14px; font-weight: 600; color: var(--bim-text-primary, #0f172a);";const s=document.createElement("div");s.textContent=Ee("setting.deleteDialogMessage"),s.style.cssText="font-size: 13px; color: var(--bim-text-secondary, #475569);";const a=document.createElement("div");a.style.cssText="display: flex; justify-content: flex-end; gap: 8px;";const o=document.createElement("button");o.type="button",o.textContent=Ee("setting.cancel"),o.style.cssText=`
|
||
height: 32px; padding: 0 12px;
|
||
border-radius: 6px; border: 1px solid ${zn};
|
||
background: var(--bim-bg-elevated, #fff); color: ${fo}; cursor: pointer;
|
||
`,o.addEventListener("click",()=>this.closeDeletePresetConfirmModal());const l=document.createElement("button");l.type="button",l.textContent=Ee("setting.confirm"),l.style.cssText=`
|
||
height: 32px; padding: 0 12px;
|
||
border-radius: 6px; border: none;
|
||
background: #ef4444; color: ${Gl}; cursor: pointer;
|
||
`,l.addEventListener("click",()=>{this.deleteSelectedPreset(),this.closeDeletePresetConfirmModal()}),a.appendChild(o),a.appendChild(l),i.appendChild(n),i.appendChild(s),i.appendChild(a),t.appendChild(i),e.appendChild(t),this.deleteConfirmModalEl=t}closeDeletePresetConfirmModal(){this.deleteConfirmModalEl&&(this.deleteConfirmModalEl.remove(),this.deleteConfirmModalEl=null)}deleteSelectedPreset(){if(!this.isSelectedPresetDeletable()||!this.selectedPresetId)return;const e=this.presetList.find(t=>t.id===this.selectedPresetId);e&&(this.presetList=this.presetList.filter(t=>t.id!==this.selectedPresetId),this.ensurePresetListWithInternalDefault(),this.selectedPresetId=this.resolveDefaultPresetId(this.presetList)??this.presetList[0]?.id??null,this.applySelectedPresetFromList(),this.emit("setting:preset-deleted",structuredClone(e)),this.reopenAtSamePosition())}openSaveAsPresetModal(e){this.closeSaveAsPresetModal();const t=document.getElementById(this.dialogId);if(!t)return;const i=document.createElement("div");i.style.cssText=`
|
||
position: absolute; inset: 0;
|
||
background: rgba(15, 23, 42, 0.35);
|
||
display: flex; align-items: center; justify-content: center;
|
||
z-index: 20;
|
||
`;const n=document.createElement("div");n.style.cssText=`
|
||
width: min(320px, calc(100% - 24px));
|
||
border-radius: 8px;
|
||
background: var(--bim-bg-elevated, #fff);
|
||
border: 1px solid ${zn};
|
||
padding: 12px;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 10px;
|
||
`;const s=document.createElement("div");s.textContent=Ee("setting.saveAsDialogTitle"),s.style.cssText="font-size: 14px; font-weight: 600; color: var(--bim-text-primary, #0f172a);";const a=document.createElement("input");a.type="text",a.value=e??`${Ee("setting.presetDefaultName")} ${this.presetList.length+1}`,a.placeholder=Ee("setting.presetNamePlaceholder"),a.style.cssText=`
|
||
width: 100%; height: 34px; padding: 0 10px;
|
||
border-radius: 6px; border: 1px solid ${zn};
|
||
background: ${EA}; color: ${fo}; outline: none;
|
||
`;const o=document.createElement("div");o.style.cssText="display: flex; justify-content: flex-end; gap: 8px;";const l=document.createElement("button");l.type="button",l.textContent=Ee("setting.cancel"),l.style.cssText=`
|
||
height: 32px; padding: 0 12px;
|
||
border-radius: 6px; border: 1px solid ${zn};
|
||
background: var(--bim-bg-elevated, #fff); color: ${fo}; cursor: pointer;
|
||
`,l.addEventListener("click",()=>this.closeSaveAsPresetModal());const c=document.createElement("button");c.type="button",c.textContent=Ee("setting.confirm"),c.style.cssText=`
|
||
height: 32px; padding: 0 12px;
|
||
border-radius: 6px; border: none;
|
||
background: ${po}; color: ${Gl}; cursor: pointer;
|
||
`,c.addEventListener("click",()=>{this.saveAsPresetWithName(a.value)&&this.closeSaveAsPresetModal()}),a.addEventListener("keydown",h=>{h.key==="Enter"&&this.saveAsPresetWithName(a.value)&&this.closeSaveAsPresetModal(),h.key==="Escape"&&this.closeSaveAsPresetModal()}),o.appendChild(l),o.appendChild(c),n.appendChild(s),n.appendChild(a),n.appendChild(o),i.appendChild(n),t.appendChild(i),this.saveAsModalEl=i,window.requestAnimationFrame(()=>a.focus())}closeSaveAsPresetModal(){this.saveAsModalEl&&(this.saveAsModalEl.remove(),this.saveAsModalEl=null)}reopenAtSamePosition(){if(!this.isOpen())return;const e=document.getElementById(this.dialogId),t=this.getScrollableContentElement();if(e&&(this.savedPosition={x:e.offsetLeft,y:e.offsetTop}),t&&(this.savedScrollTop=t.scrollTop),this.hide(),this.show(),this.savedScrollTop!==null){const i=this.savedScrollTop;this.savedScrollTop=null,window.requestAnimationFrame(()=>{const n=this.getScrollableContentElement();n&&(n.scrollTop=i)})}}getScrollableContentElement(){const e=document.getElementById(this.dialogId);if(!e)return null;const t=e.querySelector(".setting-scroll-body");return t instanceof HTMLElement?t:null}ensureSliderStyle(){if(document.querySelector("#bim-setting-slider-style"))return;const e=document.createElement("style");e.id="bim-setting-slider-style",e.textContent=`
|
||
.bim-setting-slider::-webkit-slider-thumb {
|
||
-webkit-appearance: none; appearance: none;
|
||
width: 16px; height: 16px; border-radius: 50%;
|
||
background: var(--bim-primary, #3b82f6);
|
||
cursor: pointer;
|
||
border: 2px solid var(--bim-bg-elevated, #fff);
|
||
box-shadow: 0 1px 3px rgba(0,0,0,0.2);
|
||
}
|
||
.bim-setting-slider::-moz-range-thumb {
|
||
width: 16px; height: 16px; border-radius: 50%;
|
||
background: var(--bim-primary, #3b82f6);
|
||
cursor: pointer;
|
||
border: 2px solid var(--bim-bg-elevated, #fff);
|
||
box-shadow: 0 1px 3px rgba(0,0,0,0.2);
|
||
}
|
||
.bim-setting-slider::-moz-range-track {
|
||
background: var(--bim-border-strong, #cbd5e1);
|
||
height: 4px; border-radius: 2px; border: none;
|
||
}
|
||
`,document.head.appendChild(e)}}class p9{element;headerEl;contentEl;contentBoxEl;arrowEl;titleEl;config;parent;constructor(e,t){this.config=e,this.parent=t,this.element=this.createDom()}createDom(){const e=document.createElement("div");if(e.className=`bim-collapse-item ${this.config.className||""}`,this.config.disabled&&e.classList.add("is-disabled"),e.dataset.id=this.config.id,this.headerEl=document.createElement("div"),this.headerEl.className="bim-collapse-header",this.arrowEl=document.createElement("span"),this.arrowEl.className="bim-collapse-arrow",this.arrowEl.innerHTML='<svg viewBox="0 0 1024 1024"><path d="M288 192l448 320-448 320z"></path></svg>',this.headerEl.appendChild(this.arrowEl),this.config.icon){const t=document.createElement("span");t.className="bim-collapse-icon",t.innerHTML=this.config.icon,this.headerEl.appendChild(t)}if(this.titleEl=document.createElement("span"),this.titleEl.className="bim-collapse-title",this.titleEl.textContent=Ee(this.config.title),this.headerEl.appendChild(this.titleEl),this.config.extra){const t=document.createElement("div");t.className="bim-collapse-extra",typeof this.config.extra=="string"?t.innerHTML=this.config.extra:t.appendChild(this.config.extra),this.headerEl.appendChild(t)}return this.headerEl.addEventListener("click",()=>{this.config.disabled||this.parent.toggleItem(this.config.id)}),e.appendChild(this.headerEl),this.contentEl=document.createElement("div"),this.contentEl.className="bim-collapse-content is-hidden",this.contentBoxEl=document.createElement("div"),this.contentBoxEl.className="bim-collapse-content-box",typeof this.config.content=="string"?this.contentBoxEl.innerHTML=this.config.content:this.contentBoxEl.appendChild(this.config.content),this.contentEl.appendChild(this.contentBoxEl),e.appendChild(this.contentEl),e}updateLocale(){this.titleEl&&(this.titleEl.textContent=Ee(this.config.title))}setActive(e){e?(this.element.classList.add("is-active"),this.contentEl.classList.remove("is-hidden")):(this.element.classList.remove("is-active"),this.contentEl.classList.add("is-hidden"))}}class f9{element;options;items=new Map;activeIds=new Set;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e){this.options={bordered:!0,accordion:!1,...e},this.element=document.createElement("div"),this.element.className=`bim-collapse ${this.options.className||""}`,this.options.bordered||(this.element.style.border="none"),this.options.ghost&&this.element.classList.add("is-ghost");const t=typeof this.options.container=="string"?document.getElementById(this.options.container):this.options.container;t&&t.appendChild(this.element),this.options.activeIds&&this.options.activeIds.forEach(i=>this.activeIds.add(i)),this.init()}init(){this.options.items.forEach(e=>{const t=new p9(e,this);this.items.set(e.id,t),this.element.appendChild(t.element),this.activeIds.has(e.id)&&t.setActive(!0)}),this.unsubscribeLocale=Kt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ht.subscribe(e=>{this.setTheme(e)}),this.setTheme(ht.getTheme())}toggleItem(e){const t=this.activeIds.has(e);this.options.accordion?(this.activeIds.clear(),t||this.activeIds.add(e)):t?this.activeIds.delete(e):this.activeIds.add(e),this.refreshState(),this.options.onChange&&this.options.onChange(Array.from(this.activeIds))}refreshState(){this.items.forEach((e,t)=>{e.setActive(this.activeIds.has(t))})}setTheme(e){const t=this.element.style;t.setProperty("--bim-bg-elevated",e.bgElevated),t.setProperty("--bim-border-default",e.borderDefault),t.setProperty("--bim-border-subtle",e.borderSubtle),t.setProperty("--bim-border-strong",e.borderStrong),t.setProperty("--bim-text-primary",e.textPrimary),t.setProperty("--bim-text-disabled",e.textDisabled),t.setProperty("--bim-component-bg",e.componentBg),t.setProperty("--bim-component-bg-hover",e.componentBgHover),t.setProperty("--bim-component-bg-active",e.componentBgActive)}setLocales(){this.items.forEach(e=>e.updateLocale())}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove(),this.items.clear()}}class mM extends Hn{dialogId="component-detail-dialog";dialog=null;currentSelection=null;unsubscribeSelected=null;unsubscribeDeselected=null;propertiesData=null;constructor(e){super(e)}init(){this.unsubscribeSelected=this.registry.on("component:selected",e=>{this.currentSelection=e,this.isOpen()&&this.loadAndRenderContent()}),this.unsubscribeDeselected=this.registry.on("component:deselected",()=>{this.currentSelection=null,this.isOpen()&&this.renderNoSelection()})}show(){if(!this.registry.dialog){console.warn("[ComponentDetailManager] Dialog manager not initialized");return}this.isOpen()||this.createDialog(),this.currentSelection?this.loadAndRenderContent():this.renderNoSelection()}createDialog(){const t=document.body.clientWidth-300-40;this.dialog=this.registry.dialog?.create({id:this.dialogId,title:"panel.componentDetail.title",content:"",width:"300px",height:"500px",position:{x:t,y:20},resizable:!0,onClose:()=>this.hide()})}loadAndRenderContent(){!this.dialog||!this.currentSelection||(this.showLoading(),this.engineComponent?.getComponentProperties(this.currentSelection.url,this.currentSelection.id,e=>{this.propertiesData=e,this.renderTabbedContent()}))}showLoading(){const e=document.createElement("div");e.style.cssText="height:100%;display:flex;align-items:center;justify-content:center;",e.textContent="加载中...",this.dialog?.setContent(e)}renderNoSelection(){if(!this.dialog)return;const e=document.createElement("div");e.style.cssText="height:100%;display:flex;align-items:center;justify-content:center;color:var(--bim-text-secondary,#999);",e.textContent=Ee("panel.componentDetail.noSelection")||"请先选中构件",this.dialog.setContent(e)}renderTabbedContent(){if(!this.dialog)return;const e=document.createElement("div");e.style.cssText="height:100%;display:flex;flex-direction:column;";const t=this.createPropertiesPanel();e.appendChild(t),this.dialog.setContent(e)}createPropertiesPanel(){const e=document.createElement("div");e.style.cssText="height:100%;overflow-y:auto;";const i=[...this.propertiesData?.properties||[]].reverse();if(i.length===0)return e.innerHTML='<div style="padding:20px;text-align:center;color:var(--bim-text-secondary,#999);">无属性数据</div>',e;const n=i.map((a,o)=>({id:`category-${o}`,title:a.name||`分类 ${o+1}`,content:this.createCategoryContent(a.children||[])}));new f9({container:e,accordion:!1,ghost:!0,activeIds:n.length>0?[n[0].id]:[],items:n});const s=document.createElement("style");return s.textContent=`
|
||
#${this.dialogId} .bim-collapse-header {
|
||
background-color: var(--bim-component-bg-hover) !important;
|
||
}
|
||
#${this.dialogId} .bim-collapse-header:hover {
|
||
background-color: var(--bim-component-bg-active) !important;
|
||
}
|
||
`,e.appendChild(s),e}createCategoryContent(e){const t=document.createElement("div");return e.forEach((i,n)=>{const s=document.createElement("div");s.style.cssText=`
|
||
display: flex;
|
||
border-bottom: 1px solid var(--bim-border-default, rgba(255,255,255,0.15));
|
||
`,n===e.length-1&&(s.style.borderBottom="none");const a=document.createElement("div");a.style.cssText=`
|
||
width: 120px;
|
||
flex-shrink: 0;
|
||
color: var(--bim-text-secondary, #999);
|
||
font-size: 13px;
|
||
padding: 8px 12px;
|
||
border-right: 1px solid var(--bim-border-default, rgba(255,255,255,0.15));
|
||
`,a.textContent=i.name||"-";const o=document.createElement("div");o.style.cssText=`
|
||
flex: 1;
|
||
color: var(--bim-text-primary, #fff);
|
||
font-size: 13px;
|
||
padding: 8px 12px;
|
||
word-break: break-all;
|
||
`,o.textContent=String(i.value??"-"),s.appendChild(a),s.appendChild(o),t.appendChild(s)}),t}isOpen(){return this.dialog!==null}hide(){this.dialog&&(this.dialog.destroy(),this.dialog=null)}destroy(){this.unsubscribeSelected&&(this.unsubscribeSelected(),this.unsubscribeSelected=null),this.unsubscribeDeselected&&(this.unsubscribeDeselected(),this.unsubscribeDeselected=null),this.hide(),super.destroy()}}class m9{element;options;container;messagesContainer=null;textarea=null;messages=[];_isDestroyed=!1;_isVisible=!1;unsubscribeTheme=null;unsubscribeLocale=null;rafId=null;constructor(e){this.options={width:440,title:"aiChat.title",placeholder:"aiChat.placeholder",quickPrompts:[{id:"summarize",label:"aiChat.quickPrompt.summarize"},{id:"explain",label:"aiChat.quickPrompt.explain"},{id:"generate",label:"aiChat.quickPrompt.generate"}],...e},this.container=e.container,this.element=this.createDom(),this.init()}init(){this.container.appendChild(this.element),this.hide(),this.unsubscribeTheme=ht.subscribe(e=>{this.setTheme(e)}),this.unsubscribeLocale=Kt.subscribe(()=>{this.setLocales()}),this.setTheme(ht.getTheme()),this.setLocales()}setTheme(e){const t=e.name==="dark"||e.name?.includes("dark");this.element.classList.toggle("light",!t);const i=this.element.style;i.setProperty("--bim-ai-accent",e.primary),i.setProperty("--bim-ai-text",e.textPrimary),i.setProperty("--bim-ai-muted",e.textTertiary),i.setProperty("--bim-ai-border",e.borderDefault),i.setProperty("--bim-ai-shadow",e.shadowLg)}setLocales(){const e=this.element.querySelector(".bim-ai-chat-title");e&&this.options.title&&(e.textContent=Ee(this.options.title));const t=this.element.querySelector(".bim-ai-textarea");t&&this.options.placeholder&&(t.placeholder=Ee(this.options.placeholder));const i=this.element.querySelector(".bim-ai-helper-left");i&&(i.textContent=Ee("aiChat.helper.newline"));const n=this.element.querySelector(".bim-ai-helper-right");n&&(n.textContent=Ee("aiChat.helper.send")),this.updateQuickPrompts(),this.renderMessages()}show(){this._isVisible=!0,this.element.style.display="flex",this.initPosition(),this.scrollToBottom()}initPosition(){if(this.element.style.left)return;const e=this.container.clientWidth,t=this.element.offsetWidth,i=Math.max(50,e-t-50);this.element.style.left=`${i}px`,this.element.style.top="50px"}hide(){this._isVisible=!1,this.element.style.display="none"}toggle(){this._isVisible?this.hide():this.show()}isVisible(){return this._isVisible}addMessage(e){this.messages.push(e),this.renderMessages(),this.scrollToBottom()}updateMessage(e,t){const i=this.messages.findIndex(n=>n.id===e);i!==-1&&(this.messages[i]={...this.messages[i],...t},this.renderMessages())}removeMessage(e){this.messages=this.messages.filter(t=>t.id!==e),this.renderMessages()}clearMessages(){this.messages=[],this.renderMessages()}addUserMessage(e){const t=`user-${Date.now()}`;return this.addMessage({id:t,type:"user",content:e,timestamp:Date.now()}),t}addAiMessage(e){const t=`ai-${Date.now()}`;return this.addMessage({id:t,type:"ai",content:e,timestamp:Date.now()}),t}addStepMessage(e,t){const i=`step-${Date.now()}`;return this.addMessage({id:i,type:"step",status:e,content:t,timestamp:Date.now()}),i}addThinkingMessage(){const e=`thinking-${Date.now()}`;return this.addMessage({id:e,type:"thinking",timestamp:Date.now()}),e}addQuestionMessage(e,t,i){const n=`question-${Date.now()}`;return this.addMessage({id:n,type:"question",title:e,question:t,options:i,answered:!1,timestamp:Date.now()}),n}createDom(){const e=document.createElement("div");return e.className="bim-ai-chat",e.style.width=`${this.options.width}px`,e.innerHTML=`
|
||
<div class="bim-ai-chat-header">
|
||
<span class="bim-ai-chat-title"></span>
|
||
<div class="bim-ai-chat-actions">
|
||
<button class="bim-ai-chat-action-btn" data-action="new" title="${Ee("aiChat.action.new")}">
|
||
${It("plus")}
|
||
</button>
|
||
<button class="bim-ai-chat-action-btn" data-action="history" title="${Ee("aiChat.action.history")}">
|
||
${It("history")}
|
||
</button>
|
||
<button class="bim-ai-chat-action-btn" data-action="settings" title="${Ee("aiChat.action.settings")}">
|
||
${It("settings")}
|
||
</button>
|
||
<button class="bim-ai-chat-action-btn" data-action="close" title="${Ee("aiChat.action.close")}">
|
||
${It("close")}
|
||
</button>
|
||
</div>
|
||
</div>
|
||
<div class="bim-ai-chat-messages"></div>
|
||
<div class="bim-ai-chat-composer">
|
||
<div class="bim-ai-quick-prompts"></div>
|
||
<div class="bim-ai-input-row">
|
||
<div class="bim-ai-textbox">
|
||
<textarea class="bim-ai-textarea" rows="1"></textarea>
|
||
<div class="bim-ai-helper">
|
||
<span class="bim-ai-helper-left"></span>
|
||
<span class="bim-ai-helper-right"></span>
|
||
</div>
|
||
</div>
|
||
<button class="bim-ai-send-btn">
|
||
${It("arrowUpBold")}
|
||
</button>
|
||
</div>
|
||
</div>
|
||
`,this.messagesContainer=e.querySelector(".bim-ai-chat-messages"),this.textarea=e.querySelector(".bim-ai-textarea"),this.bindEvents(e),this.updateQuickPrompts(e),e}bindEvents(e){e.querySelectorAll(".bim-ai-chat-action-btn").forEach(a=>{a.addEventListener("click",o=>{switch(o.currentTarget.dataset.action){case"new":this.options.onNewChat?.();break;case"history":this.options.onHistory?.();break;case"settings":this.options.onSettings?.();break;case"close":this.hide(),this.options.onClose?.();break}})});const t=e.querySelector(".bim-ai-chat-header");t&&this.initDrag(t),e.querySelector(".bim-ai-send-btn")?.addEventListener("click",()=>this.handleSend()),this.textarea?.addEventListener("keydown",a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),this.handleSend())}),this.textarea?.addEventListener("input",()=>{this.textarea&&(this.textarea.style.height="auto",this.textarea.style.height=Math.min(this.textarea.scrollHeight,100)+"px")});const n=a=>a.stopPropagation();["click","dblclick","mousedown","mouseup","mousemove","wheel","touchstart","touchend","touchmove"].forEach(a=>{e.addEventListener(a,n,{passive:!1})})}handleSend(){if(!this.textarea)return;const e=this.textarea.value.trim();e&&(this.textarea.value="",this.textarea.style.height="auto",this.options.onSend?.(e))}initDrag(e){let t=0,i=0,n=0,s=0,a=0,o=0,l=0,c=0;const h=u=>{u.target.closest(".bim-ai-chat-action-btn")||(u.preventDefault(),u.stopPropagation(),t=u.clientX,i=u.clientY,n=this.element.offsetLeft,s=this.element.offsetTop,a=this.container.clientWidth,o=this.container.clientHeight,l=this.element.offsetWidth,c=this.element.offsetHeight,document.addEventListener("mousemove",d,{capture:!0}),document.addEventListener("mouseup",p,{capture:!0}))},d=u=>{u.preventDefault(),u.stopPropagation(),!this.rafId&&(this.rafId=requestAnimationFrame(()=>{const A=u.clientX-t,m=u.clientY-i;let g=n+A,f=s+m;const v=a-l,b=o-c;g=Math.max(0,Math.min(g,v)),f=Math.max(0,Math.min(f,b)),this.element.style.left=`${g}px`,this.element.style.top=`${f}px`,this.rafId=null}))},p=()=>{this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null),document.removeEventListener("mousemove",d,{capture:!0}),document.removeEventListener("mouseup",p,{capture:!0})};e.addEventListener("mousedown",h)}updateQuickPrompts(e){const i=(e||this.element).querySelector(".bim-ai-quick-prompts");!i||!this.options.quickPrompts||(i.innerHTML=this.options.quickPrompts.map(n=>`
|
||
<button class="bim-ai-quick-prompt" data-prompt-id="${n.id}">
|
||
${Ee(n.label)}
|
||
</button>
|
||
`).join(""),i.querySelectorAll(".bim-ai-quick-prompt").forEach(n=>{n.addEventListener("click",s=>{const a=s.currentTarget.dataset.promptId,o=this.options.quickPrompts?.find(l=>l.id===a);o&&this.textarea&&(this.textarea.value=Ee(o.label),this.textarea.focus())})}))}renderMessages(){this.messagesContainer&&(this.messagesContainer.innerHTML=this.messages.map(e=>{switch(e.type){case"user":return this.renderUserMessage(e.content);case"ai":return this.renderAiMessage(e.content);case"step":return this.renderStepMessage(e.status,e.content);case"thinking":return this.renderThinkingMessage();case"question":return e.answered?this.renderAnsweredQuestion(e):this.renderActiveQuestion(e);default:return""}}).join(""),this.bindQuestionEvents())}renderUserMessage(e){return`
|
||
<div class="bim-ai-msg-user">
|
||
<div class="bim-ai-bubble">
|
||
<div class="bim-ai-bubble-content">${this.escapeHtml(e)}</div>
|
||
</div>
|
||
</div>
|
||
`}renderAiMessage(e){return`
|
||
<div class="bim-ai-msg-ai">
|
||
<div class="bim-ai-bubble">
|
||
<div class="bim-ai-bubble-content">${this.escapeHtml(e)}</div>
|
||
</div>
|
||
</div>
|
||
`}renderStepMessage(e,t){return`
|
||
<div class="bim-ai-step bim-ai-step-${e}">
|
||
<span class="bim-ai-step-icon">${It({running:"loader",done:"check",error:"error"}[e])}</span>
|
||
<span class="bim-ai-step-text">${this.escapeHtml(t)}</span>
|
||
</div>
|
||
`}renderThinkingMessage(){return`
|
||
<div class="bim-ai-thinking">
|
||
<span class="bim-ai-thinking-icon">${It("loader")}</span>
|
||
<span class="bim-ai-thinking-text">${Ee("aiChat.thinking")}</span>
|
||
</div>
|
||
`}renderActiveQuestion(e){const t=e.options.map(i=>`
|
||
<div class="bim-ai-option ${e.selectedOptionId===i.id?"selected":""}"
|
||
data-question-id="${e.id}" data-option-id="${i.id}" data-is-other="${i.isOther||!1}">
|
||
<div class="bim-ai-option-radio">
|
||
<div class="bim-ai-option-radio-dot"></div>
|
||
</div>
|
||
<span class="bim-ai-option-text">${i.isOther?Ee("aiChat.other"):this.escapeHtml(i.label)}</span>
|
||
</div>
|
||
${i.isOther&&e.selectedOptionId===i.id?`
|
||
<input type="text" class="bim-ai-option-input"
|
||
data-question-id="${e.id}"
|
||
placeholder="${Ee("aiChat.otherPlaceholder")}"
|
||
value="${e.customAnswer||""}">
|
||
`:""}
|
||
`).join("");return`
|
||
<div class="bim-ai-question-active" data-question-id="${e.id}">
|
||
<div class="bim-ai-question-header">
|
||
<div class="bim-ai-question-icon">${It("bot")}</div>
|
||
<span class="bim-ai-question-title">${this.escapeHtml(e.title)}</span>
|
||
</div>
|
||
<div class="bim-ai-question-content">
|
||
<div class="bim-ai-question-text">${this.escapeHtml(e.question)}</div>
|
||
<div class="bim-ai-question-options">${t}</div>
|
||
</div>
|
||
<div class="bim-ai-question-footer">
|
||
<button class="bim-ai-question-submit" data-question-id="${e.id}">
|
||
<span>${Ee("aiChat.submit")}</span>
|
||
${It("send")}
|
||
</button>
|
||
</div>
|
||
</div>
|
||
`}renderAnsweredQuestion(e){const t=e.options.find(n=>n.id===e.selectedOptionId),i=t?.isOther?e.customAnswer:t?.label;return`
|
||
<div class="bim-ai-question-answered">
|
||
<div class="bim-ai-qa-row">
|
||
<div class="bim-ai-qa-badge bim-ai-qa-badge-q">Q</div>
|
||
<span class="bim-ai-qa-question">${this.escapeHtml(e.question)}</span>
|
||
</div>
|
||
<div class="bim-ai-qa-row">
|
||
<div class="bim-ai-qa-badge bim-ai-qa-badge-a">A</div>
|
||
<span class="bim-ai-qa-answer">${this.escapeHtml(i||"")}</span>
|
||
</div>
|
||
</div>
|
||
`}bindQuestionEvents(){this.messagesContainer?.querySelectorAll(".bim-ai-option").forEach(e=>{e.addEventListener("click",t=>{const i=t.currentTarget,n=i.dataset.questionId,s=i.dataset.optionId;if(n&&s){const a=this.messages.find(o=>o.id===n);a&&!a.answered&&(a.selectedOptionId=s,this.renderMessages())}})}),this.messagesContainer?.querySelectorAll(".bim-ai-option-input").forEach(e=>{e.addEventListener("input",t=>{const i=t.target,n=i.dataset.questionId;if(n){const s=this.messages.find(a=>a.id===n);s&&(s.customAnswer=i.value)}})}),this.messagesContainer?.querySelectorAll(".bim-ai-question-submit").forEach(e=>{e.addEventListener("click",t=>{const n=t.currentTarget.dataset.questionId;if(n){const s=this.messages.find(a=>a.id===n);s&&s.selectedOptionId&&(s.answered=!0,this.renderMessages(),this.options.onQuestionSubmit?.(n,s.selectedOptionId,s.customAnswer))}})})}scrollToBottom(){this.messagesContainer&&(this.messagesContainer.scrollTop=this.messagesContainer.scrollHeight)}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}destroy(){this._isDestroyed||(this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.element.remove(),this._isDestroyed=!0)}}class gM{aiChat=null;registry;initialized=!1;constructor(e){this.registry=e}init(){if(this.initialized)return;const e=this.registry.wrapper;if(!e){console.warn("[AiChatManager] wrapper 不存在,无法初始化");return}this.aiChat=new m9({container:e,width:440,title:"aiChat.title",placeholder:"aiChat.placeholder",quickPrompts:[{id:"summarize",label:"aiChat.quickPrompt.summarize"},{id:"explain",label:"aiChat.quickPrompt.explain"},{id:"generate",label:"aiChat.quickPrompt.generate"}],onSend:t=>{console.log("[AiChatManager] 用户发送消息:",t),this.aiChat?.addUserMessage(t),this.registry.emit("aiChat:message-sent",{message:t})},onQuestionSubmit:(t,i,n)=>{console.log("[AiChatManager] 用户回答问题:",{questionId:t,optionId:i,customAnswer:n}),this.registry.emit("aiChat:question-answered",{questionId:t,optionId:i,customAnswer:n})},onNewChat:()=>{console.log("[AiChatManager] 新建对话"),this.registry.emit("aiChat:new-chat",{})},onHistory:()=>{console.log("[AiChatManager] 打开历史"),this.registry.emit("aiChat:history-opened",{})},onSettings:()=>{console.log("[AiChatManager] 打开设置"),this.registry.emit("aiChat:settings-opened",{})},onClose:()=>{console.log("[AiChatManager] 关闭 AI 聊天"),this.registry.emit("aiChat:closed",{}),this.registry.toolbar?.setBtnActive("aiChat",!1)}}),this.initialized=!0}show(){this.aiChat||this.init(),this.aiChat?.show(),this.registry.emit("aiChat:opened",{}),this.registry.toolbar?.setBtnActive("aiChat",!0)}hide(){this.aiChat?.hide(),this.registry.emit("aiChat:closed",{}),this.registry.toolbar?.setBtnActive("aiChat",!1)}toggle(){this.aiChat?.isVisible()?this.hide():this.show()}isVisible(){return this.aiChat?.isVisible()??!1}addUserMessage(e){return this.aiChat?.addUserMessage(e)??""}addAiMessage(e){return this.aiChat?.addAiMessage(e)??""}addStepMessage(e,t){return this.aiChat?.addStepMessage(e,t)??""}addThinkingMessage(){return this.aiChat?.addThinkingMessage()??""}addQuestionMessage(e,t,i){return this.aiChat?.addQuestionMessage(e,t,i)??""}updateMessage(e,t){this.aiChat?.updateMessage(e,t)}removeMessage(e){this.aiChat?.removeMessage(e)}clearMessages(){this.aiChat?.clearMessages()}destroy(){this.aiChat&&(this.aiChat.destroy(),this.aiChat=null),this.initialized=!1}}class g9{container;options;groups=[];activeBtnIds=new Set;btnRefs=new Map;dropdownElement=null;hoverTimeout=null;customColors=new Set;unsubscribeLocale=null;unsubscribeTheme=null;DEFAULT_ICON='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect></svg>';constructor(e){const t=typeof e.container=="string"?document.getElementById(e.container):e.container;if(!t)throw new Error("Container not found");this.container=t,this.options={showLabel:!0,visibility:{},direction:"row",position:"static",align:"vertical",expand:"down",...e},["backgroundColor","btnBackgroundColor","btnHoverColor","btnActiveColor","iconColor","iconActiveColor","textColor","textActiveColor"].forEach(n=>{e[n]&&this.customColors.add(n)}),this.initContainer(),this.applyStyles()}emit(e,t){this.options.registry?.emit(e,t)}initContainer(){this.container.innerHTML="",this.container.classList.add("bim-btn-group-root"),this.options.direction==="column"?this.container.classList.add("dir-column"):this.container.classList.add("dir-row"),this.options.className&&this.container.classList.add(this.options.className),this.options.type&&this.options.type!=="default"&&this.container.classList.add(`type-${this.options.type}`),this.updatePosition(),this.setupEventInterception(this.container)}setupEventInterception(e){const t=n=>{n.stopPropagation()};["click","dblclick","contextmenu","wheel","mousedown","mouseup","mousemove","touchstart","touchend","touchmove","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointerover","pointerout"].forEach(n=>{e.addEventListener(n,t,{passive:!1})})}updatePosition(){const e=this.options.position,t=this.container.style;if(t.top="",t.bottom="",t.left="",t.right="",t.transform="",e==="static"){this.container.classList.add("static");return}if(this.container.classList.remove("static"),this.container.style.position="absolute",typeof e=="object"&&"x"in e)t.left=`${e.x}px`,t.top=`${e.y}px`;else{const i="20px";switch(e){case"top-left":t.top=i,t.left=i;break;case"top-center":t.top=i,t.left="50%",t.transform="translateX(-50%)";break;case"top-right":t.top=i,t.right=i;break;case"bottom-left":t.bottom=i,t.left=i;break;case"bottom-center":t.bottom=i,t.left="50%",t.transform="translateX(-50%)";break;case"bottom-right":t.bottom=i,t.right=i;break;case"left-center":t.left=i,t.top="50%",t.transform="translateY(-50%)";break;case"right-center":t.right=i,t.top="50%",t.transform="translateY(-50%)";break;case"center":t.top="50%",t.left="50%",t.transform="translate(-50%, -50%)";break}}}applyStyles(){const e=this.container.style;this.options.backgroundColor&&e.setProperty("--bim-btn-group-section-bg",this.options.backgroundColor),this.options.btnBackgroundColor&&e.setProperty("--bim-btn-bg",this.options.btnBackgroundColor),this.options.btnHoverColor&&e.setProperty("--bim-btn-hover-bg",this.options.btnHoverColor),this.options.btnActiveColor&&e.setProperty("--bim-btn-active-bg",this.options.btnActiveColor),this.options.iconColor&&e.setProperty("--bim-icon-color",this.options.iconColor),this.options.iconActiveColor&&e.setProperty("--bim-icon-active-color",this.options.iconActiveColor),this.options.textColor&&e.setProperty("--bim-btn-text-color",this.options.textColor),this.options.textActiveColor&&e.setProperty("--bim-btn-text-active-color",this.options.textActiveColor),document.querySelectorAll(".opt-btn-dropdown").forEach(i=>{const n=i.style;this.options.iconColor&&n.setProperty("--bim-icon-color",this.options.iconColor),this.options.iconActiveColor&&n.setProperty("--bim-icon-active-color",this.options.iconActiveColor),this.options.textColor&&n.setProperty("--bim-btn-text-color",this.options.textColor),this.options.textActiveColor&&n.setProperty("--bim-btn-text-active-color",this.options.textActiveColor),this.options.btnBackgroundColor&&n.setProperty("--bim-btn-bg",this.options.btnBackgroundColor),this.options.btnHoverColor&&n.setProperty("--bim-btn-hover-bg",this.options.btnHoverColor),this.options.btnActiveColor&&n.setProperty("--bim-btn-active-bg",this.options.btnActiveColor)})}setPrimaryColor(e){this.container.style.setProperty("--bim-primary-color",e),document.querySelectorAll(".opt-btn-dropdown").forEach(i=>{i.style.setProperty("--bim-primary-color",e)})}setTheme(e){const t={backgroundColor:e.bgElevated,btnBackgroundColor:e.componentBg,btnHoverColor:e.componentBgHover,btnActiveColor:e.componentBgActive,iconColor:e.iconDefault,iconActiveColor:e.iconActive,textColor:e.textSecondary,textActiveColor:e.textPrimary};Object.entries(t).forEach(([i,n])=>{const s=i;this.customColors.has(s)||(this.options[s]=n)}),this.container.classList.remove("theme-dark","theme-light"),this.container.classList.add(`theme-${e.name}`),this.applyStyles(),this.setPrimaryColor(e.primary),this.applyThemeCssVars(e)}applyThemeCssVars(e){const t=this.container.style;t.setProperty("--bim-primary",e.primary),t.setProperty("--bim-primary-hover",e.primaryHover),t.setProperty("--bim-primary-active",e.primaryActive),t.setProperty("--bim-bg-glass",e.bgGlass),t.setProperty("--bim-bg-glass-blur",e.bgGlassBlur),t.setProperty("--bim-bg-elevated",e.bgElevated),t.setProperty("--bim-bg-overlay",e.bgOverlay),t.setProperty("--bim-bg-inset",e.bgInset),t.setProperty("--bim-text-primary",e.textPrimary),t.setProperty("--bim-text-secondary",e.textSecondary),t.setProperty("--bim-text-tertiary",e.textTertiary),t.setProperty("--bim-text-inverse",e.textInverse),t.setProperty("--bim-icon-default",e.iconDefault),t.setProperty("--bim-icon-hover",e.iconHover),t.setProperty("--bim-icon-active",e.iconActive),t.setProperty("--bim-icon-inverse",e.iconInverse),t.setProperty("--bim-border-default",e.borderDefault),t.setProperty("--bim-border-subtle",e.borderSubtle),t.setProperty("--bim-component-bg-hover",e.componentBgHover),t.setProperty("--bim-component-bg-active",e.componentBgActive),t.setProperty("--bim-shadow-sm",e.shadowSm),t.setProperty("--bim-shadow-md",e.shadowMd),t.setProperty("--bim-shadow-lg",e.shadowLg),t.setProperty("--bim-shadow-glow",e.shadowGlow),t.setProperty("--bim-floating-bg",e.floatingBg),t.setProperty("--bim-floating-border",e.floatingBorder),t.setProperty("--bim-floating-shadow",e.floatingShadow),t.setProperty("--bim-floating-btn-bg",e.floatingBtnBg),t.setProperty("--bim-floating-btn-border",e.floatingBtnBorder),t.setProperty("--bim-floating-btn-shadow",e.floatingBtnShadow),t.setProperty("--bim-floating-btn-bg-hover",e.floatingBtnBgHover),t.setProperty("--bim-floating-btn-shadow-hover",e.floatingBtnShadowHover),t.setProperty("--bim-floating-icon-color",e.floatingIconColor),t.setProperty("--bim-floating-icon-color-hover",e.floatingIconColorHover),this.syncDropdownCssVars(e)}syncDropdownCssVars(e){document.querySelectorAll(".opt-btn-dropdown").forEach(i=>{const n=i.style;n.setProperty("--bim-primary",e.primary),n.setProperty("--bim-bg-overlay",e.bgOverlay),n.setProperty("--bim-border-default",e.borderDefault),n.setProperty("--bim-text-primary",e.textPrimary),n.setProperty("--bim-text-inverse",e.textInverse),n.setProperty("--bim-shadow-lg",e.shadowLg),n.setProperty("--bim-floating-btn-bg",e.floatingBtnBg),n.setProperty("--bim-floating-btn-bg-hover",e.floatingBtnBgHover),n.setProperty("--bim-floating-icon-color",e.floatingIconColor)})}setColors(e){this.options={...this.options,...e},Object.keys(e).forEach(t=>{this.customColors.add(t)}),this.applyStyles()}async init(){this.render(),this.unsubscribeLocale=Kt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ht.subscribe(e=>{this.setTheme(e)})}setLocales(){this.render()}addGroup(e,t){if(this.groups.some(n=>n.id===e))return;const i={id:e,buttons:[]};if(t){const n=this.groups.findIndex(s=>s.id===t);n!==-1?this.groups.splice(n,0,i):this.groups.push(i)}else this.groups.push(i)}addButton(e){const{groupId:t,parentId:i}=e,n=this.groups.find(a=>a.id===t);if(!n)return;const s={...e,children:e.children||[]};if(i){const a=this.findButton(n.buttons,i);a&&(a.children||(a.children=[]),a.children.push(s))}else n.buttons.push(s)}findButton(e,t){for(const i of e){if(i.id===t)return i;if(i.children){const n=this.findButton(i.children,t);if(n)return n}}}render(){this.container.innerHTML="",this.btnRefs.clear(),this.groups.forEach((e,t)=>{const i=this.renderGroup(e,t,this.groups.length);this.container.appendChild(i)})}renderGroup(e,t,i){const n=document.createElement("div");return n.className="bim-btn-group-section",t<i-1&&n.classList.add("has-divider"),e.buttons.forEach(s=>{if(this.isVisible(s.id)){const a=this.renderButton(s);n.appendChild(a)}}),n}renderButton(e){const t=document.createElement("div");t.className="opt-btn-wrapper";const i=document.createElement("div");i.className="opt-btn",e.isActive&&this.activeBtnIds.add(e.id),(e.align||this.options.align||"vertical")==="horizontal"?i.classList.add("align-horizontal"):i.classList.add("align-vertical"),this.activeBtnIds.has(e.id)&&i.classList.add("active"),e.disabled&&i.classList.add("disabled"),this.options.showLabel&&e.label||(i.classList.add("no-label"),e.label&&(i.title=Ee(e.label)));const a=e.iconSize||32,o=e.minWidth||50;i.style.minWidth=`${o}px`;const l=document.createElement("div");l.className="opt-btn-icon",l.style.width=`${a}px`,l.style.height=`${a}px`,l.innerHTML=this.getIcon(e.icon),i.appendChild(l);const c=document.createElement("div");if(c.className="opt-btn-text-wrapper",this.options.showLabel&&e.label){const h=document.createElement("span");h.className="opt-btn-label",h.textContent=Ee(e.label),c.appendChild(h)}return c.hasChildNodes()&&i.appendChild(c),i.addEventListener("click",()=>this.handleClick(e)),i.addEventListener("mouseenter",()=>this.handleMouseEnter(e,i)),i.addEventListener("mouseleave",()=>this.handleMouseLeave()),this.btnRefs.set(e.id,i),t.appendChild(i),t}setBtnActive(e,t){const i=this.findButtonById(e);if(!i)return;const n=t!==void 0?t:!this.activeBtnIds.has(e);n?this.activeBtnIds.add(e):this.activeBtnIds.delete(e),i.isActive=n,this.updateButtonState(e)}handleClick(e){if(!e.disabled&&(!e.children||e.children.length===0)){if(e.keepActive){const i=!this.activeBtnIds.has(e.id);this.setBtnActive(e.id,i),i&&e.exclusive&&e.groupId&&this.deactivateExclusiveSiblings(e)}this.closeDropdown(),e.onClick&&e.onClick(e)}}deactivateExclusiveSiblings(e){const t=this.groups.find(i=>i.id===e.groupId);if(t){if(e.parentId){const n=this.findButton(t.buttons,e.parentId)?.children||[];for(const s of n)s&&s.id!==e.id&&s.parentId===e.parentId&&s.groupId===e.groupId&&this.activeBtnIds.has(s.id)&&(this.setBtnActive(s.id,!1),s.onClick&&s.onClick(s));return}for(const i of t.buttons)i.id!==e.id&&i.groupId===e.groupId&&(i.parentId||this.activeBtnIds.has(i.id)&&(this.setBtnActive(i.id,!1),i.onClick&&i.onClick(i)))}}handleMouseEnter(e,t){this.hoverTimeout&&clearTimeout(this.hoverTimeout),e.children&&e.children.length>0?this.showDropdown(e,t):this.closeDropdown()}handleMouseLeave(){this.hoverTimeout=window.setTimeout(()=>this.closeDropdown(),200)}showDropdown(e,t){if(this.closeDropdown(),!e.children)return;const i=document.createElement("div");i.className="opt-btn-dropdown",this.options.backgroundColor&&i.style.setProperty("--bim-toolbar-bg",this.options.backgroundColor);const n=i.style;this.options.iconColor&&n.setProperty("--bim-icon-color",this.options.iconColor),this.options.iconActiveColor&&n.setProperty("--bim-icon-active-color",this.options.iconActiveColor),this.options.textColor&&n.setProperty("--bim-btn-text-color",this.options.textColor),this.options.textActiveColor&&n.setProperty("--bim-btn-text-active-color",this.options.textActiveColor),this.options.btnBackgroundColor&&n.setProperty("--bim-btn-bg",this.options.btnBackgroundColor),this.options.btnHoverColor&&n.setProperty("--bim-btn-hover-bg",this.options.btnHoverColor),this.options.btnActiveColor&&n.setProperty("--bim-btn-active-bg",this.options.btnActiveColor);const s=t.getBoundingClientRect(),a=this.options.expand||"down";this.options.direction==="row"?i.style.flexDirection="column":i.style.flexDirection="row",this.options.type&&this.options.type!=="default"&&i.classList.add(`type-${this.options.type}`);const o=ht.getTheme();i.classList.add(`theme-${o.name}`),n.setProperty("--bim-primary",o.primary),n.setProperty("--bim-bg-overlay",o.bgOverlay),n.setProperty("--bim-border-default",o.borderDefault),n.setProperty("--bim-text-primary",o.textPrimary),n.setProperty("--bim-text-inverse",o.textInverse),n.setProperty("--bim-shadow-lg",o.shadowLg),n.setProperty("--bim-floating-btn-bg",o.floatingBtnBg),n.setProperty("--bim-floating-btn-bg-hover",o.floatingBtnBgHover),n.setProperty("--bim-floating-icon-color",o.floatingIconColor),document.body.appendChild(i),this.setupEventInterception(i),e.children.forEach(c=>{if(this.isVisible(c.id)){const h=this.renderDropdownItem(c);i.appendChild(h)}});const l=i.getBoundingClientRect();a==="up"?(i.style.bottom=window.innerHeight-s.top+8+"px",i.style.left=s.left+(s.width-l.width)/2+"px"):a==="down"?(i.style.top=s.bottom+8+"px",i.style.left=s.left+(s.width-l.width)/2+"px"):a==="right"?(i.style.top=s.top+(s.height-l.height)/2+"px",i.style.left=s.right+8+"px"):a==="left"&&(i.style.top=s.top+(s.height-l.height)/2+"px",i.style.right=window.innerWidth-s.left+8+"px"),i.addEventListener("mouseenter",()=>{this.hoverTimeout&&clearTimeout(this.hoverTimeout)}),i.addEventListener("mouseleave",()=>this.handleMouseLeave()),this.dropdownElement=i}renderDropdownItem(e){const t=document.createElement("div");t.className="opt-btn-dropdown-item",(e.align||"horizontal")==="horizontal"?t.classList.add("align-horizontal"):t.classList.add("align-vertical"),(this.activeBtnIds.has(e.id)||e.isActive)&&t.classList.add("active");const n=e.iconSize||32,s=e.minWidth;s&&(t.style.minWidth=`${s}px`);const a=document.createElement("div");if(a.className="opt-btn-icon",a.style.width=`${n}px`,a.style.height=`${n}px`,a.innerHTML=this.getIcon(e.icon),t.appendChild(a),this.options.showLabel&&e.label){const o=document.createElement("span");o.className="opt-btn-dropdown-label",o.textContent=Ee(e.label),t.appendChild(o)}else e.label&&(t.title=Ee(e.label));return t.addEventListener("click",o=>{o.stopPropagation(),this.handleClick(e)}),t}closeDropdown(){this.dropdownElement&&(this.dropdownElement.remove(),this.dropdownElement=null),this.btnRefs.forEach(e=>{const t=e.querySelector(".opt-btn-arrow");t&&t.classList.remove("rotated")})}updateButtonState(e){const t=this.btnRefs.get(e);t&&(this.activeBtnIds.has(e)?t.classList.add("active"):t.classList.remove("active"))}getIcon(e){return e||this.DEFAULT_ICON}updateButtonIcon(e,t){const i=this.btnRefs.get(e);if(!i)return;const n=i.querySelector(".opt-btn-icon");n&&(n.innerHTML=this.getIcon(t));const s=this.findButtonById(e);s&&(s.icon=t)}updateButtonVisibility(e,t){this.options.visibility||(this.options.visibility={}),this.options.visibility[e]=t,this.render()}setShowLabel(e){this.options.showLabel=e,this.updateLabelsVisibility()}updateLabelsVisibility(){this.btnRefs.forEach((e,t)=>{const i=this.findButtonById(t);if(!i)return;this.options.showLabel&&i.label?(e.classList.remove("no-label"),e.removeAttribute("title")):(e.classList.add("no-label"),i.label&&(e.title=Ee(i.label)))})}findButtonById(e){for(const t of this.groups){const i=this.findButton(t.buttons,e);if(i)return i}}setBackgroundColor(e){this.setColors({backgroundColor:e})}isVisible(e){return this.options.visibility?.[e]!==!1}setType(e){this.container.classList.remove("type-default","type-glass-pill"),this.options.type=e,e&&e!=="default"&&this.container.classList.add(`type-${e}`),this.render()}getType(){return this.options.type||"default"}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.closeDropdown(),this.container.innerHTML="",this.btnRefs.clear()}}var ai=(r=>(r[r.Unchecked=0]="Unchecked",r[r.Checked=1]="Checked",r[r.Indeterminate=2]="Indeterminate",r))(ai||{});class A9{config;element;children=[];parent=null;checkState=ai.Unchecked;contentEl;switcherEl;checkboxEl=null;titleEl;actionsEl;childrenContainer;onExpandChange;onCheckChange;onNodeClick;renderActions;constructor(e,t,i){this.config=e,this.onExpandChange=i.onExpand,this.onCheckChange=i.onCheck,this.onNodeClick=i.onClick,this.renderActions=t.renderActions,this.checkState=e.checked?ai.Checked:ai.Unchecked,this.element=this.createDom(t)}createDom(e){const t=document.createElement("div");t.className="bim-tree-node",this.config.disabled&&t.classList.add("is-disabled"),this.contentEl=document.createElement("div"),this.contentEl.className="bim-tree-node-content",this.switcherEl=document.createElement("span"),this.switcherEl.className="bim-tree-switcher",this.switcherEl.innerHTML='<svg viewBox="0 0 1024 1024"><path d="M288 192l448 320-448 320z"></path></svg>';const i=this.config.children&&this.config.children.length>0;if(i?this.config.expanded&&this.switcherEl.classList.add("is-expanded"):this.switcherEl.classList.add("is-hidden"),this.switcherEl.addEventListener("click",s=>{s.stopPropagation(),this.toggleExpand()}),this.contentEl.appendChild(this.switcherEl),e.checkable!==!1&&(this.checkboxEl=document.createElement("span"),this.checkboxEl.className="bim-tree-checkbox",this.updateCheckboxUI(),this.checkboxEl.addEventListener("click",s=>{s.stopPropagation(),!this.config.disabled&&this.toggleCheck()}),this.contentEl.appendChild(this.checkboxEl)),this.config.icon){const s=document.createElement("span");s.className="bim-tree-icon",s.innerHTML=this.config.icon.includes("<svg")?this.config.icon:`<img src="${this.config.icon}" />`,this.contentEl.appendChild(s)}this.titleEl=document.createElement("span"),this.titleEl.className="bim-tree-title",this.updateLabel(),this.contentEl.appendChild(this.titleEl),this.actionsEl=document.createElement("div"),this.actionsEl.className="bim-tree-node-actions",this.actionsEl.addEventListener("click",s=>{s.stopPropagation()}),this.contentEl.appendChild(this.actionsEl),this.contentEl.addEventListener("click",s=>{if(s.stopPropagation(),this.config.disabled)return;(this.config.clickAction||"select")==="expand"?this.toggleExpand():this.onNodeClick(this)}),t.appendChild(this.contentEl),this.childrenContainer=document.createElement("div"),this.childrenContainer.className="bim-tree-children";const n=e.indent||24;return this.childrenContainer.style.paddingLeft=`${n}px`,this.config.expanded&&i&&this.childrenContainer.classList.add("is-visible"),t.appendChild(this.childrenContainer),t}setSelected(e){if(e){if(this.contentEl.classList.add("is-selected"),this.renderActions){const t=this.renderActions(this.config);this.actionsEl.innerHTML="",typeof t=="string"?this.actionsEl.innerHTML=t:t instanceof HTMLElement&&this.actionsEl.appendChild(t)}}else this.contentEl.classList.remove("is-selected"),this.actionsEl.innerHTML=""}updateLabel(){this.titleEl&&(this.titleEl.textContent=this.config.label)}toggleExpand(e){if(!this.config.children||this.config.children.length===0)return;const t=e!==void 0?e:!this.config.expanded;this.config.expanded=t,t?(this.switcherEl.classList.add("is-expanded"),this.childrenContainer.classList.add("is-visible")):(this.switcherEl.classList.remove("is-expanded"),this.childrenContainer.classList.remove("is-visible")),e===void 0&&this.onExpandChange(this)}toggleCheck(){const e=this.checkState!==ai.Checked;this.setChecked(e?ai.Checked:ai.Unchecked,!0)}setChecked(e,t=!1,i=!1){!i&&this.checkState===e||(this.checkState=e,this.config.checked=e===ai.Checked,this.updateCheckboxUI(),t&&this.onCheckChange(this))}updateCheckboxUI(){this.checkboxEl&&(this.checkboxEl.classList.remove("is-checked","is-indeterminate"),this.checkState===ai.Checked?this.checkboxEl.classList.add("is-checked"):this.checkState===ai.Indeterminate&&this.checkboxEl.classList.add("is-indeterminate"))}appendChild(e){e.parent=this,this.children.push(e),this.childrenContainer.appendChild(e.element),this.children.length===1&&this.switcherEl.classList.remove("is-hidden")}destroy(){this.children.forEach(e=>e.destroy()),this.children=[],this.element.remove(),this.parent=null}}class v9{element;contentElement;searchInput=null;searchResults=null;options;nodeMap=new Map;rootNodes=[];selectedNode=null;lastRevealedNodeId=null;unsubscribeLocale=null;unsubscribeTheme=null;clickOutsideHandler=null;onNodeCheck;onNodeSelect;onNodeDeselect;onNodeExpand;constructor(e){this.options={checkable:!0,checkStrictly:!0,indent:24,defaultExpandAll:!0,enableSearch:!1,searchPlaceholder:"tree.searchPlaceholder",...e},this.element=document.createElement("div"),this.element.className="bim-tree",this.options.enableSearch&&this.createSearchDOM(),this.contentElement=document.createElement("div"),this.contentElement.className="bim-tree-content",this.element.appendChild(this.contentElement),e.onNodeCheck&&(this.onNodeCheck=e.onNodeCheck),e.onNodeSelect&&(this.onNodeSelect=e.onNodeSelect),e.onNodeDeselect&&(this.onNodeDeselect=e.onNodeDeselect),e.onNodeExpand&&(this.onNodeExpand=e.onNodeExpand)}createSearchDOM(){const e=document.createElement("div");e.className="bim-tree-search";const t=document.createElement("div");t.className="bim-tree-search-wrapper";const i=document.createElement("span");i.className="bim-tree-search-icon",i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="m21 21l-4.343-4.343m0 0A8 8 0 1 0 5.343 5.343a8 8 0 0 0 11.314 11.314"/></svg>',t.appendChild(i),this.searchInput=document.createElement("input"),this.searchInput.className="bim-tree-search-input",this.searchInput.type="text",this.searchInput.placeholder=Ee(this.options.searchPlaceholder||"搜索..."),this.searchInput.addEventListener("input",n=>{const s=n.target.value;this.handleSearch(s)}),t.appendChild(this.searchInput),e.appendChild(t),this.searchResults=document.createElement("div"),this.searchResults.className="bim-tree-search-results",e.appendChild(this.searchResults),this.element.appendChild(e),this.clickOutsideHandler=n=>{this.searchResults&&!this.searchResults.contains(n.target)&&!this.searchInput?.contains(n.target)&&this.searchResults.classList.remove("is-visible")},document.addEventListener("click",this.clickOutsideHandler)}init(){this.render(),this.unsubscribeLocale=Kt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ht.subscribe(e=>this.setTheme(e)),this.setTheme(ht.getTheme())}handleSearch(e){if(!this.searchResults)return;if(!e.trim()){this.searchResults.classList.remove("is-visible"),this.searchResults.innerHTML="";return}const t=[],i=e.toLowerCase();this.nodeMap.forEach(n=>{const s=n.config.label;s.toLowerCase().includes(i)&&t.push({node:n,label:s,path:this.getNodePath(n)})}),this.renderSearchResults(t)}getNodePath(e){const t=[];let i=e.parent;for(;i;)t.unshift(i.config.label),i=i.parent;return t.join(" > ")}renderSearchResults(e){if(this.searchResults){if(this.searchResults.innerHTML="",e.length===0){const t=document.createElement("div");t.className="bim-tree-search-item",t.style.cursor="default",t.style.color="#999",t.textContent="No results",this.searchResults.appendChild(t)}else e.forEach(t=>{const i=document.createElement("div");i.className="bim-tree-search-item";const n=document.createElement("span");n.className="bim-tree-search-item-title",n.textContent=t.label;const s=document.createElement("span");s.className="bim-tree-search-item-path",s.textContent=t.path,i.appendChild(n),t.path&&i.appendChild(s),i.addEventListener("click",()=>{this.revealNode(t.node)}),this.searchResults.appendChild(i)});this.searchResults.classList.add("is-visible")}}revealNode(e){if(this.lastRevealedNodeId===e.config.id&&this.isNodeFullyVisible(e))return;this.lastRevealedNodeId=e.config.id,this.searchResults&&(this.searchResults.classList.remove("is-visible"),this.searchInput&&(this.searchInput.value=""));let t=e.parent;for(;t;)t.toggleExpand(!0),t=t.parent;this.handleNodeSelect(e),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.scrollNodeIntoContentCenter(e)})})}isNodeFullyVisible(e){const t=this.contentElement;if(!t||!e?.element?.isConnected)return!1;const i=t.getBoundingClientRect(),n=e.element.getBoundingClientRect();return n.top>=i.top&&n.bottom<=i.bottom}scrollNodeIntoContentCenter(e){const t=this.contentElement;if(!t||!e?.element?.isConnected)return;const i=t.getBoundingClientRect(),n=e.element.getBoundingClientRect();if(n.top>=i.top&&n.bottom<=i.bottom)return;const s=n.top-i.top+t.scrollTop,a=Math.max(0,s-(t.clientHeight-n.height)/2);t.scrollTo({top:a,behavior:"auto"})}setTheme(e){const t=this.element.style;t.setProperty("--bim-primary",e.primary),t.setProperty("--bim-bg-elevated",e.bgElevated),t.setProperty("--bim-text-primary",e.textPrimary),t.setProperty("--bim-text-secondary",e.textSecondary),t.setProperty("--bim-text-tertiary",e.textTertiary),t.setProperty("--bim-text-disabled",e.textDisabled),t.setProperty("--bim-text-inverse",e.textInverse),t.setProperty("--bim-border-default",e.borderDefault),t.setProperty("--bim-border-disabled",e.borderDisabled),t.setProperty("--bim-component-bg-hover",e.componentBgHover),t.setProperty("--bim-component-bg-selected",e.componentBgSelected),t.setProperty("--bim-component-bg-disabled",e.componentBgDisabled),t.setProperty("--bim-shadow-md",e.shadowMd),t.setProperty("--bim-focus-ring",e.focusRing)}setLocales(){this.nodeMap.forEach(e=>e.updateLabel()),this.searchInput&&(this.searchInput.placeholder=Ee(this.options.searchPlaceholder||"tree.searchPlaceholder"))}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null),this.rootNodes.forEach(e=>e.destroy()),this.rootNodes=[],this.nodeMap.clear(),this.lastRevealedNodeId=null,this.element.remove(),this.selectedNode=null}render(){this.contentElement.innerHTML="",this.nodeMap.clear(),this.rootNodes=[],this.options.data.forEach(e=>{this.createNodeRecursively(e,null)})}createNodeRecursively(e,t){e.expanded===void 0&&(e.expanded=this.options.defaultExpandAll);const i=new A9(e,this.options,{onExpand:n=>{this.onNodeExpand&&this.onNodeExpand(n)},onCheck:n=>this.handleNodeCheck(n),onClick:n=>this.handleNodeSelect(n)});this.nodeMap.set(e.id,i),t?t.appendChild(i):(this.rootNodes.push(i),this.contentElement.appendChild(i.element)),e.children&&e.children.length>0&&e.children.forEach(n=>{this.createNodeRecursively(n,i)})}handleNodeSelect(e){if(this.selectedNode===e){e.setSelected(!1),this.selectedNode=null,this.onNodeDeselect&&this.onNodeDeselect(e);return}this.selectedNode&&this.selectedNode.setSelected(!1),e.setSelected(!0),this.selectedNode=e,this.onNodeSelect&&this.onNodeSelect(e)}handleNodeCheck(e){const t=e.checkState===ai.Checked;if(this.onNodeCheck&&this.onNodeCheck(e),this.options.checkStrictly===!1)return;const i=(s,a)=>{s.children.forEach(o=>{o.config.disabled||(o.setChecked(a,!1),i(o,a))})};t?i(e,ai.Checked):i(e,ai.Unchecked);let n=e.parent;for(;n;){if(n.config.disabled){n=n.parent;continue}const s=n.children,a=s.every(l=>l.checkState===ai.Checked),o=s.every(l=>l.checkState===ai.Unchecked);a?n.setChecked(ai.Checked,!1):o?n.setChecked(ai.Unchecked,!1):n.setChecked(ai.Indeterminate,!1),n=n.parent}}getNode(e){return this.nodeMap.get(e)}checkNode(e,t){const i=this.nodeMap.get(e);i&&i.setChecked(t?ai.Checked:ai.Unchecked,!0)}expandAll(e){this.nodeMap.forEach(t=>t.toggleExpand(e))}checkAllNodes(e){const t=e?ai.Checked:ai.Unchecked;this.nodeMap.forEach(i=>i.setChecked(t,!1,!0))}getCheckedNodes(e=!1){const t=[];return this.nodeMap.forEach(i=>{(i.checkState===ai.Checked||e&&i.checkState===ai.Indeterminate)&&t.push(i.config)}),t}}class b9{element;navElement;contentElement;options;activeId;tabMap=new Map;panelMap=new Map;panelTreeScrollTopMap=new Map;unsubscribeLocale=null;unsubscribeTheme=null;navClickHandler=null;constructor(e){this.options=e,this.activeId=e.activeId||(e.tabs[0]?.id??null),e.tabs.forEach(t=>this.tabMap.set(t.id,t)),this.element=document.createElement("div"),this.element.className="bim-tab",this.navElement=document.createElement("div"),this.navElement.className="bim-tab__nav",this.navElement.setAttribute("role","tablist"),this.element.appendChild(this.navElement),this.contentElement=document.createElement("div"),this.contentElement.className="bim-tab__content",this.element.appendChild(this.contentElement),this.options.container.appendChild(this.element)}init(){this.renderNav(),this.renderPanels(),this.setLocales(),this.setTheme(ht.getTheme()),this.unsubscribeLocale=Kt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ht.subscribe(e=>this.setTheme(e))}renderNav(){this.navElement.innerHTML="",this.navClickHandler=e=>{const t=e.target.closest(".bim-tab__item");if(!t)return;const i=t.dataset.id;!i||this.tabMap.get(i)?.disabled||this.activateTab(i)},this.navElement.addEventListener("click",this.navClickHandler),this.options.tabs.forEach(e=>{const t=document.createElement("button");if(t.type="button",t.className="bim-tab__item",t.dataset.id=e.id,t.setAttribute("role","tab"),t.id=`tab-${e.id}`,t.setAttribute("aria-selected",`${e.id===this.activeId}`),e.disabled&&(t.disabled=!0,t.setAttribute("aria-disabled","true"),t.classList.add("is-disabled")),e.icon){const n=document.createElement("span");n.className="bim-tab__icon",n.innerHTML=e.icon,t.appendChild(n)}const i=document.createElement("span");i.className="bim-tab__title",i.textContent=this.resolveTitle(e.title),t.appendChild(i),e.id===this.activeId&&t.classList.add("is-active"),this.navElement.appendChild(t)})}renderPanels(){this.contentElement.innerHTML="",this.panelMap.clear(),this.options.tabs.forEach(e=>{const t=document.createElement("div");t.className="bim-tab__panel",t.dataset.id=e.id,t.setAttribute("role","tabpanel"),t.setAttribute("aria-labelledby",`tab-${e.id}`),e.content instanceof HTMLElement?t.appendChild(e.content):typeof e.content=="string"&&(t.innerHTML=e.content),e.id===this.activeId?t.classList.add("is-active"):t.style.display="none",this.panelMap.set(e.id,t),this.contentElement.appendChild(t)})}activateTab(e){if(this.activeId===e)return;const t=this.tabMap.get(e);if(!t||t.disabled)return;this.activeId=e,this.navElement.querySelectorAll(".bim-tab__item").forEach(n=>{const s=n.dataset.id===e;n.classList.toggle("is-active",s),n.setAttribute("aria-selected",`${s}`)}),this.panelMap.forEach((n,s)=>{const a=s===e;a||this.savePanelTreeScrollTop(s,n),n.classList.toggle("is-active",a),n.style.display=a?"":"none",a&&this.restorePanelTreeScrollTop(s,n)}),this.options.onChange&&this.options.onChange(e,t)}setTheme(e){const t=this.element.style;t.setProperty("--bim-tab-bg",e.bgElevated),t.setProperty("--bim-tab-nav-bg",e.bgElevated),t.setProperty("--bim-tab-text",e.textPrimary),t.setProperty("--bim-tab-text-secondary",e.textSecondary),t.setProperty("--bim-tab-text-active",e.primary),t.setProperty("--bim-tab-border",e.borderDefault),t.setProperty("--bim-tab-hover-bg",e.componentBgHover),t.setProperty("--bim-tab-active-bg",e.componentBgActive),t.setProperty("--bim-tab-icon",e.iconDefault)}setLocales(){this.navElement.querySelectorAll(".bim-tab__item").forEach(t=>{const i=t.dataset.id;if(!i)return;const n=this.tabMap.get(i);if(!n)return;const s=t.querySelector(".bim-tab__title");s&&(s.textContent=this.resolveTitle(n.title))})}destroy(){this.navClickHandler&&(this.navElement.removeEventListener("click",this.navClickHandler),this.navClickHandler=null),this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.panelMap.clear(),this.panelTreeScrollTopMap.clear(),this.tabMap.clear(),this.element.remove()}savePanelTreeScrollTop(e,t){const i=t.querySelector(".bim-tree-content");i&&this.panelTreeScrollTopMap.set(e,i.scrollTop)}restorePanelTreeScrollTop(e,t){const i=this.panelTreeScrollTopMap.get(e);if(i===void 0)return;const n=t.querySelector(".bim-tree-content");n&&requestAnimationFrame(()=>{n.scrollTop=i})}resolveTitle(e){try{return Ee(e)||e}catch{return e}}}function AM(r,e){let t=e>>>0;for(let i=0;i<r.length;i++){const n=r.charCodeAt(i);t^=n&255,t=Math.imul(t,16777619),t^=n>>>8&255,t=Math.imul(t,16777619)}return t>>>0}async function y9(r){const e=JSON.stringify(r),t=AM(e,2166136261),i=AM(e,522970236);return`${t.toString(16).padStart(8,"0")}${i.toString(16).padStart(8,"0")}`}function vM(r){const e=new Map,t=n=>{const s=n.config.data,a=s?._modelUrl;if(a&&s?.ids?.length){let o=e.get(a);o||(o=new Set,e.set(a,o));for(const l of s.ids){const c=Number(l);Number.isFinite(c)&&o.add(c)}}for(const o of n.children||[])t(o)};t(r);const i=[];for(const[n,s]of e)s.size>0&&i.push({url:n,ids:Array.from(s)});return i}let x9=0;async function _9(r){if(!r||r.length===0)return[];const e=async(t,i)=>{const n=t.children&&t.children.length>0;let s;return t.ids?.length?s=await y9(t.ids):t.id?s=t.id:s=`node_${++x9}`,{id:s,label:t.name||"未命名",expanded:!1,checked:!0,children:n?await Promise.all(t.children.map(a=>e(a,i))):void 0,data:{...t,_modelUrl:i}}};return Promise.all(r.map(async t=>{const i=t.children&&t.children.length>0,n=t.url;return{id:n,label:t.name||"模型",expanded:!0,checked:!0,children:i?await Promise.all(t.children.map(s=>e(s,n))):void 0,data:{_modelUrl:n}}}))}class E9 extends Hn{toolbar=null;toolbarContainer=null;container;dialog=null;constructor(e,t){super(t),this.container=e,this.init()}init(){this.toolbarContainer=document.createElement("div"),this.toolbarContainer.id="bim-construct-tree",this.container.appendChild(this.toolbarContainer),this.toolbar=new g9({container:this.toolbarContainer,showLabel:!1,direction:"column",position:"top-left",align:"vertical",expand:"up",registry:this.registry}),this.toolbar.init(),this.toolbar.addGroup("construct-tree"),this.toolbar.addButton({id:"construct-tree-btn",groupId:"construct-tree",type:"button",label:"construct-tree",icon:It("目录树"),onClick:()=>{this.openConstructTreeDialog()}}),this.toolbar.render()}async openConstructTreeDialog(){this.setVisible(!1);const e=this.engineComponent?.getLevelTreeData()??[],t=this.engineComponent?.getTypeTreeData()??[],i=this.engineComponent?.getMajorTreeData()??[];console.log("[ConstructTree] 原始数据 (Level):",e),console.log("[ConstructTree] 原始数据 (Type):",t),console.log("[ConstructTree] 原始数据 (Major):",i);const n=async(m,g)=>{const f=await _9(m);console.log(`[ConstructTree] 转换后数据 (${g}):`,f);const v=new v9({data:f,checkable:!0,indent:0,enableSearch:!0,checkStrictly:!0,defaultExpandAll:!0,onNodeCheck:b=>{const y=vM(b);y.length&&(b.checkState===ai.Checked?this.engineComponent?.showModel(y):this.engineComponent?.hideModels(y))},onNodeSelect:b=>{const y=vM(b);y.length&&(this.engineComponent?.unhighlightAllModels(),this.engineComponent?.highlightModel(y),this.engineComponent?.viewScaleToModel(y))},onNodeDeselect:()=>{this.engineComponent?.unhighlightAllModels()},onNodeExpand:()=>{this.dialog?.fitWidth()}});return v.init(),v},s=await n(e,"Level"),a=await n(t,"Type"),o=await n(i,"Major"),l=document.createElement("div");l.className="construct-tab__panel-content",l.appendChild(s.element);const c=document.createElement("div");c.className="construct-tab__panel-content",c.appendChild(a.element);const h=document.createElement("div");h.className="construct-tab__panel-content",h.appendChild(o.element);const d=document.createElement("div");d.className="construct-tab__container",d.style.height="100%",d.style.overflow="hidden";const p=()=>{this.engineComponent?.showAllModels(),s.checkAllNodes(!0),a.checkAllNodes(!0),o.checkAllNodes(!0)},u=new b9({container:d,tabs:[{id:"component",title:"tab.component",content:l},{id:"type",title:"tab.type",content:c},{id:"major",title:"tab.major",content:h}],activeId:"component",onChange:()=>{this.dialog?.fitWidth()}});u.init(),p();const A=this.registry.on("menu:show-all",()=>{p()});this.dialog=this.registry.dialog.create({title:"constructTree.title",minWidth:320,height:600,content:d,position:{x:20,y:20},resizable:!1,onClose:()=>{A(),u.destroy(),s.destroy(),a.destroy(),o.destroy(),this.setVisible(!0)}}),this.dialog?.fitWidth()}refresh(){this.toolbar?.render()}destroy(){this.toolbar?.destroy(),this.toolbar=null,super.destroy()}addGroup(e,t){this.toolbar?.addGroup(e,t),this.toolbar?.render()}addButton(e){this.toolbar?.addButton(e),this.toolbar?.render()}setButtonVisibility(e,t){this.toolbar?.updateButtonVisibility(e,t)}setShowLabel(e){this.toolbar?.setShowLabel(e)}setVisible(e){this.toolbarContainer&&(this.toolbarContainer.style.visibility=e?"visible":"hidden")}setBackgroundColor(e){this.toolbar?.setBackgroundColor(e)}setColors(e){this.toolbar?.setColors(e)}}class M9{events=new Map;on(e,t){return this.events.has(e)||this.events.set(e,[]),this.events.get(e).push(t),()=>this.off(e,t)}off(e,t){const i=this.events.get(e);if(!i)return;const n=i.indexOf(t);n!==-1&&i.splice(n,1)}emit(e,t){const i=this.events.get(e);i&&i.forEach(n=>{try{n(t)}catch(s){console.error(`[EventEmitter] Error in listener for event "${e}":`,s)}})}clear(){this.events.clear()}}class ff{eventEmitter=new M9;container=null;wrapper=null;toolbar=null;dialog=null;engine3d=null;buttonGroup=null;rightKey=null;constructTree=null;measure=null;walkControl=null;sectionPlane=null;sectionAxis=null;sectionBox=null;walkPath=null;walkPlanView=null;engineInfo=null;componentDetail=null;aiChat=null;setting=null;radialToolbar=null;bottomDock=null;measureDock=null;sectionDock=null;walkDock=null;constructor(){}reset(){this.eventEmitter.clear(),this.container=null,this.wrapper=null,this.toolbar=null,this.dialog=null,this.engine3d=null,this.buttonGroup=null,this.rightKey=null,this.constructTree=null,this.measure=null,this.walkControl=null,this.sectionPlane=null,this.sectionAxis=null,this.sectionBox=null,this.walkPath=null,this.walkPlanView=null,this.engineInfo=null,this.componentDetail=null,this.aiChat=null,this.setting=null,this.radialToolbar=null,this.bottomDock=null,this.measureDock=null,this.sectionDock=null,this.walkDock=null}emit(e,t){this.eventEmitter.emit(e,t)}on(e,t){return this.eventEmitter.on(e,t)}off(e,t){this.eventEmitter.off(e,t)}clearEvents(){this.eventEmitter.clear()}}class w9{container;wrapper=null;sizeEl=null;resizeObserver=null;lastSyncedWidth=-1;lastSyncedHeight=-1;registry;dialog=null;engine=null;rightKey=null;radialToolbar=null;bottomDock=null;measureDock=null;sectionDock=null;walkDock=null;measure=null;sectionPlane=null;sectionAxis=null;sectionBox=null;walkControl=null;engineInfo=null;componentDetail=null;aiChat=null;setting=null;constructTreeBtn=null;handleWindowResize=()=>{this.updateClientSizeDisplay()};constructor(e,t){const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,this.registry=new ff,t?.locale&&Kt.setLocale(t.locale),t?.theme&&(t.theme==="custom"?console.warn("Custom theme should be set via setCustomTheme()."):ht.setTheme(t.theme)),this.init()}emit(e,t){this.registry.emit(e,t)}on(e,t){return this.registry.on(e,t)}setLocale(e){Kt.setLocale(e)}getLocale(){return Kt.getLocale()}setTheme(e){ht.setTheme(e)}setCustomTheme(e){ht.setCustomTheme(e)}init(){this.container.innerHTML="",this.wrapper=document.createElement("div"),this.wrapper.className="bim-engine-wrapper",this.container.appendChild(this.wrapper);const e=document.createElement("div");e.className="bim-engine-version",e.textContent="v2.5.9",this.wrapper.appendChild(e),this.sizeEl=document.createElement("div"),this.sizeEl.className="bim-engine-size",this.wrapper.appendChild(this.sizeEl),this.updateClientSizeDisplay(),this.bindSizeObserver(),this.registry.container=this.container,this.registry.wrapper=this.wrapper,this.engine=new XE(this.wrapper,this.registry),this.dialog=new IA(this.wrapper,this.registry),this.rightKey=new bA(this.wrapper,this.registry),this.bottomDock=new ZE(this.wrapper,this.registry),this.registry.bottomDock=this.bottomDock,this.measureDock=new iM(this.registry),this.registry.measureDock=this.measureDock,this.measureDock.init(),this.sectionDock=new nM(this.registry),this.registry.sectionDock=this.sectionDock,this.sectionDock.init(),this.walkDock=new aM(this.registry),this.registry.walkDock=this.walkDock,this.walkDock.init(),this.radialToolbar=new KE(this.wrapper,this.registry),this.measure=new oM(this.registry),this.sectionPlane=new lM(this.registry),this.sectionAxis=new cM(this.registry),this.sectionBox=new dM(this.registry),this.walkControl=new uM(this.registry),this.walkControl.init(),this.engineInfo=new pM(this.registry),this.engineInfo.init(),this.registry.engine3d=this.engine,this.registry.dialog=this.dialog,this.registry.rightKey=this.rightKey,this.registry.radialToolbar=this.radialToolbar,this.registry.measure=this.measure,this.registry.sectionPlane=this.sectionPlane,this.registry.sectionAxis=this.sectionAxis,this.registry.sectionBox=this.sectionBox,this.registry.walkControl=this.walkControl,this.registry.engineInfo=this.engineInfo,this.componentDetail=new mM(this.registry),this.registry.componentDetail=this.componentDetail,this.componentDetail.init(),this.aiChat=new gM(this.registry),this.registry.aiChat=this.aiChat,this.aiChat.init(),this.constructTreeBtn=new E9(this.wrapper,this.registry),this.registry.constructTree=this.constructTreeBtn,this.setting=new fr(this.registry),this.registry.setting=this.setting,this.setting.init(),this.updateTheme(ht.getTheme()),ht.subscribe(t=>{this.updateTheme(t)})}updateTheme(e){this.wrapper&&(this.wrapper.style.color=e.textPrimary)}updateClientSizeDisplay(){const e=this.container.clientWidth,t=this.container.clientHeight;this.sizeEl&&(this.sizeEl.textContent=`${e}px x ${t}px`),this.syncEngineSize(e,t)}syncEngineSize(e,t){e<=0||t<=0||e===this.lastSyncedWidth&&t===this.lastSyncedHeight||(this.lastSyncedWidth=e,this.lastSyncedHeight=t,this.engine?.getEngineComponent()?.resize(e,t))}bindSizeObserver(){if(typeof ResizeObserver<"u"){this.resizeObserver=new ResizeObserver(()=>{this.updateClientSizeDisplay()}),this.resizeObserver.observe(this.container);return}window.addEventListener("resize",this.handleWindowResize)}unbindSizeObserver(){if(this.resizeObserver){this.resizeObserver.disconnect(),this.resizeObserver=null;return}window.removeEventListener("resize",this.handleWindowResize)}destroy(){this.unbindSizeObserver(),this.radialToolbar?.destroy(),this.measureDock?.destroy(),this.sectionDock?.destroy(),this.walkDock?.destroy(),this.bottomDock?.destroy(),this.engine?.destroy(),this.dialog?.destroy(),this.rightKey?.destroy(),this.measure?.destroy(),this.sectionPlane?.destroy(),this.sectionAxis?.destroy(),this.sectionBox?.destroy(),this.walkControl?.destroy(),this.constructTreeBtn?.destroy(),this.aiChat?.destroy(),this.setting?.destroy(),this.sizeEl=null,this.lastSyncedWidth=-1,this.lastSyncedHeight=-1,this.container.innerHTML="",this.registry.reset()}}class S9{container;wrapper=null;sizeEl=null;resizeObserver=null;lastSyncedWidth=-1;lastSyncedHeight=-1;unsubscribeTheme=null;registry;dialog=null;engine=null;rightKey=null;radialToolbar=null;bottomDock=null;measureDock=null;sectionDock=null;walkDock=null;measure=null;sectionPlane=null;sectionAxis=null;sectionBox=null;walkControl=null;engineInfo=null;componentDetail=null;aiChat=null;setting=null;handleWindowResize=()=>{this.updateClientSizeDisplay()};constructor(e,t){const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,this.registry=new ff,t?.locale&&Kt.setLocale(t.locale),t?.theme&&(t.theme==="custom"?console.warn("Custom theme should be set via setCustomTheme()."):ht.setTheme(t.theme)),this.init()}emit(e,t){this.registry.emit(e,t)}on(e,t){return this.registry.on(e,t)}setLocale(e){Kt.setLocale(e)}getLocale(){return Kt.getLocale()}setTheme(e){ht.setTheme(e)}setCustomTheme(e){ht.setCustomTheme(e)}init(){this.container.innerHTML="",this.wrapper=document.createElement("div"),this.wrapper.className="bim-engine-wrapper",this.container.appendChild(this.wrapper);const e=document.createElement("div");e.className="bim-engine-version",e.textContent="v2.5.9",this.wrapper.appendChild(e),this.sizeEl=document.createElement("div"),this.sizeEl.className="bim-engine-size",this.wrapper.appendChild(this.sizeEl),this.updateClientSizeDisplay(),this.bindSizeObserver(),this.registry.container=this.container,this.registry.wrapper=this.wrapper,this.engine=new XE(this.wrapper,this.registry),this.dialog=new IA(this.wrapper,this.registry),this.rightKey=new bA(this.wrapper,this.registry),this.bottomDock=new ZE(this.wrapper,this.registry),this.registry.bottomDock=this.bottomDock,this.registry.engine3d=this.engine,this.registry.dialog=this.dialog,this.registry.rightKey=this.rightKey,this.measureDock=new iM(this.registry),this.registry.measureDock=this.measureDock,this.measureDock.init(),this.sectionDock=new nM(this.registry),this.registry.sectionDock=this.sectionDock,this.sectionDock.init(),this.walkDock=new aM(this.registry),this.registry.walkDock=this.walkDock,this.walkDock.init(),this.radialToolbar=new KE(this.wrapper,this.registry),this.measure=new oM(this.registry),this.sectionPlane=new lM(this.registry),this.sectionAxis=new cM(this.registry),this.sectionBox=new dM(this.registry),this.walkControl=new uM(this.registry),this.walkControl.init(),this.engineInfo=new pM(this.registry),this.engineInfo.init(),this.registry.radialToolbar=this.radialToolbar,this.registry.measure=this.measure,this.registry.sectionPlane=this.sectionPlane,this.registry.sectionAxis=this.sectionAxis,this.registry.sectionBox=this.sectionBox,this.registry.walkControl=this.walkControl,this.registry.engineInfo=this.engineInfo,this.componentDetail=new mM(this.registry),this.registry.componentDetail=this.componentDetail,this.componentDetail.init(),this.aiChat=new gM(this.registry),this.registry.aiChat=this.aiChat,this.aiChat.init(),this.setting=new fr(this.registry),this.registry.setting=this.setting,this.setting.init(),this.updateTheme(ht.getTheme()),this.unsubscribeTheme=ht.subscribe(t=>{this.updateTheme(t)})}updateTheme(e){this.wrapper&&(this.wrapper.style.color=e.textPrimary)}updateClientSizeDisplay(){const e=this.container.clientWidth,t=this.container.clientHeight;this.sizeEl&&(this.sizeEl.textContent=`${e}px x ${t}px`),this.syncEngineSize(e,t)}syncEngineSize(e,t){e<=0||t<=0||e===this.lastSyncedWidth&&t===this.lastSyncedHeight||(this.lastSyncedWidth=e,this.lastSyncedHeight=t,this.engine?.getEngineComponent()?.resize(e,t))}bindSizeObserver(){if(typeof ResizeObserver<"u"){this.resizeObserver=new ResizeObserver(()=>{this.updateClientSizeDisplay()}),this.resizeObserver.observe(this.container);return}window.addEventListener("resize",this.handleWindowResize)}unbindSizeObserver(){if(this.resizeObserver){this.resizeObserver.disconnect(),this.resizeObserver=null;return}window.removeEventListener("resize",this.handleWindowResize)}destroy(){this.unbindSizeObserver(),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.radialToolbar?.destroy(),this.measureDock?.destroy(),this.sectionDock?.destroy(),this.walkDock?.destroy(),this.bottomDock?.destroy(),this.engine?.destroy(),this.dialog?.destroy(),this.rightKey?.destroy(),this.measure?.destroy(),this.sectionPlane?.destroy(),this.sectionAxis?.destroy(),this.sectionBox?.destroy(),this.walkControl?.destroy(),this.aiChat?.destroy(),this.setting?.destroy(),this.sizeEl=null,this.lastSyncedWidth=-1,this.lastSyncedHeight=-1,this.container.innerHTML="",this.registry.reset()}}class C9{engine=null;registry;container;containerId;options;_isInitialized=!1;_isDestroyed=!1;unsubscribeTheme=null;constructor(e,t){this.registry=t,this.container=e.container,this.container.id?this.containerId=this.container.id:(this.containerId=`engine2d-container-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,this.container.id=this.containerId),this.options={backgroundColor:e.backgroundColor??1710618,gridEnabled:e.gridEnabled??!0,axesEnabled:e.axesEnabled??!0,selectionColor:e.selectionColor,highlightColor:e.highlightColor,enablePerformanceMonitoring:e.enablePerformanceMonitoring??!0}}init(){if(this._isInitialized){console.warn("[Engine2d] Engine already initialized.");return}if(this._isDestroyed){console.error("[Engine2d] Cannot initialize destroyed engine.");return}try{const e={containerId:this.containerId,backgroundColor:this.options.backgroundColor,gridEnabled:this.options.gridEnabled,axesEnabled:this.options.axesEnabled};if(this.options.selectionColor!==void 0&&(e.selectionColor=this.options.selectionColor),this.options.highlightColor!==void 0&&(e.highlightColor=this.options.highlightColor),this.options.enablePerformanceMonitoring!==void 0&&(e.enablePerformanceMonitoring=this.options.enablePerformanceMonitoring),console.log("[Engine2d] 引擎配置信息:",e),this.engine=QF(e),!this.engine)throw new Error("Failed to create 2D engine instance");this._isInitialized=!0,this.unsubscribeTheme=ht.subscribe(t=>{this.setTheme(t)}),this.setTheme(ht.getTheme()),this.engine.events&&(this.engine.events.on("entity-click",t=>{console.log("[Engine2d] 实体点击:",t),this.registry.emit("engine2d:entity-clicked",{data:t})}),this.engine.events.on("layer-visibility-changed",t=>{console.log("[Engine2d] 图层可见性变更:",t),this.registry.emit("engine2d:layer-changed",{data:t})}))}catch(e){throw console.error("[Engine2d] Failed to initialize 2D engine:",e),this._isInitialized=!1,e}}setTheme(e){}setLocales(){}isInitialized(){return this._isInitialized}async loadDrawing(e,t){if(!this._isInitialized||!this.engine){console.error("[Engine2d] Engine not initialized. Please call init() first.");return}if(!e){console.error("[Engine2d] Drawing URL is required.");return}try{console.log("[Engine2d] 开始加载图纸:",e),await this.engine.loadModel(e,t),console.log("[Engine2d] 图纸加载完成:",e),this.registry.emit("engine2d:drawing-loaded",{url:e})}catch(i){throw console.error("[Engine2d] 图纸加载失败:",i),i}}getLayers(){if(!this._isInitialized||!this.engine)return[];try{return this.engine.getLayers?.()??[]}catch(e){return console.warn("[Engine2d] Failed to get layers:",e),[]}}setLayerVisible(e,t){if(!this._isInitialized||!this.engine){console.warn("[Engine2d] Engine not initialized.");return}try{this.engine.setLayerVisible?.(e,t)}catch(i){console.warn("[Engine2d] Failed to set layer visibility:",i)}}resetView(){if(!(!this._isInitialized||!this.engine))try{this.engine.resetView?.()}catch(e){console.warn("[Engine2d] Failed to reset view:",e)}}fitToView(){if(!(!this._isInitialized||!this.engine))try{this.engine.fitToView?.()}catch(e){console.warn("[Engine2d] Failed to fit to view:",e)}}setZoom(e){!this._isInitialized||!this.engine||this.engine.setZoom?.(e)}getZoom(){return!this._isInitialized||!this.engine?1:this.engine.getZoom?.()??1}setBackgroundColor(e){!this._isInitialized||!this.engine||this.engine.setBackgroundColor?.(e)}clearScene(){!this._isInitialized||!this.engine||this.engine.clearScene?.()}resize(){!this._isInitialized||!this.engine||this.engine.resize?.()}onRawEvent(e,t){this.engine?.events?.on(e,t)}offRawEvent(e,t){this.engine?.events?.off(e,t)}destroy(){if(!this._isDestroyed){if(this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.engine){try{this.engine.dispose?.()}catch(e){console.warn("[Engine2d] Error during dispose:",e)}this.engine=null}this.container.innerHTML="",this._isDestroyed=!0,this._isInitialized=!1}}}class T9{container;registry;engineComponent=null;constructor(e,t){const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,this.registry=new ff,t?.locale&&Kt.setLocale(t.locale),t?.theme&&t.theme!=="custom"&&ht.setTheme(t.theme),this.engineComponent=new C9({container:this.container,backgroundColor:t?.backgroundColor,gridEnabled:t?.gridEnabled,axesEnabled:t?.axesEnabled,selectionColor:t?.selectionColor,highlightColor:t?.highlightColor,enablePerformanceMonitoring:t?.enablePerformanceMonitoring},this.registry),this.engineComponent.init()}async loadDrawing(e,t){return this.engineComponent?.loadDrawing(e,t)}getLayers(){return this.engineComponent?.getLayers()??[]}setLayerVisible(e,t){this.engineComponent?.setLayerVisible(e,t)}resetView(){this.engineComponent?.resetView()}fitToView(){this.engineComponent?.fitToView()}setZoom(e){this.engineComponent?.setZoom(e)}getZoom(){return this.engineComponent?.getZoom()??1}setTheme(e){ht.setTheme(e)}on(e,t){return this.registry.on(e,t)}off(e,t){this.registry.off(e,t)}onRawEvent(e,t){this.engineComponent?.onRawEvent(e,t)}offRawEvent(e,t){this.engineComponent?.offRawEvent(e,t)}destroy(){this.engineComponent?.destroy(),this.engineComponent=null,this.registry.reset()}}class I9{engine=null;registry;container;containerId;options;_isInitialized=!1;_isDestroyed=!1;unsubscribeTheme=null;constructor(e,t){this.registry=t,this.container=e.container,this.container.id?this.containerId=this.container.id:(this.containerId=`engine720-container-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,this.container.id=this.containerId),this.options={fov:e.fov??75,enableZoom:e.enableZoom??!0,enableRotate:e.enableRotate??!0,sphereRadius:e.sphereRadius??500,rotateSpeed:e.rotateSpeed,zoomSpeed:e.zoomSpeed,enableDamping:e.enableDamping,dampingFactor:e.dampingFactor,minFov:e.minFov,maxFov:e.maxFov}}init(){if(this._isInitialized){console.warn("[Engine720] Engine already initialized.");return}if(this._isDestroyed){console.error("[Engine720] Cannot initialize destroyed engine.");return}try{const e={containerId:this.containerId,fov:this.options.fov,enableZoom:this.options.enableZoom,enableRotate:this.options.enableRotate,sphereRadius:this.options.sphereRadius};if(this.options.rotateSpeed!==void 0&&(e.rotateSpeed=this.options.rotateSpeed),this.options.zoomSpeed!==void 0&&(e.zoomSpeed=this.options.zoomSpeed),this.options.enableDamping!==void 0&&(e.enableDamping=this.options.enableDamping),this.options.dampingFactor!==void 0&&(e.dampingFactor=this.options.dampingFactor),this.options.minFov!==void 0&&(e.minFov=this.options.minFov),this.options.maxFov!==void 0&&(e.maxFov=this.options.maxFov),console.log("[Engine720] 引擎配置信息:",e),this.engine=WF(e),!this.engine)throw new Error("Failed to create 720 engine instance");this._isInitialized=!0,this.unsubscribeTheme=ht.subscribe(t=>{this.setTheme(t)}),this.setTheme(ht.getTheme()),this.engine.events&&(this.engine.events.on("panorama-loaded",t=>{console.log("[Engine720] 全景加载完成:",t),this.registry.emit("engine720:panorama-loaded",{data:t})}),this.engine.events.on("panorama-load-error",t=>{console.error("[Engine720] 全景加载失败:",t),this.registry.emit("engine720:load-error",{data:t})}),this.engine.events.on("annotation-click",t=>{console.log("[Engine720] 标注点击:",t),this.registry.emit("engine720:annotation-click",{data:t})}),this.engine.events.on("view-angle-changed",t=>{this.registry.emit("engine720:view-changed",{data:t})}))}catch(e){throw console.error("[Engine720] Failed to initialize 720 engine:",e),this._isInitialized=!1,e}}setTheme(e){!this._isInitialized||this.engine}setLocales(){}isInitialized(){return this._isInitialized}async loadPanorama(e,t){if(!this._isInitialized||!this.engine){console.error("[Engine720] Engine not initialized. Please call init() first.");return}if(!e){console.error("[Engine720] Panorama URL is required.");return}try{console.log("[Engine720] 开始加载全景图:",e),await this.engine.loadPanorama(e),console.log("[Engine720] 全景图加载完成:",e)}catch(i){throw console.error("[Engine720] 全景图加载失败:",i),i}}async preloadPanoramas(e){if(!(!this._isInitialized||!this.engine))try{await this.engine.preloadPanoramas?.(e)}catch(t){console.warn("[Engine720] Failed to preload panoramas:",t)}}setFov(e){!this._isInitialized||!this.engine||this.engine.setFov?.(e)}getFov(){return!this._isInitialized||!this.engine?75:this.engine.getFov?.()??75}lookAt(e,t,i){!this._isInitialized||!this.engine||this.engine.lookAt?.(e,t,i)}resetView(){if(!(!this._isInitialized||!this.engine))try{this.engine.lookAt?.(0,0,!0),this.engine.setFov?.(75)}catch(e){console.warn("[Engine720] Failed to reset view:",e)}}pauseRendering(){!this._isInitialized||!this.engine||this.engine.pauseRendering?.()}resumeRendering(){!this._isInitialized||!this.engine||this.engine.resumeRendering?.()}resize(e,t){!this._isInitialized||!this.engine||this.engine.resize?.(e,t)}onRawEvent(e,t){this.engine?.events?.on(e,t)}offRawEvent(e,t){this.engine?.events?.off(e,t)}destroy(){if(!this._isDestroyed){if(this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.engine){try{this.engine.dispose?.()}catch(e){console.warn("[Engine720] Error during dispose:",e)}this.engine=null}this.container.innerHTML="",this._isDestroyed=!0,this._isInitialized=!1}}}class P9{container;registry;engineComponent=null;constructor(e,t){const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,this.registry=new ff,t?.locale&&Kt.setLocale(t.locale),t?.theme&&t.theme!=="custom"&&ht.setTheme(t.theme),this.engineComponent=new I9({container:this.container,fov:t?.fov,enableZoom:t?.enableZoom,enableRotate:t?.enableRotate,sphereRadius:t?.sphereRadius,rotateSpeed:t?.rotateSpeed,zoomSpeed:t?.zoomSpeed,enableDamping:t?.enableDamping,dampingFactor:t?.dampingFactor,minFov:t?.minFov,maxFov:t?.maxFov},this.registry),this.engineComponent.init()}async loadPanorama(e,t){return this.engineComponent?.loadPanorama(e,t)}async preloadPanoramas(e){return this.engineComponent?.preloadPanoramas(e)}setFov(e){this.engineComponent?.setFov(e)}getFov(){return this.engineComponent?.getFov()??75}lookAt(e,t,i){this.engineComponent?.lookAt(e,t,i)}resetView(){this.engineComponent?.resetView()}setTheme(e){ht.setTheme(e)}on(e,t){return this.registry.on(e,t)}off(e,t){this.registry.off(e,t)}onRawEvent(e,t){this.engineComponent?.onRawEvent(e,t)}offRawEvent(e,t){this.engineComponent?.offRawEvent(e,t)}destroy(){this.engineComponent?.destroy(),this.engineComponent=null,this.registry.reset()}}const R9=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 需求分析与步骤规划专家\r
|
||
\r
|
||
## 角色定位\r
|
||
\r
|
||
你是一位资深的**AI+BIM轻量化引擎架构专家**,具备以下核心能力:\r
|
||
\r
|
||
1. **深度理解BIM引擎架构**:精通BIM引擎的模块化设计、API体系、数据结构和交互模式\r
|
||
2. **需求分析能力**:能够准确理解用户意图,识别模糊需求,提出精准的澄清问题\r
|
||
3. **任务分解能力**:将复杂需求拆解为可执行的、原子化的操作步骤\r
|
||
4. **技术决策能力**:根据需求特点选择最优的API组合和实现路径\r
|
||
\r
|
||
你的职责是通过分析用户需求,生成结构化的执行步骤,指导代码生成模块完成BIM引擎的功能实现。\r
|
||
\r
|
||
## 工作流程\r
|
||
\r
|
||
如果存在疑问,你就不能输出最终的步骤,只有当你把所有的疑问清楚后,你才可以输出步骤,如果存在疑问,你要以bim模型为载体,不能问一下和bim模型不想干的问题,尽量没有或减少问题\r
|
||
\r
|
||
### 阶段一:需求理解与分析\r
|
||
\r
|
||
当接收到用户需求时,你需要:\r
|
||
\r
|
||
1. **深度分析需求**:\r
|
||
- 理解用户的核心目标\r
|
||
- 识别涉及到的BIM引擎模块(场景、相机、模型、测量、剖切等)\r
|
||
- 分析数据流向和依赖关系\r
|
||
- 评估需求的复杂度和可行性\r
|
||
\r
|
||
2. **识别模糊点**:\r
|
||
- 检查需求中是否存在歧义、缺失信息或边界条件不明确的情况\r
|
||
- 判断是否需要用户澄清才能继续\r
|
||
\r
|
||
3. **决策是否需要提问**:\r
|
||
- **仅在必要时提问**:如果需求足够清晰,直接进入步骤规划阶段\r
|
||
- **避免过度提问**:不要为了提问而提问,不要询问可以从上下文推断的信息\r
|
||
- **精准提问**:每个问题都应该针对关键决策点,影响后续实现路径\r
|
||
\r
|
||
### 阶段二:需求澄清(如需要)\r
|
||
\r
|
||
如果需要用户澄清,请按照以下格式输出:\r
|
||
\r
|
||
**输出格式**:\r
|
||
\`\`\`\r
|
||
##question## \r
|
||
json内容\r
|
||
\`\`\`\r
|
||
\r
|
||
**JSON格式规范**:\r
|
||
\`\`\`json\r
|
||
[\r
|
||
{\r
|
||
"id": 0,\r
|
||
"question": "您是否需要设置所有的构件?",\r
|
||
"answers": [\r
|
||
"A. 是的,设置所有构件",\r
|
||
"B. 只设置1F层的构件",\r
|
||
"C. 根据特定条件筛选构件"\r
|
||
]\r
|
||
},\r
|
||
{\r
|
||
"id": 1,\r
|
||
"question": "颜色设置的优先级是什么?",\r
|
||
"answers": [\r
|
||
"A. 按构件类型设置",\r
|
||
"B. 按楼层设置",\r
|
||
"C. 按自定义属性设置"\r
|
||
]\r
|
||
}\r
|
||
]\r
|
||
\`\`\`\r
|
||
\r
|
||
**提问原则**:\r
|
||
- 每个问题必须针对一个明确的决策点\r
|
||
- 答案选项应该互斥且覆盖主要场景\r
|
||
- 问题数量控制在3个以内,优先询问最关键的问题\r
|
||
- 问题描述清晰、具体,避免模糊表述\r
|
||
- 不要强行提问,尽量减少或不提问题\r
|
||
### 阶段三:步骤规划\r
|
||
\r
|
||
当需求清晰后,你需要将用户意图拆解为一系列可执行的步骤。\r
|
||
\r
|
||
**输出格式**:\r
|
||
\`\`\`\r
|
||
##steps## \r
|
||
json内容\r
|
||
\r
|
||
\`\`\`\r
|
||
\r
|
||
**JSON格式规范**:\r
|
||
\`\`\`json\r
|
||
[\r
|
||
{\r
|
||
"id": 0,\r
|
||
"content": "获取所有桩基模型",\r
|
||
"description": "通过modelTree模块遍历模型树,筛选出类型为'桩基'的所有构件,返回构件ID数组和构件对象数组",\r
|
||
"output": "{\\"modelIds\\": [\\"id1\\", \\"id2\\", ...], \\"models\\": [modelObject1, modelObject2, ...]}",\r
|
||
"dependencies": [],\r
|
||
"apiModules": ["modelTree", "dataModule"]\r
|
||
},\r
|
||
{\r
|
||
"id": 1,\r
|
||
"content": "设置桩基模型颜色为红色",\r
|
||
"description": "使用modelMapperBatch模块的批量设置方法,将上一步获取的所有桩基模型的颜色属性设置为红色(RGB: 255, 0, 0)",\r
|
||
"output": "{\\"success\\": true, \\"count\\": 10, \\"failedIds\\": []}",\r
|
||
"dependencies": [0],\r
|
||
"apiModules": ["modelMapperBatch"]\r
|
||
}\r
|
||
]\r
|
||
\`\`\`\r
|
||
\r
|
||
**字段说明**:\r
|
||
- \`id\`: 步骤唯一标识符,从0开始递增\r
|
||
- \`content\`: 步骤的简短描述(一句话概括)\r
|
||
- \`description\`: 步骤的详细功能说明,包括:\r
|
||
- 具体要做什么\r
|
||
- 使用哪些API模块\r
|
||
- 如何处理数据\r
|
||
- 可能的边界情况\r
|
||
- \`output\`: 步骤输出的数据格式说明(JSON Schema格式),用于:\r
|
||
- 指导代码生成模块返回正确的数据结构\r
|
||
- 确保步骤间的数据传递正确\r
|
||
- \`dependencies\`: 依赖的步骤ID数组,表示此步骤需要等待哪些步骤完成\r
|
||
- \`apiModules\`: 此步骤涉及到的BIM引擎模块名称数组(如:modelTree, cameraModule, measure等)\r
|
||
\r
|
||
**步骤规划原则**:\r
|
||
1. **原子化**:每个步骤应该只完成一个明确的功能点\r
|
||
2. **可执行**:每个步骤都应该能够独立生成可执行的代码\r
|
||
3. **依赖清晰**:明确标注步骤间的依赖关系,确保执行顺序正确\r
|
||
4. **数据流转**:每个步骤的输出格式要明确,便于后续步骤使用\r
|
||
5. **模块化**:合理利用BIM引擎的模块化设计,选择最合适的API\r
|
||
6. **错误处理**:在关键步骤中考虑异常情况的处理\r
|
||
\r
|
||
## 硬性要求\r
|
||
\r
|
||
### 1. 输出格式规范\r
|
||
- **必须严格遵循**上述JSON格式,字段名称和类型不能改变\r
|
||
- JSON必须是有效的、可解析的格式\r
|
||
- 步骤ID必须连续且从0开始\r
|
||
- 依赖关系必须正确,不能出现循环依赖\r
|
||
\r
|
||
### 2. 需求理解要求\r
|
||
- **深度理解**:不能停留在表面理解,要理解用户的真实意图和业务场景\r
|
||
- **上下文感知**:结合BIM引擎的特性,理解每个需求在BIM场景下的实际意义\r
|
||
- **技术可行性**:确保规划的步骤在BIM引擎API能力范围内\r
|
||
\r
|
||
### 3. 步骤质量要求\r
|
||
- **完整性**:步骤应该覆盖用户需求的所有方面,不能遗漏关键环节\r
|
||
- **准确性**:步骤描述要准确,不能有歧义或错误\r
|
||
- **可执行性**:每个步骤都应该能够生成可执行的代码\r
|
||
- **效率性**:优先选择高效的API组合,避免不必要的中间步骤\r
|
||
\r
|
||
### 4. 错误预防\r
|
||
- 检查步骤间的数据格式是否匹配\r
|
||
- 确保依赖关系正确,避免执行顺序错误\r
|
||
- 验证API模块名称是否正确\r
|
||
- 考虑边界情况和异常处理\r
|
||
\r
|
||
### 5. 代码生成友好\r
|
||
- 步骤描述要足够详细,让代码生成模块能够准确理解意图\r
|
||
- 输出格式说明要具体,使用JSON Schema或示例数据\r
|
||
- 明确标注使用的API模块,便于代码生成时快速定位\r
|
||
\r
|
||
## 最佳实践\r
|
||
\r
|
||
1. **先理解后规划**:充分理解需求后再开始规划步骤,避免返工\r
|
||
2. **模块优先**:优先使用BIM引擎提供的功能模块,而不是底层API\r
|
||
3. **数据驱动**:明确每个步骤的输入输出,确保数据流清晰\r
|
||
4. **可扩展性**:考虑未来可能的扩展需求,设计灵活的步骤结构\r
|
||
5. **用户友好**:步骤描述要清晰易懂,便于用户理解整个执行流程\r
|
||
\r
|
||
\r
|
||
''`},Symbol.toStringTag,{value:"Module"})),D9=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 代码生成专家\r
|
||
\r
|
||
## 角色定位\r
|
||
\r
|
||
你是一位资深的**BIM引擎代码生成专家**,具备以下核心能力:\r
|
||
\r
|
||
1. **BIM引擎API精通**:深度掌握BIM引擎的所有模块API、方法签名、参数类型和返回值\r
|
||
2. **代码生成能力**:能够根据步骤描述,生成高质量、可执行、符合规范的JavaScript代码\r
|
||
3. **上下文理解**:能够理解步骤间的数据流转,正确处理前序步骤的输出结果\r
|
||
4. **错误处理能力**:具备完善的异常处理和边界情况处理能力\r
|
||
5. **代码质量意识**:生成的代码应该具备良好的可读性、可维护性和性能\r
|
||
\r
|
||
你的职责是根据步骤规划模块提供的步骤描述,生成可直接在BIM引擎环境中执行的JavaScript代码片段。\r
|
||
\r
|
||
## 工作流程\r
|
||
\r
|
||
### 阶段一:理解步骤要求\r
|
||
\r
|
||
当接收到步骤执行请求时,你需要:\r
|
||
\r
|
||
1. **解析步骤信息**:\r
|
||
- 理解步骤的\`content\`(简短描述)和\`description\`(详细说明)\r
|
||
- 识别步骤涉及到的BIM引擎模块(\`apiModules\`字段)\r
|
||
- 理解步骤的依赖关系(\`dependencies\`字段)\r
|
||
- 明确步骤的预期输出格式(\`output\`字段)\r
|
||
\r
|
||
2. **分析上下文数据**:\r
|
||
- 如果有前序步骤的输出结果,分析其数据结构\r
|
||
- 理解当前步骤需要使用的输入数据\r
|
||
- 验证数据格式是否匹配步骤要求\r
|
||
\r
|
||
3. **确定实现方案**:\r
|
||
- 根据步骤描述,选择最合适的BIM引擎API\r
|
||
- 设计数据转换和处理逻辑\r
|
||
- 规划错误处理策略\r
|
||
\r
|
||
### 阶段二:生成代码\r
|
||
\r
|
||
根据步骤要求生成可执行的JavaScript代码。\r
|
||
\r
|
||
**输出格式**:\r
|
||
\`\`\`\r
|
||
##code##\r
|
||
[可执行的JavaScript代码]\r
|
||
\`\`\`\r
|
||
\r
|
||
**代码生成规范**:\r
|
||
\r
|
||
1. **代码结构**:\r
|
||
- 代码必须是一个完整的、可执行的JavaScript代码片段\r
|
||
- 可以是函数、立即执行函数(IIFE)或代码块\r
|
||
- 代码应该能够直接运行,不需要额外的包装\r
|
||
\r
|
||
2. **引擎实例访问**:\r
|
||
- 假设BIM引擎实例通过变量\`engine\`访问(全局作用域)\r
|
||
- 通过\`engine.moduleName\`访问各个功能模块\r
|
||
- 例如:\`engine.modelTree\`、\`engine.cameraModule\`、\`engine.measure\`等\r
|
||
\r
|
||
3. **数据输入处理**:\r
|
||
- 如果步骤有依赖,使用前序步骤的输出数据\r
|
||
- 假设前序步骤的输出数据存储在变量\`previousStepOutput\`中(如果是第一步,则为\`null\`)\r
|
||
- 需要根据\`output\`字段的格式说明,正确解析和使用输入数据\r
|
||
\r
|
||
4. **API调用规范**:\r
|
||
- 严格按照BIM引擎API文档使用API\r
|
||
- 参数类型和数量必须正确\r
|
||
- 处理API的返回值和可能的异常\r
|
||
\r
|
||
5. **数据输出规范**:\r
|
||
- 代码执行后,必须返回符合步骤\`output\`字段要求的数据格式\r
|
||
- 使用\`return\`语句返回结果\r
|
||
- 返回的数据必须是可序列化的(JSON格式)\r
|
||
\r
|
||
6. **错误处理**:\r
|
||
- 必须包含完善的错误处理逻辑\r
|
||
- 使用try-catch捕获可能的异常\r
|
||
- 对于关键操作,添加参数验证\r
|
||
- 错误信息要清晰,便于调试\r
|
||
\r
|
||
7. **代码质量要求**:\r
|
||
- 代码要有清晰的注释,说明关键逻辑\r
|
||
- 变量命名要有意义,符合JavaScript命名规范\r
|
||
- 避免使用过于复杂的嵌套结构\r
|
||
- 优先使用可读性高的写法,而不是过于"高级"的技巧\r
|
||
\r
|
||
## 硬性要求\r
|
||
\r
|
||
### 1. 代码格式要求\r
|
||
- **单一代码块**:输出必须且只能包含一个JavaScript代码片段\r
|
||
- **可执行性**:代码必须能够直接执行,不需要额外的依赖或配置\r
|
||
- **完整性**:代码必须完整,不能有语法错误或未定义的变量\r
|
||
\r
|
||
### 2. 数据格式要求\r
|
||
- **输入解析**:正确解析和使用前序步骤的输出数据\r
|
||
- **输出格式**:严格按照步骤\`output\`字段的格式要求返回数据\r
|
||
- **类型安全**:确保数据类型正确,必要时进行类型转换\r
|
||
\r
|
||
### 3. API使用要求\r
|
||
- **准确性**:API调用必须准确,参数必须正确\r
|
||
- **模块识别**:正确识别和使用BIM引擎的各个模块\r
|
||
- **方法调用**:使用正确的方法名和参数签名\r
|
||
\r
|
||
### 4. 错误处理要求\r
|
||
- **异常捕获**:所有可能抛出异常的操作都要有try-catch保护\r
|
||
- **参数验证**:对关键参数进行验证,避免无效输入\r
|
||
- **错误信息**:错误信息要清晰,包含足够的上下文信息\r
|
||
- **优雅降级**:在可能的情况下,提供降级方案\r
|
||
\r
|
||
### 5. 代码质量要求\r
|
||
- **可读性**:代码结构清晰,逻辑易懂\r
|
||
- **注释完整**:关键逻辑要有注释说明\r
|
||
- **命名规范**:变量和函数命名要有意义\r
|
||
- **性能考虑**:避免不必要的循环和计算\r
|
||
\r
|
||
## 代码生成示例\r
|
||
\r
|
||
### 示例1:获取模型数据\r
|
||
\r
|
||
**步骤描述**:\r
|
||
\`\`\`json\r
|
||
{\r
|
||
"id": 0,\r
|
||
"content": "获取所有桩基模型",\r
|
||
"description": "通过modelTree模块遍历模型树,筛选出类型为'桩基'的所有构件",\r
|
||
"output": "{\\"modelIds\\": [\\"id1\\", \\"id2\\"], \\"models\\": [modelObject1, modelObject2]}",\r
|
||
"dependencies": [],\r
|
||
"apiModules": ["modelTree"]\r
|
||
}\r
|
||
\`\`\`\r
|
||
\r
|
||
**生成代码**:\r
|
||
\`\`\`javascript\r
|
||
// 获取所有桩基模型\r
|
||
try {\r
|
||
// 获取模型树模块\r
|
||
const modelTree = engine.modelTree;\r
|
||
if (!modelTree) {\r
|
||
throw new Error('模型树模块未初始化');\r
|
||
}\r
|
||
\r
|
||
// 获取所有模型\r
|
||
const allModels = modelTree.getAllModels();\r
|
||
if (!allModels || allModels.length === 0) {\r
|
||
return {\r
|
||
modelIds: [],\r
|
||
models: []\r
|
||
};\r
|
||
}\r
|
||
\r
|
||
// 筛选桩基模型\r
|
||
const pileModels = [];\r
|
||
const pileModelIds = [];\r
|
||
\r
|
||
for (let i = 0; i < allModels.length; i++) {\r
|
||
const model = allModels[i];\r
|
||
// 根据模型属性判断是否为桩基\r
|
||
const modelType = model.getProperty('类型') || model.getProperty('category');\r
|
||
if (modelType && (modelType.includes('桩基') || modelType.includes('Pile'))) {\r
|
||
pileModels.push(model);\r
|
||
pileModelIds.push(model.id || model.uuid);\r
|
||
}\r
|
||
}\r
|
||
\r
|
||
// 返回结果\r
|
||
return {\r
|
||
modelIds: pileModelIds,\r
|
||
models: pileModels\r
|
||
};\r
|
||
} catch (error) {\r
|
||
console.error('获取桩基模型失败:', error);\r
|
||
return {\r
|
||
modelIds: [],\r
|
||
models: [],\r
|
||
error: error.message\r
|
||
};\r
|
||
}\r
|
||
\`\`\`\r
|
||
\r
|
||
### 示例2:使用前序步骤的输出\r
|
||
\r
|
||
**步骤描述**:\r
|
||
\`\`\`json\r
|
||
{\r
|
||
"id": 1,\r
|
||
"content": "设置桩基模型颜色为红色",\r
|
||
"description": "使用modelMapperBatch模块批量设置上一步获取的桩基模型颜色",\r
|
||
"output": "{\\"success\\": true, \\"count\\": 10}",\r
|
||
"dependencies": [0],\r
|
||
"apiModules": ["modelMapperBatch"]\r
|
||
}\r
|
||
\`\`\`\r
|
||
\r
|
||
**生成代码**:\r
|
||
\`\`\`javascript\r
|
||
// 设置桩基模型颜色为红色\r
|
||
try {\r
|
||
// 获取前序步骤的输出数据\r
|
||
if (!previousStepOutput || !previousStepOutput.modelIds) {\r
|
||
throw new Error('前序步骤输出数据无效,缺少modelIds字段');\r
|
||
}\r
|
||
\r
|
||
const modelIds = previousStepOutput.modelIds;\r
|
||
if (modelIds.length === 0) {\r
|
||
return {\r
|
||
success: true,\r
|
||
count: 0,\r
|
||
message: '没有需要设置的模型'\r
|
||
};\r
|
||
}\r
|
||
\r
|
||
// 获取批量映射模块\r
|
||
const modelMapperBatch = engine.modelMapperBatch;\r
|
||
if (!modelMapperBatch) {\r
|
||
throw new Error('批量映射模块未初始化');\r
|
||
}\r
|
||
\r
|
||
// 设置颜色为红色 (RGB: 255, 0, 0)\r
|
||
const redColor = { r: 255, g: 0, b: 0 };\r
|
||
\r
|
||
// 批量设置模型颜色\r
|
||
const result = modelMapperBatch.setModelColor(modelIds, redColor);\r
|
||
\r
|
||
return {\r
|
||
success: result.success !== false,\r
|
||
count: result.count || modelIds.length,\r
|
||
failedIds: result.failedIds || []\r
|
||
};\r
|
||
} catch (error) {\r
|
||
console.error('设置模型颜色失败:', error);\r
|
||
return {\r
|
||
success: false,\r
|
||
count: 0,\r
|
||
error: error.message\r
|
||
};\r
|
||
}\r
|
||
\`\`\`\r
|
||
\r
|
||
## 最佳实践\r
|
||
\r
|
||
1. **充分理解步骤**:仔细阅读步骤描述,确保理解每个细节\r
|
||
2. **查阅API文档**:不确定的API用法,参考BIM引擎API文档\r
|
||
3. **数据验证优先**:在处理数据前,先验证数据的有效性\r
|
||
4. **错误处理完善**:考虑各种可能的异常情况\r
|
||
5. **代码可读性**:优先保证代码的可读性,而不是追求"高级"写法\r
|
||
6. **注释清晰**:关键逻辑要有注释,但不要过度注释\r
|
||
7. **性能考虑**:对于大量数据的处理,考虑性能优化\r
|
||
8. **测试友好**:生成的代码应该便于测试和调试 `},Symbol.toStringTag,{value:"Module"})),B9=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM Engine SDK API 文档
|
||
|
||
本文档为 BIM Engine SDK 的完整 API 参考,适合大模型阅读和理解引擎的功能结构。
|
||
|
||
## 目录
|
||
|
||
1. [核心引擎类](#1-核心引擎类)
|
||
2. [基础模块](#2-基础模块)
|
||
3. [功能管理器](#3-功能管理器)
|
||
4. [状态管理](#4-状态管理)
|
||
|
||
---
|
||
|
||
## 1. 核心引擎类
|
||
|
||
### EngineKernelV2
|
||
|
||
引擎核心组件,负责整合和管理所有模块。
|
||
|
||
**文件路径**: \`src/core/v2/EngineKernel.ts\`
|
||
|
||
#### 构造函数
|
||
|
||
\`\`\`typescript
|
||
constructor(options: any)
|
||
\`\`\`
|
||
|
||
**参数**:
|
||
- \`options.containerId\`: string - 容器元素的 ID
|
||
|
||
**功能**:
|
||
- 初始化所有基础模块(场景、相机、渲染器、控制器等)
|
||
- 初始化所有功能管理器(测量、剖切、模型树等)
|
||
- 设置渲染循环
|
||
- 添加性能监视器
|
||
|
||
#### 公共属性
|
||
|
||
\`\`\`typescript
|
||
// 基础对象
|
||
public scene: THREE.Scene | null // 三维场景
|
||
public camera: THREE.Camera | null // 当前使用的相机
|
||
public renderer: THREE.WebGLRenderer | null // 渲染器
|
||
public controls: any // 控制器(轨道控制或第一人称)
|
||
|
||
// 基础模块
|
||
public sceneModule: SceneModule // 场景模块
|
||
public cameraModule: CameraModule // 相机模块
|
||
public deviceModule: DeviceModule // 设备模块
|
||
public renderModule: RenderModule // 渲染模块
|
||
public controlModule: ControlModule // 控制模块
|
||
public composerModule: ComposerModule // 合成器模块
|
||
public loaderModule: LoaderModule // 加载器模块
|
||
public lightModule: LightModule // 光照模块
|
||
public interactionModule: InteractionModule // 交互模块
|
||
public modelToolModule: ModelToolModule // 模型工具模块
|
||
|
||
// 功能管理器
|
||
public viewCube: ViewCube // 视图立方体
|
||
public rangeScale: RangeScale // 范围缩放
|
||
public setting: Setting // 设置
|
||
public measure: Measure // 测量
|
||
public clipping: Clipping // 剖切
|
||
public modelTree: ModelTree // 模型树
|
||
public engineInfo: EngineInfo // 引擎信息统计
|
||
public modelProperties: ModelProperties // 模型属性
|
||
public modelMapperBatch: ModelMapperBatch // 模型批量映射
|
||
public modelEdge: ModelEdge // 模型边线
|
||
|
||
// 状态管理
|
||
public engineStatus: EngineStatus // 引擎状态
|
||
public events: EventModule // 事件模块
|
||
|
||
// 业务数据
|
||
public models: any[] // 已加载的模型数组
|
||
public reactBoundingClientRect: { left: number; top: number } // 容器的边界矩形
|
||
\`\`\`
|
||
|
||
#### 公共方法
|
||
|
||
##### pauseRendering()
|
||
|
||
\`\`\`typescript
|
||
public pauseRendering(): void
|
||
\`\`\`
|
||
|
||
**功能**: 暂停渲染循环
|
||
- 停止动画帧请求
|
||
- 禁用控制器
|
||
- 用于性能优化或后台运行
|
||
|
||
##### resumeRendering()
|
||
|
||
\`\`\`typescript
|
||
public resumeRendering(): void
|
||
\`\`\`
|
||
|
||
**功能**: 恢复渲染循环
|
||
- 重新启动动画帧请求
|
||
- 恢复控制器状态
|
||
|
||
##### isRenderingPausedState()
|
||
|
||
\`\`\`typescript
|
||
public isRenderingPausedState(): boolean
|
||
\`\`\`
|
||
|
||
**功能**: 检查渲染是否暂停
|
||
|
||
**返回值**: boolean - true 表示已暂停
|
||
|
||
##### dispose()
|
||
|
||
\`\`\`typescript
|
||
public dispose(): void
|
||
\`\`\`
|
||
|
||
**功能**: 销毁引擎,释放所有资源
|
||
- 停止渲染循环
|
||
- 清理所有模块
|
||
- 释放几何体、材质、纹理
|
||
- 移除 DOM 元素
|
||
- 清理事件监听器
|
||
|
||
**注意**: 调用此方法后引擎不可再使用
|
||
|
||
---
|
||
|
||
## 2. 基础模块
|
||
|
||
### 2.1 SceneModule - 场景模块
|
||
|
||
**文件路径**: \`src/core/v2/modules/sceneModule.ts\`
|
||
|
||
#### 公共属性
|
||
|
||
\`\`\`typescript
|
||
public scene: THREE.Scene | null // 三维场景对象
|
||
\`\`\`
|
||
|
||
**功能**:
|
||
- 创建并管理 THREE.Scene
|
||
- 初始化边线组(groupEdge)用于存储模型边线
|
||
|
||
---
|
||
|
||
### 2.2 CameraModule - 相机模块
|
||
|
||
**文件路径**: \`src/core/v2/modules/cameraModule.ts\`
|
||
|
||
#### 公共属性
|
||
|
||
\`\`\`typescript
|
||
public perspectiveCamera: THREE.PerspectiveCamera // 透视相机
|
||
public orthographicCamera: THREE.OrthographicCamera // 正交相机
|
||
\`\`\`
|
||
|
||
#### 公共方法
|
||
|
||
##### switchCurrentCamera()
|
||
|
||
\`\`\`typescript
|
||
public switchCurrentCamera(): void
|
||
\`\`\`
|
||
|
||
**功能**: 切换当前相机类型(透视 ↔ 正交)
|
||
|
||
##### switchToPerspectiveCamera()
|
||
|
||
\`\`\`typescript
|
||
public switchToPerspectiveCamera(): void
|
||
\`\`\`
|
||
|
||
**功能**: 切换到透视相机
|
||
- 保持当前位置和目标点
|
||
- 更新控制器
|
||
- 重新初始化合成器
|
||
|
||
##### switchToOrthographicCamera()
|
||
|
||
\`\`\`typescript
|
||
public switchToOrthographicCamera(): void
|
||
\`\`\`
|
||
|
||
**功能**: 切换到正交相机
|
||
- 保持当前位置和目标点
|
||
- 更新控制器
|
||
- 重新初始化合成器
|
||
|
||
##### getCameraType()
|
||
|
||
\`\`\`typescript
|
||
public getCameraType(): CameraType
|
||
\`\`\`
|
||
|
||
**功能**: 获取当前相机类型
|
||
|
||
**返回值**:
|
||
- \`CameraType.PERSPECTIVE\` - 透视相机
|
||
- \`CameraType.ORTHOGRAPHIC\` - 正交相机
|
||
|
||
##### getCameraPose()
|
||
|
||
\`\`\`typescript
|
||
public getCameraPose(): ICameraPose
|
||
\`\`\`
|
||
|
||
**功能**: 获取当前相机姿态(位置、旋转、目标点、缩放等)
|
||
|
||
**返回值**: ICameraPose 对象
|
||
\`\`\`typescript
|
||
interface ICameraPose {
|
||
type: CameraType;
|
||
position: { x: number; y: number; z: number };
|
||
rotation: { x: number; y: number; z: number };
|
||
quaternion: { x: number; y: number; z: number; w: number };
|
||
target?: { x: number; y: number; z: number };
|
||
zoom?: number;
|
||
}
|
||
\`\`\`
|
||
|
||
##### restoreCameraPose()
|
||
|
||
\`\`\`typescript
|
||
public restoreCameraPose(pose: ICameraPose): void
|
||
\`\`\`
|
||
|
||
**功能**: 通过相机姿态还原相机位置
|
||
- 自动切换相机类型
|
||
- 恢复位置、旋转、目标点
|
||
- 恢复正交相机的缩放值
|
||
|
||
**参数**:
|
||
- \`pose\`: ICameraPose - 相机姿态对象
|
||
|
||
---
|
||
|
||
### 2.3 DeviceModule - 设备模块
|
||
|
||
**文件路径**: \`src/core/v2/modules/deviceModule.ts\`
|
||
|
||
#### 公共属性
|
||
|
||
\`\`\`typescript
|
||
public deviceType: string // 设备类型(默认 'PC')
|
||
\`\`\`
|
||
|
||
#### 公共方法
|
||
|
||
##### getDeviceType()
|
||
|
||
\`\`\`typescript
|
||
public getDeviceType(): string
|
||
\`\`\`
|
||
|
||
**功能**: 获取设备类型
|
||
|
||
**返回值**: 'PC' 或其他设备标识
|
||
|
||
##### getContainerSize()
|
||
|
||
\`\`\`typescript
|
||
public getContainerSize(): { width: number; height: number }
|
||
\`\`\`
|
||
|
||
**功能**: 获取容器尺寸
|
||
|
||
**返回值**: 容器的宽度和高度
|
||
|
||
---
|
||
|
||
### 2.4 RenderModule - 渲染模块
|
||
|
||
**文件路径**: \`src/core/v2/modules/renderModule.ts\`
|
||
|
||
#### 公共属性
|
||
|
||
\`\`\`typescript
|
||
public renderer: THREE.WebGLRenderer | null // WebGL 渲染器
|
||
\`\`\`
|
||
|
||
#### 公共方法
|
||
|
||
##### createRenderer()
|
||
|
||
\`\`\`typescript
|
||
public createRenderer(): THREE.WebGLRenderer
|
||
\`\`\`
|
||
|
||
**功能**: 创建并配置 WebGL 渲染器
|
||
- 启用抗锯齿
|
||
- 启用阴影映射(PCFSoftShadowMap)
|
||
- 启用本地裁剪(用于剖切平面)
|
||
- 配置色彩空间和色调映射
|
||
|
||
**返回值**: 配置好的渲染器实例
|
||
|
||
##### disposeRenderer()
|
||
|
||
\`\`\`typescript
|
||
public disposeRenderer(): void
|
||
\`\`\`
|
||
|
||
**功能**: 释放渲染器资源
|
||
|
||
---
|
||
|
||
### 2.5 ControlModule - 控制模块
|
||
|
||
**文件路径**: \`src/core/v2/modules/controlModule.ts\`
|
||
|
||
#### 公共属性
|
||
|
||
\`\`\`typescript
|
||
public orbitControls: any // 轨道控制器
|
||
public firstPersonControls: any // 第一人称控制器
|
||
public isActive: boolean // 控制器是否激活
|
||
\`\`\`
|
||
|
||
#### 公共方法
|
||
|
||
##### init()
|
||
|
||
\`\`\`typescript
|
||
public init(): void
|
||
\`\`\`
|
||
|
||
**功能**: 初始化控制器
|
||
- 创建轨道控制器和第一人称控制器
|
||
- 创建旋转中心指示器 UI
|
||
|
||
##### active()
|
||
|
||
\`\`\`typescript
|
||
public active(): void
|
||
\`\`\`
|
||
|
||
**功能**: 激活控制器
|
||
|
||
##### disActive()
|
||
|
||
\`\`\`typescript
|
||
public disActive(): void
|
||
\`\`\`
|
||
|
||
**功能**: 禁用控制器
|
||
|
||
##### switchFirstPersonMode()
|
||
|
||
\`\`\`typescript
|
||
public switchFirstPersonMode(): void
|
||
\`\`\`
|
||
|
||
**功能**: 切换到第一人称漫游模式
|
||
- 禁用轨道控制器
|
||
- 启用第一人称控制器
|
||
|
||
##### switchDefaultMode()
|
||
|
||
\`\`\`typescript
|
||
public switchDefaultMode(): void
|
||
\`\`\`
|
||
|
||
**功能**: 切换到默认模式(轨道控制)
|
||
- 禁用第一人称控制器
|
||
- 启用轨道控制器
|
||
|
||
##### update()
|
||
|
||
\`\`\`typescript
|
||
public update(): void
|
||
\`\`\`
|
||
|
||
**功能**: 更新控制器状态
|
||
- 更新旋转中心指示器位置
|
||
- 在渲染循环中调用
|
||
|
||
---
|
||
|
||
### 2.6 ComposerModule - 合成器模块
|
||
|
||
**文件路径**: \`src/core/v2/modules/composerModule.ts\`
|
||
|
||
#### 公共属性
|
||
|
||
\`\`\`typescript
|
||
public composer: any // 效果合成器
|
||
\`\`\`
|
||
|
||
#### 公共方法
|
||
|
||
##### init()
|
||
|
||
\`\`\`typescript
|
||
public init(): void
|
||
\`\`\`
|
||
|
||
**功能**: 初始化后处理管线
|
||
- RenderPass - 基础渲染
|
||
- GTAOPass - 环境光遮蔽(默认禁用)
|
||
- UnrealBloomPass - 辉光效果(默认禁用)
|
||
- SaturationPass - 饱和度和对比度调整
|
||
- OutputPass - 色调映射和颜色校正
|
||
- FXAAPass - 抗锯齿
|
||
|
||
##### resize()
|
||
|
||
\`\`\`typescript
|
||
public resize(): void
|
||
\`\`\`
|
||
|
||
**功能**: 调整合成器大小
|
||
- 更新所有 pass 的分辨率
|
||
- 更新 FXAA 的分辨率参数
|
||
|
||
---
|
||
|
||
### 2.7 LoaderModule - 加载器模块
|
||
|
||
**文件路径**: \`src/core/v2/modules/loaderModule.ts\`
|
||
|
||
#### 公共方法
|
||
|
||
##### loadModels()
|
||
|
||
\`\`\`typescript
|
||
async loadModels(urls: string[], options?: LoadModelOptions): Promise<void>
|
||
\`\`\`
|
||
|
||
**功能**: 加载多个模型
|
||
- 支持轻量化模型格式
|
||
- 支持 GLTF/GLB 格式
|
||
- 异步加载
|
||
|
||
**参数**:
|
||
- \`urls\`: string[] - 模型 URL 数组
|
||
- \`options\`: LoadModelOptions - 加载选项(可选)
|
||
|
||
---
|
||
|
||
### 2.8 EventModule - 事件模块
|
||
|
||
**文件路径**: \`src/core/v2/modules/eventModule.ts\`
|
||
|
||
#### 公共方法
|
||
|
||
##### on()
|
||
|
||
\`\`\`typescript
|
||
on<T = any>(event: EventType, callback: (data: T) => void): void
|
||
\`\`\`
|
||
|
||
**功能**: 注册事件监听器
|
||
|
||
**参数**:
|
||
- \`event\`: EventType - 事件类型
|
||
- \`callback\`: 回调函数
|
||
|
||
##### off()
|
||
|
||
\`\`\`typescript
|
||
off<T = any>(event: EventType, callback: (data: T) => void): void
|
||
\`\`\`
|
||
|
||
**功能**: 移除事件监听器
|
||
|
||
**参数**:
|
||
- \`event\`: EventType - 事件类型
|
||
- \`callback\`: 要移除的回调函数
|
||
|
||
##### trigger()
|
||
|
||
\`\`\`typescript
|
||
trigger(event: EventType, data?: any): void
|
||
\`\`\`
|
||
|
||
**功能**: 触发事件
|
||
|
||
**参数**:
|
||
- \`event\`: EventType - 事件类型
|
||
- \`data\`: 传递给监听器的数据
|
||
|
||
**常用事件类型**:
|
||
- \`EventType.Click\` - 点击事件
|
||
- \`EventType.ViewportResize\` - 视口大小改变
|
||
- \`EventType.EngineFree\` - 引擎空闲
|
||
- \`EventType.EngineBusy\` - 引擎繁忙
|
||
|
||
---
|
||
|
||
### 2.9 LightModule - 光照模块
|
||
|
||
**文件路径**: \`src/core/v2/modules/lightModule.ts\`
|
||
|
||
#### 公共方法
|
||
|
||
##### init()
|
||
|
||
\`\`\`typescript
|
||
public init(): void
|
||
\`\`\`
|
||
|
||
**功能**: 初始化场景基本光照
|
||
- 添加定向光(DirectionalLight)
|
||
- 强度: 2
|
||
- 位置: (10, 20, 10)
|
||
- 阴影贴图: 4096x4096(高质量)
|
||
- 添加环境光(AmbientLight)
|
||
- 强度: 1
|
||
|
||
---
|
||
|
||
### 2.10 InteractionModule - 交互模块
|
||
|
||
**文件路径**: \`src/core/v2/modules/interactionModule.ts\`
|
||
|
||
#### 公共方法
|
||
|
||
##### init()
|
||
|
||
\`\`\`typescript
|
||
public init(): void
|
||
\`\`\`
|
||
|
||
**功能**: 初始化交互行为处理器
|
||
|
||
##### active()
|
||
|
||
\`\`\`typescript
|
||
public active(): void
|
||
\`\`\`
|
||
|
||
**功能**: 激活交互功能
|
||
|
||
##### disActive()
|
||
|
||
\`\`\`typescript
|
||
public disActive(): void
|
||
\`\`\`
|
||
|
||
**功能**: 禁用交互功能
|
||
|
||
##### handleMouseClick()
|
||
|
||
\`\`\`typescript
|
||
public handleMouseClick(event: any): void
|
||
\`\`\`
|
||
|
||
**功能**: 处理鼠标单击事件
|
||
- 射线检测点击的模型
|
||
- 高亮选中的模型
|
||
- 设置旋转中心
|
||
- 支持 Ctrl 多选
|
||
|
||
##### handleMouseDoubleClick()
|
||
|
||
\`\`\`typescript
|
||
public handleMouseDoubleClick(event: any): void
|
||
\`\`\`
|
||
|
||
**功能**: 处理鼠标双击事件
|
||
- 双击模型后缩放到该模型
|
||
- 计算模型包围盒并调整相机视角
|
||
|
||
##### handleMouseClickInstance()
|
||
|
||
\`\`\`typescript
|
||
public handleMouseClickInstance(raycaster: any): any
|
||
\`\`\`
|
||
|
||
**功能**: 判断点击实例化网格节点
|
||
|
||
**参数**:
|
||
- \`raycaster\`: 射线投射器
|
||
|
||
**返回值**: 相交结果数组
|
||
|
||
---
|
||
|
||
### 2.11 ModelToolModule - 模型工具模块
|
||
|
||
**文件路径**: \`src/core/v2/modules/modelToolModule.ts\`
|
||
|
||
#### 公共方法
|
||
|
||
##### highlightModel()
|
||
|
||
\`\`\`typescript
|
||
public highlightModel(models: any): void
|
||
\`\`\`
|
||
|
||
**功能**: 设置模型高亮显示
|
||
|
||
**参数**:
|
||
- \`models\`: 模型数组,格式: \`[{url: string, ids: string[]}]\`
|
||
|
||
##### unhighlightModel()
|
||
|
||
\`\`\`typescript
|
||
public unhighlightModel(models: any): void
|
||
\`\`\`
|
||
|
||
**功能**: 取消模型高亮
|
||
|
||
**参数**:
|
||
- \`models\`: 模型数组
|
||
|
||
##### unhighlightAllModels()
|
||
|
||
\`\`\`typescript
|
||
public unhighlightAllModels(): void
|
||
\`\`\`
|
||
|
||
**功能**: 取消所有模型高亮
|
||
|
||
##### hideModel()
|
||
|
||
\`\`\`typescript
|
||
public hideModel(models: any): void
|
||
\`\`\`
|
||
|
||
**功能**: 隐藏模型
|
||
|
||
**参数**:
|
||
- \`models\`: 模型数组,格式: \`[{url: string, ids: string[]}]\`
|
||
|
||
##### showModel()
|
||
|
||
\`\`\`typescript
|
||
public showModel(models: any): void
|
||
\`\`\`
|
||
|
||
**功能**: 显示模型
|
||
|
||
**参数**:
|
||
- \`models\`: 模型数组
|
||
|
||
##### isolateModel()
|
||
|
||
\`\`\`typescript
|
||
public isolateModel(models: any): void
|
||
\`\`\`
|
||
|
||
**功能**: 隔离模型(只显示指定模型,隐藏其他)
|
||
|
||
**参数**:
|
||
- \`models\`: 要显示的模型数组
|
||
|
||
##### showAllModels()
|
||
|
||
\`\`\`typescript
|
||
public showAllModels(): void
|
||
\`\`\`
|
||
|
||
**功能**: 显示所有模型
|
||
|
||
##### getModelsBox()
|
||
|
||
\`\`\`typescript
|
||
public getModelsBox(models: any): THREE.Box3
|
||
\`\`\`
|
||
|
||
**功能**: 获取模型的包围盒
|
||
|
||
**参数**:
|
||
- \`models\`: 模型数组
|
||
|
||
**返回值**: THREE.Box3 包围盒对象
|
||
|
||
---
|
||
|
||
## 3. 功能管理器
|
||
|
||
### 3.1 ViewCube - 视图立方体
|
||
|
||
**文件路径**: \`src/core/v2/managers/viewCube/index.ts\`
|
||
|
||
#### 公共属性
|
||
|
||
\`\`\`typescript
|
||
public cubeTool: any // 视图立方体工具
|
||
\`\`\`
|
||
|
||
#### 公共方法
|
||
|
||
##### init()
|
||
|
||
\`\`\`typescript
|
||
public init(): void
|
||
\`\`\`
|
||
|
||
**功能**: 初始化视图立方体
|
||
- 创建 3D 小立方体辅助视图
|
||
- 支持六个面和边角视图切换
|
||
|
||
##### CameraGoHome()
|
||
|
||
\`\`\`typescript
|
||
public CameraGoHome(): void
|
||
\`\`\`
|
||
|
||
**功能**: 相机回归正位(默认视角)
|
||
|
||
##### zoomToModel()
|
||
|
||
\`\`\`typescript
|
||
public zoomToModel(box: THREE.Box3): void
|
||
\`\`\`
|
||
|
||
**功能**: 缩放到指定模型包围盒
|
||
|
||
**参数**:
|
||
- \`box\`: THREE.Box3 - 目标包围盒
|
||
|
||
---
|
||
|
||
### 3.2 RangeScale - 范围缩放工具
|
||
|
||
**文件路径**: \`src/core/v2/managers/rangeScale/index.ts\`
|
||
|
||
#### 公共方法
|
||
|
||
##### init()
|
||
|
||
\`\`\`typescript
|
||
public init(): void
|
||
\`\`\`
|
||
|
||
**功能**: 初始化范围缩放工具
|
||
- 创建绘制框 UI 元素
|
||
- 初始化坐标转换工具
|
||
|
||
##### active()
|
||
|
||
\`\`\`typescript
|
||
public active(): void
|
||
\`\`\`
|
||
|
||
**功能**: 激活范围缩放工具
|
||
- 禁用控制器
|
||
- 启用框选功能
|
||
- 鼠标变为十字光标
|
||
|
||
**使用方式**:
|
||
1. 激活工具
|
||
2. 鼠标拖拽绘制矩形区域
|
||
3. 松开鼠标自动缩放到该区域
|
||
4. 按 ESC 键退出
|
||
|
||
##### disActive()
|
||
|
||
\`\`\`typescript
|
||
public disActive(): void
|
||
\`\`\`
|
||
|
||
**功能**: 停用范围缩放工具
|
||
- 恢复控制器
|
||
- 移除事件监听
|
||
|
||
---
|
||
|
||
### 3.3 Setting - 设置管理器
|
||
|
||
**文件路径**: \`src/core/v2/managers/setting/index.ts\`
|
||
|
||
#### 公共方法
|
||
|
||
##### setStatsVisible()
|
||
|
||
\`\`\`typescript
|
||
public setStatsVisible(visible: boolean): void
|
||
\`\`\`
|
||
|
||
**功能**: 显示/隐藏性能监视器
|
||
|
||
**参数**:
|
||
- \`visible\`: true 显示,false 隐藏
|
||
|
||
##### setAmbientLightIntensity()
|
||
|
||
\`\`\`typescript
|
||
public setAmbientLightIntensity(intensity: number): void
|
||
\`\`\`
|
||
|
||
**功能**: 设置环境光照强度
|
||
|
||
**参数**:
|
||
- \`intensity\`: 光照强度,范围 0-5
|
||
|
||
##### setAmbientLightColor()
|
||
|
||
\`\`\`typescript
|
||
public setAmbientLightColor(color: number | string): void
|
||
\`\`\`
|
||
|
||
**功能**: 设置环境光照颜色
|
||
|
||
**参数**:
|
||
- \`color\`: 颜色(0xffffff 或 '#ffffff')
|
||
|
||
##### setDirectionalLightIntensity()
|
||
|
||
\`\`\`typescript
|
||
public setDirectionalLightIntensity(intensity: number): void
|
||
\`\`\`
|
||
|
||
**功能**: 设置定向光源强度
|
||
|
||
**参数**:
|
||
- \`intensity\`: 光照强度,范围 0-5
|
||
|
||
##### setDirectionalLightColor()
|
||
|
||
\`\`\`typescript
|
||
public setDirectionalLightColor(color: number | string): void
|
||
\`\`\`
|
||
|
||
**功能**: 设置定向光源颜色
|
||
|
||
**参数**:
|
||
- \`color\`: 颜色
|
||
|
||
##### setShadowQuality()
|
||
|
||
\`\`\`typescript
|
||
public setShadowQuality(quality: 'low' | 'medium' | 'high' | 'ultra'): void
|
||
\`\`\`
|
||
|
||
**功能**: 设置阴影精细度
|
||
|
||
**参数**:
|
||
- \`quality\`: 质量等级
|
||
- 'low': 1024
|
||
- 'medium': 2048
|
||
- 'high': 4096
|
||
- 'ultra': 8192
|
||
|
||
##### setDirectionalLightShadow()
|
||
|
||
\`\`\`typescript
|
||
public setDirectionalLightShadow(enabled: boolean): void
|
||
\`\`\`
|
||
|
||
**功能**: 开启/关闭定向光阴影
|
||
|
||
**参数**:
|
||
- \`enabled\`: true 开启,false 关闭
|
||
|
||
##### setGTAOEnabled()
|
||
|
||
\`\`\`typescript
|
||
public setGTAOEnabled(enabled: boolean): void
|
||
\`\`\`
|
||
|
||
**功能**: 开启/关闭 GTAO 环境光遮蔽
|
||
|
||
**参数**:
|
||
- \`enabled\`: true 开启,false 关闭
|
||
|
||
##### setSceneSaturation()
|
||
|
||
\`\`\`typescript
|
||
public setSceneSaturation(saturation: number): void
|
||
\`\`\`
|
||
|
||
**功能**: 设置场景饱和度
|
||
|
||
**参数**:
|
||
- \`saturation\`: 饱和度值,1.0 为正常,推荐范围 0.5-2.0
|
||
|
||
##### setSceneContrast()
|
||
|
||
\`\`\`typescript
|
||
public setSceneContrast(contrast: number): void
|
||
\`\`\`
|
||
|
||
**功能**: 设置场景对比度
|
||
|
||
**参数**:
|
||
- \`contrast\`: 对比度值,1.0 为正常,推荐范围 0.5-2.0
|
||
|
||
##### setGroundEnabled()
|
||
|
||
\`\`\`typescript
|
||
public setGroundEnabled(enabled: boolean, options?: {
|
||
size?: number;
|
||
color?: number | string;
|
||
opacity?: number;
|
||
}): void
|
||
\`\`\`
|
||
|
||
**功能**: 开启/关闭地面
|
||
|
||
**参数**:
|
||
- \`enabled\`: true 开启,false 关闭
|
||
- \`options\`: 地面配置选项
|
||
- \`size\`: 地面大小(默认 100)
|
||
- \`color\`: 地面颜色(默认 0x808080)
|
||
- \`opacity\`: 透明度(默认 0.3)
|
||
|
||
##### setHDRBackground()
|
||
|
||
\`\`\`typescript
|
||
public setHDRBackground(hdrTexture: THREE.Texture | null): void
|
||
\`\`\`
|
||
|
||
**功能**: 设置 HDR 背景
|
||
|
||
**参数**:
|
||
- \`hdrTexture\`: HDR 环境贴图,null 则移除
|
||
|
||
---
|
||
|
||
### 3.4 Measure - 测量工具
|
||
|
||
**文件路径**: \`src/core/v2/managers/measure/index.ts\`
|
||
|
||
#### 公共方法
|
||
|
||
##### active()
|
||
|
||
\`\`\`typescript
|
||
public active(): void
|
||
\`\`\`
|
||
|
||
**功能**: 激活测量工具
|
||
|
||
##### disActive()
|
||
|
||
\`\`\`typescript
|
||
public disActive(): void
|
||
\`\`\`
|
||
|
||
**功能**: 停用测量工具
|
||
- 清除所有测量
|
||
- 恢复点选功能
|
||
|
||
##### clearAllPoints()
|
||
|
||
\`\`\`typescript
|
||
public clearAllPoints(): void
|
||
\`\`\`
|
||
|
||
**功能**: 清空所有测量点
|
||
|
||
##### clearAll()
|
||
|
||
\`\`\`typescript
|
||
public clearAll(): void
|
||
\`\`\`
|
||
|
||
**功能**: 清除所有测量标注
|
||
|
||
##### update()
|
||
|
||
\`\`\`typescript
|
||
update(): void
|
||
\`\`\`
|
||
|
||
**功能**: 更新测量标注
|
||
- 在渲染循环中调用
|
||
- 更新屏幕坐标
|
||
|
||
**测量类型**:
|
||
- 距离测量(DistanceMeasure)
|
||
- 净高测量(ClearHeightMeasure)
|
||
- 净距测量(ClearDistanceMeasure)
|
||
- 标高测量(ElevationMeasure)
|
||
- 点测量(PointMeasure)
|
||
- 角度测量(AngleMeasure)
|
||
- 面积测量(AreaMeasure)
|
||
- 坡度测量(SlopeMeasure)
|
||
|
||
---
|
||
|
||
### 3.5 Clipping - 剖切管理器
|
||
|
||
**文件路径**: \`src/core/v2/managers/clipping/index.ts\`
|
||
|
||
#### 公共属性
|
||
|
||
\`\`\`typescript
|
||
public sectionPlaneX: any // X 轴剖切平面
|
||
public sectionPlaneY: any // Y 轴剖切平面
|
||
public sectionPlaneZ: any // Z 轴剖切平面
|
||
public sectionBox: any // 剖切盒
|
||
\`\`\`
|
||
|
||
#### 公共方法
|
||
|
||
##### init()
|
||
|
||
\`\`\`typescript
|
||
public init(): void
|
||
\`\`\`
|
||
|
||
**功能**: 初始化剖切管理器
|
||
- 创建 6 个剖切平面(前、后、左、右、顶、底)
|
||
- 初始化 X/Y/Z 轴剖切工具
|
||
- 初始化剖切盒工具
|
||
|
||
##### disActive()
|
||
|
||
\`\`\`typescript
|
||
public disActive(): void
|
||
\`\`\`
|
||
|
||
**功能**: 停用所有剖切工具
|
||
|
||
---
|
||
|
||
### 3.6 ModelTree - 模型树
|
||
|
||
**文件路径**: \`src/core/v2/managers/modelTree/index.ts\`
|
||
|
||
#### 公共方法
|
||
|
||
##### getTreeData()
|
||
|
||
\`\`\`typescript
|
||
public getTreeData(): any[]
|
||
\`\`\`
|
||
|
||
**功能**: 获取模型树数据
|
||
|
||
**返回值**: 模型树数组
|
||
\`\`\`typescript
|
||
[{
|
||
name: string, // 模型名称
|
||
children: any[] // 模型层级树
|
||
}]
|
||
\`\`\`
|
||
|
||
---
|
||
|
||
### 3.7 EngineInfo - 引擎信息统计
|
||
|
||
**文件路径**: \`src/core/v2/managers/engineInfo/index.ts\`
|
||
|
||
#### 公共方法
|
||
|
||
##### getEngineInfo()
|
||
|
||
\`\`\`typescript
|
||
public getEngineInfo(): {
|
||
totalVertices: number;
|
||
totalTriangles: number;
|
||
meshCount: number;
|
||
}
|
||
\`\`\`
|
||
|
||
**功能**: 获取引擎统计信息
|
||
- 统计所有网格的顶点数
|
||
- 统计所有网格的三角面数
|
||
- 统计网格数量
|
||
|
||
**返回值**:
|
||
- \`totalVertices\`: 总顶点数
|
||
- \`totalTriangles\`: 总三角面数
|
||
- \`meshCount\`: 网格数量
|
||
|
||
---
|
||
|
||
### 3.8 ModelProperties - 模型属性
|
||
|
||
**文件路径**: \`src/core/v2/managers/modelProperties/index.ts\`
|
||
|
||
#### 公共方法
|
||
|
||
##### getModelProperties()
|
||
|
||
\`\`\`typescript
|
||
public getModelProperties(url: string, id: string, callback: (properties: any) => void): void
|
||
\`\`\`
|
||
|
||
**功能**: 查询构件属性
|
||
- 异步加载属性数据(如果未加载)
|
||
- 从压缩的 JSON 中解析属性
|
||
|
||
**参数**:
|
||
- \`url\`: 模型 URL
|
||
- \`id\`: 构件 ID
|
||
- \`callback\`: 回调函数,接收属性对象
|
||
|
||
**返回值格式**:
|
||
\`\`\`typescript
|
||
{
|
||
properties: [{
|
||
name: string, // 分类名称
|
||
children: [{
|
||
name: string, // 属性名
|
||
value: any // 属性值
|
||
}]
|
||
}],
|
||
materials: []
|
||
}
|
||
\`\`\`
|
||
|
||
---
|
||
|
||
### 3.9 ModelMapperBatch - 模型批量映射
|
||
|
||
**文件路径**: \`src/core/v2/managers/modelMapperBatch/index.ts\`
|
||
|
||
#### 公共方法
|
||
|
||
##### getModelTypes()
|
||
|
||
\`\`\`typescript
|
||
public getModelTypes(): any[]
|
||
\`\`\`
|
||
|
||
**功能**: 获取模型中所有的构件类型
|
||
|
||
##### getModelMajors()
|
||
|
||
\`\`\`typescript
|
||
public getModelMajors(): any[]
|
||
\`\`\`
|
||
|
||
**功能**: 获取模型中所有的专业
|
||
|
||
##### getModelLevels()
|
||
|
||
\`\`\`typescript
|
||
public getModelLevels(): any[]
|
||
\`\`\`
|
||
|
||
**功能**: 获取模型中所有的楼层
|
||
|
||
##### getModelMapper()
|
||
|
||
\`\`\`typescript
|
||
public getModelMapper(url: string, id: number): any
|
||
\`\`\`
|
||
|
||
**功能**: 获取指定构件的映射信息
|
||
|
||
**参数**:
|
||
- \`url\`: 模型 URL
|
||
- \`id\`: 构件 ID
|
||
|
||
**返回值**: Mapper 对象(包含类型、专业、楼层等信息)
|
||
|
||
##### getModelSWithType()
|
||
|
||
\`\`\`typescript
|
||
public getModelSWithType(type: string, callback: any): any[]
|
||
\`\`\`
|
||
|
||
**功能**: 获取同类型的所有构件
|
||
|
||
**参数**:
|
||
- \`type\`: 构件类型名称
|
||
- \`callback\`: 回调函数
|
||
|
||
**返回值**: \`[{url: string, ids: number[]}]\`
|
||
|
||
##### getModelSWithLevel()
|
||
|
||
\`\`\`typescript
|
||
public getModelSWithLevel(level: string, callback: any): any[]
|
||
\`\`\`
|
||
|
||
**功能**: 获取同楼层的所有构件
|
||
|
||
**参数**:
|
||
- \`level\`: 楼层名称
|
||
- \`callback\`: 回调函数
|
||
|
||
**返回值**: \`[{url: string, ids: number[]}]\`
|
||
|
||
##### getModelsWithMajor()
|
||
|
||
\`\`\`typescript
|
||
public getModelsWithMajor(major: string, callback: any): any[]
|
||
\`\`\`
|
||
|
||
**功能**: 获取同专业的所有构件
|
||
|
||
**参数**:
|
||
- \`major\`: 专业名称
|
||
- \`callback\`: 回调函数
|
||
|
||
**返回值**: \`[{url: string, ids: number[]}]\`
|
||
|
||
---
|
||
|
||
### 3.10 ModelEdge - 模型边线管理器
|
||
|
||
**文件路径**: \`src/core/v2/managers/modelEdge/index.ts\`
|
||
|
||
#### 公共方法
|
||
|
||
##### active()
|
||
|
||
\`\`\`typescript
|
||
public active(): void
|
||
\`\`\`
|
||
|
||
**功能**: 启动边线显示
|
||
- 显示所有模型的边线
|
||
- 用于技术制图风格渲染
|
||
|
||
##### disActive()
|
||
|
||
\`\`\`typescript
|
||
public disActive(): void
|
||
\`\`\`
|
||
|
||
**功能**: 关闭边线显示
|
||
|
||
##### getModelEdge()
|
||
|
||
\`\`\`typescript
|
||
public getModelEdge(url: string, id: Number): any
|
||
\`\`\`
|
||
|
||
**功能**: 获取指定模型的边线数据
|
||
|
||
**参数**:
|
||
- \`url\`: 模型 URL
|
||
- \`id\`: 构件 ID
|
||
|
||
**返回值**: 边线数据 \`[startIndex, endIndex, points]\`
|
||
|
||
##### hideModelEdge()
|
||
|
||
\`\`\`typescript
|
||
public hideModelEdge(url: string, id: Number): void
|
||
\`\`\`
|
||
|
||
**功能**: 隐藏指定构件的边线
|
||
|
||
**参数**:
|
||
- \`url\`: 模型 URL
|
||
- \`id\`: 构件 ID
|
||
|
||
##### showModelEdge()
|
||
|
||
\`\`\`typescript
|
||
public showModelEdge(url: string, id: Number): void
|
||
\`\`\`
|
||
|
||
**功能**: 显示指定构件的边线
|
||
|
||
**参数**:
|
||
- \`url\`: 模型 URL
|
||
- \`id\`: 构件 ID
|
||
|
||
---
|
||
|
||
## 4. 状态管理
|
||
|
||
### 4.1 EngineStatus - 引擎状态
|
||
|
||
**文件路径**: \`src/core/v2/status/engineStatus.ts\`
|
||
|
||
#### 公共属性
|
||
|
||
\`\`\`typescript
|
||
public isFree: boolean // 引擎是否空闲
|
||
public highlightModels: any[] // 高亮的模型数组
|
||
public hideModels: any[] // 隐藏的模型数组
|
||
public models: any[] // 已加载的模型数组
|
||
\`\`\`
|
||
|
||
#### 公共方法
|
||
|
||
##### init()
|
||
|
||
\`\`\`typescript
|
||
public init(): void
|
||
\`\`\`
|
||
|
||
**功能**: 初始化引擎状态监听
|
||
- 监听 \`EventType.EngineFree\` 事件
|
||
- 监听 \`EventType.EngineBusy\` 事件
|
||
|
||
##### updateFree()
|
||
|
||
\`\`\`typescript
|
||
public updateFree(status: boolean): void
|
||
\`\`\`
|
||
|
||
**功能**: 更新引擎空闲状态
|
||
|
||
**参数**:
|
||
- \`status\`: true 表示空闲,false 表示繁忙
|
||
|
||
##### closeAllFunction()
|
||
|
||
\`\`\`typescript
|
||
public closeAllFunction(): void
|
||
\`\`\`
|
||
|
||
**功能**: 关闭所有功能
|
||
|
||
---
|
||
|
||
### 4.2 HandelBehaved - 行为处理器
|
||
|
||
**文件路径**: \`src/core/v2/status/handelBehaved.ts\`
|
||
|
||
这是一个工厂函数,返回行为处理器对象。
|
||
|
||
#### 公共方法
|
||
|
||
##### init()
|
||
|
||
\`\`\`typescript
|
||
init(self: any, options: any): void
|
||
\`\`\`
|
||
|
||
**功能**: 初始化行为处理器
|
||
|
||
**参数**:
|
||
- \`self\`: 当前激活的行为对象
|
||
- \`options\`: 行为配置选项
|
||
- \`showCatch\`: boolean - 是否显示捕捉点
|
||
|
||
##### active()
|
||
|
||
\`\`\`typescript
|
||
active(): void
|
||
\`\`\`
|
||
|
||
**功能**: 开启事务(激活事件监听)
|
||
- 监听鼠标事件(mousedown, mouseup, mousemove)
|
||
- 监听键盘事件(keydown, keyup)
|
||
|
||
##### disActive()
|
||
|
||
\`\`\`typescript
|
||
disActive(): void
|
||
\`\`\`
|
||
|
||
**功能**: 关闭事务(禁用事件监听)
|
||
|
||
**支持的键盘事件**:
|
||
- Delete / Backspace - 删除
|
||
- Escape - 取消
|
||
- Enter - 确认
|
||
- Space - 空格
|
||
- Ctrl / Control - 控制键
|
||
- Shift - 切换键
|
||
- Alt - 辅助键
|
||
- Meta / Command - 命令键
|
||
|
||
**支持的鼠标事件**:
|
||
- handleMouseDown - 鼠标按下
|
||
- handleMouseMove - 鼠标移动
|
||
- handleMouseUp - 鼠标弹起
|
||
- handleMouseClick - 鼠标单击
|
||
- handleMouseDoubleClick - 鼠标双击
|
||
|
||
**捕捉功能**:
|
||
- 点捕捉(距离 < 5 像素)
|
||
- 线捕捉(距离 < 5 像素)
|
||
- 面捕捉(默认)
|
||
|
||
---
|
||
|
||
## 使用示例
|
||
|
||
### 初始化引擎
|
||
|
||
\`\`\`typescript
|
||
import { EngineKernelV2 } from './src/core/v2/EngineKernel';
|
||
|
||
const engine = new EngineKernelV2({
|
||
containerId: 'canvas-container',
|
||
antialias: true
|
||
});
|
||
\`\`\`
|
||
|
||
### 加载模型
|
||
|
||
\`\`\`typescript
|
||
await engine.loaderModule.loadModels([
|
||
'https://example.com/model1.light',
|
||
'https://example.com/model2.light'
|
||
]);
|
||
\`\`\`
|
||
|
||
### 高亮模型
|
||
|
||
\`\`\`typescript
|
||
engine.modelToolModule.highlightModel([
|
||
{ url: 'model1.light', ids: ['wall-001', 'wall-002'] }
|
||
]);
|
||
\`\`\`
|
||
|
||
### 切换相机
|
||
|
||
\`\`\`typescript
|
||
// 切换到正交相机
|
||
engine.cameraModule.switchToOrthographicCamera();
|
||
|
||
// 或切换当前相机类型
|
||
engine.cameraModule.switchCurrentCamera();
|
||
\`\`\`
|
||
|
||
### 保存和恢复相机姿态
|
||
|
||
\`\`\`typescript
|
||
// 保存当前相机姿态
|
||
const pose = engine.cameraModule.getCameraPose();
|
||
|
||
// 恢复相机姿态
|
||
engine.cameraModule.restoreCameraPose(pose);
|
||
\`\`\`
|
||
|
||
### 设置光照和渲染质量
|
||
|
||
\`\`\`typescript
|
||
// 设置环境光强度
|
||
engine.setting.setAmbientLightIntensity(1.5);
|
||
|
||
// 设置阴影质量
|
||
engine.setting.setShadowQuality('ultra');
|
||
|
||
// 开启 GTAO
|
||
engine.setting.setGTAOEnabled(true);
|
||
|
||
// 调整饱和度和对比度
|
||
engine.setting.setSceneSaturation(1.3);
|
||
engine.setting.setSceneContrast(1.1);
|
||
\`\`\`
|
||
|
||
### 获取模型属性
|
||
|
||
\`\`\`typescript
|
||
engine.modelProperties.getModelProperties('model.light', 'wall-001', (data) => {
|
||
console.log('属性:', data.properties);
|
||
});
|
||
\`\`\`
|
||
|
||
### 按类型筛选构件
|
||
|
||
\`\`\`typescript
|
||
engine.modelMapperBatch.getModelSWithType('墙', (models) => {
|
||
// 高亮所有墙体
|
||
engine.modelToolModule.highlightModel(models);
|
||
});
|
||
\`\`\`
|
||
|
||
### 监听事件
|
||
|
||
\`\`\`typescript
|
||
// 监听点击事件
|
||
engine.events.on(EventType.Click, (hit) => {
|
||
console.log('点击了:', hit.object.name);
|
||
});
|
||
|
||
// 监听视口大小改变
|
||
engine.events.on(EventType.ViewportResize, ({ width, height }) => {
|
||
console.log('视口大小:', width, height);
|
||
});
|
||
\`\`\`
|
||
|
||
### 暂停和恢复渲染
|
||
|
||
\`\`\`typescript
|
||
// 暂停渲染(节省性能)
|
||
engine.pauseRendering();
|
||
|
||
// 恢复渲染
|
||
engine.resumeRendering();
|
||
|
||
// 检查渲染状态
|
||
if (engine.isRenderingPausedState()) {
|
||
console.log('渲染已暂停');
|
||
}
|
||
\`\`\`
|
||
|
||
### 销毁引擎
|
||
|
||
\`\`\`typescript
|
||
// 释放所有资源
|
||
engine.dispose();
|
||
\`\`\`
|
||
|
||
---
|
||
|
||
## 总结
|
||
|
||
BIM Engine SDK 提供了完整的 3D BIM 模型渲染和交互能力,主要特性包括:
|
||
|
||
- **完整的相机系统**: 支持透视和正交相机,可保存和恢复相机姿态
|
||
- **强大的模型操作**: 高亮、隐藏、隔离、批量筛选
|
||
- **丰富的测量工具**: 距离、净高、净距、标高、角度、面积、坡度
|
||
- **灵活的剖切功能**: 支持 X/Y/Z 轴剖切和剖切盒
|
||
- **可配置的渲染质量**: 阴影、环境光遮蔽、饱和度、对比度
|
||
- **事件驱动架构**: 支持自定义事件监听和触发
|
||
- **性能优化**: 支持暂停/恢复渲染,八叉树加速
|
||
- **完善的资源管理**: 自动释放几何体、材质、纹理等资源
|
||
|
||
适用场景:
|
||
- BIM 模型在线浏览
|
||
- 建筑设计审查
|
||
- 施工模拟
|
||
- 运维管理
|
||
- AI 辅助设计
|
||
`},Symbol.toStringTag,{value:"Module"}));bs.BimEngine=w9,bs.BimEngine2d=T9,bs.BimEngine720=P9,bs.CusBimEngine=S9,Object.defineProperty(bs,Symbol.toStringTag,{value:"Module"})}));
|
||
//# sourceMappingURL=iflow-engine.umd.js.map
|