12530 lines
2.8 MiB
12530 lines
2.8 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}.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}.bim-dialog{position:absolute;background:var(--bim-dialog-bg, var(--bim-bg-elevated));border:1px solid var(--bim-dialog-border-color, var(--bim-border-default));border-radius:var(--bim-dialog-radius, 4px);box-shadow:var(--bim-shadow-lg);display:flex;flex-direction:column;z-index:10001;color:var(--bim-dialog-text-color, var(--bim-text-secondary));overflow:hidden;min-width:200px;min-height:100px;pointer-events:auto}.bim-dialog-header{position:relative;min-height:58px;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:0 10px 0 18px;cursor:default;-webkit-user-select:none;user-select:none;flex-shrink:0;border-bottom:1px solid var(--bim-border-subtle, var(--bim-dialog-border-color, var(--bim-border-default)));box-shadow:var(--bim-shadow-sm);z-index:1}.bim-dialog-header.draggable{cursor:move}.bim-dialog-title{flex:1;min-width:0;font-size:18px;font-weight:300;line-height:1.2;letter-spacing:.01em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--bim-dialog-title-color, var(--bim-text-primary))}.bim-dialog-close{display:flex;align-items:center;justify-content:center;width:38px;height:38px;cursor:pointer;color:var(--bim-text-secondary);border-radius:4px;transition:background-color .2s ease,color .2s ease,box-shadow .2s ease;flex-shrink:0;margin-left:8px}.bim-dialog-close:hover{color:var(--bim-text-primary);background-color:var(--bim-component-bg-hover, rgba(15, 23, 42, .06));box-shadow:inset 0 0 0 1px var(--bim-border-subtle, var(--bim-dialog-border-color, var(--bim-border-default)))}.bim-dialog-close svg{display:block;width:20px;height:20px}.bim-dialog-content{flex:1;overflow:auto;font-size:14px;color:var(--bim-dialog-text-color, var(--bim-text-secondary));background:var(--bim-dialog-bg, var(--bim-bg-elevated))}.bim-dialog-resize-handle{position:absolute;width:28px;height:28px;right:2px;bottom:2px;cursor:se-resize;z-index:10;border-radius:4px 0;transition:background-color .2s ease}.bim-dialog-resize-handle:hover{background:var(--bim-component-bg-hover, rgba(15, 23, 42, .04))}.bim-dialog-resize-handle:after{content:"";position:absolute;right:7px;bottom:7px;width:11px;height:11px;border-right:2px solid var(--bim-text-tertiary);border-bottom:2px solid var(--bim-text-tertiary)}.bim-dialog-resize-handle:before{content:"";position:absolute;right:11px;bottom:11px;width:6px;height:6px;border-right:2px solid var(--bim-text-tertiary);border-bottom:2px solid var(--bim-text-tertiary);opacity:.85}.bim-dialog-resize-handle:hover:after,.bim-dialog-resize-handle:hover:before{border-color:var(--bim-text-primary)}.engine-view-dropdown-trigger{position:absolute;top:50px;right:95px;z-index:999;width:32px;height:32px;display:flex;align-items:center;justify-content:center;cursor:pointer;color:#fff;filter:drop-shadow(0 2px 4px rgba(0,0,0,.3));transition:filter .2s ease;background:none;border:none;padding:0}.engine-info-button{position:absolute;bottom:20px;left:10px;z-index:999;width:32px;height:32px;display:flex;align-items:center;justify-content:center;cursor:pointer;color:#fff;filter:drop-shadow(0 2px 4px rgba(0,0,0,.3));transition:filter .2s ease;background:none;border:none;padding:0}.engine-info-button:hover{filter:drop-shadow(0 3px 6px rgba(0,0,0,.5))}.engine-info-button svg{width:24px;height:24px}.engine-view-dropdown-trigger:hover{filter:drop-shadow(0 3px 6px rgba(0,0,0,.5))}.engine-view-dropdown-trigger svg{width:24px;height:24px}.engine-view-dropdown-menu{background:var(--bim-panel-bg, rgba(255, 255, 255, .95));border:1px solid var(--bim-panel-border, rgba(226, 232, 240, .6));border-radius:8px;box-shadow:var(--bim-shadow-lg, 0 10px 25px rgba(0, 0, 0, .15));min-width:160px;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);animation:dropdownIn .15s ease-out}.engine-view-dropdown-item{padding:2px 4px;cursor:pointer;font-size:12px;color:var(--bim-text-primary, #0f172a);transition:all .15s ease;line-height:1.5;white-space:nowrap}.engine-view-dropdown-item:hover{background:var(--bim-component-bg-hover, rgba(15, 23, 42, .04));color:var(--bim-primary, #2563eb)}.engine-view-dropdown-item:active{background:var(--bim-component-bg-active, rgba(15, 23, 42, .08))}.engine-view-dropdown-item:not(:last-child){border-bottom:1px solid var(--bim-panel-border, rgba(226, 232, 240, .6))}@keyframes dropdownIn{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}.bim-help-panel-overlay{position:fixed;inset:0;background:#0009;display:flex;justify-content:center;align-items:center;z-index:10000;visibility:hidden;opacity:0;transition:opacity .2s ease}.bim-help-panel-overlay.active{visibility:visible;opacity:1}.bim-help-panel-container{background:var(--bim-panel-bg);width:720px;max-width:92%;max-height:85vh;border-radius:10px;box-shadow:var(--bim-shadow-lg);display:flex;flex-direction:column;overflow:hidden;border:1px solid var(--bim-panel-border)}.bim-help-panel-close{position:absolute;right:16px;top:12px;width:32px;height:32px;display:flex;align-items:center;justify-content:center;font-size:22px;cursor:pointer;color:var(--bim-text-tertiary);background:transparent;border:none;line-height:1;z-index:10;transition:color .15s ease}.bim-help-panel-close:hover{color:var(--bim-text-primary)}.bim-help-panel-header{display:flex;justify-content:center;padding:16px 20px;gap:8px;border-bottom:1px solid var(--bim-divider);background:var(--bim-panel-header-bg);flex-shrink:0}.bim-help-panel-tab-btn{background:var(--bim-component-bg);border:1px solid var(--bim-border-default);padding:8px 28px;font-size:14px;font-weight:600;cursor:pointer;transition:all .15s ease;border-radius:5px;color:var(--bim-text-secondary)}.bim-help-panel-tab-btn:hover{border-color:var(--bim-border-strong);color:var(--bim-text-primary)}.bim-help-panel-tab-btn.active{border:2px solid var(--bim-text-primary);color:var(--bim-text-primary);background:var(--bim-component-bg)}.bim-help-panel-body{padding:20px 24px;overflow-y:auto;flex:1}.bim-help-panel-body::-webkit-scrollbar{width:5px}.bim-help-panel-body::-webkit-scrollbar-track{background:transparent}.bim-help-panel-body::-webkit-scrollbar-thumb{background:var(--bim-scrollbar-thumb);border-radius:3px}.bim-help-panel-tab-content{display:none;grid-template-columns:repeat(3,1fr);gap:12px}.bim-help-panel-tab-content.active{display:grid}.bim-help-panel-card{background:var(--bim-component-bg);border:1px solid var(--bim-border-subtle);border-radius:8px;padding:16px 14px;display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:110px;gap:10px}.bim-help-panel-card-span-2{grid-column:span 2}.bim-help-panel-card-title{font-size:13px;color:var(--bim-text-primary);font-weight:700;width:100%;text-align:left;border-left:3px solid var(--bim-primary);padding-left:8px}.bim-help-panel-control-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap;color:var(--bim-text-primary);font-size:13px}.bim-help-panel-kbd{background:var(--bim-bg-base);border:1px solid var(--bim-border-default);border-radius:4px;box-shadow:0 2px 0 var(--bim-border-subtle);color:var(--bim-text-primary);display:inline-flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;padding:4px 10px;min-width:24px;height:26px;font-family:ui-monospace,SFMono-Regular,monospace}.bim-help-panel-wasd-group{display:flex;flex-direction:column;align-items:center;gap:4px}.bim-help-panel-kbd-row{display:flex;gap:4px}.bim-help-panel-rule-desc{font-size:12px;color:var(--bim-text-secondary);line-height:1.5;text-align:center}.bim-help-panel-bold{color:var(--bim-text-primary);font-weight:700}.bim-help-panel-mouse-box{width:22px;height:32px;border:2px solid var(--bim-text-primary);border-radius:8px;position:relative;background:var(--bim-bg-base);flex-shrink:0}.bim-help-panel-mouse-box:after{content:"";position:absolute;top:4px;left:50%;height:10px;border-right:2px solid var(--bim-text-primary);transform:translate(-50%)}.bim-help-panel-mouse-left{position:absolute;top:0;left:0;width:50%;height:55%;border-radius:6px 0 0;background:var(--bim-text-primary)}.bim-help-panel-mouse-right{position:absolute;top:0;right:0;width:50%;height:55%;border-radius:0 6px 0 0;background:var(--bim-text-primary)}.bim-help-panel-mouse-wheel{position:absolute;top:6px;left:50%;width:4px;height:8px;background:var(--bim-text-primary);border-radius:2px;transform:translate(-50%);z-index:2}.bim-help-panel-teleport-icon{width:28px;height:28px;border:2px solid var(--bim-text-primary);border-radius:50%;position:relative;display:flex;justify-content:center;align-items:center;flex-shrink:0}.bim-help-panel-teleport-icon:before,.bim-help-panel-teleport-icon:after{content:"";position:absolute;background:var(--bim-text-primary)}.bim-help-panel-teleport-icon:before{width:36px;height:2px}.bim-help-panel-teleport-icon:after{width:2px;height:36px}.bim-help-panel-teleport-inner{width:6px;height:6px;background:var(--bim-text-primary);border-radius:50%;z-index:2}.bim-help-panel-footer{display:flex;justify-content:center;gap:16px;padding:16px 24px 24px;border-top:1px solid var(--bim-divider);flex-shrink:0}.bim-help-panel-btn{padding:10px 48px;border-radius:6px;border:none;font-size:14px;cursor:pointer;font-weight:600;transition:all .15s ease}.bim-help-panel-btn-primary{background:var(--bim-primary);color:var(--bim-text-inverse)}.bim-help-panel-btn-primary:hover{background:var(--bim-primary-hover)}.bim-help-panel-btn-secondary{background:var(--bim-component-bg-hover);color:var(--bim-text-secondary);border:1px solid var(--bim-border-default)}.bim-help-panel-btn-secondary:hover{background:var(--bim-component-bg-active);color:var(--bim-text-primary)}@media(max-width:640px){.bim-help-panel-container{width:96%;max-height:90vh}.bim-help-panel-tab-content{grid-template-columns:1fr}.bim-help-panel-card-span-2{grid-column:span 1}.bim-help-panel-tab-btn{padding:8px 20px;font-size:13px}.bim-help-panel-btn{padding:10px 24px}}.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-dock-panel{display:flex;align-items:center;gap:10px;padding:0;background:transparent;border:none;border-radius:8px;box-shadow:none;color:var(--bim-text-secondary, #64748b);-webkit-user-select:none;user-select:none}.walk-dock-panel .walk-divider{height:32px;width:1px;background:var(--bim-divider);flex-shrink:0}.walk-dock-left{display:flex;gap:10px}.walk-dock-settings{display:flex;align-items:center;gap:10px;flex:1}.walk-icon-btn{width:32px;height:32px;display:flex;align-items:center;justify-content:center;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%);cursor:pointer;transition:all .2s ease}.walk-icon-btn:hover{border-color:#94a3b880;background:color-mix(in srgb,var(--bim-component-bg-hover, #dce5f2) 64%,#ffffff 36%)}.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-icon-btn svg{width:20px;height:20px}.walk-icon-btn.active svg{fill:currentColor}.walk-speed-control{display:flex;align-items:center;gap:8px}.walk-speed-label,.walk-checkbox-label,.walk-select-label{font-size:12px;color:var(--bim-text-primary);white-space:nowrap}.walk-speed-group{display:flex;align-items:center;gap:8px;padding:2px;border:1px solid rgba(148,163,184,.28);background:color-mix(in srgb,var(--bim-bg-inset, #edf1f6) 92%,#ffffff 8%);border-radius:6px}.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);border-radius:4px;cursor:pointer;transition:all .2s ease}.walk-speed-btn:hover{border-color:#94a3b880}.walk-speed-btn:disabled{opacity:.5;cursor:not-allowed}.walk-speed-display{min-width:30px;font-size:12px;color:var(--bim-text-primary, #0f172a);text-align:center;font-weight:700}.walk-checkbox-wrapper{display:flex;align-items:center;gap:8px;cursor:pointer}.walk-checkbox{width:14px;height:14px;accent-color:var(--bim-primary, #3b82f6);cursor:pointer}.walk-checkbox:disabled,.walk-checkbox-wrapper input:disabled+.walk-checkbox-label{opacity:.5;cursor:not-allowed}.walk-select-wrapper{display:flex;align-items:center;gap:8px}.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);border-radius:6px;cursor:pointer}.walk-select option{background:var(--bim-bg-elevated);color:var(--bim-text-primary)}.walk-exit-btn{height:32px;padding:0 12px;border-radius:8px;font-size:12px;background:var(--bim-primary);border:none;color:var(--bim-text-inverse);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}.component-tree-drawer{--bim-component-tree-bg: #ffffff;--bim-component-tree-blur: 0px;--bim-component-tree-border: rgba(148, 163, 184, .28);--bim-component-tree-shadow: 0 14px 36px rgba(15, 23, 42, .08);--bim-component-tree-text: #0f172a;--bim-component-tree-muted: #475569;--bim-component-tree-tab-bg: #f8fafc;--bim-component-tree-tab-hover: #f1f5f9;--bim-component-tree-tab-active: #eff6ff;--bim-component-tree-tab-active-border: #3b82f6;--bim-component-tree-tab-active-text: #1d4ed8;--bim-component-tree-close-bg: #f8fafc;--bim-component-tree-close-hover: #eef2f7;--bim-component-tree-page-title: var(--bim-component-tree-text);--bim-component-tree-page-description: var(--bim-component-tree-muted);--bim-component-tree-surface: #ffffff;--bim-component-tree-surface-border: rgba(148, 163, 184, .14);--bim-component-tree-subtab-nav-bg: #e2e8f0;--bim-component-tree-subtab-nav-border: rgba(148, 163, 184, .26);--bim-component-tree-subtab-text: #334155;--bim-component-tree-subtab-hover-bg: rgba(255, 255, 255, .72);--bim-component-tree-subtab-hover-text: #0f172a;--bim-component-tree-subtab-active-bg: #ffffff;--bim-component-tree-subtab-active-text: #0f172a;--bim-component-tree-subtab-active-border: rgba(59, 130, 246, .22);--bim-component-tree-subtab-active-shadow: 0 1px 2px rgba(15, 23, 42, .08);--bim-component-tree-tree-bg: #ffffff;--bim-component-tree-tree-border: rgba(148, 163, 184, .18);position:absolute;top:0;left:0;bottom:0;width:min(320px,100%);display:flex;flex-direction:column;border:1px solid var(--bim-component-tree-border);border-radius:0;background:var(--bim-component-tree-bg);backdrop-filter:blur(var(--bim-component-tree-blur));-webkit-backdrop-filter:blur(var(--bim-component-tree-blur));box-shadow:var(--bim-component-tree-shadow);color:var(--bim-component-tree-text);overflow:hidden;transform:translate(calc(-100% - 24px));opacity:0;pointer-events:none;transition:transform .22s ease,opacity .22s ease;z-index:1200}.component-tree-drawer.is-open{transform:translate(0);opacity:1;pointer-events:auto}.component-tree-drawer-header{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 10px 10px 12px;border-bottom:1px solid var(--bim-component-tree-border)}.component-tree-drawer-tabs{min-width:0;display:flex;align-items:center;flex-wrap:nowrap}.component-tree-drawer-tab{appearance:none;border:none;background:transparent;color:var(--bim-component-tree-muted);border-radius:0;padding:8px 14px;min-height:34px;font-size:14px;font-weight:500;line-height:1;cursor:pointer;transition:color .18s ease;position:relative}.component-tree-drawer-tab:not(:last-child):after{content:"";position:absolute;right:0;top:50%;transform:translateY(-50%);width:1px;height:16px;background-color:var(--bim-component-tree-border)}.component-tree-drawer-tab:hover{color:var(--bim-component-tree-text)}.component-tree-drawer-tab.is-active{color:var(--bim-component-tree-tab-active-text);font-weight:600}.component-tree-drawer-close{flex:0 0 auto;width:44px;height:44px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:4px;background:var(--bim-component-tree-close-bg);color:var(--bim-component-tree-text);cursor:pointer;transition:background-color .18s ease,border-color .18s ease,color .18s ease;margin-left:8px}.component-tree-drawer-close:hover{background:var(--bim-component-tree-close-hover);border-color:var(--bim-component-tree-border);box-shadow:inset 0 0 0 1px var(--bim-component-tree-border)}.component-tree-drawer-close svg{width:40px;height:40px}.component-tree-drawer-body{flex:1;display:flex;flex-direction:column;min-height:0;padding:10px 12px 12px;overflow:hidden}.component-tree-drawer-panel{display:none;flex:1 1 auto;min-height:0;height:100%;overflow:hidden}.component-tree-drawer-panel.is-active{display:flex;flex-direction:column}.component-tree-drawer-page{min-height:100%;display:flex;flex-direction:column;justify-content:flex-start;gap:8px;padding:12px;border:1px solid var(--bim-component-tree-surface-border);border-radius:8px;background:var(--bim-component-tree-surface)}.component-tree-drawer-page-title{margin:0;font-size:15px;line-height:1.3;color:var(--bim-component-tree-page-title)}.component-tree-drawer-page-description{margin:0;font-size:12px;line-height:1.6;color:var(--bim-component-tree-page-description)}.component-tree-drawer-pin-page{gap:0;padding:0;border:none;background:transparent}.component-tree-drawer-add-pin-btn{appearance:none;border:none;background:var(--bim-pin-primary, #3b82f6);color:#fff;border-radius:10px;padding:12px 16px;font-size:14px;font-weight:600;line-height:1;cursor:pointer;transition:all .2s ease;display:flex;align-items:center;justify-content:center;gap:8px;width:100%;box-shadow:0 1px 3px #3b82f64d}.component-tree-drawer-add-pin-btn:hover{background:var(--bim-pin-primary-hover, #2563eb);transform:translateY(-1px);box-shadow:0 4px 12px #3b82f666}.component-tree-drawer-add-pin-btn:active{transform:translateY(0)}.component-tree-drawer-add-pin-btn svg{width:18px;height:18px;flex-shrink:0}.component-tree-drawer-pin-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:48px 20px;text-align:center}.component-tree-drawer-pin-empty-icon{width:48px;height:48px;display:flex;align-items:center;justify-content:center;color:var(--bim-pin-muted, #94a3b8);opacity:.5}.component-tree-drawer-pin-empty-icon svg{width:100%;height:100%}.component-tree-drawer-pin-empty-title{font-size:15px;font-weight:600;color:var(--bim-pin-text, #1e293b)}.component-tree-drawer-pin-empty-desc{font-size:13px;color:var(--bim-pin-muted, #64748b);line-height:1.5}.component-tree-drawer-pin-list{display:flex;flex-direction:column;gap:10px;overflow-y:auto;overflow-x:hidden;max-height:100%;padding:0 4px}.component-tree-drawer-pin-item{background:var(--bim-pin-card-bg, #ffffff);border:1px solid var(--bim-pin-border, #e2e8f0);border-radius:12px;padding:2px;cursor:pointer;transition:all .2s ease;box-shadow:var(--bim-pin-shadow, 0 1px 3px rgba(0, 0, 0, .05));overflow:hidden}.component-tree-drawer-pin-item:hover{border-color:var(--bim-component-tree-tab-active-border, #3b82f6);box-shadow:var(--bim-pin-shadow-hover, 0 4px 12px rgba(0, 0, 0, .1));transform:translateY(-1px)}.component-tree-drawer-pin-content{display:flex;align-items:center;gap:12px;padding:10px 14px;min-height:48px}.component-tree-drawer-pin-icon{flex:0 0 auto;width:36px;height:36px;display:flex;align-items:center;justify-content:center;background:var(--bim-component-tree-tab-active, #eff6ff);color:var(--bim-component-tree-tab-active-text, #1d4ed8);border-radius:10px}.component-tree-drawer-pin-icon svg{width:20px;height:20px}.component-tree-drawer-pin-info{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:2px}.component-tree-drawer-pin-name{font-size:14px;font-weight:600;color:var(--bim-pin-text, #1e293b);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.4}.component-tree-drawer-pin-index{font-size:11px;font-weight:500;color:var(--bim-pin-muted, #94a3b8);line-height:1.3}.component-tree-drawer-pin-actions{flex:0 0 auto;display:flex;align-items:center;gap:2px;opacity:0;transition:opacity .18s ease}.component-tree-drawer-pin-item:hover .component-tree-drawer-pin-actions{opacity:1}.component-tree-drawer-pin-action-btn{appearance:none;border:none;background:transparent;color:var(--bim-pin-muted, #94a3b8);width:32px;height:32px;display:inline-flex;align-items:center;justify-content:center;border-radius:8px;cursor:pointer;transition:all .18s ease;padding:0}.component-tree-drawer-pin-action-btn:hover{background:var(--bim-component-tree-tab-hover, #f1f5f9);color:var(--bim-pin-text, #1e293b)}.component-tree-drawer-pin-action-btn svg{width:16px;height:16px}.component-tree-drawer-pin-edit-wrapper{display:flex;align-items:center;gap:8px;padding:10px 14px}.component-tree-drawer-pin-input{flex:1 1 auto;min-width:0;appearance:none;border:2px solid var(--bim-component-tree-tab-active-border, #3b82f6);background:var(--bim-pin-bg, #ffffff);color:var(--bim-pin-text, #1e293b);border-radius:8px;padding:8px 12px;font-size:14px;font-weight:600;outline:none;transition:box-shadow .2s ease}.component-tree-drawer-pin-input:focus{box-shadow:0 0 0 3px #3b82f626}.component-tree-drawer-pin-edit-actions{flex:0 0 auto;display:flex;align-items:center;gap:4px}.component-tree-drawer-pin-edit-btn{appearance:none;border:none;width:32px;height:32px;display:inline-flex;align-items:center;justify-content:center;border-radius:8px;cursor:pointer;transition:all .18s ease;padding:0}.component-tree-drawer-pin-edit-save{background:#10b981;color:#fff}.component-tree-drawer-pin-edit-save:hover{background:#059669}.component-tree-drawer-pin-edit-cancel{background:#f1f5f9;color:#64748b}.component-tree-drawer-pin-edit-cancel:hover{background:#e2e8f0;color:#475569}.component-tree-drawer-pin-edit-btn svg{width:16px;height:16px}.component-tree-drawer-construct-tree,.component-tree-drawer-construct-tree-mount{flex:1;min-height:0;height:100%;display:flex;flex-direction:column;overflow:hidden}.component-tree-drawer-construct-tree-tab-container,.component-tree-drawer-construct-tree-tab-container .bim-tab,.component-tree-drawer-construct-tree-tab-container .bim-tab__content,.component-tree-drawer-construct-tree-tab-container .bim-tab__panel,.component-tree-drawer-construct-tree-panel,.component-tree-drawer-construct-tree-tab-container .construct-tab__panel-content,.component-tree-drawer-construct-tree-tab-container .bim-tree{height:100%;min-height:0;overflow:hidden}.component-tree-drawer-construct-tree-tab-container .bim-tab{display:flex;flex-direction:column;background:transparent}.component-tree-drawer-construct-tree-tab-container .bim-tab__nav{flex:0 0 auto;gap:6px;padding:4px;margin:0 0 8px;background:var(--bim-component-tree-subtab-nav-bg);border-color:var(--bim-component-tree-subtab-nav-border);border-radius:10px}.component-tree-drawer-construct-tree-tab-container .bim-tab__item{min-height:32px;padding:7px 10px;font-size:12px;font-weight:600;color:var(--bim-component-tree-subtab-text);border:1px solid transparent}.component-tree-drawer-construct-tree-tab-container .bim-tab__item:hover{color:var(--bim-component-tree-subtab-hover-text);background:var(--bim-component-tree-subtab-hover-bg)}.component-tree-drawer-construct-tree-tab-container .bim-tab__item.is-active{color:var(--bim-component-tree-subtab-active-text);background:var(--bim-component-tree-subtab-active-bg);border-color:var(--bim-component-tree-subtab-active-border);box-shadow:var(--bim-component-tree-subtab-active-shadow)}.component-tree-drawer-construct-tree-tab-container .bim-tab__content{flex:1;min-height:0;overflow:hidden}.component-tree-drawer-construct-tree-panel,.component-tree-drawer-construct-tree-tab-container .construct-tab__panel-content{overflow:hidden}.component-tree-drawer-construct-tree-tab-container .bim-tree{border:1px solid var(--bim-component-tree-tree-border);border-radius:10px;background:var(--bim-component-tree-tree-bg)}.component-tree-drawer-construct-tree-tab-container .bim-tree-search{padding:8px 8px 6px}.component-tree-drawer-construct-tree-tab-container .bim-tree-search-input{height:28px;font-size:12px}.component-tree-drawer-construct-tree-tab-container .bim-tree-content{flex:1 1 auto;min-height:0;padding:4px 6px 8px;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain}@media(max-width:768px){.component-tree-drawer{right:0}.component-tree-drawer-header{align-items:flex-start}.component-tree-drawer-tabs{gap:6px}.component-tree-drawer-tab{padding:8px 12px;min-height:34px}}.component-tree-drawer-view,.component-tree-drawer-view-mount{flex:1;min-height:0;height:100%;display:flex;flex-direction:column;overflow:hidden}.component-tree-drawer-view-mount .bim-tree{height:100%;min-height:0;border:1px solid var(--bim-component-tree-tree-border);border-radius:10px;background:var(--bim-component-tree-tree-bg);overflow:hidden}.component-tree-drawer-view-mount .bim-tree-search{padding:8px 8px 6px}.component-tree-drawer-view-mount .bim-tree-search-input{height:28px;font-size:12px}.component-tree-drawer-view-mount .bim-tree-content{flex:1 1 auto;min-height:0;padding:4px 6px 8px;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain}.component-tree-drawer-view-empty{display:flex;align-items:center;justify-content:center;height:100%;min-height:0;padding:24px;font-size:13px;color:var(--bim-component-tree-muted);text-align:center}.component-tree-drawer-pin-toolbar{margin-bottom:10px}.component-tree-drawer-pin-btn-group{display:flex;gap:6px;width:100%;flex-wrap:nowrap}.component-tree-drawer-add-pin-btn,.component-tree-drawer-add-folder-btn{appearance:none;border:1px solid var(--bim-component-tree-tree-border);color:var(--bim-pin-text, #1e293b);border-radius:8px;padding:0 10px;height:30px;font-size:12px;font-weight:600;line-height:1;cursor:pointer;transition:background-color .18s ease,border-color .18s ease,color .18s ease,transform .18s ease;display:flex;align-items:center;justify-content:center;gap:6px;background:var(--bim-pin-card-bg, #ffffff);box-shadow:none;white-space:nowrap;flex:0 0 auto;min-width:0}.component-tree-drawer-add-pin-btn svg,.component-tree-drawer-add-folder-btn svg{width:14px;height:14px;flex-shrink:0}.component-tree-drawer-add-pin-btn{background:var(--bim-pin-soft, rgba(59, 130, 246, .12));border-color:color-mix(in srgb,var(--bim-pin-primary, #3b82f6) 26%,var(--bim-component-tree-tree-border));color:var(--bim-component-tree-tab-active-text, #1d4ed8);flex:1 1 auto}.component-tree-drawer-add-pin-btn:hover{background:color-mix(in srgb,var(--bim-pin-primary, #3b82f6) 14%,var(--bim-pin-card-bg, #ffffff));border-color:color-mix(in srgb,var(--bim-pin-primary, #3b82f6) 38%,var(--bim-component-tree-tree-border))}.component-tree-drawer-add-folder-btn{background:transparent;padding-inline:9px}.component-tree-drawer-add-folder-btn:hover{background:var(--bim-component-tree-tab-hover, #f1f5f9);border-color:var(--bim-component-tree-tree-border);color:var(--bim-pin-text, #1e293b)}.component-tree-drawer-add-pin-btn:focus-visible,.component-tree-drawer-add-folder-btn:focus-visible,.pin-node-action-btn:focus-visible,.pin-node-edit-btn:focus-visible,.pin-node-edit-input:focus-visible{outline:2px solid color-mix(in srgb,var(--bim-pin-primary, #3b82f6) 60%,white);outline-offset:2px}.component-tree-drawer-add-pin-btn:active,.component-tree-drawer-add-folder-btn:active{transform:translateY(-1px)}.component-tree-drawer-pin-tree-container{flex:1;min-height:0;overflow:hidden}.component-tree-drawer-pin-tree-container .bim-tree{height:100%;border:1px solid var(--bim-component-tree-tree-border);border-radius:10px;background:var(--bim-component-tree-tree-bg);overflow:hidden}.component-tree-drawer-pin-tree-container .bim-tree-content{flex:1 1 auto;min-height:0;padding:6px 8px 10px;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain}.component-tree-drawer-pin-tree-container .bim-tree-node-content{min-height:34px;border-radius:8px;padding-right:6px}.component-tree-drawer-pin-tree-container .bim-tree-node-content.is-selected{background:color-mix(in srgb,var(--bim-pin-primary, #3b82f6) 12%,var(--bim-component-tree-tree-bg))}.component-tree-drawer-pin-tree-container .bim-tree-title{font-size:13px;font-weight:500}.component-tree-drawer-pin-tree-container .bim-tree-node-actions{display:flex}.pin-node-actions{display:flex;align-items:center;gap:4px;opacity:0;transition:opacity .18s ease}.bim-tree-node-content:hover .pin-node-actions,.bim-tree-node-content.is-selected .pin-node-actions,.bim-tree-node-content:focus-within .pin-node-actions{opacity:1}.pin-node-action-btn{appearance:none;border:none;background:transparent;color:var(--bim-pin-muted, #94a3b8);width:24px;height:24px;display:inline-flex;align-items:center;justify-content:center;border-radius:6px;cursor:pointer;transition:all .18s ease;padding:0}.pin-node-action-btn:hover{background:var(--bim-component-tree-tab-hover, #f1f5f9);color:var(--bim-pin-text, #1e293b)}.pin-node-action-btn svg{width:13px;height:13px}.pin-node-edit-wrapper{display:flex;align-items:center;gap:6px;flex:1;min-width:0}.pin-node-edit-input{flex:1;min-width:0;appearance:none;border:1px solid color-mix(in srgb,var(--bim-pin-primary, #3b82f6) 35%,var(--bim-component-tree-tree-border));background:var(--bim-pin-bg, #ffffff);color:var(--bim-pin-text, #1e293b);border-radius:6px;padding:5px 8px;font-size:13px;font-weight:500;outline:none;transition:box-shadow .2s ease}.pin-node-edit-input:focus{box-shadow:0 0 0 3px #3b82f626}.pin-node-edit-actions{display:flex;align-items:center;gap:4px;flex-shrink:0}.pin-node-edit-btn{appearance:none;border:none;width:24px;height:24px;display:inline-flex;align-items:center;justify-content:center;border-radius:6px;cursor:pointer;transition:all .18s ease;padding:0}.pin-node-edit-btn svg{width:12px;height:12px}.pin-node-edit-save{background:#10b981;color:#fff}.pin-node-edit-save:hover{background:#059669}.pin-node-edit-cancel{background:#f1f5f9;color:#64748b}.pin-node-edit-cancel:hover{background:#e2e8f0;color:#475569}.pin-delete-dialog{display:flex;flex-direction:column;align-items:center;gap:14px;min-width:0;padding:20px 22px 18px}.pin-delete-dialog-symbol{width:52px;height:52px;display:inline-flex;align-items:center;justify-content:center;border-radius:50%;background:color-mix(in srgb,#f59e0b 12%,var(--bim-pin-card-bg, #ffffff));color:#d97706;font-size:30px;font-weight:700;line-height:1}.pin-delete-dialog-text{font-size:14px;line-height:1.7;color:var(--bim-pin-text, #1e293b);word-break:break-word;text-align:center}.pin-delete-dialog-actions{display:flex;justify-content:flex-end;gap:8px;width:100%;margin-top:2px}.pin-delete-dialog-btn{min-width:88px;height:36px;padding:0 14px;border-radius:10px;border:1px solid var(--bim-component-tree-tree-border);background:var(--bim-pin-card-bg, #ffffff);color:var(--bim-pin-text, #1e293b);font-size:13px;font-weight:600;cursor:pointer;transition:background-color .18s ease,border-color .18s ease,color .18s ease}.pin-delete-dialog-btn.is-secondary:hover{background:var(--bim-component-tree-tab-hover, #f1f5f9)}.pin-delete-dialog-btn.is-danger{border-color:color-mix(in srgb,#ef4444 30%,var(--bim-component-tree-tree-border));background:color-mix(in srgb,#ef4444 10%,var(--bim-pin-card-bg, #ffffff));color:#b91c1c}.pin-delete-dialog-btn.is-danger:hover{background:color-mix(in srgb,#ef4444 16%,var(--bim-pin-card-bg, #ffffff))}.pin-delete-dialog-btn:focus-visible{outline:2px solid color-mix(in srgb,var(--bim-pin-primary, #3b82f6) 60%,white);outline-offset:2px}@media(max-width:560px){.component-tree-drawer-pin-btn-group{width:100%}.component-tree-drawer-add-pin-btn,.component-tree-drawer-add-folder-btn{flex:1 1 0}}@media(prefers-reduced-motion:reduce){.component-tree-drawer,.component-tree-drawer-tab,.component-tree-drawer-close{transition:none}}.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}.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;overflow:hidden;text-overflow:ellipsis}.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-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)}.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(0px 0px 2px rgba(0,0,0,.3))}.measureBack{cursor:pointer;pointer-events:auto;fill:#fff;rx:5;ry:5;filter:drop-shadow(0px 0px 3px rgba(0,0,0,.3));text-align:center}.measureLabel{position:absolute;fill:#fff;font-family:tahoma;font-size:14px;stroke:#009bea;font-weight:200;pointer-events:none;text-anchor:middle}.measurePointer{fill:#009bea}.Hight{stroke:#fff;font-weight:500;filter:drop-shadow(0px 0px 2px rgb(0,195,255))}.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}}')),document.head.appendChild(e)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
|
||
(function(_r,Dd){typeof exports=="object"&&typeof module<"u"?Dd(exports,require("opentype.js")):typeof define=="function"&&define.amd?define(["exports","opentype.js"],Dd):(_r=typeof globalThis<"u"?globalThis:_r||self,Dd(_r.IflowEngine={},_r["{}"]))})(this,(function(_r,Dd){"use strict";var pt=typeof document<"u"?document.currentScript:null;function YR(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const KR=YR(Dd),ww={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"}}},$R={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 ZR{currentTheme=ww;listeners=[];constructor(){}getTheme(){return this.currentTheme}setTheme(e){e==="light"?this.applyTheme(ww):this.applyTheme($R)}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 ct=new ZR,JR={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:"请输入要搜索的内容",noResults:"未找到匹配结果"},constructTree:{title:"目录树"},componentTreeDrawer:{actions:{close:"关闭抽屉",add:"新增",addPin:"新增图钉",addFolder:"新增文件夹",edit:"编辑",delete:"删除",save:"保存",cancel:"取消"},tabs:{view:"视图",pin:"图钉",constructTree:"构件树"},empty:{pinTitle:"暂无图钉",pinDesc:"点击上方按钮添加第一个图钉"},dialogs:{noticeTitle:"提示",deleteFolderTitle:"删除文件夹",deleteFolderMessage:"确认删除该文件夹以及文件夹下面的所有图钉吗?",deleteFolderMessagePrefix:"是否删除【",deleteFolderMessageSuffix:"】文件夹以及文件夹下面所有的图钉数据。",confirm:"确定"},placeholders:{view:"视图页面占位,后续在这里接入视图相关内容。",pin:"暂无图钉,点击上方按钮添加",constructTree:"构件树页面占位,后续在这里接入新的构件树能力。"}},viewTab:{category:{ceilingPlans:"天花板平面",elevations:"立面",floorPlans:"楼层平面",sections:"剖面"},empty:"暂无视图数据"},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:"重置",fill:"填充"}},sectionAxis:{dialogTitle:"轴向剖切",actions:{hide:"隐藏",reverse:"反向",reset:"重置",axisX:"X",axisY:"Y",axisZ:"Z",fill:"填充"}},sectionBox:{dialogTitle:"剖切盒",actions:{hide:"隐藏",reverse:"反向",fitToModel:"适应",reset:"重置",fill:"填充"},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:"提交"},viewDropdown:{triggerTitle:"视图控制",switchOrthographic:"切换到正交视图",switchPerspective:"切换到透视视图",saveMainView:"将当前视图设为主视图",restoreMainView:"重置主视图",captureScreenshot:"截图保存"},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"},help:{engineControl:"引擎控制",fpsControl:"第一视角控制",gotIt:"好的,知道了",dontRemind:"不再提醒我",rotate:"旋转",mouseLeftDrag:"鼠标左键拖拽",pan:"平移",shiftLeftDrag:"Shift + 左键 / 右键拖拽",zoom:"缩放",mouseWheel:"鼠标滚轮",boxSelect:"框选",ctrlLeftDrag:"Ctrl + 左键拖拽",multiSelect:"加选 / 减选",ctrlShiftClick:"Ctrl + 单击 (加) / Shift + 单击 (减)",homeView:"回到主视图",doubleClickBlank:"双击空白区域",rotateRuleTitle:"旋转点变换规则",rotateRuleDesc:"鼠标悬停构件时,按当前位置设定旋转中心;悬停空白区域时,保持上一次旋转中心。",roam:"漫游",or:"或",upDown:"向上和向下移动",qeKey:"Q / E",landOnFloor:"开启重力将落在最近楼层",run:"运行 (加速)",shiftArrow:"Shift + 方向键",teleport:"传送",doubleClick:"双击目标",lookAround:"环视",leftDrag:"使用左键拖动视图",adjustSpeed:"调整速度",rotateView:"旋转视图",panView:"平移视图",zoomView:"缩放视图",resetView:"视图复位",mouseLeftDragShort:"鼠标左键拖拽",mouseRightDragShort:"鼠标右键拖拽",mouseWheelShort:"滚动鼠标滚轮",componentSelect:"构件选择",click:"单击",addSelect:"加选构件",removeSelect:"减选构件",doubleClickBlankShort:"双击空白区域",pointToComponent:"指向构件:",pointToComponentDesc:"以鼠标点击位置为旋转中心",pointToBlank:"指向空白:",pointToBlankDesc:"保持上一次确定的旋转中心",roamMove:"漫游移动",roamMoveDesc:"使用 WASD 或方向键进行移动",speedUp:"加速移动",lookAroundDesc:"左键拖动视图查看四周",teleportDesc:"双击目标构件或地面"}},e4={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",noResults:"No matching results"},constructTree:{title:"Construct Tree"},componentTreeDrawer:{actions:{close:"Close drawer",add:"Add",addPin:"Add Pin",addFolder:"Add Folder",edit:"Edit",delete:"Delete",save:"Save",cancel:"Cancel"},tabs:{view:"View",pin:"Pins",constructTree:"Component Tree"},empty:{pinTitle:"No pins yet",pinDesc:"Click the button above to add your first pin"},dialogs:{noticeTitle:"Notice",deleteFolderTitle:"Delete Folder",deleteFolderMessage:"Delete this folder and all pins inside it?",deleteFolderMessagePrefix:'Delete folder "',deleteFolderMessageSuffix:'" and all pin data inside it?',confirm:"Confirm"},placeholders:{view:"View page placeholder. View-related content will be added here later.",pin:"No pins yet. Click the button above to add one.",constructTree:"Component tree placeholder. The new tree capability will be added here later."}},viewTab:{category:{ceilingPlans:"Ceiling Plans",elevations:"Elevations",floorPlans:"Floor Plans",sections:"Sections"},empty:"No view data available"},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",fill:"Fill"}},sectionAxis:{dialogTitle:"Axis Section",actions:{hide:"Hide",reverse:"Reverse",reset:"Reset",axisX:"X",axisY:"Y",axisZ:"Z",fill:"Fill"}},sectionBox:{dialogTitle:"Section Box",actions:{hide:"Hide",reverse:"Reverse",fitToModel:"Fit",reset:"Reset",fill:"Fill"},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"},viewDropdown:{triggerTitle:"View Controls",switchOrthographic:"Switch to Orthographic",switchPerspective:"Switch to Perspective",saveMainView:"Set Current as Main View",restoreMainView:"Reset Main View",captureScreenshot:"Capture Screenshot"},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"},help:{engineControl:"Engine Controls",fpsControl:"First Person Controls",gotIt:"Got it",dontRemind:"Don't remind me again",rotate:"Rotate",mouseLeftDrag:"Left mouse drag",pan:"Pan",shiftLeftDrag:"Shift + Left/Right drag",zoom:"Zoom",mouseWheel:"Mouse wheel",boxSelect:"Box Select",ctrlLeftDrag:"Ctrl + Left drag",multiSelect:"Add/Remove Selection",ctrlShiftClick:"Ctrl + Click (Add) / Shift + Click (Remove)",homeView:"Home View",doubleClickBlank:"Double click empty area",rotateRuleTitle:"Rotation Center Rule",rotateRuleDesc:"Hovering over a component sets the rotation center to that position; hovering over empty area keeps the last rotation center.",roam:"Roam",or:"or",upDown:"Move Up/Down",qeKey:"Q / E",landOnFloor:"Enable gravity to land on nearest floor",run:"Run (Speed up)",shiftArrow:"Shift + Arrow keys",teleport:"Teleport",doubleClick:"Double click target",lookAround:"Look Around",leftDrag:"Drag view with left button",adjustSpeed:"Adjust Speed",rotateView:"Rotate View",panView:"Pan View",zoomView:"Zoom View",resetView:"Reset View",mouseLeftDragShort:"Left mouse drag",mouseRightDragShort:"Right mouse drag",mouseWheelShort:"Scroll mouse wheel",componentSelect:"Component Selection",click:"Click",addSelect:"Add to selection",removeSelect:"Remove from selection",doubleClickBlankShort:"Double click empty area",pointToComponent:"Point to component:",pointToComponentDesc:"Set rotation center at click position",pointToBlank:"Point to blank:",pointToBlankDesc:"Keep last rotation center",roamMove:"Roam Move",roamMoveDesc:"Use WASD or arrow keys to move",speedUp:"Speed Up",lookAroundDesc:"Drag view with left button",teleportDesc:"Double click target component or ground"}},t4={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:"請輸入要搜尋的內容",noResults:"未找到符合結果"},constructTree:{title:"目錄樹"},componentTreeDrawer:{actions:{close:"關閉抽屜",add:"新增",addPin:"新增圖釘",addFolder:"新增文件夾",edit:"編輯",delete:"刪除",save:"保存",cancel:"取消"},tabs:{view:"視圖",pin:"圖釘",constructTree:"構件樹"},empty:{pinTitle:"暫無圖釘",pinDesc:"點擊上方按鈕添加第一個圖釘"},dialogs:{noticeTitle:"提示",deleteFolderTitle:"刪除文件夾",deleteFolderMessage:"確認刪除該文件夾以及文件夾下面的所有圖釘嗎?",deleteFolderMessagePrefix:"是否刪除【",deleteFolderMessageSuffix:"】文件夾以及文件夾下面所有的圖釘資料。",confirm:"確定"},placeholders:{view:"視圖頁面占位,後續會在這裡接入視圖相關內容。",pin:"暫無圖釘,點擊上方按鈕添加",constructTree:"構件樹頁面占位,後續會在這裡接入新的構件樹能力。"}},viewTab:{category:{ceilingPlans:"天花板平面",elevations:"立面",floorPlans:"樓層平面",sections:"剖面"},empty:"暫無視圖資料"},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:"重設",fill:"填充"}},sectionAxis:{dialogTitle:"軸向剖切",actions:{hide:"隱藏",reverse:"反向",reset:"重設",axisX:"X",axisY:"Y",axisZ:"Z",fill:"填充"}},sectionBox:{dialogTitle:"剖切盒",actions:{hide:"隱藏",reverse:"反向",fitToModel:"適應",reset:"重設",fill:"填充"},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:"提交"},viewDropdown:{triggerTitle:"視圖控制",switchOrthographic:"切換到正交視圖",switchPerspective:"切換到透視視圖",saveMainView:"將當前視圖設為主視圖",restoreMainView:"重置主視圖",captureScreenshot:"截圖保存"},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"},help:{engineControl:"引擎控制",fpsControl:"第一人稱控制",gotIt:"好的,知道了",dontRemind:"不再提醒我",rotate:"旋轉",mouseLeftDrag:"滑鼠左鍵拖曳",pan:"平移",shiftLeftDrag:"Shift + 左鍵 / 右鍵拖曳",zoom:"縮放",mouseWheel:"滑鼠滾輪",boxSelect:"框選",ctrlLeftDrag:"Ctrl + 左鍵拖曳",multiSelect:"加選 / 減選",ctrlShiftClick:"Ctrl + 點擊 (加) / Shift + 點擊 (減)",homeView:"回到主視圖",doubleClickBlank:"雙擊空白區域",rotateRuleTitle:"旋轉點變換規則",rotateRuleDesc:"滑鼠懸停構件時,按當前位置設定旋轉中心;懸停空白區域時,保持上一次旋轉中心。",roam:"漫遊",or:"或",upDown:"向上和向下移動",qeKey:"Q / E",landOnFloor:"開啟重力將落在最近樓層",run:"運行 (加速)",shiftArrow:"Shift + 方向鍵",teleport:"傳送",doubleClick:"雙擊目標",lookAround:"環視",leftDrag:"使用左鍵拖動視圖",adjustSpeed:"調整速度",rotateView:"旋轉視圖",panView:"平移視圖",zoomView:"縮放視圖",resetView:"視圖復位",mouseLeftDragShort:"滑鼠左鍵拖曳",mouseRightDragShort:"滑鼠右鍵拖曳",mouseWheelShort:"滾動滑鼠滾輪",componentSelect:"構件選擇",click:"點擊",addSelect:"加選構件",removeSelect:"減選構件",doubleClickBlankShort:"雙擊空白區域",pointToComponent:"指向構件:",pointToComponentDesc:"以滑鼠點擊位置為旋轉中心",pointToBlank:"指向空白:",pointToBlankDesc:"保持上一次確定的旋轉中心",roamMove:"漫遊移動",roamMoveDesc:"使用 WASD 或方向鍵進行移動",speedUp:"加速移動",lookAroundDesc:"左鍵拖動視圖查看四周",teleportDesc:"雙擊目標構件或地面"}};class i4{currentLocale="zh-CN";messages={"zh-CN":JR,"en-US":e4,"zh-TW":t4};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 Ft=new i4,de=s=>Ft.t(s);class n4{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-border-subtle",e.borderSubtle),t.setProperty("--bim-component-bg-hover",e.componentBgHover),t.setProperty("--bim-shadow-sm",e.shadowSm),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=ct.subscribe(e=>{this.setTheme(e)}),this.unsubscribeLocale=Ft.subscribe(()=>{this.setLocales()}))}setLocales(){if(this.options.title&&!this.options.header){const e=this.header.querySelector(".bim-dialog-title");e&&(e.textContent=de(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");if(i.className="bim-dialog-header",this.options.draggable&&i.classList.add("draggable"),this.options.header)i.appendChild(this.options.header);else{const o=document.createElement("span");o.className="bim-dialog-title",o.textContent=this.options.title?de(this.options.title):"",i.appendChild(o)}if(!this.options.hideCloseButton){const o=document.createElement("span");o.className="bim-dialog-close",this.options.closeIcon?typeof this.options.closeIcon=="string"?o.innerHTML=this.options.closeIcon:o.appendChild(this.options.closeIcon):o.innerHTML=`<svg width="24" height="24" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||
<path d="M12 4L4 12M4 4L12 12" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"/>
|
||
</svg>`,o.onclick=()=>{this.close()},i.appendChild(o)}const n=document.createElement("div");if(n.className="bim-dialog-content",typeof this.options.content=="string"?n.innerHTML=this.options.content:this.options.content instanceof HTMLElement&&n.appendChild(this.options.content),e.appendChild(i),e.appendChild(n),this.options.resizable){const o=document.createElement("div");o.className="bim-dialog-resize-handle",e.appendChild(o)}const r=o=>{o.stopPropagation()};return["click","dblclick","contextmenu","wheel","mousedown","mouseup","mousemove","touchstart","touchend","touchmove","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointerover","pointerout"].forEach(o=>{e.addEventListener(o,r,{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 r=Math.max(i,t);n>0&&(r=Math.min(r,n)),this.element.style.height=`${r}px`,e?this.initPosition():this.clampToContainer()}clampToContainer(){const e=this.container.clientWidth,t=this.container.clientHeight,i=this.element.offsetWidth,n=this.element.offsetHeight,r=this.options.bottomOffset??70,a=this.element.offsetLeft,o=this.element.offsetTop,l=Math.max(0,e-i),c=Math.max(0,t-n-r),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,r=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,r=e.y;else switch(e){case"center":n=(a-l)/2,r=(o-c)/2;break;case"top-left":n=0,r=0;break;case"top-center":n=(a-l)/2,r=0;break;case"top-right":n=a-l,r=0;break;case"left-center":n=0,r=(o-c)/2;break;case"right-center":n=a-l,r=(o-c)/2;break;case"bottom-left":n=0,r=o-c-i;break;case"bottom-center":n=(a-l)/2,r=o-c-i;break;case"bottom-right":n=a-l,r=o-c-i;break;default:n=(a-l)/2,r=(o-c)/2}n=Math.max(0,Math.min(n,a-l)),r=Math.max(0,Math.min(r,o-c-i)),this.element.style.left=`${n}px`,this.element.style.top=`${r}px`}initDrag(){let e=0,t=0,i=0,n=0,r=0,a=0,o=0,l=0,c=0;const h=p=>{p.preventDefault(),p.stopPropagation(),e=p.clientX,t=p.clientY,i=this.element.offsetLeft,n=this.element.offsetTop,r=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",u,{capture:!0})},d=p=>{p.preventDefault(),p.stopPropagation(),!this.rafId&&(this.rafId=requestAnimationFrame(()=>{const m=p.clientX-e,v=p.clientY-t;let g=i+m,f=n+v;const A=r-o,b=a-l-c;g=Math.max(0,Math.min(g,A)),f=Math.max(0,Math.min(f,b)),this.element.style.left=`${g}px`,this.element.style.top=`${f}px`,this.rafId=null}))},u=()=>{this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null),document.removeEventListener("mousemove",d,{capture:!0}),document.removeEventListener("mouseup",u,{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,r=0,a=0,o=0,l=0,c=0;const h=p=>{p.preventDefault(),p.stopPropagation(),t=p.clientX,i=p.clientY,n=this.element.offsetWidth,r=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",u,{capture:!0})},d=p=>{p.preventDefault(),p.stopPropagation(),!this.rafId&&(this.rafId=requestAnimationFrame(()=>{const m=p.clientX-t,v=p.clientY-i,g=a-l,f=o-c,A=Math.min(g,Math.max(this.options.minWidth||100,n+m)),b=Math.min(f,Math.max(this.options.minHeight||50,r+v));this.element.style.width=`${A}px`,this.element.style.height=`${b}px`,this.rafId=null}))},u=()=>{this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null),document.removeEventListener("mousemove",d,{capture:!0}),document.removeEventListener("mouseup",u,{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 Cs{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 Ew extends Cs{container;activeDialogs=[];constructor(e,t){super(t),this.container=e}create(e){const t=new n4({container:this.container,...e,onClose:()=>{this.activeDialogs=this.activeDialogs.filter(i=>i!==t),e.onClose&&e.onClose()}});return t.setTheme(ct.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 Mw={测量:'<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 xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><path d="M24 6L10 22h10v18h8V22h10L24 6z" opacity="0.35"/><path d="M8 24h32v4H8z"/></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>',doubleArrowDown:'<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 6-6-6 1.41-1.41z"/><path fill="currentColor" d="M7.41 14.59L12 19.17l4.59-4.58L18 16l-6 6-6-6 1.41-1.41z"/></svg>',pin:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="m3 21l4.63-4.631m.005-.005l-2.78-2.78c-.954-.953.006-2.996 1.31-3.078c1.178-.075 3.905.352 4.812-.555l2.49-2.49c.617-.618.225-2 .185-2.762c-.058-1.016 1.558-2.271 2.415-1.414l4.647 4.648c.86.858-.4 2.469-1.413 2.415c-.762-.04-2.145-.432-2.763.185l-2.49 2.49c-.906.907-.48 3.633-.554 4.811c-.082 1.305-2.125 2.265-3.08 1.31z"/></svg>',folder:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M10 4l2 2h8a2 2 0 0 1 2 2v8.5A3.5 3.5 0 0 1 18.5 20h-13A3.5 3.5 0 0 1 2 16.5v-9A3.5 3.5 0 0 1 5.5 4z" opacity="0.2"/><path fill="currentColor" d="M5.5 4A3.5 3.5 0 0 0 2 7.5v9A3.5 3.5 0 0 0 5.5 20h13a3.5 3.5 0 0 0 3.5-3.5V8A2 2 0 0 0 20 6h-8l-2-2zm0 1.5h3.879l2 2H20a.5.5 0 0 1 .5.5v1H3.5v-1.5a2 2 0 0 1 2-2m-2 5h17v6a2 2 0 0 1-2 2h-13a2 2 0 0 1-2-2z"/></svg>',folderPlus:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M10 4l2 2h8a2 2 0 0 1 2 2v1.5h-1.5V8a.5.5 0 0 0-.5-.5h-8.621l-2-2H5.5a2 2 0 0 0-2 2V9H2V7.5A3.5 3.5 0 0 1 5.5 4z"/><path fill="currentColor" d="M5.5 10A3.5 3.5 0 0 0 2 13.5v3A3.5 3.5 0 0 0 5.5 20H12v-1.5H5.5a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2H12V10z" opacity="0.4"/><path fill="currentColor" d="M17.25 12v3.25H14v1.5h3.25V20h1.5v-3.25H22v-1.5h-3.25V12z"/></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 gt(s){const e=Mw[s];return e||(console.warn(`[IconManager] Icon "${s}" not found, using default icon`),Mw.default)}class Af{element;overlay;container;options;viewTabBtn;fpsTabBtn;viewContent;fpsContent;confirmBtn;dontRemindBtn;unsubscribeLocale=null;unsubscribeTheme=null;static STORAGE_KEY="bim-engine:help-panel:hidden";constructor(e={}){this.options=e}init(){this.element=this.createPanel(),this.unsubscribeLocale=Ft.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ct.subscribe(e=>this.setTheme(e)),this.setLocales(),this.setTheme(ct.getTheme())}show(){this.overlay.classList.add("active")}hide(){this.overlay.classList.remove("active")}isVisible(){return this.overlay.classList.contains("active")}shouldAutoShow(){const e=this.options.storageKey??Af.STORAGE_KEY;return localStorage.getItem(e)!=="true"}createPanel(){const e=document.createElement("div");e.className="bim-help-panel-wrapper",this.overlay=document.createElement("div"),this.overlay.className="bim-help-panel-overlay",this.overlay.addEventListener("click",r=>{r.target===this.overlay&&this.hide()}),this.container=document.createElement("div"),this.container.className="bim-help-panel-container";const t=this.createHeader(),i=this.createBody(),n=this.createFooter();return this.container.appendChild(t),this.container.appendChild(i),this.container.appendChild(n),this.overlay.appendChild(this.container),e.appendChild(this.overlay),e}createHeader(){const e=document.createElement("div");return e.className="bim-help-panel-header",this.viewTabBtn=document.createElement("button"),this.viewTabBtn.className="bim-help-panel-tab-btn active",this.viewTabBtn.addEventListener("click",()=>this.switchTab("view")),this.fpsTabBtn=document.createElement("button"),this.fpsTabBtn.className="bim-help-panel-tab-btn",this.fpsTabBtn.addEventListener("click",()=>this.switchTab("fps")),e.appendChild(this.viewTabBtn),e.appendChild(this.fpsTabBtn),e}createBody(){const e=document.createElement("div");return e.className="bim-help-panel-body",this.viewContent=this.createViewTabContent(),this.fpsContent=this.createFpsTabContent(),e.appendChild(this.viewContent),e.appendChild(this.fpsContent),e}createViewTabContent(){const e=document.createElement("div");e.className="bim-help-panel-tab-content active",e.dataset.tab="view",e.appendChild(this.createMouseCard("rotateView","left")),e.appendChild(this.createMouseCard("panView","right")),e.appendChild(this.createMouseCard("zoomView","wheel"));const t=this.createCard("boxSelect","ctrlLeftDrag");e.appendChild(t);const i=this.createMultiSelectCard();e.appendChild(i);const n=this.createCard("resetView","doubleClickBlankShort");e.appendChild(n);const r=this.createRuleCard();return e.appendChild(r),e}createMouseCard(e,t){const i=document.createElement("div");i.className="bim-help-panel-card";const n=document.createElement("div");n.className="bim-help-panel-card-title",n.dataset.localeKey=`help.${e}`;const r=document.createElement("div");r.className="bim-help-panel-control-row";const a=document.createElement("div");if(a.className="bim-help-panel-mouse-box",t==="left"){const l=document.createElement("div");l.className="bim-help-panel-mouse-left",a.appendChild(l)}else if(t==="right"){const l=document.createElement("div");l.className="bim-help-panel-mouse-right",a.appendChild(l)}else if(t==="wheel"){const l=document.createElement("div");l.className="bim-help-panel-mouse-wheel",a.appendChild(l)}r.appendChild(a);const o=document.createElement("div");return o.className="bim-help-panel-rule-desc",o.dataset.localeKey=`help.${t==="left"?"mouseLeftDragShort":t==="right"?"mouseRightDragShort":"mouseWheelShort"}`,i.appendChild(n),i.appendChild(r),i.appendChild(o),i}createMultiSelectCard(){const e=document.createElement("div");e.className="bim-help-panel-card bim-help-panel-card-span-2";const t=document.createElement("div");t.className="bim-help-panel-card-title",t.dataset.localeKey="help.componentSelect";const i=document.createElement("div");return i.className="bim-help-panel-control-row",i.style.gap="40px",i.innerHTML=`
|
||
<div style="text-align:center;">
|
||
<div class="bim-help-panel-control-row"><kbd class="bim-help-panel-kbd">Ctrl</kbd> <span class="bim-help-panel-bold">+</span> <span class="bim-help-panel-bold">${de("help.click")}</span></div>
|
||
<div class="bim-help-panel-rule-desc" data-locale-key="help.addSelect">${de("help.addSelect")}</div>
|
||
</div>
|
||
<div style="text-align:center;">
|
||
<div class="bim-help-panel-control-row"><kbd class="bim-help-panel-kbd">Shift</kbd> <span class="bim-help-panel-bold">+</span> <span class="bim-help-panel-bold">${de("help.click")}</span></div>
|
||
<div class="bim-help-panel-rule-desc" data-locale-key="help.removeSelect">${de("help.removeSelect")}</div>
|
||
</div>
|
||
`,e.appendChild(t),e.appendChild(i),e}createRuleCard(){const e=document.createElement("div");e.className="bim-help-panel-card bim-help-panel-card-span-2";const t=document.createElement("div");t.className="bim-help-panel-card-title",t.dataset.localeKey="help.rotateRuleTitle";const i=document.createElement("div");return i.className="bim-help-panel-rule-desc",i.style.textAlign="left",i.style.width="100%",i.innerHTML=`
|
||
<div style="margin-bottom:6px;"><span class="bim-help-panel-bold">• ${de("help.pointToComponent")}</span> ${de("help.pointToComponentDesc")}</div>
|
||
<div><span class="bim-help-panel-bold">• ${de("help.pointToBlank")}</span> ${de("help.pointToBlankDesc")}</div>
|
||
`,e.appendChild(t),e.appendChild(i),e}createFpsTabContent(){const e=document.createElement("div");e.className="bim-help-panel-tab-content",e.dataset.tab="fps";const t=document.createElement("div");t.className="bim-help-panel-card bim-help-panel-card-span-2";const i=document.createElement("div");i.className="bim-help-panel-card-title",i.dataset.localeKey="help.roamMove";const n=document.createElement("div");n.className="bim-help-panel-control-row",n.style.gap="48px",n.innerHTML=`
|
||
<div class="bim-help-panel-wasd-group">
|
||
<div class="bim-help-panel-kbd-row"><kbd class="bim-help-panel-kbd">W</kbd></div>
|
||
<div class="bim-help-panel-kbd-row">
|
||
<kbd class="bim-help-panel-kbd">A</kbd>
|
||
<kbd class="bim-help-panel-kbd">S</kbd>
|
||
<kbd class="bim-help-panel-kbd">D</kbd>
|
||
</div>
|
||
</div>
|
||
<span style="color:var(--bim-text-tertiary);font-weight:100;">|</span>
|
||
<div class="bim-help-panel-wasd-group">
|
||
<div class="bim-help-panel-kbd-row"><kbd class="bim-help-panel-kbd">▲</kbd></div>
|
||
<div class="bim-help-panel-kbd-row">
|
||
<kbd class="bim-help-panel-kbd">◄</kbd>
|
||
<kbd class="bim-help-panel-kbd">▼</kbd>
|
||
<kbd class="bim-help-panel-kbd">►</kbd>
|
||
</div>
|
||
</div>
|
||
`;const r=document.createElement("div");r.className="bim-help-panel-rule-desc",r.dataset.localeKey="help.roamMoveDesc",t.appendChild(i),t.appendChild(n),t.appendChild(r),e.appendChild(t),e.appendChild(this.createCard("speedUp","shiftArrow")),e.appendChild(this.createCard("upDown","qeKey","landOnFloor"));const a=document.createElement("div");a.className="bim-help-panel-card";const o=document.createElement("div");o.className="bim-help-panel-card-title",o.dataset.localeKey="help.lookAround";const l=document.createElement("div");l.className="bim-help-panel-control-row";const c=document.createElement("div");c.className="bim-help-panel-mouse-box";const h=document.createElement("div");h.className="bim-help-panel-mouse-left",c.appendChild(h),l.appendChild(c);const d=document.createElement("div");d.className="bim-help-panel-rule-desc",d.dataset.localeKey="help.lookAroundDesc",a.appendChild(o),a.appendChild(l),a.appendChild(d),e.appendChild(a);const u=document.createElement("div");u.className="bim-help-panel-card";const p=document.createElement("div");p.className="bim-help-panel-card-title",p.dataset.localeKey="help.teleport";const m=document.createElement("div");m.className="bim-help-panel-control-row";const v=document.createElement("div");v.className="bim-help-panel-teleport-icon";const g=document.createElement("div");g.className="bim-help-panel-teleport-inner",v.appendChild(g),m.appendChild(v);const f=document.createElement("div");return f.className="bim-help-panel-rule-desc",f.dataset.localeKey="help.teleportDesc",u.appendChild(p),u.appendChild(m),u.appendChild(f),e.appendChild(u),e}createCard(e,t,i){const n=document.createElement("div");n.className="bim-help-panel-card";const r=document.createElement("div");r.className="bim-help-panel-card-title",r.dataset.localeKey=`help.${e}`;const a=document.createElement("div");if(a.className="bim-help-panel-control-row",a.dataset.localeKey=`help.${t}`,n.appendChild(r),n.appendChild(a),i){const o=document.createElement("div");o.className="bim-help-panel-rule-desc",o.dataset.localeKey=`help.${i}`,n.appendChild(o)}return n}createFooter(){const e=document.createElement("div");return e.className="bim-help-panel-footer",this.confirmBtn=document.createElement("button"),this.confirmBtn.className="bim-help-panel-btn bim-help-panel-btn-primary",this.confirmBtn.addEventListener("click",()=>this.hide()),this.dontRemindBtn=document.createElement("button"),this.dontRemindBtn.className="bim-help-panel-btn bim-help-panel-btn-secondary",this.dontRemindBtn.addEventListener("click",()=>this.dontRemind()),e.appendChild(this.confirmBtn),e.appendChild(this.dontRemindBtn),e}switchTab(e){this.viewTabBtn.classList.toggle("active",e==="view"),this.fpsTabBtn.classList.toggle("active",e==="fps"),this.viewContent.classList.toggle("active",e==="view"),this.fpsContent.classList.toggle("active",e==="fps")}dontRemind(){const e=this.options.storageKey??Af.STORAGE_KEY;localStorage.setItem(e,"true"),this.hide()}setLocales(){this.viewTabBtn.textContent=de("help.engineControl"),this.fpsTabBtn.textContent=de("help.fpsControl"),this.confirmBtn.textContent=de("help.gotIt"),this.dontRemindBtn.textContent=de("help.dontRemind"),this.element.querySelectorAll("[data-locale-key]").forEach(e=>{const t=e.getAttribute("data-locale-key");t&&(e.textContent=de(t))})}setTheme(e){this.element.style.setProperty("--bim-bg-overlay","rgba(0, 0, 0, 0.5)"),this.element.style.setProperty("--bim-panel-bg",e.bgElevated),this.element.style.setProperty("--bim-panel-border",e.panelBorder),this.element.style.setProperty("--bim-shadow-lg",e.shadowLg),this.element.style.setProperty("--bim-text-primary",e.textPrimary),this.element.style.setProperty("--bim-text-secondary",e.textSecondary),this.element.style.setProperty("--bim-text-tertiary",e.textTertiary),this.element.style.setProperty("--bim-primary",e.primary),this.element.style.setProperty("--bim-primary-hover",e.primaryHover),this.element.style.setProperty("--bim-text-inverse",e.textInverse),this.element.style.setProperty("--bim-divider",e.divider),this.element.style.setProperty("--bim-border-default",e.borderDefault),this.element.style.setProperty("--bim-border-subtle",e.borderSubtle),this.element.style.setProperty("--bim-component-bg",e.componentBg),this.element.style.setProperty("--bim-component-bg-hover",e.componentBgHover),this.element.style.setProperty("--bim-bg-inset",e.bgInset),this.element.style.setProperty("--bim-scrollbar-thumb",e.scrollbarThumb),this.element.style.setProperty("--bim-scrollbar-thumb-hover",e.scrollbarThumbHover)}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.overlay&&this.overlay.remove()}}const Ic="183",ls={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},cs={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Sw=0,pA=1,Cw=2,s4=3,r4=0,Rd=1,Tw=2,Pc=3,Yn=0,an=1,qt=2,vi=0,Ko=1,bf=2,fA=3,mA=4,yf=5,a4=6,Kn=100,Iw=101,Pw=102,Dw=103,Rw=104,Va=200,Bw=201,Lw=202,kw=203,xf=204,_f=205,Bd=206,Ow=207,Ld=208,Fw=209,Nw=210,Uw=211,zw=212,Hw=213,Gw=214,wf=0,Ef=1,Mf=2,$o=3,Sf=4,Cf=5,Tf=6,If=7,kd=0,Vw=1,Ww=2,on=0,Pf=1,Df=2,Rf=3,Yr=4,Bf=5,Lf=6,kf=7,gA="attached",Qw="detached",Of=300,wr=301,Wa=302,Dc=303,Od=304,Rc=306,ln=1e3,Bn=1001,Bc=1002,Jt=1003,Fd=1004,o4=1004,Zo=1005,l4=1005,wt=1006,Lc=1007,c4=1007,$n=1008,h4=1008,bt=1009,vA=1010,AA=1011,kc=1012,Ff=1013,Ts=1014,xi=1015,li=1016,Nf=1017,Uf=1018,Qa=1020,Nd=35902,Ud=35899,bA=1021,Oc=1022,_i=1023,Er=1026,Mr=1027,Sr=1028,zd=1029,Is=1030,zf=1031,d4=1032,Hf=1033,Jo=33776,ja=33777,Hd=33778,Xa=33779,Gd=35840,Gf=35841,el=35842,Fc=35843,Vd=36196,Nc=37492,Uc=37496,Wd=37488,Qd=37489,jd=37490,Xd=37491,qa=37808,Vf=37809,Wf=37810,Qf=37811,tl=37812,jf=37813,Xf=37814,qf=37815,Yf=37816,Kf=37817,$f=37818,Zf=37819,Jf=37820,em=37821,il=36492,tm=36494,qd=36495,Yd=36283,Kd=36284,$d=36285,Zd=36286,jw=2200,Xw=2201,qw=2202,zc=2300,Hc=2301,im=2302,yA=2303,nl=2400,sl=2401,Jd=2402,nm=2500,xA=2501,Yw=0,_A=1,sm=2,Kw=3200,u4=3201,p4=3202,f4=3203,Ya=0,$w=1,qs="",ci="srgb",qi="srgb-linear",eu="linear",Yt="srgb",m4="",g4="rg",v4="ga",A4=0,rl=7680,b4=7681,y4=7682,x4=7683,_4=34055,w4=34056,E4=5386,M4=512,S4=513,C4=514,T4=515,I4=516,P4=517,D4=518,wA=519,Zw=512,Jw=513,eE=514,rm=515,tE=516,iE=517,am=518,nE=519,tu=35044,R4=35048,B4=35040,L4=35045,k4=35049,O4=35041,F4=35046,N4=35050,U4=35042,z4="100",EA="300 es",hs=2e3,al=2001,H4={COMPUTE:"compute",RENDER:"render"},G4={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},V4={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},W4={TEXTURE_COMPARE:"depthTextureCompare"};function Q4(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}const j4={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Gc(s,e){return new j4[s](e)}function sE(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function iu(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function rE(){const s=iu("canvas");return s.style.display="block",s}const aE={};let Ka=null;function X4(s){Ka=s}function q4(){return Ka}function nu(...s){const e="THREE."+s.shift();Ka?Ka("log",e,...s):console.log(e,...s)}function oE(s){const e=s[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=s[1];t&&t.isStackTrace?s[0]+=" "+t.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function Je(...s){s=oE(s);const e="THREE."+s.shift();if(Ka)Ka("warn",e,...s);else{const t=s[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...s)}}function ft(...s){s=oE(s);const e="THREE."+s.shift();if(Ka)Ka("error",e,...s);else{const t=s[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...s)}}function su(...s){const e=s.join(" ");e in aE||(aE[e]=!0,Je(...s))}function Y4(s,e,t){return new Promise(function(i,n){function r(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:n();break;case s.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}const K4={[wf]:Ef,[Mf]:Tf,[Sf]:If,[$o]:Cf,[Ef]:wf,[Tf]:Mf,[If]:Sf,[Cf]:$o};class Ys{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 r=n.indexOf(t);r!==-1&&n.splice(r,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 r=0,a=n.length;r<a;r++)n[r].call(this,e);e.target=null}}}const _n=["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 lE=1234567;const ol=Math.PI/180,Vc=180/Math.PI;function ds(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(_n[s&255]+_n[s>>8&255]+_n[s>>16&255]+_n[s>>24&255]+"-"+_n[e&255]+_n[e>>8&255]+"-"+_n[e>>16&15|64]+_n[e>>24&255]+"-"+_n[t&63|128]+_n[t>>8&255]+"-"+_n[t>>16&255]+_n[t>>24&255]+_n[i&255]+_n[i>>8&255]+_n[i>>16&255]+_n[i>>24&255]).toLowerCase()}function At(s,e,t){return Math.max(e,Math.min(t,s))}function MA(s,e){return(s%e+e)%e}function $4(s,e,t,i,n){return i+(s-e)*(n-i)/(t-e)}function Z4(s,e,t){return s!==e?(t-s)/(e-s):0}function ru(s,e,t){return(1-t)*s+t*e}function J4(s,e,t,i){return ru(s,e,1-Math.exp(-t*i))}function eB(s,e=1){return e-Math.abs(MA(s,e*2)-e)}function tB(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function iB(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function nB(s,e){return s+Math.floor(Math.random()*(e-s+1))}function sB(s,e){return s+Math.random()*(e-s)}function rB(s){return s*(.5-Math.random())}function aB(s){s!==void 0&&(lE=s);let e=lE+=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 oB(s){return s*ol}function lB(s){return s*Vc}function cB(s){return(s&s-1)===0&&s!==0}function hB(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function dB(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function uB(s,e,t,i,n){const r=Math.cos,a=Math.sin,o=r(t/2),l=a(t/2),c=r((e+i)/2),h=a((e+i)/2),d=r((e-i)/2),u=a((e-i)/2),p=r((i-e)/2),m=a((i-e)/2);switch(n){case"XYX":s.set(o*h,l*d,l*u,o*c);break;case"YZY":s.set(l*u,o*h,l*d,o*c);break;case"ZXZ":s.set(l*d,l*u,o*h,o*c);break;case"XZX":s.set(o*h,l*m,l*p,o*c);break;case"YXY":s.set(l*p,o*h,l*m,o*c);break;case"ZYZ":s.set(l*m,l*p,o*h,o*c);break;default:Je("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function Ln(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function Et(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const Bt={DEG2RAD:ol,RAD2DEG:Vc,generateUUID:ds,clamp:At,euclideanModulo:MA,mapLinear:$4,inverseLerp:Z4,lerp:ru,damp:J4,pingpong:eB,smoothstep:tB,smootherstep:iB,randInt:nB,randFloat:sB,randFloatSpread:rB,seededRandom:aB,degToRad:oB,radToDeg:lB,isPowerOfTwo:cB,ceilPowerOfTwo:hB,floorPowerOfTwo:dB,setQuaternionFromProperEuler:uB,normalize:Et,denormalize:Ln};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=At(this.x,e.x,t.x),this.y=At(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=At(this.x,e,t),this.y=At(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(At(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(At(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),r=this.x-e.x,a=this.y-e.y;return this.x=r*i-a*n+e.x,this.y=r*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 Lt{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,r,a,o){let l=i[n+0],c=i[n+1],h=i[n+2],d=i[n+3],u=r[a+0],p=r[a+1],m=r[a+2],v=r[a+3];if(d!==v||l!==u||c!==p||h!==m){let g=l*u+c*p+h*m+d*v;g<0&&(u=-u,p=-p,m=-m,v=-v,g=-g);let f=1-o;if(g<.9995){const A=Math.acos(g),b=Math.sin(A);f=Math.sin(f*A)/b,o=Math.sin(o*A)/b,l=l*f+u*o,c=c*f+p*o,h=h*f+m*o,d=d*f+v*o}else{l=l*f+u*o,c=c*f+p*o,h=h*f+m*o,d=d*f+v*o;const A=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=A,c*=A,h*=A,d*=A}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,n,r,a){const o=i[n],l=i[n+1],c=i[n+2],h=i[n+3],d=r[a],u=r[a+1],p=r[a+2],m=r[a+3];return e[t]=o*m+h*d+l*p-c*u,e[t+1]=l*m+h*u+c*d-o*p,e[t+2]=c*m+h*p+o*u-l*d,e[t+3]=h*m-o*d-l*u-c*p,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,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),h=o(n/2),d=o(r/2),u=l(i/2),p=l(n/2),m=l(r/2);switch(a){case"XYZ":this._x=u*h*d+c*p*m,this._y=c*p*d-u*h*m,this._z=c*h*m+u*p*d,this._w=c*h*d-u*p*m;break;case"YXZ":this._x=u*h*d+c*p*m,this._y=c*p*d-u*h*m,this._z=c*h*m-u*p*d,this._w=c*h*d+u*p*m;break;case"ZXY":this._x=u*h*d-c*p*m,this._y=c*p*d+u*h*m,this._z=c*h*m+u*p*d,this._w=c*h*d-u*p*m;break;case"ZYX":this._x=u*h*d-c*p*m,this._y=c*p*d+u*h*m,this._z=c*h*m-u*p*d,this._w=c*h*d+u*p*m;break;case"YZX":this._x=u*h*d+c*p*m,this._y=c*p*d+u*h*m,this._z=c*h*m-u*p*d,this._w=c*h*d-u*p*m;break;case"XZY":this._x=u*h*d-c*p*m,this._y=c*p*d-u*h*m,this._z=c*h*m+u*p*d,this._w=c*h*d+u*p*m;break;default:Je("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],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],d=t[10],u=i+o+d;if(u>0){const p=.5/Math.sqrt(u+1);this._w=.25/p,this._x=(h-l)*p,this._y=(r-c)*p,this._z=(a-n)*p}else if(i>o&&i>d){const p=2*Math.sqrt(1+i-o-d);this._w=(h-l)/p,this._x=.25*p,this._y=(n+a)/p,this._z=(r+c)/p}else if(o>d){const p=2*Math.sqrt(1+o-i-d);this._w=(r-c)/p,this._x=(n+a)/p,this._y=.25*p,this._z=(l+h)/p}else{const p=2*Math.sqrt(1+d-i-o);this._w=(a-n)/p,this._x=(r+c)/p,this._y=(l+h)/p,this._z=.25*p}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(At(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,r=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-r*l,this._y=n*h+a*l+r*o-i*c,this._z=r*h+a*c+i*l-n*o,this._w=a*h-i*o-n*l-r*c,this._onChangeCallback(),this}slerp(e,t){let i=e._x,n=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,n=-n,r=-r,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+r*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+r*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),r=Math.sqrt(i);return this.set(n*Math.sin(e),n*Math.cos(e),r*Math.sin(t),r*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 P{constructor(e=0,t=0,i=0){P.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(cE.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(cE.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*n,this.y=r[1]*t+r[4]*i+r[7]*n,this.z=r[2]*t+r[5]*i+r[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,r=e.elements,a=1/(r[3]*t+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*n+r[12])*a,this.y=(r[1]*t+r[5]*i+r[9]*n+r[13])*a,this.z=(r[2]*t+r[6]*i+r[10]*n+r[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,n=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*n-o*i),h=2*(o*t-r*n),d=2*(r*i-a*t);return this.x=t+l*c+a*d-o*h,this.y=i+l*h+o*c-r*d,this.z=n+l*d+r*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,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*n,this.y=r[1]*t+r[5]*i+r[9]*n,this.z=r[2]*t+r[6]*i+r[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=At(this.x,e.x,t.x),this.y=At(this.y,e.y,t.y),this.z=At(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=At(this.x,e,t),this.y=At(this.y,e,t),this.z=At(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(At(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,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=n*l-r*o,this.y=r*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 SA.copy(this).projectOnVector(e),this.sub(SA)}reflect(e){return this.sub(SA.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(At(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 SA=new P,cE=new Lt;class yt{constructor(e,t,i,n,r,a,o,l,c){yt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,n,r,a,o,l,c)}set(e,t,i,n,r,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=n,h[2]=o,h[3]=t,h[4]=r,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,r=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],h=i[4],d=i[7],u=i[2],p=i[5],m=i[8],v=n[0],g=n[3],f=n[6],A=n[1],b=n[4],y=n[7],x=n[2],_=n[5],M=n[8];return r[0]=a*v+o*A+l*x,r[3]=a*g+o*b+l*_,r[6]=a*f+o*y+l*M,r[1]=c*v+h*A+d*x,r[4]=c*g+h*b+d*_,r[7]=c*f+h*y+d*M,r[2]=u*v+p*A+m*x,r[5]=u*g+p*b+m*_,r[8]=u*f+p*y+m*M,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],r=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*r*h+i*o*l+n*r*c-n*a*l}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=h*a-o*c,u=o*l-h*r,p=c*r-a*l,m=t*d+i*u+n*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/m;return e[0]=d*v,e[1]=(n*c-h*i)*v,e[2]=(o*i-n*a)*v,e[3]=u*v,e[4]=(h*t-n*l)*v,e[5]=(n*r-o*t)*v,e[6]=p*v,e[7]=(i*l-c*t)*v,e[8]=(a*t-i*r)*v,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,r,a,o){const l=Math.cos(r),c=Math.sin(r);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(CA.makeScale(e,t)),this}rotate(e){return this.premultiply(CA.makeRotation(-e)),this}translate(e,t){return this.premultiply(CA.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 CA=new yt,hE=new yt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),dE=new yt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function pB(){const s={enabled:!0,workingColorSpace:qi,spaces:{},convert:function(n,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===Yt&&(n.r=Kr(n.r),n.g=Kr(n.g),n.b=Kr(n.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(n.applyMatrix3(this.spaces[r].toXYZ),n.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Yt&&(n.r=Wc(n.r),n.g=Wc(n.g),n.b=Wc(n.b))),n},workingToColorSpace:function(n,r){return this.convert(n,this.workingColorSpace,r)},colorSpaceToWorking:function(n,r){return this.convert(n,r,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===qs?eu:this.spaces[n].transfer},getToneMappingMode:function(n){return this.spaces[n].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(n,r=this.workingColorSpace){return n.fromArray(this.spaces[r].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,r,a){return n.copy(this.spaces[r].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,r){return su("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(n,r)},toWorkingColorSpace:function(n,r){return su("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(n,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return s.define({[qi]:{primaries:e,whitePoint:i,transfer:eu,toXYZ:hE,fromXYZ:dE,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:ci},outputColorSpaceConfig:{drawingBufferColorSpace:ci}},[ci]:{primaries:e,whitePoint:i,transfer:Yt,toXYZ:hE,fromXYZ:dE,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:ci}}}),s}const It=pB();function Kr(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Wc(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let Qc;class uE{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{Qc===void 0&&(Qc=iu("canvas")),Qc.width=e.width,Qc.height=e.height;const n=Qc.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),i=Qc}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=iu("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),r=n.data;for(let a=0;a<r.length;a++)r[a]=Kr(r[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(Kr(t[i]/255)*255):t[i]=Kr(t[i]);return{data:t,width:e.width,height:e.height}}else return Je("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let fB=0;class $a{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:fB++}),this.uuid=ds(),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 r;if(Array.isArray(n)){r=[];for(let a=0,o=n.length;a<o;a++)n[a].isDataTexture?r.push(TA(n[a].image)):r.push(TA(n[a]))}else r=TA(n);i.url=r}return t||(e.images[this.uuid]=i),i}}function TA(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?uE.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(Je("Texture: Unable to serialize Texture."),{})}let mB=0;const IA=new P;class Ai extends Ys{constructor(e=Ai.DEFAULT_IMAGE,t=Ai.DEFAULT_MAPPING,i=Bn,n=Bn,r=wt,a=$n,o=_i,l=bt,c=Ai.DEFAULT_ANISOTROPY,h=qs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:mB++}),this.uuid=ds(),this.name="",this.source=new $a(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=r,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 yt,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(IA).x}get height(){return this.source.getSize(IA).y}get depth(){return this.source.getSize(IA).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){Je(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){Je(`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!==Of)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case ln:e.x=e.x-Math.floor(e.x);break;case Bn:e.x=e.x<0?0:1;break;case Bc: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 ln:e.y=e.y-Math.floor(e.y);break;case Bn:e.y=e.y<0?0:1;break;case Bc: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++}}Ai.DEFAULT_IMAGE=null,Ai.DEFAULT_MAPPING=Of,Ai.DEFAULT_ANISOTROPY=1;class zt{constructor(e=0,t=0,i=0,n=1){zt.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,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*n+a[12]*r,this.y=a[1]*t+a[5]*i+a[9]*n+a[13]*r,this.z=a[2]*t+a[6]*i+a[10]*n+a[14]*r,this.w=a[3]*t+a[7]*i+a[11]*n+a[15]*r,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,r;const l=e.elements,c=l[0],h=l[4],d=l[8],u=l[1],p=l[5],m=l[9],v=l[2],g=l[6],f=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-v)<.01&&Math.abs(m-g)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+v)<.1&&Math.abs(m+g)<.1&&Math.abs(c+p+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(c+1)/2,y=(p+1)/2,x=(f+1)/2,_=(h+u)/4,M=(d+v)/4,E=(m+g)/4;return b>y&&b>x?b<.01?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(b),n=_/i,r=M/i):y>x?y<.01?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(y),i=_/n,r=E/n):x<.01?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(x),i=M/r,n=E/r),this.set(i,n,r,t),this}let A=Math.sqrt((g-m)*(g-m)+(d-v)*(d-v)+(u-h)*(u-h));return Math.abs(A)<.001&&(A=1),this.x=(g-m)/A,this.y=(d-v)/A,this.z=(u-h)/A,this.w=Math.acos((c+p+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=At(this.x,e.x,t.x),this.y=At(this.y,e.y,t.y),this.z=At(this.z,e.z,t.z),this.w=At(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=At(this.x,e,t),this.y=At(this.y,e,t),this.z=At(this.z,e,t),this.w=At(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(At(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 PA extends Ys{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:wt,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 zt(0,0,e,t),this.scissorTest=!1,this.viewport=new zt(0,0,e,t),this.textures=[];const n={width:e,height:t,depth:i.depth},r=new Ai(n),a=i.count;for(let o=0;o<a;o++)this.textures[o]=r.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:wt,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,r=this.textures.length;n<r;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 $a(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 ki extends PA{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class om extends Ai{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=Jt,this.minFilter=Jt,this.wrapR=Bn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class gB extends ki{constructor(e=1,t=1,i=1,n={}){super(e,t,n),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new om(null,e,t,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}}class au extends Ai{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=Jt,this.minFilter=Jt,this.wrapR=Bn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class vB extends ki{constructor(e=1,t=1,i=1,n={}){super(e,t,n),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new au(null,e,t,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}}class Ke{constructor(e,t,i,n,r,a,o,l,c,h,d,u,p,m,v,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,r,a,o,l,c,h,d,u,p,m,v,g)}set(e,t,i,n,r,a,o,l,c,h,d,u,p,m,v,g){const f=this.elements;return f[0]=e,f[4]=t,f[8]=i,f[12]=n,f[1]=r,f[5]=a,f[9]=o,f[13]=l,f[2]=c,f[6]=h,f[10]=d,f[14]=u,f[3]=p,f[7]=m,f[11]=v,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/jc.setFromMatrixColumn(e,0).length(),r=1/jc.setFromMatrixColumn(e,1).length(),a=1/jc.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]*r,t[5]=i[5]*r,t[6]=i[6]*r,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,r=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(n),c=Math.sin(n),h=Math.cos(r),d=Math.sin(r);if(e.order==="XYZ"){const u=a*h,p=a*d,m=o*h,v=o*d;t[0]=l*h,t[4]=-l*d,t[8]=c,t[1]=p+m*c,t[5]=u-v*c,t[9]=-o*l,t[2]=v-u*c,t[6]=m+p*c,t[10]=a*l}else if(e.order==="YXZ"){const u=l*h,p=l*d,m=c*h,v=c*d;t[0]=u+v*o,t[4]=m*o-p,t[8]=a*c,t[1]=a*d,t[5]=a*h,t[9]=-o,t[2]=p*o-m,t[6]=v+u*o,t[10]=a*l}else if(e.order==="ZXY"){const u=l*h,p=l*d,m=c*h,v=c*d;t[0]=u-v*o,t[4]=-a*d,t[8]=m+p*o,t[1]=p+m*o,t[5]=a*h,t[9]=v-u*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const u=a*h,p=a*d,m=o*h,v=o*d;t[0]=l*h,t[4]=m*c-p,t[8]=u*c+v,t[1]=l*d,t[5]=v*c+u,t[9]=p*c-m,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const u=a*l,p=a*c,m=o*l,v=o*c;t[0]=l*h,t[4]=v-u*d,t[8]=m*d+p,t[1]=d,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=p*d+m,t[10]=u-v*d}else if(e.order==="XZY"){const u=a*l,p=a*c,m=o*l,v=o*c;t[0]=l*h,t[4]=-d,t[8]=c*h,t[1]=u*d+v,t[5]=a*h,t[9]=p*d-m,t[2]=m*d-p,t[6]=o*h,t[10]=v*d+u}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(AB,e,bB)}lookAt(e,t,i){const n=this.elements;return us.subVectors(e,t),us.lengthSq()===0&&(us.z=1),us.normalize(),Za.crossVectors(i,us),Za.lengthSq()===0&&(Math.abs(i.z)===1?us.x+=1e-4:us.z+=1e-4,us.normalize(),Za.crossVectors(i,us)),Za.normalize(),lm.crossVectors(us,Za),n[0]=Za.x,n[4]=lm.x,n[8]=us.x,n[1]=Za.y,n[5]=lm.y,n[9]=us.y,n[2]=Za.z,n[6]=lm.z,n[10]=us.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,r=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],h=i[1],d=i[5],u=i[9],p=i[13],m=i[2],v=i[6],g=i[10],f=i[14],A=i[3],b=i[7],y=i[11],x=i[15],_=n[0],M=n[4],E=n[8],w=n[12],T=n[1],R=n[5],D=n[9],L=n[13],I=n[2],O=n[6],N=n[10],G=n[14],V=n[3],H=n[7],J=n[11],W=n[15];return r[0]=a*_+o*T+l*I+c*V,r[4]=a*M+o*R+l*O+c*H,r[8]=a*E+o*D+l*N+c*J,r[12]=a*w+o*L+l*G+c*W,r[1]=h*_+d*T+u*I+p*V,r[5]=h*M+d*R+u*O+p*H,r[9]=h*E+d*D+u*N+p*J,r[13]=h*w+d*L+u*G+p*W,r[2]=m*_+v*T+g*I+f*V,r[6]=m*M+v*R+g*O+f*H,r[10]=m*E+v*D+g*N+f*J,r[14]=m*w+v*L+g*G+f*W,r[3]=A*_+b*T+y*I+x*V,r[7]=A*M+b*R+y*O+x*H,r[11]=A*E+b*D+y*N+x*J,r[15]=A*w+b*L+y*G+x*W,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],r=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],d=e[6],u=e[10],p=e[14],m=e[3],v=e[7],g=e[11],f=e[15],A=l*p-c*u,b=o*p-c*d,y=o*u-l*d,x=a*p-c*h,_=a*u-l*h,M=a*d-o*h;return t*(v*A-g*b+f*y)-i*(m*A-g*x+f*_)+n*(m*b-v*x+f*M)-r*(m*y-v*_+g*M)}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],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=e[9],u=e[10],p=e[11],m=e[12],v=e[13],g=e[14],f=e[15],A=t*o-i*a,b=t*l-n*a,y=t*c-r*a,x=i*l-n*o,_=i*c-r*o,M=n*c-r*l,E=h*v-d*m,w=h*g-u*m,T=h*f-p*m,R=d*g-u*v,D=d*f-p*v,L=u*f-p*g,I=A*L-b*D+y*R+x*T-_*w+M*E;if(I===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/I;return e[0]=(o*L-l*D+c*R)*O,e[1]=(n*D-i*L-r*R)*O,e[2]=(v*M-g*_+f*x)*O,e[3]=(u*_-d*M-p*x)*O,e[4]=(l*T-a*L-c*w)*O,e[5]=(t*L-n*T+r*w)*O,e[6]=(g*y-m*M-f*b)*O,e[7]=(h*M-u*y+p*b)*O,e[8]=(a*D-o*T+c*E)*O,e[9]=(i*T-t*D-r*E)*O,e[10]=(m*_-v*y+f*A)*O,e[11]=(d*y-h*_-p*A)*O,e[12]=(o*w-a*R-l*E)*O,e[13]=(t*R-i*w+n*E)*O,e[14]=(v*b-m*x-g*A)*O,e[15]=(h*x-d*b+u*A)*O,this}scale(e){const t=this.elements,i=e.x,n=e.y,r=e.z;return t[0]*=i,t[4]*=n,t[8]*=r,t[1]*=i,t[5]*=n,t[9]*=r,t[2]*=i,t[6]*=n,t[10]*=r,t[3]*=i,t[7]*=n,t[11]*=r,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),r=1-i,a=e.x,o=e.y,l=e.z,c=r*a,h=r*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,r*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,r,a){return this.set(1,i,r,0,e,1,a,0,t,n,1,0,0,0,0,1),this}compose(e,t,i){const n=this.elements,r=t._x,a=t._y,o=t._z,l=t._w,c=r+r,h=a+a,d=o+o,u=r*c,p=r*h,m=r*d,v=a*h,g=a*d,f=o*d,A=l*c,b=l*h,y=l*d,x=i.x,_=i.y,M=i.z;return n[0]=(1-(v+f))*x,n[1]=(p+y)*x,n[2]=(m-b)*x,n[3]=0,n[4]=(p-y)*_,n[5]=(1-(u+f))*_,n[6]=(g+A)*_,n[7]=0,n[8]=(m+b)*M,n[9]=(g-A)*M,n[10]=(1-(u+v))*M,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 r=this.determinant();if(r===0)return i.set(1,1,1),t.identity(),this;let a=jc.set(n[0],n[1],n[2]).length();const o=jc.set(n[4],n[5],n[6]).length(),l=jc.set(n[8],n[9],n[10]).length();r<0&&(a=-a),Ks.copy(this);const c=1/a,h=1/o,d=1/l;return Ks.elements[0]*=c,Ks.elements[1]*=c,Ks.elements[2]*=c,Ks.elements[4]*=h,Ks.elements[5]*=h,Ks.elements[6]*=h,Ks.elements[8]*=d,Ks.elements[9]*=d,Ks.elements[10]*=d,t.setFromRotationMatrix(Ks),i.x=a,i.y=o,i.z=l,this}makePerspective(e,t,i,n,r,a,o=hs,l=!1){const c=this.elements,h=2*r/(t-e),d=2*r/(i-n),u=(t+e)/(t-e),p=(i+n)/(i-n);let m,v;if(l)m=r/(a-r),v=a*r/(a-r);else if(o===hs)m=-(a+r)/(a-r),v=-2*a*r/(a-r);else if(o===al)m=-a/(a-r),v=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=d,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=v,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,n,r,a,o=hs,l=!1){const c=this.elements,h=2/(t-e),d=2/(i-n),u=-(t+e)/(t-e),p=-(i+n)/(i-n);let m,v;if(l)m=1/(a-r),v=a/(a-r);else if(o===hs)m=-2/(a-r),v=-(a+r)/(a-r);else if(o===al)m=-1/(a-r),v=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=u,c[1]=0,c[5]=d,c[9]=0,c[13]=p,c[2]=0,c[6]=0,c[10]=m,c[14]=v,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 jc=new P,Ks=new Ke,AB=new P(0,0,0),bB=new P(1,1,1),Za=new P,lm=new P,us=new P,pE=new Ke,fE=new Lt;class Yi{constructor(e=0,t=0,i=0,n=Yi.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,r=n[0],a=n[4],o=n[8],l=n[1],c=n[5],h=n[9],d=n[2],u=n[6],p=n[10];switch(t){case"XYZ":this._y=Math.asin(At(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-At(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(At(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-At(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,p),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(At(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-At(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,p),this._y=0);break;default:Je("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return pE.makeRotationFromQuaternion(e),this.setFromRotationMatrix(pE,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return fE.setFromEuler(this),this.setFromQuaternion(fE,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}}Yi.DEFAULT_ORDER="XYZ";class cm{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 yB=0;const mE=new P,Xc=new Lt,$r=new Ke,hm=new P,ou=new P,xB=new P,_B=new Lt,gE=new P(1,0,0),vE=new P(0,1,0),AE=new P(0,0,1),bE={type:"added"},wB={type:"removed"},qc={type:"childadded",child:null},DA={type:"childremoved",child:null};class Pt extends Ys{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:yB++}),this.uuid=ds(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Pt.DEFAULT_UP.clone();const e=new P,t=new Yi,i=new Lt,n=new P(1,1,1);function r(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(r),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 yt}}),this.matrix=new Ke,this.matrixWorld=new Ke,this.matrixAutoUpdate=Pt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new cm,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 Xc.setFromAxisAngle(e,t),this.quaternion.multiply(Xc),this}rotateOnWorldAxis(e,t){return Xc.setFromAxisAngle(e,t),this.quaternion.premultiply(Xc),this}rotateX(e){return this.rotateOnAxis(gE,e)}rotateY(e){return this.rotateOnAxis(vE,e)}rotateZ(e){return this.rotateOnAxis(AE,e)}translateOnAxis(e,t){return mE.copy(e).applyQuaternion(this.quaternion),this.position.add(mE.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(gE,e)}translateY(e){return this.translateOnAxis(vE,e)}translateZ(e){return this.translateOnAxis(AE,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4($r.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?hm.copy(e):hm.set(e,t,i);const n=this.parent;this.updateWorldMatrix(!0,!1),ou.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?$r.lookAt(ou,hm,this.up):$r.lookAt(hm,ou,this.up),this.quaternion.setFromRotationMatrix($r),n&&($r.extractRotation(n.matrixWorld),Xc.setFromRotationMatrix($r),this.quaternion.premultiply(Xc.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(ft("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(bE),qc.child=e,this.dispatchEvent(qc),qc.child=null):ft("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(wB),DA.child=e,this.dispatchEvent(DA),DA.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),$r.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),$r.multiply(e.parent.matrixWorld)),e.applyMatrix4($r),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(bE),qc.child=e,this.dispatchEvent(qc),qc.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 r=0,a=n.length;r<a;r++)n[r].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(ou,e,xB),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ou,_B,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,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*i-r[8]*n,r[13]+=i-r[1]*t-r[5]*i-r[9]*n,r[14]+=n-r[2]*t-r[6]*i-r[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 r=0,a=n.length;r<a;r++)n[r].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 r(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=r(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];r(e.shapes,d)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(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(r(e.materials,this.material[l]));n.material=o}else n.material=r(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(r(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),u=a(e.skeletons),p=a(e.animations),m=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),u.length>0&&(i.skeletons=u),p.length>0&&(i.animations=p),m.length>0&&(i.nodes=m)}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}}Pt.DEFAULT_UP=new P(0,1,0),Pt.DEFAULT_MATRIX_AUTO_UPDATE=!0,Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Si extends Pt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const EB={type:"move"};class dm{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Si,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 Si,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new P),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Si,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new P),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,r=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 v of e.hand.values()){const g=t.getJointPose(v,i),f=this._getHandJoint(c,v);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"],u=h.position.distanceTo(d.position),p=.02,m=.005;c.inputState.pinching&&u>p+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=p-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(n=t.getPose(e.targetRaySpace,i),n===null&&r!==null&&(n=r),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(EB)))}return o!==null&&(o.visible=n!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Si;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const yE={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},Ja={h:0,s:0,l:0},um={h:0,s:0,l:0};function RA(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class qe{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=ci){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,It.colorSpaceToWorking(this,t),this}setRGB(e,t,i,n=It.workingColorSpace){return this.r=e,this.g=t,this.b=i,It.colorSpaceToWorking(this,n),this}setHSL(e,t,i,n=It.workingColorSpace){if(e=MA(e,1),t=At(t,0,1),i=At(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,a=2*i-r;this.r=RA(a,r,e+1/3),this.g=RA(a,r,e),this.b=RA(a,r,e-1/3)}return It.colorSpaceToWorking(this,n),this}setStyle(e,t=ci){function i(r){r!==void 0&&parseFloat(r)<1&&Je("Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=n[1],o=n[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Je("Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=n[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Je("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=ci){const i=yE[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Je("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=Kr(e.r),this.g=Kr(e.g),this.b=Kr(e.b),this}copyLinearToSRGB(e){return this.r=Wc(e.r),this.g=Wc(e.g),this.b=Wc(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ci){return It.workingToColorSpace(wn.copy(this),e),Math.round(At(wn.r*255,0,255))*65536+Math.round(At(wn.g*255,0,255))*256+Math.round(At(wn.b*255,0,255))}getHexString(e=ci){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=It.workingColorSpace){It.workingToColorSpace(wn.copy(this),t);const i=wn.r,n=wn.g,r=wn.b,a=Math.max(i,n,r),o=Math.min(i,n,r);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-r)/d+(n<r?6:0);break;case n:l=(r-i)/d+2;break;case r:l=(i-n)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=It.workingColorSpace){return It.workingToColorSpace(wn.copy(this),t),e.r=wn.r,e.g=wn.g,e.b=wn.b,e}getStyle(e=ci){It.workingToColorSpace(wn.copy(this),e);const t=wn.r,i=wn.g,n=wn.b;return e!==ci?`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(Ja),this.setHSL(Ja.h+e,Ja.s+t,Ja.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(Ja),e.getHSL(um);const i=ru(Ja.h,um.h,t),n=ru(Ja.s,um.s,t),r=ru(Ja.l,um.l,t);return this.setHSL(i,n,r),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,r=e.elements;return this.r=r[0]*t+r[3]*i+r[6]*n,this.g=r[1]*t+r[4]*i+r[7]*n,this.b=r[2]*t+r[5]*i+r[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 wn=new qe;qe.NAMES=yE;class pm{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new qe(e),this.density=t}clone(){return new pm(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class fm{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new qe(e),this.near=t,this.far=i}clone(){return new fm(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class ll extends Pt{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 Yi,this.environmentIntensity=1,this.environmentRotation=new Yi,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 $s=new P,Zr=new P,BA=new P,Jr=new P,Yc=new P,Kc=new P,xE=new P,LA=new P,kA=new P,OA=new P,FA=new zt,NA=new zt,UA=new zt;class ii{constructor(e=new P,t=new P,i=new P){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,n){n.subVectors(i,t),$s.subVectors(e,t),n.cross($s);const r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(e,t,i,n,r){$s.subVectors(n,t),Zr.subVectors(i,t),BA.subVectors(e,t);const a=$s.dot($s),o=$s.dot(Zr),l=$s.dot(BA),c=Zr.dot(Zr),h=Zr.dot(BA),d=a*c-o*o;if(d===0)return r.set(0,0,0),null;const u=1/d,p=(c*l-o*h)*u,m=(a*h-o*l)*u;return r.set(1-p-m,m,p)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,Jr)===null?!1:Jr.x>=0&&Jr.y>=0&&Jr.x+Jr.y<=1}static getInterpolation(e,t,i,n,r,a,o,l){return this.getBarycoord(e,t,i,n,Jr)===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(r,Jr.x),l.addScaledVector(a,Jr.y),l.addScaledVector(o,Jr.z),l)}static getInterpolatedAttribute(e,t,i,n,r,a){return FA.setScalar(0),NA.setScalar(0),UA.setScalar(0),FA.fromBufferAttribute(e,t),NA.fromBufferAttribute(e,i),UA.fromBufferAttribute(e,n),a.setScalar(0),a.addScaledVector(FA,r.x),a.addScaledVector(NA,r.y),a.addScaledVector(UA,r.z),a}static isFrontFacing(e,t,i,n){return $s.subVectors(i,t),Zr.subVectors(e,t),$s.cross(Zr).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 $s.subVectors(this.c,this.b),Zr.subVectors(this.a,this.b),$s.cross(Zr).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ii.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return ii.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,n,r){return ii.getInterpolation(e,this.a,this.b,this.c,t,i,n,r)}containsPoint(e){return ii.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ii.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,n=this.b,r=this.c;let a,o;Yc.subVectors(n,i),Kc.subVectors(r,i),LA.subVectors(e,i);const l=Yc.dot(LA),c=Kc.dot(LA);if(l<=0&&c<=0)return t.copy(i);kA.subVectors(e,n);const h=Yc.dot(kA),d=Kc.dot(kA);if(h>=0&&d<=h)return t.copy(n);const u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(i).addScaledVector(Yc,a);OA.subVectors(e,r);const p=Yc.dot(OA),m=Kc.dot(OA);if(m>=0&&p<=m)return t.copy(r);const v=p*c-l*m;if(v<=0&&c>=0&&m<=0)return o=c/(c-m),t.copy(i).addScaledVector(Kc,o);const g=h*m-p*d;if(g<=0&&d-h>=0&&p-m>=0)return xE.subVectors(r,n),o=(d-h)/(d-h+(p-m)),t.copy(n).addScaledVector(xE,o);const f=1/(g+v+u);return a=v*f,o=u*f,t.copy(i).addScaledVector(Yc,a).addScaledVector(Kc,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class xt{constructor(e=new P(1/0,1/0,1/0),t=new P(-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(Zs.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Zs.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=Zs.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 r=i.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Zs):Zs.fromBufferAttribute(r,a),Zs.applyMatrix4(e.matrixWorld),this.expandByPoint(Zs);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),mm.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),mm.copy(i.boundingBox)),mm.applyMatrix4(e.matrixWorld),this.union(mm)}const n=e.children;for(let r=0,a=n.length;r<a;r++)this.expandByObject(n[r],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,Zs),Zs.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(lu),gm.subVectors(this.max,lu),$c.subVectors(e.a,lu),Zc.subVectors(e.b,lu),Jc.subVectors(e.c,lu),eo.subVectors(Zc,$c),to.subVectors(Jc,Zc),cl.subVectors($c,Jc);let t=[0,-eo.z,eo.y,0,-to.z,to.y,0,-cl.z,cl.y,eo.z,0,-eo.x,to.z,0,-to.x,cl.z,0,-cl.x,-eo.y,eo.x,0,-to.y,to.x,0,-cl.y,cl.x,0];return!zA(t,$c,Zc,Jc,gm)||(t=[1,0,0,0,1,0,0,0,1],!zA(t,$c,Zc,Jc,gm))?!1:(vm.crossVectors(eo,to),t=[vm.x,vm.y,vm.z],zA(t,$c,Zc,Jc,gm))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Zs).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Zs).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:(ea[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ea[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ea[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ea[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ea[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ea[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ea[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ea[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ea),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 ea=[new P,new P,new P,new P,new P,new P,new P,new P],Zs=new P,mm=new xt,$c=new P,Zc=new P,Jc=new P,eo=new P,to=new P,cl=new P,lu=new P,gm=new P,vm=new P,hl=new P;function zA(s,e,t,i,n){for(let r=0,a=s.length-3;r<=a;r+=3){hl.fromArray(s,r);const o=n.x*Math.abs(hl.x)+n.y*Math.abs(hl.y)+n.z*Math.abs(hl.z),l=e.dot(hl),c=t.dot(hl),h=i.dot(hl);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const ta=MB();function MB(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),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 r=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,r[l]=c|h}for(let l=1024;l<2048;++l)r[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:r,exponentTable:a,offsetTable:o}}function Zn(s){Math.abs(s)>65504&&Je("DataUtils.toHalfFloat(): Value out of range."),s=At(s,-65504,65504),ta.floatView[0]=s;const e=ta.uint32View[0],t=e>>23&511;return ta.baseTable[t]+((e&8388607)>>ta.shiftTable[t])}function cu(s){const e=s>>10;return ta.uint32View[0]=ta.mantissaTable[ta.offsetTable[e]+(s&1023)]+ta.exponentTable[e],ta.floatView[0]}class hu{static toHalfFloat(e){return Zn(e)}static fromHalfFloat(e){return cu(e)}}const Gi=new P,Am=new be;let SB=0;class _t{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:SB++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=tu,this.updateRanges=[],this.gpuType=xi,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,r=this.itemSize;n<r;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++)Am.fromBufferAttribute(this,t),Am.applyMatrix3(e),this.setXY(t,Am.x,Am.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Gi.fromBufferAttribute(this,t),Gi.applyMatrix3(e),this.setXYZ(t,Gi.x,Gi.y,Gi.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Gi.fromBufferAttribute(this,t),Gi.applyMatrix4(e),this.setXYZ(t,Gi.x,Gi.y,Gi.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Gi.fromBufferAttribute(this,t),Gi.applyNormalMatrix(e),this.setXYZ(t,Gi.x,Gi.y,Gi.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Gi.fromBufferAttribute(this,t),Gi.transformDirection(e),this.setXYZ(t,Gi.x,Gi.y,Gi.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=Ln(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Et(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Ln(t,this.array)),t}setX(e,t){return this.normalized&&(t=Et(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Ln(t,this.array)),t}setY(e,t){return this.normalized&&(t=Et(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=Ln(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Et(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=Ln(t,this.array)),t}setW(e,t){return this.normalized&&(t=Et(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Et(t,this.array),i=Et(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=Et(t,this.array),i=Et(i,this.array),n=Et(n,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this}setXYZW(e,t,i,n,r){return e*=this.itemSize,this.normalized&&(t=Et(t,this.array),i=Et(i,this.array),n=Et(n,this.array),r=Et(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this.array[e+3]=r,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!==tu&&(e.usage=this.usage),e}}class CB extends _t{constructor(e,t,i){super(new Int8Array(e),t,i)}}class TB extends _t{constructor(e,t,i){super(new Uint8Array(e),t,i)}}class IB extends _t{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}}class PB extends _t{constructor(e,t,i){super(new Int16Array(e),t,i)}}class HA extends _t{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class DB extends _t{constructor(e,t,i){super(new Int32Array(e),t,i)}}class GA extends _t{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class RB extends _t{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=cu(this.array[e*this.itemSize]);return this.normalized&&(t=Ln(t,this.array)),t}setX(e,t){return this.normalized&&(t=Et(t,this.array)),this.array[e*this.itemSize]=Zn(t),this}getY(e){let t=cu(this.array[e*this.itemSize+1]);return this.normalized&&(t=Ln(t,this.array)),t}setY(e,t){return this.normalized&&(t=Et(t,this.array)),this.array[e*this.itemSize+1]=Zn(t),this}getZ(e){let t=cu(this.array[e*this.itemSize+2]);return this.normalized&&(t=Ln(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Et(t,this.array)),this.array[e*this.itemSize+2]=Zn(t),this}getW(e){let t=cu(this.array[e*this.itemSize+3]);return this.normalized&&(t=Ln(t,this.array)),t}setW(e,t){return this.normalized&&(t=Et(t,this.array)),this.array[e*this.itemSize+3]=Zn(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Et(t,this.array),i=Et(i,this.array)),this.array[e+0]=Zn(t),this.array[e+1]=Zn(i),this}setXYZ(e,t,i,n){return e*=this.itemSize,this.normalized&&(t=Et(t,this.array),i=Et(i,this.array),n=Et(n,this.array)),this.array[e+0]=Zn(t),this.array[e+1]=Zn(i),this.array[e+2]=Zn(n),this}setXYZW(e,t,i,n,r){return e*=this.itemSize,this.normalized&&(t=Et(t,this.array),i=Et(i,this.array),n=Et(n,this.array),r=Et(r,this.array)),this.array[e+0]=Zn(t),this.array[e+1]=Zn(i),this.array[e+2]=Zn(n),this.array[e+3]=Zn(r),this}}class it extends _t{constructor(e,t,i){super(new Float32Array(e),t,i)}}const BB=new xt,du=new P,VA=new P;class cn{constructor(e=new P,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):BB.setFromPoints(e).getCenter(i);let n=0;for(let r=0,a=e.length;r<a;r++)n=Math.max(n,i.distanceToSquared(e[r]));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;du.subVectors(e,this.center);const t=du.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),n=(i-this.radius)*.5;this.center.addScaledVector(du,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):(VA.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(du.copy(e.center).add(VA)),this.expandByPoint(du.copy(e.center).sub(VA))),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 LB=0;const Ps=new Ke,WA=new Pt,eh=new P,ps=new xt,uu=new xt,hn=new P;class dt extends Ys{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:LB++}),this.uuid=ds(),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(Q4(e)?GA:HA)(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 r=new yt().getNormalMatrix(e);i.applyNormalMatrix(r),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 Ps.makeRotationFromQuaternion(e),this.applyMatrix4(Ps),this}rotateX(e){return Ps.makeRotationX(e),this.applyMatrix4(Ps),this}rotateY(e){return Ps.makeRotationY(e),this.applyMatrix4(Ps),this}rotateZ(e){return Ps.makeRotationZ(e),this.applyMatrix4(Ps),this}translate(e,t,i){return Ps.makeTranslation(e,t,i),this.applyMatrix4(Ps),this}scale(e,t,i){return Ps.makeScale(e,t,i),this.applyMatrix4(Ps),this}lookAt(e){return WA.lookAt(e),WA.updateMatrix(),this.applyMatrix4(WA.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(eh).negate(),this.translate(eh.x,eh.y,eh.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let n=0,r=e.length;n<r;n++){const a=e[n];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new it(i,3))}else{const i=Math.min(e.length,t.count);for(let n=0;n<i;n++){const r=e[n];t.setXYZ(n,r.x,r.y,r.z||0)}e.length>t.count&&Je("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 xt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ft("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new P(-1/0,-1/0,-1/0),new P(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 r=t[i];ps.setFromBufferAttribute(r),this.morphTargetsRelative?(hn.addVectors(this.boundingBox.min,ps.min),this.boundingBox.expandByPoint(hn),hn.addVectors(this.boundingBox.max,ps.max),this.boundingBox.expandByPoint(hn)):(this.boundingBox.expandByPoint(ps.min),this.boundingBox.expandByPoint(ps.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ft('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 cn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ft("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new P,1/0);return}if(e){const i=this.boundingSphere.center;if(ps.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];uu.setFromBufferAttribute(o),this.morphTargetsRelative?(hn.addVectors(ps.min,uu.min),ps.expandByPoint(hn),hn.addVectors(ps.max,uu.max),ps.expandByPoint(hn)):(ps.expandByPoint(uu.min),ps.expandByPoint(uu.max))}ps.getCenter(i);let n=0;for(let r=0,a=e.count;r<a;r++)hn.fromBufferAttribute(e,r),n=Math.max(n,i.distanceToSquared(hn));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)hn.fromBufferAttribute(o,c),l&&(eh.fromBufferAttribute(e,c),hn.add(eh)),n=Math.max(n,i.distanceToSquared(hn))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&ft('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){ft("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,n=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new _t(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let E=0;E<i.count;E++)o[E]=new P,l[E]=new P;const c=new P,h=new P,d=new P,u=new be,p=new be,m=new be,v=new P,g=new P;function f(E,w,T){c.fromBufferAttribute(i,E),h.fromBufferAttribute(i,w),d.fromBufferAttribute(i,T),u.fromBufferAttribute(r,E),p.fromBufferAttribute(r,w),m.fromBufferAttribute(r,T),h.sub(c),d.sub(c),p.sub(u),m.sub(u);const R=1/(p.x*m.y-m.x*p.y);isFinite(R)&&(v.copy(h).multiplyScalar(m.y).addScaledVector(d,-p.y).multiplyScalar(R),g.copy(d).multiplyScalar(p.x).addScaledVector(h,-m.x).multiplyScalar(R),o[E].add(v),o[w].add(v),o[T].add(v),l[E].add(g),l[w].add(g),l[T].add(g))}let A=this.groups;A.length===0&&(A=[{start:0,count:e.count}]);for(let E=0,w=A.length;E<w;++E){const T=A[E],R=T.start,D=T.count;for(let L=R,I=R+D;L<I;L+=3)f(e.getX(L+0),e.getX(L+1),e.getX(L+2))}const b=new P,y=new P,x=new P,_=new P;function M(E){x.fromBufferAttribute(n,E),_.copy(x);const w=o[E];b.copy(w),b.sub(x.multiplyScalar(x.dot(w))).normalize(),y.crossVectors(_,w);const R=y.dot(l[E])<0?-1:1;a.setXYZW(E,b.x,b.y,b.z,R)}for(let E=0,w=A.length;E<w;++E){const T=A[E],R=T.start,D=T.count;for(let L=R,I=R+D;L<I;L+=3)M(e.getX(L+0)),M(e.getX(L+1)),M(e.getX(L+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 _t(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let u=0,p=i.count;u<p;u++)i.setXYZ(u,0,0,0);const n=new P,r=new P,a=new P,o=new P,l=new P,c=new P,h=new P,d=new P;if(e)for(let u=0,p=e.count;u<p;u+=3){const m=e.getX(u+0),v=e.getX(u+1),g=e.getX(u+2);n.fromBufferAttribute(t,m),r.fromBufferAttribute(t,v),a.fromBufferAttribute(t,g),h.subVectors(a,r),d.subVectors(n,r),h.cross(d),o.fromBufferAttribute(i,m),l.fromBufferAttribute(i,v),c.fromBufferAttribute(i,g),o.add(h),l.add(h),c.add(h),i.setXYZ(m,o.x,o.y,o.z),i.setXYZ(v,l.x,l.y,l.z),i.setXYZ(g,c.x,c.y,c.z)}else for(let u=0,p=t.count;u<p;u+=3)n.fromBufferAttribute(t,u+0),r.fromBufferAttribute(t,u+1),a.fromBufferAttribute(t,u+2),h.subVectors(a,r),d.subVectors(n,r),h.cross(d),i.setXYZ(u+0,h.x,h.y,h.z),i.setXYZ(u+1,h.x,h.y,h.z),i.setXYZ(u+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++)hn.fromBufferAttribute(e,t),hn.normalize(),e.setXYZ(t,hn.x,hn.y,hn.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,d=o.normalized,u=new c.constructor(l.length*h);let p=0,m=0;for(let v=0,g=l.length;v<g;v++){o.isInterleavedBufferAttribute?p=l[v]*o.data.stride+o.offset:p=l[v]*h;for(let f=0;f<h;f++)u[m++]=c[p++]}return new _t(u,h,d)}if(this.index===null)return Je("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new dt,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 r=this.morphAttributes;for(const o in r){const l=[],c=r[o];for(let h=0,d=c.length;h<d;h++){const u=c[h],p=e(u,i);l.push(p)}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 r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let d=0,u=c.length;d<u;d++){const p=c[d];h.push(p.toJSON(e.data))}h.length>0&&(n[l]=h,r=!0)}r&&(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 r=e.morphAttributes;for(const c in r){const h=[],d=r[c];for(let u=0,p=d.length;u<p;u++)h.push(d[u].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 th{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=tu,this.updateRanges=[],this.version=0,this.uuid=ds()}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,r=this.stride;n<r;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=ds()),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=ds()),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 kn=new P;class ia{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++)kn.fromBufferAttribute(this,t),kn.applyMatrix4(e),this.setXYZ(t,kn.x,kn.y,kn.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)kn.fromBufferAttribute(this,t),kn.applyNormalMatrix(e),this.setXYZ(t,kn.x,kn.y,kn.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)kn.fromBufferAttribute(this,t),kn.transformDirection(e),this.setXYZ(t,kn.x,kn.y,kn.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Ln(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Et(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=Et(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Et(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Et(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Et(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=Ln(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Ln(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Ln(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Ln(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Et(t,this.array),i=Et(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=Et(t,this.array),i=Et(i,this.array),n=Et(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,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Et(t,this.array),i=Et(i,this.array),n=Et(n,this.array),r=Et(r,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]=r,this}clone(e){if(e===void 0){nu("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 r=0;r<this.itemSize;r++)t.push(this.data.array[n+r])}return new _t(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 ia(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){nu("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 r=0;r<this.itemSize;r++)t.push(this.data.array[n+r])}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 kB=0;class Ki extends Ys{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:kB++}),this.uuid=ds(),this.name="",this.type="Material",this.blending=Ko,this.side=Yn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=xf,this.blendDst=_f,this.blendEquation=Kn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new qe(0,0,0),this.blendAlpha=0,this.depthFunc=$o,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=wA,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=rl,this.stencilZFail=rl,this.stencilZPass=rl,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){Je(`Material: parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){Je(`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!==Ko&&(i.blending=this.blending),this.side!==Yn&&(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!==xf&&(i.blendSrc=this.blendSrc),this.blendDst!==_f&&(i.blendDst=this.blendDst),this.blendEquation!==Kn&&(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!==$o&&(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!==wA&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==rl&&(i.stencilFail=this.stencilFail),this.stencilZFail!==rl&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==rl&&(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(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=n(e.textures),a=n(e.images);r.length>0&&(i.textures=r),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 r=0;r!==n;++r)i[r]=t[r].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 bm extends Ki{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new qe(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 ih;const pu=new P,nh=new P,sh=new P,rh=new be,fu=new be,_E=new Ke,ym=new P,mu=new P,xm=new P,wE=new be,QA=new be,EE=new be;class gu extends Pt{constructor(e=new bm){if(super(),this.isSprite=!0,this.type="Sprite",ih===void 0){ih=new dt;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 th(t,5);ih.setIndex([0,1,2,0,2,3]),ih.setAttribute("position",new ia(i,3,0,!1)),ih.setAttribute("uv",new ia(i,2,3,!1))}this.geometry=ih,this.material=e,this.center=new be(.5,.5),this.count=1}raycast(e,t){e.camera===null&&ft('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),nh.setFromMatrixScale(this.matrixWorld),_E.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),sh.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&nh.multiplyScalar(-sh.z);const i=this.material.rotation;let n,r;i!==0&&(r=Math.cos(i),n=Math.sin(i));const a=this.center;_m(ym.set(-.5,-.5,0),sh,a,nh,n,r),_m(mu.set(.5,-.5,0),sh,a,nh,n,r),_m(xm.set(.5,.5,0),sh,a,nh,n,r),wE.set(0,0),QA.set(1,0),EE.set(1,1);let o=e.ray.intersectTriangle(ym,mu,xm,!1,pu);if(o===null&&(_m(mu.set(-.5,.5,0),sh,a,nh,n,r),QA.set(0,1),o=e.ray.intersectTriangle(ym,xm,mu,!1,pu),o===null))return;const l=e.ray.origin.distanceTo(pu);l<e.near||l>e.far||t.push({distance:l,point:pu.clone(),uv:ii.getInterpolation(pu,ym,mu,xm,wE,QA,EE,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 _m(s,e,t,i,n,r){rh.subVectors(s,t).addScalar(.5).multiply(i),n!==void 0?(fu.x=r*rh.x-n*rh.y,fu.y=n*rh.x+r*rh.y):fu.copy(rh),s.copy(e),s.x+=fu.x,s.y+=fu.y,s.applyMatrix4(_E)}const wm=new P,ME=new P;class SE extends Pt{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 r=t[i];this.addLevel(r.object.clone(),r.distance,r.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);const n=this.levels;let r;for(r=0;r<n.length&&!(t<n[r].distance);r++);return n.splice(r,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 r=t[i].distance;if(t[i].object.visible&&(r-=r*t[i].hysteresis),e<r)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){wm.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(wm);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){wm.setFromMatrixPosition(e.matrixWorld),ME.setFromMatrixPosition(this.matrixWorld);const i=wm.distanceTo(ME)/e.zoom;t[0].object.visible=!0;let n,r;for(n=1,r=t.length;n<r;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<r;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,r=i.length;n<r;n++){const a=i[n];t.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return t}}const na=new P,jA=new P,Em=new P,io=new P,XA=new P,Mm=new P,qA=new P;class Cr{constructor(e=new P,t=new P(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,na)),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=na.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(na.copy(this.origin).addScaledVector(this.direction,t),na.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){jA.copy(e).add(t).multiplyScalar(.5),Em.copy(t).sub(e).normalize(),io.copy(this.origin).sub(jA);const r=e.distanceTo(t)*.5,a=-this.direction.dot(Em),o=io.dot(this.direction),l=-io.dot(Em),c=io.lengthSq(),h=Math.abs(1-a*a);let d,u,p,m;if(h>0)if(d=a*l-o,u=a*o-l,m=r*h,d>=0)if(u>=-m)if(u<=m){const v=1/h;d*=v,u*=v,p=d*(d+a*u+2*o)+u*(a*d+u+2*l)+c}else u=r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*l)+c;else u=-r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*l)+c;else u<=-m?(d=Math.max(0,-(-a*r+o)),u=d>0?-r:Math.min(Math.max(-r,-l),r),p=-d*d+u*(u+2*l)+c):u<=m?(d=0,u=Math.min(Math.max(-r,-l),r),p=u*(u+2*l)+c):(d=Math.max(0,-(a*r+o)),u=d>0?r:Math.min(Math.max(-r,-l),r),p=-d*d+u*(u+2*l)+c);else u=a>0?-r:r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),n&&n.copy(jA).addScaledVector(Em,u),p}intersectSphere(e,t){na.subVectors(e.center,this.origin);const i=na.dot(this.direction),n=na.dot(na)-i*i,r=e.radius*e.radius;if(n>r)return null;const a=Math.sqrt(r-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,r,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return c>=0?(i=(e.min.x-u.x)*c,n=(e.max.x-u.x)*c):(i=(e.max.x-u.x)*c,n=(e.min.x-u.x)*c),h>=0?(r=(e.min.y-u.y)*h,a=(e.max.y-u.y)*h):(r=(e.max.y-u.y)*h,a=(e.min.y-u.y)*h),i>a||r>n||((r>i||isNaN(i))&&(i=r),(a<n||isNaN(n))&&(n=a),d>=0?(o=(e.min.z-u.z)*d,l=(e.max.z-u.z)*d):(o=(e.max.z-u.z)*d,l=(e.min.z-u.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,na)!==null}intersectTriangle(e,t,i,n,r){XA.subVectors(t,e),Mm.subVectors(i,e),qA.crossVectors(XA,Mm);let a=this.direction.dot(qA),o;if(a>0){if(n)return null;o=1}else if(a<0)o=-1,a=-a;else return null;io.subVectors(this.origin,e);const l=o*this.direction.dot(Mm.crossVectors(io,Mm));if(l<0)return null;const c=o*this.direction.dot(XA.cross(io));if(c<0||l+c>a)return null;const h=-o*io.dot(qA);return h<0?null:this.at(h/a,r)}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 Wt extends Ki{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new qe(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 Yi,this.combine=kd,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 CE=new Ke,dl=new Cr,Sm=new cn,TE=new P,Cm=new P,Tm=new P,Im=new P,YA=new P,Pm=new P,IE=new P,Dm=new P;class We extends Pt{constructor(e=new dt,t=new Wt){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 r=0,a=n.length;r<a;r++){const o=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){const i=this.geometry,n=i.attributes.position,r=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(n,e);const o=this.morphTargetInfluences;if(r&&o){Pm.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const h=o[l],d=r[l];h!==0&&(YA.fromBufferAttribute(d,e),a?Pm.addScaledVector(YA,h):Pm.addScaledVector(YA.sub(t),h))}t.add(Pm)}return t}raycast(e,t){const i=this.geometry,n=this.material,r=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Sm.copy(i.boundingSphere),Sm.applyMatrix4(r),dl.copy(e.ray).recast(e.near),!(Sm.containsPoint(dl.origin)===!1&&(dl.intersectSphere(Sm,TE)===null||dl.origin.distanceToSquared(TE)>(e.far-e.near)**2))&&(CE.copy(r).invert(),dl.copy(e.ray).applyMatrix4(CE),!(i.boundingBox!==null&&dl.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,dl)))}_computeIntersections(e,t,i){let n;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,p=r.drawRange;if(o!==null)if(Array.isArray(a))for(let m=0,v=u.length;m<v;m++){const g=u[m],f=a[g.materialIndex],A=Math.max(g.start,p.start),b=Math.min(o.count,Math.min(g.start+g.count,p.start+p.count));for(let y=A,x=b;y<x;y+=3){const _=o.getX(y),M=o.getX(y+1),E=o.getX(y+2);n=Rm(this,f,e,i,c,h,d,_,M,E),n&&(n.faceIndex=Math.floor(y/3),n.face.materialIndex=g.materialIndex,t.push(n))}}else{const m=Math.max(0,p.start),v=Math.min(o.count,p.start+p.count);for(let g=m,f=v;g<f;g+=3){const A=o.getX(g),b=o.getX(g+1),y=o.getX(g+2);n=Rm(this,a,e,i,c,h,d,A,b,y),n&&(n.faceIndex=Math.floor(g/3),t.push(n))}}else if(l!==void 0)if(Array.isArray(a))for(let m=0,v=u.length;m<v;m++){const g=u[m],f=a[g.materialIndex],A=Math.max(g.start,p.start),b=Math.min(l.count,Math.min(g.start+g.count,p.start+p.count));for(let y=A,x=b;y<x;y+=3){const _=y,M=y+1,E=y+2;n=Rm(this,f,e,i,c,h,d,_,M,E),n&&(n.faceIndex=Math.floor(y/3),n.face.materialIndex=g.materialIndex,t.push(n))}}else{const m=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let g=m,f=v;g<f;g+=3){const A=g,b=g+1,y=g+2;n=Rm(this,a,e,i,c,h,d,A,b,y),n&&(n.faceIndex=Math.floor(g/3),t.push(n))}}}}function OB(s,e,t,i,n,r,a,o){let l;if(e.side===an?l=i.intersectTriangle(a,r,n,!0,o):l=i.intersectTriangle(n,r,a,e.side===Yn,o),l===null)return null;Dm.copy(o),Dm.applyMatrix4(s.matrixWorld);const c=t.ray.origin.distanceTo(Dm);return c<t.near||c>t.far?null:{distance:c,point:Dm.clone(),object:s}}function Rm(s,e,t,i,n,r,a,o,l,c){s.getVertexPosition(o,Cm),s.getVertexPosition(l,Tm),s.getVertexPosition(c,Im);const h=OB(s,e,t,i,Cm,Tm,Im,IE);if(h){const d=new P;ii.getBarycoord(IE,Cm,Tm,Im,d),n&&(h.uv=ii.getInterpolatedAttribute(n,o,l,c,d,new be)),r&&(h.uv1=ii.getInterpolatedAttribute(r,o,l,c,d,new be)),a&&(h.normal=ii.getInterpolatedAttribute(a,o,l,c,d,new P),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new P,materialIndex:0};ii.getNormal(Cm,Tm,Im,u.normal),h.face=u,h.barycoord=d}return h}const PE=new P,DE=new zt,RE=new zt,FB=new P,BE=new Ke,Bm=new P,KA=new cn,LE=new Ke,$A=new Cr;class ZA extends We{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=gA,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 xt),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Bm),this.boundingBox.expandByPoint(Bm)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new cn),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Bm),this.boundingSphere.expandByPoint(Bm)}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(),KA.copy(this.boundingSphere),KA.applyMatrix4(n),e.ray.intersectsSphere(KA)!==!1&&(LE.copy(n).invert(),$A.copy(e.ray).applyMatrix4(LE),!(this.boundingBox!==null&&$A.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,$A)))}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 zt,t=this.geometry.attributes.skinWeight;for(let i=0,n=t.count;i<n;i++){e.fromBufferAttribute(t,i);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===gA?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Qw?this.bindMatrixInverse.copy(this.bindMatrix).invert():Je("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,n=this.geometry;DE.fromBufferAttribute(n.attributes.skinIndex,e),RE.fromBufferAttribute(n.attributes.skinWeight,e),PE.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){const a=RE.getComponent(r);if(a!==0){const o=DE.getComponent(r);BE.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(FB.copy(PE).applyMatrix4(BE),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Lm extends Pt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class On extends Ai{constructor(e=null,t=1,i=1,n,r,a,o,l,c=Jt,h=Jt,d,u){super(null,a,o,l,c,h,n,r,d,u),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const kE=new Ke,NB=new Ke;class vu{constructor(e=[],t=[]){this.uuid=ds(),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){Je("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 r=0,a=e.length;r<a;r++){const o=e[r]?e[r].matrixWorld:NB;kE.multiplyMatrices(o,t[r]),kE.toArray(i,r*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new vu(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 On(t,e,e,_i,xi);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 r=e.bones[i];let a=t[r];a===void 0&&(Je("Skeleton: No bone found with UUID:",r),a=new Lm),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,r=t.length;n<r;n++){const a=t[n];e.bones.push(a.uuid);const o=i[n];e.boneInverses.push(o.toArray())}return e}}class no extends _t{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 ah=new Ke,OE=new Ke,km=[],FE=new xt,UB=new Ke,Au=new We,bu=new cn;class hi extends We{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new no(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,UB)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new xt),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,ah),FE.copy(e.boundingBox).applyMatrix4(ah),this.boundingBox.union(FE)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new cn),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,ah),bu.copy(e.boundingSphere).applyMatrix4(ah),this.boundingSphere.union(bu)}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,r=i.length+1,a=e*r+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(Au.geometry=this.geometry,Au.material=this.material,Au.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),bu.copy(this.boundingSphere),bu.applyMatrix4(i),e.ray.intersectsSphere(bu)!==!1))for(let r=0;r<n;r++){this.getMatrixAt(r,ah),OE.multiplyMatrices(i,ah),Au.matrixWorld=OE,Au.raycast(e,km);for(let a=0,o=km.length;a<o;a++){const l=km[a];l.instanceId=r,l.object=this,t.push(l)}km.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new no(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 On(new Float32Array(n*this.count),n,this.count,Sr,xi));const r=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;r[l]=o,r.set(i,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const JA=new P,zB=new P,HB=new yt;class $t{constructor(e=new P(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=JA.subVectors(i,t).cross(zB.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(JA),n=this.normal.dot(i);if(n===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/n;return r<0||r>1?null:t.copy(e.start).addScaledVector(i,r)}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||HB.getNormalMatrix(e),n=this.coplanarPoint(JA).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),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 ul=new cn,GB=new be(.5,.5),Om=new P;class oh{constructor(e=new $t,t=new $t,i=new $t,n=new $t,r=new $t,a=new $t){this.planes=[e,t,i,n,r,a]}set(e,t,i,n,r,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(r),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=hs,i=!1){const n=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],h=r[4],d=r[5],u=r[6],p=r[7],m=r[8],v=r[9],g=r[10],f=r[11],A=r[12],b=r[13],y=r[14],x=r[15];if(n[0].setComponents(c-a,p-h,f-m,x-A).normalize(),n[1].setComponents(c+a,p+h,f+m,x+A).normalize(),n[2].setComponents(c+o,p+d,f+v,x+b).normalize(),n[3].setComponents(c-o,p-d,f-v,x-b).normalize(),i)n[4].setComponents(l,u,g,y).normalize(),n[5].setComponents(c-l,p-u,f-g,x-y).normalize();else if(n[4].setComponents(c-l,p-u,f-g,x-y).normalize(),t===hs)n[5].setComponents(c+l,p+u,f+g,x+y).normalize();else if(t===al)n[5].setComponents(l,u,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(),ul.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),ul.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ul)}intersectsSprite(e){ul.center.set(0,0,0);const t=GB.distanceTo(e.center);return ul.radius=.7071067811865476+t,ul.applyMatrix4(e.matrixWorld),this.intersectsSphere(ul)}intersectsSphere(e){const t=this.planes,i=e.center,n=-e.radius;for(let r=0;r<6;r++)if(t[r].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(Om.x=n.normal.x>0?e.max.x:e.min.x,Om.y=n.normal.y>0?e.max.y:e.min.y,Om.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(Om)<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 Tr=new Ke,Ir=new oh;class Fm{constructor(){this.coordinateSystem=hs}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(Tr.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),Ir.setFromProjectionMatrix(Tr,n.coordinateSystem,n.reversedDepth),Ir.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(Tr.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),Ir.setFromProjectionMatrix(Tr,n.coordinateSystem,n.reversedDepth),Ir.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(Tr.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),Ir.setFromProjectionMatrix(Tr,n.coordinateSystem,n.reversedDepth),Ir.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(Tr.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),Ir.setFromProjectionMatrix(Tr,n.coordinateSystem,n.reversedDepth),Ir.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(Tr.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),Ir.setFromProjectionMatrix(Tr,n.coordinateSystem,n.reversedDepth),Ir.containsPoint(e))return!0}return!1}clone(){return new Fm}}function eb(s,e){return s-e}function VB(s,e){return s.z-e.z}function WB(s,e){return e.z-s.z}class QB{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,i,n){const r=this.pool,a=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const o=r[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 Jn=new Ke,jB=new qe(1,1,1),NE=new oh,XB=new Fm,Nm=new xt,pl=new cn,yu=new P,UE=new P,qB=new P,tb=new QB,En=new We,Um=[];function YB(s,e,t=0){const i=e.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==e.array.constructor){const n=s.count;for(let r=0;r<n;r++)for(let a=0;a<i;a++)e.setComponent(r+t,a,s.getComponent(r,a))}else e.array.set(s.array,t*i);e.needsUpdate=!0}function fl(s,e){if(s.constructor!==e.constructor){const t=Math.min(s.length,e.length);for(let i=0;i<t;i++)e[i]=s[i]}else{const t=Math.min(s.length,e.length);e.set(new s.constructor(s.buffer,0,t))}}class zE extends We{constructor(e,t,i=t*2,n){super(new dt,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 On(t,e,e,_i,xi);this._matricesTexture=i}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),i=new On(t,e,e,zd,Ts);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 On(t,e,e,_i,xi);i.colorSpace=It.workingColorSpace,this._colorsTexture=i}_initializeGeometry(e){const t=this.geometry,i=this._maxVertexCount,n=this._maxIndexCount;if(this._geometryInitialized===!1){for(const r in e.attributes){const a=e.getAttribute(r),{array:o,itemSize:l,normalized:c}=a,h=new o.constructor(i*l),d=new _t(h,l,c);t.setAttribute(r,d)}if(e.getIndex()!==null){const r=i>65535?new Uint32Array(n):new Uint16Array(n);t.setIndex(new _t(r,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),r=t.getAttribute(i);if(n.itemSize!==r.itemSize||n.normalized!==r.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 xt);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 r=t[i].geometryIndex;this.getMatrixAt(i,Jn),this.getBoundingBoxAt(r,Nm).applyMatrix4(Jn),e.union(Nm)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new cn);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 r=t[i].geometryIndex;this.getMatrixAt(i,Jn),this.getBoundingSphereAt(r,pl).applyMatrix4(Jn),e.union(pl)}}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(eb),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=i):(n=this._instanceInfo.length,this._instanceInfo.push(i));const r=this._matricesTexture;Jn.identity().toArray(r.image.data,n*16),r.needsUpdate=!0;const a=this._colorsTexture;return a&&(jB.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},r=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(eb),l=this._availableGeometryIds.shift(),r[l]=n):(l=this._geometryCount,this._geometryCount++,r.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,r=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),u=i.getAttribute(h);YB(d,u,l);const p=d.itemSize;for(let m=d.count,v=c;m<v;m++){const g=l+m;for(let f=0;f<p;f++)u.setComponent(g,f,0)}u.needsUpdate=!0,u.addUpdateRange(l*p,c*p)}if(n){const h=o.indexStart,d=o.reservedIndexCount;o.indexCount=t.getIndex().count;for(let u=0;u<a.count;u++)r.setX(h+u,l+a.getX(u));for(let u=a.count,p=d;u<p;u++)r.setX(h+u,l);r.needsUpdate=!0,r.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,r=i.length;n<r;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),r=this.geometry;for(let a=0,o=i.length;a<o;a++){const l=n[a],c=i[l];if(c.active!==!1){if(r.index!==null){if(c.indexStart!==t){const{indexStart:h,vertexStart:d,reservedIndexCount:u}=c,p=r.index,m=p.array,v=e-d;for(let g=h;g<h+u;g++)m[g]=m[g]+v;p.array.copyWithin(t,h,h+u),p.addUpdateRange(t,u),p.needsUpdate=!0,c.indexStart=t}t+=c.reservedIndexCount}if(c.vertexStart!==e){const{vertexStart:h,reservedVertexCount:d}=c,u=r.attributes;for(const p in u){const m=u[p],{array:v,itemSize:g}=m;v.copyWithin(e*g,h*g,(h+d)*g),m.addUpdateRange(e*g,d*g),m.needsUpdate=!0}c.vertexStart=e}e+=c.reservedVertexCount,c.start=r.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 r=new xt,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)),r.expandByPoint(yu.fromBufferAttribute(o,h))}n.boundingBox=r}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 r=new cn;this.getBoundingBoxAt(e,Nm),Nm.getCenter(r.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)),yu.fromBufferAttribute(o,d),l=Math.max(l,r.center.distanceToSquared(yu))}r.radius=Math.sqrt(l),n.boundingSphere=r}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(eb);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),r=new Int32Array(e);fl(this._multiDrawCounts,n),fl(this._multiDrawStarts,r),this._multiDrawCounts=n,this._multiDrawStarts=r,this._maxInstanceCount=e;const a=this._indirectTexture,o=this._matricesTexture,l=this._colorsTexture;a.dispose(),this._initIndirectTexture(),fl(a.image.data,this._indirectTexture.image.data),o.dispose(),this._initMatricesTexture(),fl(o.image.data,this._matricesTexture.image.data),l&&(l.dispose(),this._initColorsTexture(),fl(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 r=this.geometry;r.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new dt,this._initializeGeometry(r));const a=this.geometry;r.index&&fl(r.index.array,a.index.array);for(const o in r.attributes)fl(r.attributes[o].array,a.attributes[o].array)}raycast(e,t){const i=this._instanceInfo,n=this._geometryInfo,r=this.matrixWorld,a=this.geometry;En.material=this.material,En.geometry.index=a.index,En.geometry.attributes=a.attributes,En.geometry.boundingBox===null&&(En.geometry.boundingBox=new xt),En.geometry.boundingSphere===null&&(En.geometry.boundingSphere=new cn);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];En.geometry.setDrawRange(h.start,h.count),this.getMatrixAt(o,En.matrixWorld).premultiply(r),this.getBoundingBoxAt(c,En.geometry.boundingBox),this.getBoundingSphereAt(c,En.geometry.boundingSphere),En.raycast(e,Um);for(let d=0,u=Um.length;d<u;d++){const p=Um[d];p.object=this,p.batchId=o,t.push(p)}Um.length=0}En.material=null,En.geometry.index=null,En.geometry.attributes={},En.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,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=n.getIndex();let o=a===null?1:a.array.BYTES_PER_ELEMENT,l=1;r.wireframe&&(l=2,o=n.attributes.position.count>65535?4:2);const c=this._instanceInfo,h=this._multiDrawStarts,d=this._multiDrawCounts,u=this._geometryInfo,p=this.perObjectFrustumCulled,m=this._indirectTexture,v=m.image.data,g=i.isArrayCamera?XB:NE;p&&!i.isArrayCamera&&(Jn.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),NE.setFromProjectionMatrix(Jn,i.coordinateSystem,i.reversedDepth));let f=0;if(this.sortObjects){Jn.copy(this.matrixWorld).invert(),yu.setFromMatrixPosition(i.matrixWorld).applyMatrix4(Jn),UE.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(Jn);for(let y=0,x=c.length;y<x;y++)if(c[y].visible&&c[y].active){const _=c[y].geometryIndex;this.getMatrixAt(y,Jn),this.getBoundingSphereAt(_,pl).applyMatrix4(Jn);let M=!1;if(p&&(M=!g.intersectsSphere(pl,i)),!M){const E=u[_],w=qB.subVectors(pl.center,yu).dot(UE);tb.push(E.start,E.count,w,y)}}const A=tb.list,b=this.customSort;b===null?A.sort(r.transparent?WB:VB):b.call(this,A,i);for(let y=0,x=A.length;y<x;y++){const _=A[y];h[f]=_.start*o*l,d[f]=_.count*l,v[f]=_.index,f++}tb.reset()}else for(let A=0,b=c.length;A<b;A++)if(c[A].visible&&c[A].active){const y=c[A].geometryIndex;let x=!1;if(p&&(this.getMatrixAt(A,Jn),this.getBoundingSphereAt(y,pl).applyMatrix4(Jn),x=!g.intersectsSphere(pl,i)),!x){const _=u[y];h[f]=_.start*o*l,d[f]=_.count*l,v[f]=A,f++}}m.needsUpdate=!0,this._multiDrawCount=f,this._visibilityChanged=!1}onBeforeShadow(e,t,i,n,r,a){this.onBeforeRender(e,null,n,r,a)}}class bi extends Ki{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new qe(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 zm=new P,Hm=new P,HE=new Ke,xu=new Cr,Gm=new cn,ib=new P,GE=new P;class Ci extends Pt{constructor(e=new dt,t=new bi){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,r=t.count;n<r;n++)zm.fromBufferAttribute(t,n-1),Hm.fromBufferAttribute(t,n),i[n]=i[n-1],i[n]+=zm.distanceTo(Hm);e.setAttribute("lineDistance",new it(i,1))}else Je("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Gm.copy(i.boundingSphere),Gm.applyMatrix4(n),Gm.radius+=r,e.ray.intersectsSphere(Gm)===!1)return;HE.copy(n).invert(),xu.copy(e.ray).applyMatrix4(HE);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=i.index,u=i.attributes.position;if(h!==null){const p=Math.max(0,a.start),m=Math.min(h.count,a.start+a.count);for(let v=p,g=m-1;v<g;v+=c){const f=h.getX(v),A=h.getX(v+1),b=Vm(this,e,xu,l,f,A,v);b&&t.push(b)}if(this.isLineLoop){const v=h.getX(m-1),g=h.getX(p),f=Vm(this,e,xu,l,v,g,m-1);f&&t.push(f)}}else{const p=Math.max(0,a.start),m=Math.min(u.count,a.start+a.count);for(let v=p,g=m-1;v<g;v+=c){const f=Vm(this,e,xu,l,v,v+1,v);f&&t.push(f)}if(this.isLineLoop){const v=Vm(this,e,xu,l,m-1,p,m-1);v&&t.push(v)}}}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 r=0,a=n.length;r<a;r++){const o=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Vm(s,e,t,i,n,r,a){const o=s.geometry.attributes.position;if(zm.fromBufferAttribute(o,n),Hm.fromBufferAttribute(o,r),t.distanceSqToSegment(zm,Hm,ib,GE)>i)return;ib.applyMatrix4(s.matrixWorld);const c=e.ray.origin.distanceTo(ib);if(!(c<e.near||c>e.far))return{distance:c,point:GE.clone().applyMatrix4(s.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:s}}const VE=new P,WE=new P;class Oi extends Ci{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,r=t.count;n<r;n+=2)VE.fromBufferAttribute(t,n),WE.fromBufferAttribute(t,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+VE.distanceTo(WE);e.setAttribute("lineDistance",new it(i,1))}else Je("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class nb extends Ci{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Wm extends Ki{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new qe(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 QE=new Ke,sb=new Cr,Qm=new cn,jm=new P;class Xm extends Pt{constructor(e=new dt,t=new Wm){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,r=e.params.Points.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Qm.copy(i.boundingSphere),Qm.applyMatrix4(n),Qm.radius+=r,e.ray.intersectsSphere(Qm)===!1)return;QE.copy(n).invert(),sb.copy(e.ray).applyMatrix4(QE);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=i.index,d=i.attributes.position;if(c!==null){const u=Math.max(0,a.start),p=Math.min(c.count,a.start+a.count);for(let m=u,v=p;m<v;m++){const g=c.getX(m);jm.fromBufferAttribute(d,g),jE(jm,g,l,n,e,t,this)}}else{const u=Math.max(0,a.start),p=Math.min(d.count,a.start+a.count);for(let m=u,v=p;m<v;m++)jm.fromBufferAttribute(d,m),jE(jm,m,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 r=0,a=n.length;r<a;r++){const o=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function jE(s,e,t,i,n,r,a){const o=sb.distanceSqToPoint(s);if(o<t){const l=new P;sb.closestPointToPoint(s,l),l.applyMatrix4(i);const c=n.ray.origin.distanceTo(l);if(c<n.near||c>n.far)return;r.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class XE extends Ai{constructor(e,t,i,n,r=wt,a=wt,o,l,c){super(e,t,i,n,r,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 KB extends XE{constructor(e,t,i,n,r,a,o,l){super({},e,t,i,n,r,a,o,l),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class $B extends Ai{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Jt,this.minFilter=Jt,this.generateMipmaps=!1,this.needsUpdate=!0}}class lh extends Ai{constructor(e,t,i,n,r,a,o,l,c,h,d,u){super(null,a,o,l,c,h,n,r,d,u),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class qE extends lh{constructor(e,t,i,n,r,a){super(e,t,i,r,a),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=Bn,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class YE extends lh{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,wr),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class _u extends Ai{constructor(e=[],t=wr,i,n,r,a,o,l,c,h){super(e,t,i,n,r,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class KE extends Ai{constructor(e,t,i,n,r,a,o,l,c){super(e,t,i,n,r,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class so extends Ai{constructor(e,t,i=Ts,n,r,a,o=Jt,l=Jt,c,h=Er,d=1){if(h!==Er&&h!==Mr)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const u={width:e,height:t,depth:d};super(u,n,r,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 $a(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 $E extends so{constructor(e,t=Ts,i=wr,n,r,a=Jt,o=Jt,l,c=Er){const h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,t,i,n,r,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 rb extends Ai{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class fi extends dt{constructor(e=1,t=1,i=1,n=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:n,heightSegments:r,depthSegments:a};const o=this;n=Math.floor(n),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],h=[],d=[];let u=0,p=0;m("z","y","x",-1,-1,i,t,e,a,r,0),m("z","y","x",1,-1,i,t,-e,a,r,1),m("x","z","y",1,1,e,i,t,n,a,2),m("x","z","y",1,-1,e,i,-t,n,a,3),m("x","y","z",1,-1,e,t,i,n,r,4),m("x","y","z",-1,-1,e,t,-i,n,r,5),this.setIndex(l),this.setAttribute("position",new it(c,3)),this.setAttribute("normal",new it(h,3)),this.setAttribute("uv",new it(d,2));function m(v,g,f,A,b,y,x,_,M,E,w){const T=y/M,R=x/E,D=y/2,L=x/2,I=_/2,O=M+1,N=E+1;let G=0,V=0;const H=new P;for(let J=0;J<N;J++){const W=J*R-L;for(let X=0;X<O;X++){const me=X*T-D;H[v]=me*A,H[g]=W*b,H[f]=I,c.push(H.x,H.y,H.z),H[v]=0,H[g]=0,H[f]=_>0?1:-1,h.push(H.x,H.y,H.z),d.push(X/M),d.push(1-J/E),G+=1}}for(let J=0;J<E;J++)for(let W=0;W<M;W++){const X=u+W+O*J,me=u+W+O*(J+1),Ee=u+(W+1)+O*(J+1),Me=u+(W+1)+O*J;l.push(X,me,Me),l.push(me,Ee,Me),V+=6}o.addGroup(p,V,w),p+=V,u+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new fi(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class qm extends dt{constructor(e=1,t=1,i=4,n=8,r=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:i,radialSegments:n,heightSegments:r},t=Math.max(0,t),i=Math.max(1,Math.floor(i)),n=Math.max(3,Math.floor(n)),r=Math.max(1,Math.floor(r));const a=[],o=[],l=[],c=[],h=t/2,d=Math.PI/2*e,u=t,p=2*d+u,m=i*2+r,v=n+1,g=new P,f=new P;for(let A=0;A<=m;A++){let b=0,y=0,x=0,_=0;if(A<=i){const w=A/i,T=w*Math.PI/2;y=-h-e*Math.cos(T),x=e*Math.sin(T),_=-e*Math.cos(T),b=w*d}else if(A<=i+r){const w=(A-i)/r;y=-h+w*t,x=e,_=0,b=d+w*u}else{const w=(A-i-r)/i,T=w*Math.PI/2;y=h+e*Math.sin(T),x=e*Math.cos(T),_=e*Math.sin(T),b=d+u+w*d}const M=Math.max(0,Math.min(1,b/p));let E=0;A===0?E=.5/n:A===m&&(E=-.5/n);for(let w=0;w<=n;w++){const T=w/n,R=T*Math.PI*2,D=Math.sin(R),L=Math.cos(R);f.x=-x*L,f.y=y,f.z=x*D,o.push(f.x,f.y,f.z),g.set(-x*L,_,x*D),g.normalize(),l.push(g.x,g.y,g.z),c.push(T+E,M)}if(A>0){const w=(A-1)*v;for(let T=0;T<n;T++){const R=w+T,D=w+T+1,L=A*v+T,I=A*v+T+1;a.push(R,D,L),a.push(D,I,L)}}}this.setIndex(a),this.setAttribute("position",new it(o,3)),this.setAttribute("normal",new it(l,3)),this.setAttribute("uv",new it(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new qm(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class Ym extends dt{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 r=[],a=[],o=[],l=[],c=new P,h=new be;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let d=0,u=3;d<=t;d++,u+=3){const p=i+d/t*n;c.x=e*Math.cos(p),c.y=e*Math.sin(p),a.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(a[u]/e+1)/2,h.y=(a[u+1]/e+1)/2,l.push(h.x,h.y)}for(let d=1;d<=t;d++)r.push(d,d+1,0);this.setIndex(r),this.setAttribute("position",new it(a,3)),this.setAttribute("normal",new it(o,3)),this.setAttribute("uv",new it(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ym(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class $i extends dt{constructor(e=1,t=1,i=1,n=32,r=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:n,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:l};const c=this;n=Math.floor(n),r=Math.floor(r);const h=[],d=[],u=[],p=[];let m=0;const v=[],g=i/2;let f=0;A(),a===!1&&(e>0&&b(!0),t>0&&b(!1)),this.setIndex(h),this.setAttribute("position",new it(d,3)),this.setAttribute("normal",new it(u,3)),this.setAttribute("uv",new it(p,2));function A(){const y=new P,x=new P;let _=0;const M=(t-e)/i;for(let E=0;E<=r;E++){const w=[],T=E/r,R=T*(t-e)+e;for(let D=0;D<=n;D++){const L=D/n,I=L*l+o,O=Math.sin(I),N=Math.cos(I);x.x=R*O,x.y=-T*i+g,x.z=R*N,d.push(x.x,x.y,x.z),y.set(O,M,N).normalize(),u.push(y.x,y.y,y.z),p.push(L,1-T),w.push(m++)}v.push(w)}for(let E=0;E<n;E++)for(let w=0;w<r;w++){const T=v[w][E],R=v[w+1][E],D=v[w+1][E+1],L=v[w][E+1];(e>0||w!==0)&&(h.push(T,R,L),_+=3),(t>0||w!==r-1)&&(h.push(R,D,L),_+=3)}c.addGroup(f,_,0),f+=_}function b(y){const x=m,_=new be,M=new P;let E=0;const w=y===!0?e:t,T=y===!0?1:-1;for(let D=1;D<=n;D++)d.push(0,g*T,0),u.push(0,T,0),p.push(.5,.5),m++;const R=m;for(let D=0;D<=n;D++){const I=D/n*l+o,O=Math.cos(I),N=Math.sin(I);M.x=w*N,M.y=g*T,M.z=w*O,d.push(M.x,M.y,M.z),u.push(0,T,0),_.x=O*.5+.5,_.y=N*.5*T+.5,p.push(_.x,_.y),m++}for(let D=0;D<n;D++){const L=x+D,I=R+D;y===!0?h.push(I,I+1,L):h.push(I+1,I,L),E+=3}c.addGroup(f,E,y===!0?1:2),f+=E}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $i(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class wu extends $i{constructor(e=1,t=1,i=32,n=1,r=!1,a=0,o=Math.PI*2){super(0,e,t,i,n,r,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:n,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(e){return new wu(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class ro extends dt{constructor(e=[],t=[],i=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:n};const r=[],a=[];o(n),c(i),h(),this.setAttribute("position",new it(r,3)),this.setAttribute("normal",new it(r.slice(),3)),this.setAttribute("uv",new it(a,2)),n===0?this.computeVertexNormals():this.normalizeNormals();function o(A){const b=new P,y=new P,x=new P;for(let _=0;_<t.length;_+=3)p(t[_+0],b),p(t[_+1],y),p(t[_+2],x),l(b,y,x,A)}function l(A,b,y,x){const _=x+1,M=[];for(let E=0;E<=_;E++){M[E]=[];const w=A.clone().lerp(y,E/_),T=b.clone().lerp(y,E/_),R=_-E;for(let D=0;D<=R;D++)D===0&&E===_?M[E][D]=w:M[E][D]=w.clone().lerp(T,D/R)}for(let E=0;E<_;E++)for(let w=0;w<2*(_-E)-1;w++){const T=Math.floor(w/2);w%2===0?(u(M[E][T+1]),u(M[E+1][T]),u(M[E][T])):(u(M[E][T+1]),u(M[E+1][T+1]),u(M[E+1][T]))}}function c(A){const b=new P;for(let y=0;y<r.length;y+=3)b.x=r[y+0],b.y=r[y+1],b.z=r[y+2],b.normalize().multiplyScalar(A),r[y+0]=b.x,r[y+1]=b.y,r[y+2]=b.z}function h(){const A=new P;for(let b=0;b<r.length;b+=3){A.x=r[b+0],A.y=r[b+1],A.z=r[b+2];const y=g(A)/2/Math.PI+.5,x=f(A)/Math.PI+.5;a.push(y,1-x)}m(),d()}function d(){for(let A=0;A<a.length;A+=6){const b=a[A+0],y=a[A+2],x=a[A+4],_=Math.max(b,y,x),M=Math.min(b,y,x);_>.9&&M<.1&&(b<.2&&(a[A+0]+=1),y<.2&&(a[A+2]+=1),x<.2&&(a[A+4]+=1))}}function u(A){r.push(A.x,A.y,A.z)}function p(A,b){const y=A*3;b.x=e[y+0],b.y=e[y+1],b.z=e[y+2]}function m(){const A=new P,b=new P,y=new P,x=new P,_=new be,M=new be,E=new be;for(let w=0,T=0;w<r.length;w+=9,T+=6){A.set(r[w+0],r[w+1],r[w+2]),b.set(r[w+3],r[w+4],r[w+5]),y.set(r[w+6],r[w+7],r[w+8]),_.set(a[T+0],a[T+1]),M.set(a[T+2],a[T+3]),E.set(a[T+4],a[T+5]),x.copy(A).add(b).add(y).divideScalar(3);const R=g(x);v(_,T+0,A,R),v(M,T+2,b,R),v(E,T+4,y,R)}}function v(A,b,y,x){x<0&&A.x===1&&(a[b]=A.x-1),y.x===0&&y.z===0&&(a[b]=x/2/Math.PI+.5)}function g(A){return Math.atan2(A.z,-A.x)}function f(A){return Math.atan2(-A.y,Math.sqrt(A.x*A.x+A.z*A.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ro(e.vertices,e.indices,e.radius,e.detail)}}class Km extends ro{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,n=1/i,r=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,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(r,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Km(e.radius,e.detail)}}const $m=new P,Zm=new P,ab=new P,Jm=new ii;class ZE extends dt{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const n=Math.pow(10,4),r=Math.cos(ol*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),u={},p=[];for(let m=0;m<l;m+=3){a?(c[0]=a.getX(m),c[1]=a.getX(m+1),c[2]=a.getX(m+2)):(c[0]=m,c[1]=m+1,c[2]=m+2);const{a:v,b:g,c:f}=Jm;if(v.fromBufferAttribute(o,c[0]),g.fromBufferAttribute(o,c[1]),f.fromBufferAttribute(o,c[2]),Jm.getNormal(ab),d[0]=`${Math.round(v.x*n)},${Math.round(v.y*n)},${Math.round(v.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 A=0;A<3;A++){const b=(A+1)%3,y=d[A],x=d[b],_=Jm[h[A]],M=Jm[h[b]],E=`${y}_${x}`,w=`${x}_${y}`;w in u&&u[w]?(ab.dot(u[w].normal)<=r&&(p.push(_.x,_.y,_.z),p.push(M.x,M.y,M.z)),u[w]=null):E in u||(u[E]={index0:c[A],index1:c[b],normal:ab.clone()})}}for(const m in u)if(u[m]){const{index0:v,index1:g}=u[m];$m.fromBufferAttribute(o,v),Zm.fromBufferAttribute(o,g),p.push($m.x,$m.y,$m.z),p.push(Zm.x,Zm.y,Zm.z)}this.setAttribute("position",new it(p,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class Js{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){Je("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),r=0;t.push(0);for(let a=1;a<=e;a++)i=this.getPoint(a/e),r+=i.distanceTo(n),t.push(r),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 r=i.length;let a;t?a=t:a=e*i[r-1];let o=0,l=r-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/(r-1);const h=i[n],u=i[n+1]-h,p=(a-h)/u;return(n+p)/(r-1)}getTangent(e,t){let n=e-1e-4,r=e+1e-4;n<0&&(n=0),r>1&&(r=1);const a=this.getPoint(n),o=this.getPoint(r),l=t||(a.isVector2?new be:new P);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 P,n=[],r=[],a=[],o=new P,l=new Ke;for(let p=0;p<=e;p++){const m=p/e;n[p]=this.getTangentAt(m,new P)}r[0]=new P,a[0]=new P;let c=Number.MAX_VALUE;const h=Math.abs(n[0].x),d=Math.abs(n[0].y),u=Math.abs(n[0].z);h<=c&&(c=h,i.set(1,0,0)),d<=c&&(c=d,i.set(0,1,0)),u<=c&&i.set(0,0,1),o.crossVectors(n[0],i).normalize(),r[0].crossVectors(n[0],o),a[0].crossVectors(n[0],r[0]);for(let p=1;p<=e;p++){if(r[p]=r[p-1].clone(),a[p]=a[p-1].clone(),o.crossVectors(n[p-1],n[p]),o.length()>Number.EPSILON){o.normalize();const m=Math.acos(At(n[p-1].dot(n[p]),-1,1));r[p].applyMatrix4(l.makeRotationAxis(o,m))}a[p].crossVectors(n[p],r[p])}if(t===!0){let p=Math.acos(At(r[0].dot(r[e]),-1,1));p/=e,n[0].dot(o.crossVectors(r[0],r[e]))>0&&(p=-p);for(let m=1;m<=e;m++)r[m].applyMatrix4(l.makeRotationAxis(n[m],p*m)),a[m].crossVectors(n[m],r[m])}return{tangents:n,normals:r,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 Eu extends Js{constructor(e=0,t=0,i=1,n=1,r=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=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new be){const i=t,n=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=n;for(;r>n;)r-=n;r<Number.EPSILON&&(a?r=0:r=n),this.aClockwise===!0&&!a&&(r===n?r=-n:r=r-n);const o=this.aStartAngle+e*r;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),u=l-this.aX,p=c-this.aY;l=u*h-p*d+this.aX,c=u*d+p*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 JE extends Eu{constructor(e,t,i,n,r,a){super(e,t,i,i,n,r,a),this.isArcCurve=!0,this.type="ArcCurve"}}function ob(){let s=0,e=0,t=0,i=0;function n(r,a,o,l){s=r,e=o,t=-3*r+3*a-2*o-l,i=2*r-2*a+o+l}return{initCatmullRom:function(r,a,o,l,c){n(a,o,c*(o-r),c*(l-a))},initNonuniformCatmullRom:function(r,a,o,l,c,h,d){let u=(a-r)/c-(o-r)/(c+h)+(o-a)/h,p=(o-a)/h-(l-a)/(h+d)+(l-o)/d;u*=h,p*=h,n(a,o,u,p)},calc:function(r){const a=r*r,o=a*r;return s+e*r+t*a+i*o}}}const eg=new P,lb=new ob,cb=new ob,hb=new ob;class eM extends Js{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 P){const i=t,n=this.points,r=n.length,a=(r-(this.closed?0:1))*e;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/r)+1)*r:l===0&&o===r-1&&(o=r-2,l=1);let c,h;this.closed||o>0?c=n[(o-1)%r]:(eg.subVectors(n[0],n[1]).add(n[0]),c=eg);const d=n[o%r],u=n[(o+1)%r];if(this.closed||o+2<r?h=n[(o+2)%r]:(eg.subVectors(n[r-1],n[r-2]).add(n[r-1]),h=eg),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(d),p),v=Math.pow(d.distanceToSquared(u),p),g=Math.pow(u.distanceToSquared(h),p);v<1e-4&&(v=1),m<1e-4&&(m=v),g<1e-4&&(g=v),lb.initNonuniformCatmullRom(c.x,d.x,u.x,h.x,m,v,g),cb.initNonuniformCatmullRom(c.y,d.y,u.y,h.y,m,v,g),hb.initNonuniformCatmullRom(c.z,d.z,u.z,h.z,m,v,g)}else this.curveType==="catmullrom"&&(lb.initCatmullRom(c.x,d.x,u.x,h.x,this.tension),cb.initCatmullRom(c.y,d.y,u.y,h.y,this.tension),hb.initCatmullRom(c.z,d.z,u.z,h.z,this.tension));return i.set(lb.calc(l),cb.calc(l),hb.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 P().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function tM(s,e,t,i,n){const r=(i-e)*.5,a=(n-t)*.5,o=s*s,l=s*o;return(2*t-2*i+r+a)*l+(-3*t+3*i-2*r-a)*o+r*s+t}function ZB(s,e){const t=1-s;return t*t*e}function JB(s,e){return 2*(1-s)*s*e}function eL(s,e){return s*s*e}function Mu(s,e,t,i){return ZB(s,e)+JB(s,t)+eL(s,i)}function tL(s,e){const t=1-s;return t*t*t*e}function iL(s,e){const t=1-s;return 3*t*t*s*e}function nL(s,e){return 3*(1-s)*s*s*e}function sL(s,e){return s*s*s*e}function Su(s,e,t,i,n){return tL(s,e)+iL(s,t)+nL(s,i)+sL(s,n)}class db extends Js{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,r=this.v1,a=this.v2,o=this.v3;return i.set(Su(e,n.x,r.x,a.x,o.x),Su(e,n.y,r.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 iM extends Js{constructor(e=new P,t=new P,i=new P,n=new P){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=n}getPoint(e,t=new P){const i=t,n=this.v0,r=this.v1,a=this.v2,o=this.v3;return i.set(Su(e,n.x,r.x,a.x,o.x),Su(e,n.y,r.y,a.y,o.y),Su(e,n.z,r.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 ub extends Js{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 nM extends Js{constructor(e=new P,t=new P){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new P){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 P){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 pb extends Js{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,r=this.v1,a=this.v2;return i.set(Mu(e,n.x,r.x,a.x),Mu(e,n.y,r.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 fb extends Js{constructor(e=new P,t=new P,i=new P){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new P){const i=t,n=this.v0,r=this.v1,a=this.v2;return i.set(Mu(e,n.x,r.x,a.x),Mu(e,n.y,r.y,a.y),Mu(e,n.z,r.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 mb extends Js{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new be){const i=t,n=this.points,r=(n.length-1)*e,a=Math.floor(r),o=r-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(tM(o,l.x,c.x,h.x,d.x),tM(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 tg=Object.freeze({__proto__:null,ArcCurve:JE,CatmullRomCurve3:eM,CubicBezierCurve:db,CubicBezierCurve3:iM,EllipseCurve:Eu,LineCurve:ub,LineCurve3:nM,QuadraticBezierCurve:pb,QuadraticBezierCurve3:fb,SplineCurve:mb});class sM extends Js{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 tg[i](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),n=this.getCurveLengths();let r=0;for(;r<n.length;){if(n[r]>=i){const a=n[r]-i,o=this.curves[r],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}r++}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,r=this.curves;n<r.length;n++){const a=r[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 tg[n.type]().fromJSON(n))}return this}}class Cu extends sM{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 ub(this.currentPoint.clone(),new be(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,n){const r=new pb(this.currentPoint.clone(),new be(e,t),new be(i,n));return this.curves.push(r),this.currentPoint.set(i,n),this}bezierCurveTo(e,t,i,n,r,a){const o=new db(this.currentPoint.clone(),new be(e,t),new be(i,n),new be(r,a));return this.curves.push(o),this.currentPoint.set(r,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new mb(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,n,r,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,i,n,r,a),this}absarc(e,t,i,n,r,a){return this.absellipse(e,t,i,i,n,r,a),this}ellipse(e,t,i,n,r,a,o,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+c,t+h,i,n,r,a,o,l),this}absellipse(e,t,i,n,r,a,o,l){const c=new Eu(e,t,i,n,r,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 sa extends Cu{constructor(e){super(e),this.uuid=ds(),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 Cu().fromJSON(n))}return this}}function rL(s,e,t=2){const i=e&&e.length,n=i?e[0]*t:s.length;let r=rM(s,0,n,t,!0);const a=[];if(!r||r.next===r.prev)return a;let o,l,c;if(i&&(r=hL(s,e,r,t)),s.length>80*t){o=s[0],l=s[1];let h=o,d=l;for(let u=t;u<n;u+=t){const p=s[u],m=s[u+1];p<o&&(o=p),m<l&&(l=m),p>h&&(h=p),m>d&&(d=m)}c=Math.max(h-o,d-l),c=c!==0?32767/c:0}return Tu(r,a,t,o,l,c,0),a}function rM(s,e,t,i,n){let r;if(n===xL(s,e,t,i)>0)for(let a=e;a<t;a+=i)r=cM(a/i|0,s[a],s[a+1],r);else for(let a=t-i;a>=e;a-=i)r=cM(a/i|0,s[a],s[a+1],r);return r&&ch(r,r.next)&&(Du(r),r=r.next),r}function ml(s,e){if(!s)return s;e||(e=s);let t=s,i;do if(i=!1,!t.steiner&&(ch(t,t.next)||Ti(t.prev,t,t.next)===0)){if(Du(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Tu(s,e,t,i,n,r,a){if(!s)return;!a&&r&&mL(s,i,n,r);let o=s;for(;s.prev!==s.next;){const l=s.prev,c=s.next;if(r?oL(s,i,n,r):aL(s)){e.push(l.i,s.i,c.i),Du(s),s=c.next,o=c.next;continue}if(s=c,s===o){a?a===1?(s=lL(ml(s),e),Tu(s,e,t,i,n,r,2)):a===2&&cL(s,e,t,i,n,r):Tu(ml(s),e,t,i,n,r,1);break}}}function aL(s){const e=s.prev,t=s,i=s.next;if(Ti(e,t,i)>=0)return!1;const n=e.x,r=t.x,a=i.x,o=e.y,l=t.y,c=i.y,h=Math.min(n,r,a),d=Math.min(o,l,c),u=Math.max(n,r,a),p=Math.max(o,l,c);let m=i.next;for(;m!==e;){if(m.x>=h&&m.x<=u&&m.y>=d&&m.y<=p&&Iu(n,o,r,l,a,c,m.x,m.y)&&Ti(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function oL(s,e,t,i){const n=s.prev,r=s,a=s.next;if(Ti(n,r,a)>=0)return!1;const o=n.x,l=r.x,c=a.x,h=n.y,d=r.y,u=a.y,p=Math.min(o,l,c),m=Math.min(h,d,u),v=Math.max(o,l,c),g=Math.max(h,d,u),f=gb(p,m,e,t,i),A=gb(v,g,e,t,i);let b=s.prevZ,y=s.nextZ;for(;b&&b.z>=f&&y&&y.z<=A;){if(b.x>=p&&b.x<=v&&b.y>=m&&b.y<=g&&b!==n&&b!==a&&Iu(o,h,l,d,c,u,b.x,b.y)&&Ti(b.prev,b,b.next)>=0||(b=b.prevZ,y.x>=p&&y.x<=v&&y.y>=m&&y.y<=g&&y!==n&&y!==a&&Iu(o,h,l,d,c,u,y.x,y.y)&&Ti(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;b&&b.z>=f;){if(b.x>=p&&b.x<=v&&b.y>=m&&b.y<=g&&b!==n&&b!==a&&Iu(o,h,l,d,c,u,b.x,b.y)&&Ti(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;y&&y.z<=A;){if(y.x>=p&&y.x<=v&&y.y>=m&&y.y<=g&&y!==n&&y!==a&&Iu(o,h,l,d,c,u,y.x,y.y)&&Ti(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function lL(s,e){let t=s;do{const i=t.prev,n=t.next.next;!ch(i,n)&&oM(i,t,t.next,n)&&Pu(i,n)&&Pu(n,i)&&(e.push(i.i,t.i,n.i),Du(t),Du(t.next),t=s=n),t=t.next}while(t!==s);return ml(t)}function cL(s,e,t,i,n,r){let a=s;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&AL(a,o)){let l=lM(a,o);a=ml(a,a.next),l=ml(l,l.next),Tu(a,e,t,i,n,r,0),Tu(l,e,t,i,n,r,0);return}o=o.next}a=a.next}while(a!==s)}function hL(s,e,t,i){const n=[];for(let r=0,a=e.length;r<a;r++){const o=e[r]*i,l=r<a-1?e[r+1]*i:s.length,c=rM(s,o,l,i,!1);c===c.next&&(c.steiner=!0),n.push(vL(c))}n.sort(dL);for(let r=0;r<n.length;r++)t=uL(n[r],t);return t}function dL(s,e){let t=s.x-e.x;if(t===0&&(t=s.y-e.y,t===0)){const i=(s.next.y-s.y)/(s.next.x-s.x),n=(e.next.y-e.y)/(e.next.x-e.x);t=i-n}return t}function uL(s,e){const t=pL(s,e);if(!t)return e;const i=lM(t,s);return ml(i,i.next),ml(t,t.next)}function pL(s,e){let t=e;const i=s.x,n=s.y;let r=-1/0,a;if(ch(s,t))return t;do{if(ch(s,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>r&&(r=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&&aM(n<c?i:r,n,l,c,n<c?r:i,n,t.x,t.y)){const d=Math.abs(n-t.y)/(i-t.x);Pu(t,s)&&(d<h||d===h&&(t.x>a.x||t.x===a.x&&fL(a,t)))&&(a=t,h=d)}t=t.next}while(t!==o);return a}function fL(s,e){return Ti(s.prev,s,e.prev)<0&&Ti(e.next,s,s.next)<0}function mL(s,e,t,i){let n=s;do n.z===0&&(n.z=gb(n.x,n.y,e,t,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==s);n.prevZ.nextZ=null,n.prevZ=null,gL(n)}function gL(s){let e,t=1;do{let i=s,n;s=null;let r=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--),r?r.nextZ=n:s=n,n.prevZ=r,r=n;i=a}r.nextZ=null,t*=2}while(e>1);return s}function gb(s,e,t,i,n){return s=(s-t)*n|0,e=(e-i)*n|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function vL(s){let e=s,t=s;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==s);return t}function aM(s,e,t,i,n,r,a,o){return(n-a)*(e-o)>=(s-a)*(r-o)&&(s-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(r-o)>=(n-a)*(i-o)}function Iu(s,e,t,i,n,r,a,o){return!(s===a&&e===o)&&aM(s,e,t,i,n,r,a,o)}function AL(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!bL(s,e)&&(Pu(s,e)&&Pu(e,s)&&yL(s,e)&&(Ti(s.prev,s,e.prev)||Ti(s,e.prev,e))||ch(s,e)&&Ti(s.prev,s,s.next)>0&&Ti(e.prev,e,e.next)>0)}function Ti(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function ch(s,e){return s.x===e.x&&s.y===e.y}function oM(s,e,t,i){const n=ng(Ti(s,e,t)),r=ng(Ti(s,e,i)),a=ng(Ti(t,i,s)),o=ng(Ti(t,i,e));return!!(n!==r&&a!==o||n===0&&ig(s,t,e)||r===0&&ig(s,i,e)||a===0&&ig(t,s,i)||o===0&&ig(t,e,i))}function ig(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function ng(s){return s>0?1:s<0?-1:0}function bL(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&oM(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function Pu(s,e){return Ti(s.prev,s,s.next)<0?Ti(s,e,s.next)>=0&&Ti(s,s.prev,e)>=0:Ti(s,e,s.prev)<0||Ti(s,s.next,e)<0}function yL(s,e){let t=s,i=!1;const n=(s.x+e.x)/2,r=(s.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&n<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==s);return i}function lM(s,e){const t=vb(s.i,s.x,s.y),i=vb(e.i,e.x,e.y),n=s.next,r=e.prev;return s.next=e,e.prev=s,t.next=n,n.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function cM(s,e,t,i){const n=vb(s,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 Du(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function vb(s,e,t){return{i:s,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function xL(s,e,t,i){let n=0;for(let r=e,a=t-i;r<t;r+=i)n+=(s[a]-s[r])*(s[r+1]+s[a+1]),a=r;return n}class _L{static triangulate(e,t,i=2){return rL(e,t,i)}}class er{static area(e){const t=e.length;let i=0;for(let n=t-1,r=0;r<t;n=r++)i+=e[n].x*e[r].y-e[r].x*e[n].y;return i*.5}static isClockWise(e){return er.area(e)<0}static triangulateShape(e,t){const i=[],n=[],r=[];hM(e),dM(i,e);let a=e.length;t.forEach(hM);for(let l=0;l<t.length;l++)n.push(a),a+=t[l].length,dM(i,t[l]);const o=_L.triangulate(i,n);for(let l=0;l<o.length;l+=3)r.push(o.slice(l,l+3));return r}}function hM(s){const e=s.length;e>2&&s[e-1].equals(s[0])&&s.pop()}function dM(s,e){for(let t=0;t<e.length;t++)s.push(e[t].x),s.push(e[t].y)}class hh extends dt{constructor(e=new sa([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=[],r=[];for(let o=0,l=e.length;o<l;o++){const c=e[o];a(c)}this.setAttribute("position",new it(n,3)),this.setAttribute("uv",new it(r,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 u=t.bevelEnabled!==void 0?t.bevelEnabled:!0,p=t.bevelThickness!==void 0?t.bevelThickness:.2,m=t.bevelSize!==void 0?t.bevelSize:p-.1,v=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3;const f=t.extrudePath,A=t.UVGenerator!==void 0?t.UVGenerator:wL;let b,y=!1,x,_,M,E;if(f){b=f.getSpacedPoints(h),y=!0,u=!1;const B=f.isCatmullRomCurve3?f.closed:!1;x=f.computeFrenetFrames(h,B),_=new P,M=new P,E=new P}u||(g=0,p=0,m=0,v=0);const w=o.extractPoints(c);let T=w.shape;const R=w.holes;if(!er.isClockWise(T)){T=T.reverse();for(let B=0,re=R.length;B<re;B++){const ee=R[B];er.isClockWise(ee)&&(R[B]=ee.reverse())}}function L(B){const ee=10000000000000001e-36;let Q=B[0];for(let k=1;k<=B.length;k++){const ie=k%B.length,fe=B[ie],xe=fe.x-Q.x,te=fe.y-Q.y,C=xe*xe+te*te,S=Math.max(Math.abs(fe.x),Math.abs(fe.y),Math.abs(Q.x),Math.abs(Q.y)),F=ee*S*S;if(C<=F){B.splice(ie,1),k--;continue}Q=fe}}L(T),R.forEach(L);const I=R.length,O=T;for(let B=0;B<I;B++){const re=R[B];T=T.concat(re)}function N(B,re,ee){return re||ft("ExtrudeGeometry: vec does not exist"),B.clone().addScaledVector(re,ee)}const G=T.length;function V(B,re,ee){let Q,k,ie;const fe=B.x-re.x,xe=B.y-re.y,te=ee.x-B.x,C=ee.y-B.y,S=fe*fe+xe*xe,F=fe*C-xe*te;if(Math.abs(F)>Number.EPSILON){const q=Math.sqrt(S),K=Math.sqrt(te*te+C*C),Y=re.x-xe/q,ye=re.y+fe/q,pe=ee.x-C/K,Ue=ee.y+te/K,He=((pe-Y)*C-(Ue-ye)*te)/(fe*C-xe*te);Q=Y+fe*He-B.x,k=ye+xe*He-B.y;const oe=Q*Q+k*k;if(oe<=2)return new be(Q,k);ie=Math.sqrt(oe/2)}else{let q=!1;fe>Number.EPSILON?te>Number.EPSILON&&(q=!0):fe<-Number.EPSILON?te<-Number.EPSILON&&(q=!0):Math.sign(xe)===Math.sign(C)&&(q=!0),q?(Q=-xe,k=fe,ie=Math.sqrt(S)):(Q=fe,k=xe,ie=Math.sqrt(S/2))}return new be(Q/ie,k/ie)}const H=[];for(let B=0,re=O.length,ee=re-1,Q=B+1;B<re;B++,ee++,Q++)ee===re&&(ee=0),Q===re&&(Q=0),H[B]=V(O[B],O[ee],O[Q]);const J=[];let W,X=H.concat();for(let B=0,re=I;B<re;B++){const ee=R[B];W=[];for(let Q=0,k=ee.length,ie=k-1,fe=Q+1;Q<k;Q++,ie++,fe++)ie===k&&(ie=0),fe===k&&(fe=0),W[Q]=V(ee[Q],ee[ie],ee[fe]);J.push(W),X=X.concat(W)}let me;if(g===0)me=er.triangulateShape(O,R);else{const B=[],re=[];for(let ee=0;ee<g;ee++){const Q=ee/g,k=p*Math.cos(Q*Math.PI/2),ie=m*Math.sin(Q*Math.PI/2)+v;for(let fe=0,xe=O.length;fe<xe;fe++){const te=N(O[fe],H[fe],ie);Te(te.x,te.y,-k),Q===0&&B.push(te)}for(let fe=0,xe=I;fe<xe;fe++){const te=R[fe];W=J[fe];const C=[];for(let S=0,F=te.length;S<F;S++){const q=N(te[S],W[S],ie);Te(q.x,q.y,-k),Q===0&&C.push(q)}Q===0&&re.push(C)}}me=er.triangulateShape(B,re)}const Ee=me.length,Me=m+v;for(let B=0;B<G;B++){const re=u?N(T[B],X[B],Me):T[B];y?(M.copy(x.normals[0]).multiplyScalar(re.x),_.copy(x.binormals[0]).multiplyScalar(re.y),E.copy(b[0]).add(M).add(_),Te(E.x,E.y,E.z)):Te(re.x,re.y,0)}for(let B=1;B<=h;B++)for(let re=0;re<G;re++){const ee=u?N(T[re],X[re],Me):T[re];y?(M.copy(x.normals[B]).multiplyScalar(ee.x),_.copy(x.binormals[B]).multiplyScalar(ee.y),E.copy(b[B]).add(M).add(_),Te(E.x,E.y,E.z)):Te(ee.x,ee.y,d/h*B)}for(let B=g-1;B>=0;B--){const re=B/g,ee=p*Math.cos(re*Math.PI/2),Q=m*Math.sin(re*Math.PI/2)+v;for(let k=0,ie=O.length;k<ie;k++){const fe=N(O[k],H[k],Q);Te(fe.x,fe.y,d+ee)}for(let k=0,ie=R.length;k<ie;k++){const fe=R[k];W=J[k];for(let xe=0,te=fe.length;xe<te;xe++){const C=N(fe[xe],W[xe],Q);y?Te(C.x,C.y+b[h-1].y,b[h-1].x+ee):Te(C.x,C.y,d+ee)}}}$(),se();function $(){const B=n.length/3;if(u){let re=0,ee=G*re;for(let Q=0;Q<Ee;Q++){const k=me[Q];Le(k[2]+ee,k[1]+ee,k[0]+ee)}re=h+g*2,ee=G*re;for(let Q=0;Q<Ee;Q++){const k=me[Q];Le(k[0]+ee,k[1]+ee,k[2]+ee)}}else{for(let re=0;re<Ee;re++){const ee=me[re];Le(ee[2],ee[1],ee[0])}for(let re=0;re<Ee;re++){const ee=me[re];Le(ee[0]+G*h,ee[1]+G*h,ee[2]+G*h)}}i.addGroup(B,n.length/3-B,0)}function se(){const B=n.length/3;let re=0;he(O,re),re+=O.length;for(let ee=0,Q=R.length;ee<Q;ee++){const k=R[ee];he(k,re),re+=k.length}i.addGroup(B,n.length/3-B,1)}function he(B,re){let ee=B.length;for(;--ee>=0;){const Q=ee;let k=ee-1;k<0&&(k=B.length-1);for(let ie=0,fe=h+g*2;ie<fe;ie++){const xe=G*ie,te=G*(ie+1),C=re+Q+xe,S=re+k+xe,F=re+k+te,q=re+Q+te;Oe(C,S,F,q)}}}function Te(B,re,ee){l.push(B),l.push(re),l.push(ee)}function Le(B,re,ee){tt(B),tt(re),tt(ee);const Q=n.length/3,k=A.generateTopUV(i,n,Q-3,Q-2,Q-1);Ye(k[0]),Ye(k[1]),Ye(k[2])}function Oe(B,re,ee,Q){tt(B),tt(re),tt(Q),tt(re),tt(ee),tt(Q);const k=n.length/3,ie=A.generateSideWallUV(i,n,k-6,k-3,k-2,k-1);Ye(ie[0]),Ye(ie[1]),Ye(ie[3]),Ye(ie[1]),Ye(ie[2]),Ye(ie[3])}function tt(B){n.push(l[B*3+0]),n.push(l[B*3+1]),n.push(l[B*3+2])}function Ye(B){r.push(B.x),r.push(B.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 EL(t,i,e)}static fromJSON(e,t){const i=[];for(let r=0,a=e.shapes.length;r<a;r++){const o=t[e.shapes[r]];i.push(o)}const n=e.options.extrudePath;return n!==void 0&&(e.options.extrudePath=new tg[n.type]().fromJSON(n)),new hh(i,e.options)}}const wL={generateTopUV:function(s,e,t,i,n){const r=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(r,a),new be(o,l),new be(c,h)]},generateSideWallUV:function(s,e,t,i,n,r){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],u=e[n*3],p=e[n*3+1],m=e[n*3+2],v=e[r*3],g=e[r*3+1],f=e[r*3+2];return Math.abs(o-h)<Math.abs(a-c)?[new be(a,1-l),new be(c,1-d),new be(u,1-m),new be(v,1-f)]:[new be(o,1-l),new be(h,1-d),new be(p,1-m),new be(g,1-f)]}};function EL(s,e,t){if(t.shapes=[],Array.isArray(s))for(let i=0,n=s.length;i<n;i++){const r=s[i];t.shapes.push(r.uuid)}else t.shapes.push(s.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class sg extends ro{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],r=[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,r,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new sg(e.radius,e.detail)}}class rg extends dt{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=At(n,0,Math.PI*2);const r=[],a=[],o=[],l=[],c=[],h=1/t,d=new P,u=new be,p=new P,m=new P,v=new P;let g=0,f=0;for(let A=0;A<=e.length-1;A++)switch(A){case 0:g=e[A+1].x-e[A].x,f=e[A+1].y-e[A].y,p.x=f*1,p.y=-g,p.z=f*0,v.copy(p),p.normalize(),l.push(p.x,p.y,p.z);break;case e.length-1:l.push(v.x,v.y,v.z);break;default:g=e[A+1].x-e[A].x,f=e[A+1].y-e[A].y,p.x=f*1,p.y=-g,p.z=f*0,m.copy(p),p.x+=v.x,p.y+=v.y,p.z+=v.z,p.normalize(),l.push(p.x,p.y,p.z),v.copy(m)}for(let A=0;A<=t;A++){const b=i+A*h*n,y=Math.sin(b),x=Math.cos(b);for(let _=0;_<=e.length-1;_++){d.x=e[_].x*y,d.y=e[_].y,d.z=e[_].x*x,a.push(d.x,d.y,d.z),u.x=A/t,u.y=_/(e.length-1),o.push(u.x,u.y);const M=l[3*_+0]*y,E=l[3*_+1],w=l[3*_+0]*x;c.push(M,E,w)}}for(let A=0;A<t;A++)for(let b=0;b<e.length-1;b++){const y=b+A*e.length,x=y,_=y+e.length,M=y+e.length+1,E=y+1;r.push(x,_,E),r.push(M,E,_)}this.setIndex(r),this.setAttribute("position",new it(a,3)),this.setAttribute("uv",new it(o,2)),this.setAttribute("normal",new it(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new rg(e.points,e.segments,e.phiStart,e.phiLength)}}class ra extends ro{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 ra(e.radius,e.detail)}}class Ds extends dt{constructor(e=1,t=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:n};const r=e/2,a=t/2,o=Math.floor(i),l=Math.floor(n),c=o+1,h=l+1,d=e/o,u=t/l,p=[],m=[],v=[],g=[];for(let f=0;f<h;f++){const A=f*u-a;for(let b=0;b<c;b++){const y=b*d-r;m.push(y,-A,0),v.push(0,0,1),g.push(b/o),g.push(1-f/l)}}for(let f=0;f<l;f++)for(let A=0;A<o;A++){const b=A+c*f,y=A+c*(f+1),x=A+1+c*(f+1),_=A+1+c*f;p.push(b,y,_),p.push(y,x,_)}this.setIndex(p),this.setAttribute("position",new it(m,3)),this.setAttribute("normal",new it(v,3)),this.setAttribute("uv",new it(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ds(e.width,e.height,e.widthSegments,e.heightSegments)}}class ag extends dt{constructor(e=.5,t=1,i=32,n=1,r=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:n,thetaStart:r,thetaLength:a},i=Math.max(3,i),n=Math.max(1,n);const o=[],l=[],c=[],h=[];let d=e;const u=(t-e)/n,p=new P,m=new be;for(let v=0;v<=n;v++){for(let g=0;g<=i;g++){const f=r+g/i*a;p.x=d*Math.cos(f),p.y=d*Math.sin(f),l.push(p.x,p.y,p.z),c.push(0,0,1),m.x=(p.x/t+1)/2,m.y=(p.y/t+1)/2,h.push(m.x,m.y)}d+=u}for(let v=0;v<n;v++){const g=v*(i+1);for(let f=0;f<i;f++){const A=f+g,b=A,y=A+i+1,x=A+i+2,_=A+1;o.push(b,y,_),o.push(y,x,_)}}this.setIndex(o),this.setAttribute("position",new it(l,3)),this.setAttribute("normal",new it(c,3)),this.setAttribute("uv",new it(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ag(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Ru extends dt{constructor(e=new sa([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=[],r=[],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 it(n,3)),this.setAttribute("normal",new it(r,3)),this.setAttribute("uv",new it(a,2));function c(h){const d=n.length/3,u=h.extractPoints(t);let p=u.shape;const m=u.holes;er.isClockWise(p)===!1&&(p=p.reverse());for(let g=0,f=m.length;g<f;g++){const A=m[g];er.isClockWise(A)===!0&&(m[g]=A.reverse())}const v=er.triangulateShape(p,m);for(let g=0,f=m.length;g<f;g++){const A=m[g];p=p.concat(A)}for(let g=0,f=p.length;g<f;g++){const A=p[g];n.push(A.x,A.y,0),r.push(0,0,1),a.push(A.x,A.y)}for(let g=0,f=v.length;g<f;g++){const A=v[g],b=A[0]+d,y=A[1]+d,x=A[2]+d;i.push(b,y,x),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 ML(t,e)}static fromJSON(e,t){const i=[];for(let n=0,r=e.shapes.length;n<r;n++){const a=t[e.shapes[n]];i.push(a)}return new Ru(i,e.curveSegments)}}function ML(s,e){if(e.shapes=[],Array.isArray(s))for(let t=0,i=s.length;t<i;t++){const n=s[t];e.shapes.push(n.uuid)}else e.shapes.push(s.uuid);return e}class ao extends dt{constructor(e=1,t=32,i=16,n=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:n,phiLength:r,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 P,u=new P,p=[],m=[],v=[],g=[];for(let f=0;f<=i;f++){const A=[],b=f/i;let y=0;f===0&&a===0?y=.5/t:f===i&&l===Math.PI&&(y=-.5/t);for(let x=0;x<=t;x++){const _=x/t;d.x=-e*Math.cos(n+_*r)*Math.sin(a+b*o),d.y=e*Math.cos(a+b*o),d.z=e*Math.sin(n+_*r)*Math.sin(a+b*o),m.push(d.x,d.y,d.z),u.copy(d).normalize(),v.push(u.x,u.y,u.z),g.push(_+y,1-b),A.push(c++)}h.push(A)}for(let f=0;f<i;f++)for(let A=0;A<t;A++){const b=h[f][A+1],y=h[f][A],x=h[f+1][A],_=h[f+1][A+1];(f!==0||a>0)&&p.push(b,y,_),(f!==i-1||l<Math.PI)&&p.push(y,x,_)}this.setIndex(p),this.setAttribute("position",new it(m,3)),this.setAttribute("normal",new it(v,3)),this.setAttribute("uv",new it(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ao(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class og extends ro{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 og(e.radius,e.detail)}}class aa extends dt{constructor(e=1,t=.4,i=12,n=48,r=Math.PI*2,a=0,o=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:n,arc:r,thetaStart:a,thetaLength:o},i=Math.floor(i),n=Math.floor(n);const l=[],c=[],h=[],d=[],u=new P,p=new P,m=new P;for(let v=0;v<=i;v++){const g=a+v/i*o;for(let f=0;f<=n;f++){const A=f/n*r;p.x=(e+t*Math.cos(g))*Math.cos(A),p.y=(e+t*Math.cos(g))*Math.sin(A),p.z=t*Math.sin(g),c.push(p.x,p.y,p.z),u.x=e*Math.cos(A),u.y=e*Math.sin(A),m.subVectors(p,u).normalize(),h.push(m.x,m.y,m.z),d.push(f/n),d.push(v/i)}}for(let v=1;v<=i;v++)for(let g=1;g<=n;g++){const f=(n+1)*v+g-1,A=(n+1)*(v-1)+g-1,b=(n+1)*(v-1)+g,y=(n+1)*v+g;l.push(f,A,y),l.push(A,b,y)}this.setIndex(l),this.setAttribute("position",new it(c,3)),this.setAttribute("normal",new it(h,3)),this.setAttribute("uv",new it(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new aa(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class lg extends dt{constructor(e=1,t=.4,i=64,n=8,r=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:n,p:r,q:a},i=Math.floor(i),n=Math.floor(n);const o=[],l=[],c=[],h=[],d=new P,u=new P,p=new P,m=new P,v=new P,g=new P,f=new P;for(let b=0;b<=i;++b){const y=b/i*r*Math.PI*2;A(y,r,a,e,p),A(y+.01,r,a,e,m),g.subVectors(m,p),f.addVectors(m,p),v.crossVectors(g,f),f.crossVectors(v,g),v.normalize(),f.normalize();for(let x=0;x<=n;++x){const _=x/n*Math.PI*2,M=-t*Math.cos(_),E=t*Math.sin(_);d.x=p.x+(M*f.x+E*v.x),d.y=p.y+(M*f.y+E*v.y),d.z=p.z+(M*f.z+E*v.z),l.push(d.x,d.y,d.z),u.subVectors(d,p).normalize(),c.push(u.x,u.y,u.z),h.push(b/i),h.push(x/n)}}for(let b=1;b<=i;b++)for(let y=1;y<=n;y++){const x=(n+1)*(b-1)+(y-1),_=(n+1)*b+(y-1),M=(n+1)*b+y,E=(n+1)*(b-1)+y;o.push(x,_,E),o.push(_,M,E)}this.setIndex(o),this.setAttribute("position",new it(l,3)),this.setAttribute("normal",new it(c,3)),this.setAttribute("uv",new it(h,2));function A(b,y,x,_,M){const E=Math.cos(b),w=Math.sin(b),T=x/y*b,R=Math.cos(T);M.x=_*(2+R)*.5*E,M.y=_*(2+R)*w*.5,M.z=_*Math.sin(T)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new lg(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class cg extends dt{constructor(e=new fb(new P(-1,-1,0),new P(-1,1,0),new P(1,1,0)),t=64,i=1,n=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:n,closed:r};const a=e.computeFrenetFrames(t,r);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const o=new P,l=new P,c=new be;let h=new P;const d=[],u=[],p=[],m=[];v(),this.setIndex(m),this.setAttribute("position",new it(d,3)),this.setAttribute("normal",new it(u,3)),this.setAttribute("uv",new it(p,2));function v(){for(let b=0;b<t;b++)g(b);g(r===!1?t:0),A(),f()}function g(b){h=e.getPointAt(b/t,h);const y=a.normals[b],x=a.binormals[b];for(let _=0;_<=n;_++){const M=_/n*Math.PI*2,E=Math.sin(M),w=-Math.cos(M);l.x=w*y.x+E*x.x,l.y=w*y.y+E*x.y,l.z=w*y.z+E*x.z,l.normalize(),u.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 x=(n+1)*(b-1)+(y-1),_=(n+1)*b+(y-1),M=(n+1)*b+y,E=(n+1)*(b-1)+y;m.push(x,_,E),m.push(_,M,E)}}function A(){for(let b=0;b<=t;b++)for(let y=0;y<=n;y++)c.x=b/t,c.y=y/n,p.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 cg(new tg[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class uM extends dt{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],i=new Set,n=new P,r=new P;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],u=d.start,p=d.count;for(let m=u,v=u+p;m<v;m+=3)for(let g=0;g<3;g++){const f=o.getX(m+g),A=o.getX(m+(g+1)%3);n.fromBufferAttribute(a,f),r.fromBufferAttribute(a,A),pM(n,r,i)===!0&&(t.push(n.x,n.y,n.z),t.push(r.x,r.y,r.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),r.fromBufferAttribute(a,d),pM(n,r,i)===!0&&(t.push(n.x,n.y,n.z),t.push(r.x,r.y,r.z))}}this.setAttribute("position",new it(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function pM(s,e,t){const i=`${s.x},${s.y},${s.z}-${e.x},${e.y},${e.z}`,n=`${e.x},${e.y},${e.z}-${s.x},${s.y},${s.z}`;return t.has(i)===!0||t.has(n)===!0?!1:(t.add(i),t.add(n),!0)}var fM=Object.freeze({__proto__:null,BoxGeometry:fi,CapsuleGeometry:qm,CircleGeometry:Ym,ConeGeometry:wu,CylinderGeometry:$i,DodecahedronGeometry:Km,EdgesGeometry:ZE,ExtrudeGeometry:hh,IcosahedronGeometry:sg,LatheGeometry:rg,OctahedronGeometry:ra,PlaneGeometry:Ds,PolyhedronGeometry:ro,RingGeometry:ag,ShapeGeometry:Ru,SphereGeometry:ao,TetrahedronGeometry:og,TorusGeometry:aa,TorusKnotGeometry:lg,TubeGeometry:cg,WireframeGeometry:uM});class mM extends Ki{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new qe(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 dh(s){const e={};for(const t in s){e[t]={};for(const i in s[t]){const n=s[t][i];n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)?n.isRenderTargetTexture?(Je("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(s){const e={};for(let t=0;t<s.length;t++){const i=dh(s[t]);for(const n in i)e[n]=i[n]}return e}function SL(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function gM(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:It.workingColorSpace}const Mn={clone:dh,merge:Fn};var CL=`void main() {
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,TL=`void main() {
|
||
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
||
}`;class mi extends Ki{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=CL,this.fragmentShader=TL,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=dh(e.uniforms),this.uniformsGroups=SL(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 hg extends mi{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class oo extends Ki{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new qe(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 qe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ya,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 Yi,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 Rs extends oo{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 At(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 qe(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 qe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new qe(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 vM extends Ki{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new qe(16777215),this.specular=new qe(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ya,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 Yi,this.combine=kd,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 AM extends Ki{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new qe(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ya,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 dg extends Ki{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ya,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 Ab extends Ki{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new qe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ya,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 Yi,this.combine=kd,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 bb extends Ki{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Kw,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 yb extends Ki{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 bM extends Ki{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new qe(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ya,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 yM extends bi{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 gl(s,e){return!s||s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function xM(s){function e(n,r){return s[n]-s[r]}const t=s.length,i=new Array(t);for(let n=0;n!==t;++n)i[n]=n;return i.sort(e),i}function xb(s,e,t){const i=s.length,n=new s.constructor(i);for(let r=0,a=0;a!==i;++r){const o=t[r]*e;for(let l=0;l!==e;++l)n[a++]=s[o+l]}return n}function _b(s,e,t,i){let n=1,r=s[0];for(;r!==void 0&&r[i]===void 0;)r=s[n++];if(r===void 0)return;let a=r[i];if(a!==void 0)if(Array.isArray(a))do a=r[i],a!==void 0&&(e.push(r.time),t.push(...a)),r=s[n++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[i],a!==void 0&&(e.push(r.time),a.toArray(t,t.length)),r=s[n++];while(r!==void 0);else do a=r[i],a!==void 0&&(e.push(r.time),t.push(a)),r=s[n++];while(r!==void 0)}function IL(s,e,t,i,n=30){const r=s.clone();r.name=e;const a=[];for(let l=0;l<r.tracks.length;++l){const c=r.tracks[l],h=c.getValueSize(),d=[],u=[];for(let p=0;p<c.times.length;++p){const m=c.times[p]*n;if(!(m<t||m>=i)){d.push(c.times[p]);for(let v=0;v<h;++v)u.push(c.values[p*h+v])}}d.length!==0&&(c.times=gl(d,c.times.constructor),c.values=gl(u,c.values.constructor),a.push(c))}r.tracks=a;let o=1/0;for(let l=0;l<r.tracks.length;++l)o>r.tracks[l].times[0]&&(o=r.tracks[l].times[0]);for(let l=0;l<r.tracks.length;++l)r.tracks[l].shift(-1*o);return r.resetDuration(),r}function PL(s,e=0,t=s,i=30){i<=0&&(i=30);const n=t.tracks.length,r=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=s.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 u=0;const p=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=p/3);const m=o.times.length-1;let v;if(r<=o.times[0]){const f=h,A=d-h;v=o.values.slice(f,A)}else if(r>=o.times[m]){const f=m*d+h,A=f+d-h;v=o.values.slice(f,A)}else{const f=o.createInterpolant(),A=h,b=d-h;f.evaluate(r),v=f.resultBuffer.slice(A,b)}l==="quaternion"&&new Lt().fromArray(v).normalize().conjugate().toArray(v);const g=c.times.length;for(let f=0;f<g;++f){const A=f*p+u;if(l==="quaternion")Lt.multiplyQuaternionsFlat(c.values,A,v,0,c.values,A);else{const b=p-u*2;for(let y=0;y<b;++y)c.values[A+y]-=v[y]}}}return s.blendMode=xA,s}class DL{static convertArray(e,t){return gl(e,t)}static isTypedArray(e){return sE(e)}static getKeyframeOrder(e){return xM(e)}static sortedArray(e,t,i){return xb(e,t,i)}static flattenJSON(e,t,i,n){_b(e,t,i,n)}static subclip(e,t,i,n,r=30){return IL(e,t,i,n,r)}static makeClipAdditive(e,t=0,i=e,n=30){return PL(e,t,i,n)}}class vl{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],r=t[i-1];e:{t:{let a;i:{n:if(!(e<n)){for(let o=i+2;;){if(n===void 0){if(e<r)break n;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(r=n,n=t[++i],e<n)break t}a=t.length;break i}if(!(e>=r)){const o=t[1];e<o&&(i=2,r=o);for(let l=i-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(n=r,r=t[--i-1],e>=r)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],r=t[i-1],r===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,r,n)}return this.interpolate_(i,r,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n;for(let a=0;a!==n;++a)t[a]=i[r+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class _M extends vl{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:nl,endingEnd:nl}}intervalChanged_(e,t,i){const n=this.parameterPositions;let r=e-2,a=e+1,o=n[r],l=n[a];if(o===void 0)switch(this.getSettings_().endingStart){case sl:r=e,o=2*t-i;break;case Jd:r=n.length-2,o=t+n[r]-n[r+1];break;default:r=e,o=i}if(l===void 0)switch(this.getSettings_().endingEnd){case sl:a=e,l=2*i-t;break;case Jd: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=r*h,this._offsetNext=a*h}interpolate_(e,t,i,n){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this._offsetPrev,d=this._offsetNext,u=this._weightPrev,p=this._weightNext,m=(i-t)/(n-t),v=m*m,g=v*m,f=-u*g+2*u*v-u*m,A=(1+u)*g+(-1.5-2*u)*v+(-.5+u)*m+1,b=(-1-p)*g+(1.5+p)*v+.5*m,y=p*g-p*v;for(let x=0;x!==o;++x)r[x]=f*a[h+x]+A*a[c+x]+b*a[l+x]+y*a[d+x];return r}}class wb extends vl{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=(i-t)/(n-t),d=1-h;for(let u=0;u!==o;++u)r[u]=a[c+u]*d+a[l+u]*h;return r}}class wM extends vl{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class EM extends vl{interpolate_(e,t,i,n){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this.settings||this.DefaultSettings_,d=h.inTangents,u=h.outTangents;if(!d||!u){const v=(i-t)/(n-t),g=1-v;for(let f=0;f!==o;++f)r[f]=a[c+f]*g+a[l+f]*v;return r}const p=o*2,m=e-1;for(let v=0;v!==o;++v){const g=a[c+v],f=a[l+v],A=m*p+v*2,b=u[A],y=u[A+1],x=e*p+v*2,_=d[x],M=d[x+1];let E=(i-t)/(n-t),w,T,R,D,L;for(let I=0;I<8;I++){w=E*E,T=w*E,R=1-E,D=R*R,L=D*R;const N=L*t+3*D*E*b+3*R*w*_+T*n-i;if(Math.abs(N)<1e-10)break;const G=3*D*(b-t)+6*R*E*(_-b)+3*w*(n-_);if(Math.abs(G)<1e-10)break;E=E-N/G,E=Math.max(0,Math.min(1,E))}r[v]=L*g+3*D*E*y+3*R*w*M+T*f}return r}}class Bs{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=gl(t,this.TimeBufferType),this.values=gl(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:gl(e.times,Array),values:gl(e.values,Array)};const n=e.getInterpolation();n!==e.DefaultInterpolation&&(i.interpolation=n)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new wM(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new wb(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new _M(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){const t=new EM(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.settings=this.settings),t}setInterpolation(e){let t;switch(e){case zc:t=this.InterpolantFactoryMethodDiscrete;break;case Hc:t=this.InterpolantFactoryMethodLinear;break;case im:t=this.InterpolantFactoryMethodSmooth;break;case yA: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 Je("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return zc;case this.InterpolantFactoryMethodLinear:return Hc;case this.InterpolantFactoryMethodSmooth:return im;case this.InterpolantFactoryMethodBezier:return yA}}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 r=0,a=n-1;for(;r!==n&&i[r]<e;)++r;for(;a!==-1&&i[a]>t;)--a;if(++a,r!==0||a!==n){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=i.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(ft("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,n=this.values,r=i.length;r===0&&(ft("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){const l=i[o];if(typeof l=="number"&&isNaN(l)){ft("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){ft("KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(n!==void 0&&sE(n))for(let o=0,l=n.length;o!==l;++o){const c=n[o];if(isNaN(c)){ft("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()===im,r=e.length-1;let a=1;for(let o=1;o<r;++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,u=d-i,p=d+i;for(let m=0;m!==i;++m){const v=t[d+m];if(v!==t[u+m]||v!==t[p+m]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const d=o*i,u=a*i;for(let p=0;p!==i;++p)t[u+p]=t[d+p]}++a}}if(r>0){e[a]=e[r];for(let o=r*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}}Bs.prototype.ValueTypeName="",Bs.prototype.TimeBufferType=Float32Array,Bs.prototype.ValueBufferType=Float32Array,Bs.prototype.DefaultInterpolation=Hc;class Al extends Bs{constructor(e,t,i){super(e,t,i)}}Al.prototype.ValueTypeName="bool",Al.prototype.ValueBufferType=Array,Al.prototype.DefaultInterpolation=zc,Al.prototype.InterpolantFactoryMethodLinear=void 0,Al.prototype.InterpolantFactoryMethodSmooth=void 0;class Eb extends Bs{constructor(e,t,i,n){super(e,t,i,n)}}Eb.prototype.ValueTypeName="color";class bl extends Bs{constructor(e,t,i,n){super(e,t,i,n)}}bl.prototype.ValueTypeName="number";class MM extends vl{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=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)Lt.slerpFlat(r,0,a,c-o,a,c,l);return r}}class yl extends Bs{constructor(e,t,i,n){super(e,t,i,n)}InterpolantFactoryMethodLinear(e){return new MM(this.times,this.values,this.getValueSize(),e)}}yl.prototype.ValueTypeName="quaternion",yl.prototype.InterpolantFactoryMethodSmooth=void 0;class xl extends Bs{constructor(e,t,i){super(e,t,i)}}xl.prototype.ValueTypeName="string",xl.prototype.ValueBufferType=Array,xl.prototype.DefaultInterpolation=zc,xl.prototype.InterpolantFactoryMethodLinear=void 0,xl.prototype.InterpolantFactoryMethodSmooth=void 0;class _l extends Bs{constructor(e,t,i,n){super(e,t,i,n)}}_l.prototype.ValueTypeName="vector";class uh{constructor(e="",t=-1,i=[],n=nm){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=ds(),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(BL(i[a]).scale(n));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}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 r=0,a=i.length;r!==a;++r)t.push(Bs.toJSON(i[r]));return n}static CreateFromMorphTargetSequence(e,t,i,n){const r=t.length,a=[];for(let o=0;o<r;o++){let l=[],c=[];l.push((o+r-1)%r,o,(o+1)%r),c.push(0,1,0);const h=xM(l);l=xb(l,1,h),c=xb(c,1,h),!n&&l[0]===0&&(l.push(r),c.push(c[0])),a.push(new bl(".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={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],h=c.name.match(r);if(h&&h.length>1){const d=h[1];let u=n[d];u||(n[d]=u=[]),u.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(Je("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return ft("AnimationClip: No animation in JSONLoader data."),null;const i=function(d,u,p,m,v){if(p.length!==0){const g=[],f=[];_b(p,g,f,m),g.length!==0&&v.push(new d(u,g,f))}},n=[],r=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 u=c[d].keys;if(!(!u||u.length===0))if(u[0].morphTargets){const p={};let m;for(m=0;m<u.length;m++)if(u[m].morphTargets)for(let v=0;v<u[m].morphTargets.length;v++)p[u[m].morphTargets[v]]=-1;for(const v in p){const g=[],f=[];for(let A=0;A!==u[m].morphTargets.length;++A){const b=u[m];g.push(b.time),f.push(b.morphTarget===v?1:0)}n.push(new bl(".morphTargetInfluence["+v+"]",g,f))}l=p.length*a}else{const p=".bones["+t[d].name+"]";i(_l,p+".position",u,"pos",n),i(yl,p+".quaternion",u,"rot",n),i(_l,p+".scale",u,"scl",n)}}return n.length===0?null:new this(r,l,n,o)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,n=e.length;i!==n;++i){const r=this.tracks[i];t=Math.max(t,r.times[r.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 RL(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return bl;case"vector":case"vector2":case"vector3":case"vector4":return _l;case"color":return Eb;case"quaternion":return yl;case"bool":case"boolean":return Al;case"string":return xl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function BL(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=RL(s.type);if(s.times===void 0){const t=[],i=[];_b(s.keys,t,i,"value"),s.times=t,s.values=i}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const Pr={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(SM(s)||(this.files[s]=e))},get:function(s){if(this.enabled!==!1&&!SM(s))return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};function SM(s){try{const e=s.slice(s.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}class Mb{constructor(e,t,i){const n=this;let r=!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++,r===!1&&n.onStart!==void 0&&n.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,n.onProgress!==void 0&&n.onProgress(h,a,o),a===o&&(r=!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,u=c.length;d<u;d+=2){const p=c[d],m=c[d+1];if(p.global&&(p.lastIndex=0),p.test(h))return m}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 CM=new Mb;class dn{constructor(e){this.manager=e!==void 0?e:CM,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,r){i.load(e,n,t,r)})}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}}dn.DEFAULT_MATERIAL_NAME="__DEFAULT";const oa={};class LL extends Error{constructor(e,t){super(e),this.response=t}}class gn extends dn{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 r=Pr.get(`file:${e}`);if(r!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(oa[e]!==void 0){oa[e].push({onLoad:t,onProgress:i,onError:n});return}oa[e]=[],oa[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&&Je("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=oa[e],d=c.body.getReader(),u=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),p=u?parseInt(u):0,m=p!==0;let v=0;const g=new ReadableStream({start(f){A();function A(){d.read().then(({done:b,value:y})=>{if(b)f.close();else{v+=y.byteLength;const x=new ProgressEvent("progress",{lengthComputable:m,loaded:v,total:p});for(let _=0,M=h.length;_<M;_++){const E=h[_];E.onProgress&&E.onProgress(x)}f.enqueue(y),A()}},b=>{f.error(b)})}}});return new Response(g)}else throw new LL(`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),u=d&&d[1]?d[1].toLowerCase():void 0,p=new TextDecoder(u);return c.arrayBuffer().then(m=>p.decode(m))}}}).then(c=>{Pr.add(`file:${e}`,c);const h=oa[e];delete oa[e];for(let d=0,u=h.length;d<u;d++){const p=h[d];p.onLoad&&p.onLoad(c)}}).catch(c=>{const h=oa[e];if(h===void 0)throw this.manager.itemError(e),c;delete oa[e];for(let d=0,u=h.length;d<u;d++){const p=h[d];p.onError&&p.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 kL extends dn{constructor(e){super(e)}load(e,t,i,n){const r=this,a=new gn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(r.parse(JSON.parse(o)))}catch(l){n?n(l):ft(l),r.manager.itemError(e)}},i,n)}parse(e){const t=[];for(let i=0;i<e.length;i++){const n=uh.parse(e[i]);t.push(n)}return t}}class OL extends dn{constructor(e){super(e)}load(e,t,i,n){const r=this,a=[],o=new lh,l=new gn(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(r.withCredentials);let c=0;function h(d){l.load(e[d],function(u){const p=r.parse(u,!0);a[d]={width:p.width,height:p.height,format:p.format,mipmaps:p.mipmaps},c+=1,c===6&&(p.mipmapCount===1&&(o.minFilter=wt),o.image=a,o.format=p.format,o.needsUpdate=!0,t&&t(o))},i,n)}if(Array.isArray(e))for(let d=0,u=e.length;d<u;++d)h(d);else l.load(e,function(d){const u=r.parse(d,!0);if(u.isCubemap){const p=u.mipmaps.length/u.mipmapCount;for(let m=0;m<p;m++){a[m]={mipmaps:[]};for(let v=0;v<u.mipmapCount;v++)a[m].mipmaps.push(u.mipmaps[m*u.mipmapCount+v]),a[m].format=u.format,a[m].width=u.width,a[m].height=u.height}o.image=a}else o.image.width=u.width,o.image.height=u.height,o.mipmaps=u.mipmaps;u.mipmapCount===1&&(o.minFilter=wt),o.format=u.format,o.needsUpdate=!0,t&&t(o)},i,n);return o}}const ph=new WeakMap;class Bu extends dn{constructor(e){super(e)}load(e,t,i,n){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Pr.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)r.manager.itemStart(e),setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);else{let d=ph.get(a);d===void 0&&(d=[],ph.set(a,d)),d.push({onLoad:t,onError:n})}return a}const o=iu("img");function l(){h(),t&&t(this);const d=ph.get(this)||[];for(let u=0;u<d.length;u++){const p=d[u];p.onLoad&&p.onLoad(this)}ph.delete(this),r.manager.itemEnd(e)}function c(d){h(),n&&n(d),Pr.remove(`image:${e}`);const u=ph.get(this)||[];for(let p=0;p<u.length;p++){const m=u[p];m.onError&&m.onError(d)}ph.delete(this),r.manager.itemError(e),r.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),Pr.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class FL extends dn{constructor(e){super(e)}load(e,t,i,n){const r=new _u;r.colorSpace=ci;const a=new Bu(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function l(c){a.load(e[c],function(h){r.images[c]=h,o++,o===6&&(r.needsUpdate=!0,t&&t(r))},void 0,n)}for(let c=0;c<e.length;++c)l(c);return r}}class TM extends dn{constructor(e){super(e)}load(e,t,i,n){const r=this,a=new On,o=new gn(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(r.withCredentials),o.load(e,function(l){let c;try{c=r.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:Bn,a.wrapT=c.wrapT!==void 0?c.wrapT:Bn,a.magFilter=c.magFilter!==void 0?c.magFilter:wt,a.minFilter=c.minFilter!==void 0?c.minFilter:wt,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=$n),c.mipmapCount===1&&(a.minFilter=wt),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c)},i,n),a}}class lo extends dn{constructor(e){super(e)}load(e,t,i,n){const r=new Ai,a=new Bu(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){r.image=o,r.needsUpdate=!0,t!==void 0&&t(r)},i,n),r}}class co extends Pt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new qe(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 IM extends co{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new qe(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 Sb=new Ke,PM=new P,DM=new P;class Cb{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=bt,this.map=null,this.mapPass=null,this.matrix=new Ke,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new oh,this._frameExtents=new be(1,1),this._viewportCount=1,this._viewports=[new zt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;PM.setFromMatrixPosition(e.matrixWorld),t.position.copy(PM),DM.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(DM),t.updateMatrixWorld(),Sb.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Sb,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===al||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(Sb)}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 ug=new P,pg=new Lt,Dr=new P;class fg extends Pt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ke,this.projectionMatrix=new Ke,this.projectionMatrixInverse=new Ke,this.coordinateSystem=hs,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(ug,pg,Dr),Dr.x===1&&Dr.y===1&&Dr.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ug,pg,Dr.set(1,1,1)).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorld.decompose(ug,pg,Dr),Dr.x===1&&Dr.y===1&&Dr.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ug,pg,Dr.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const ho=new P,RM=new be,BM=new be;class wi extends fg{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=Vc*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(ol*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Vc*2*Math.atan(Math.tan(ol*.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){ho.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ho.x,ho.y).multiplyScalar(-e/ho.z),ho.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(ho.x,ho.y).multiplyScalar(-e/ho.z)}getViewSize(e,t){return this.getViewBounds(e,RM,BM),t.subVectors(BM,RM)}setViewOffset(e,t,i,n,r,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=r,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(ol*.5*this.fov)/this.zoom,i=2*t,n=this.aspect*i,r=-.5*n;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*n/l,t-=a.offsetY*i/c,n*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+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 NL extends Cb{constructor(){super(new wi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,i=Vc*2*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;(i!==t.fov||n!==t.aspect||r!==t.far)&&(t.fov=i,t.aspect=n,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Tb extends co{constructor(e,t,i=0,n=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.target=new Pt,this.distance=i,this.angle=n,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new NL}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 UL extends Cb{constructor(){super(new wi(90,1,.5,500)),this.isPointLightShadow=!0}}class Ib extends co{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 UL}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 Zi extends fg{constructor(e=-1,t=1,i=1,n=-1,r=.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=r,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,r,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=r,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 r=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;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,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 zL extends Cb{constructor(){super(new Zi(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class tr extends co{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.target=new Pt,this.shadow=new zL}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 Lu extends co{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class LM extends co{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 Pb{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new P)}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,r=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*n),t.addScaledVector(a[2],.488603*r),t.addScaledVector(a[3],.488603*i),t.addScaledVector(a[4],1.092548*(i*n)),t.addScaledVector(a[5],1.092548*(n*r)),t.addScaledVector(a[6],.315392*(3*r*r-1)),t.addScaledVector(a[7],1.092548*(i*r)),t.addScaledVector(a[8],.546274*(i*i-n*n)),t}getIrradianceAt(e,t){const i=e.x,n=e.y,r=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*r),t.addScaledVector(a[3],2*.511664*i),t.addScaledVector(a[4],2*.429043*i*n),t.addScaledVector(a[5],2*.429043*n*r),t.addScaledVector(a[6],.743125*r*r-.247708),t.addScaledVector(a[7],2*.429043*i*r),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,r=e.z;t[0]=.282095,t[1]=.488603*n,t[2]=.488603*r,t[3]=.488603*i,t[4]=1.092548*i*n,t[5]=1.092548*n*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*i*r,t[8]=.546274*(i*i-n*n)}}class kM extends co{constructor(e=new Pb,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 mg extends dn{constructor(e){super(e),this.textures={}}load(e,t,i,n){const r=this,a=new gn(r.manager);a.setPath(r.path),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.withCredentials),a.load(e,function(o){try{t(r.parse(JSON.parse(o)))}catch(l){n?n(l):ft(l),r.manager.itemError(e)}},i,n)}parse(e){const t=this.textures;function i(r){return t[r]===void 0&&Je("MaterialLoader: Undefined texture",r),t[r]}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 qe().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 r in e.uniforms){const a=e.uniforms[r];switch(n.uniforms[r]={},a.type){case"t":n.uniforms[r].value=i(a.value);break;case"c":n.uniforms[r].value=new qe().setHex(a.value);break;case"v2":n.uniforms[r].value=new be().fromArray(a.value);break;case"v3":n.uniforms[r].value=new P().fromArray(a.value);break;case"v4":n.uniforms[r].value=new zt().fromArray(a.value);break;case"m3":n.uniforms[r].value=new yt().fromArray(a.value);break;case"m4":n.uniforms[r].value=new Ke().fromArray(a.value);break;default:n.uniforms[r].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 r in e.extensions)n.extensions[r]=e.extensions[r];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 r=e.normalScale;Array.isArray(r)===!1&&(r=[r,r]),n.normalScale=new be().fromArray(r)}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 mg.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:mM,SpriteMaterial:bm,RawShaderMaterial:hg,ShaderMaterial:mi,PointsMaterial:Wm,MeshPhysicalMaterial:Rs,MeshStandardMaterial:oo,MeshPhongMaterial:vM,MeshToonMaterial:AM,MeshNormalMaterial:dg,MeshLambertMaterial:Ab,MeshDepthMaterial:bb,MeshDistanceMaterial:yb,MeshBasicMaterial:Wt,MeshMatcapMaterial:bM,LineDashedMaterial:yM,LineBasicMaterial:bi,Material:Ki};return new t[e]}}class uo{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 OM extends dt{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 FM extends dn{constructor(e){super(e)}load(e,t,i,n){const r=this,a=new gn(r.manager);a.setPath(r.path),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.withCredentials),a.load(e,function(o){try{t(r.parse(JSON.parse(o)))}catch(l){n?n(l):ft(l),r.manager.itemError(e)}},i,n)}parse(e){const t={},i={};function n(p,m){if(t[m]!==void 0)return t[m];const g=p.interleavedBuffers[m],f=r(p,g.buffer),A=Gc(g.type,f),b=new th(A,g.stride);return b.uuid=g.uuid,t[m]=b,b}function r(p,m){if(i[m]!==void 0)return i[m];const g=p.arrayBuffers[m],f=new Uint32Array(g).buffer;return i[m]=f,f}const a=e.isInstancedBufferGeometry?new OM:new dt,o=e.data.index;if(o!==void 0){const p=Gc(o.type,o.array);a.setIndex(new _t(p,1))}const l=e.data.attributes;for(const p in l){const m=l[p];let v;if(m.isInterleavedBufferAttribute){const g=n(e.data,m.data);v=new ia(g,m.itemSize,m.offset,m.normalized)}else{const g=Gc(m.type,m.array),f=m.isInstancedBufferAttribute?no:_t;v=new f(g,m.itemSize,m.normalized)}m.name!==void 0&&(v.name=m.name),m.usage!==void 0&&v.setUsage(m.usage),a.setAttribute(p,v)}const c=e.data.morphAttributes;if(c)for(const p in c){const m=c[p],v=[];for(let g=0,f=m.length;g<f;g++){const A=m[g];let b;if(A.isInterleavedBufferAttribute){const y=n(e.data,A.data);b=new ia(y,A.itemSize,A.offset,A.normalized)}else{const y=Gc(A.type,A.array);b=new _t(y,A.itemSize,A.normalized)}A.name!==void 0&&(b.name=A.name),v.push(b)}a.morphAttributes[p]=v}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);const d=e.data.groups||e.data.drawcalls||e.data.offsets;if(d!==void 0)for(let p=0,m=d.length;p!==m;++p){const v=d[p];a.addGroup(v.start,v.count,v.materialIndex)}const u=e.data.boundingSphere;return u!==void 0&&(a.boundingSphere=new cn().fromJSON(u)),e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class HL extends dn{constructor(e){super(e)}load(e,t,i,n){const r=this,a=this.path===""?uo.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const o=new gn(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)),ft("ObjectLoader: Can't load "+e);return}r.parse(c,t)},i,n)}async loadAsync(e,t){const i=this,n=this.path===""?uo.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||n;const r=new gn(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials);const a=await r.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),r=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,r,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 u in a)if(a[u].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),r=await this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,r),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 r=new sa().fromJSON(e[i]);t[r.uuid]=r}return t}parseSkeletons(e,t){const i={},n={};if(t.traverse(function(r){r.isBone&&(n[r.uuid]=r)}),e!==void 0)for(let r=0,a=e.length;r<a;r++){const o=new vu().fromJSON(e[r],n);i[o.uuid]=o}return i}parseGeometries(e,t){const i={};if(e!==void 0){const n=new FM;for(let r=0,a=e.length;r<a;r++){let o;const l=e[r];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":o=n.parse(l);break;default:l.type in fM?o=fM[l.type].fromJSON(l,t):Je(`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 r=new mg;r.setTextures(t);for(let a=0,o=e.length;a<o;a++){const l=e[a];i[l.uuid]===void 0&&(i[l.uuid]=r.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],r=uh.parse(n);t[r.uuid]=r}return t}parseImages(e,t){const i=this,n={};let r;function a(l){return i.manager.itemStart(l),r.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:Gc(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new Mb(t);r=new Bu(l),r.setCrossOrigin(this.crossOrigin);for(let c=0,h=e.length;c<h;c++){const d=e[c],u=d.url;if(Array.isArray(u)){const p=[];for(let m=0,v=u.length;m<v;m++){const g=u[m],f=o(g);f!==null&&(f instanceof HTMLImageElement?p.push(f):p.push(new On(f.data,f.width,f.height)))}n[d.uuid]=new $a(p)}else{const p=o(d.url);n[d.uuid]=new $a(p)}}}return n}async parseImagesAsync(e){const t=this,i={};let n;async function r(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:Gc(a.type,a.data),width:a.width,height:a.height}:null}if(e!==void 0&&e.length>0){n=new Bu(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,u=c.length;d<u;d++){const p=c[d],m=await r(p);m!==null&&(m instanceof HTMLImageElement?h.push(m):h.push(new On(m.data,m.width,m.height)))}i[l.uuid]=new $a(h)}else{const h=await r(l.url);i[l.uuid]=new $a(h)}}}return i}parseTextures(e,t){function i(r,a){return typeof r=="number"?r:(Je("ObjectLoader.parseTexture: Constant should be in numeric form.",r),a[r])}const n={};if(e!==void 0)for(let r=0,a=e.length;r<a;r++){const o=e[r];o.image===void 0&&Je('ObjectLoader: No "image" specified for',o.uuid),t[o.image]===void 0&&Je("ObjectLoader: Undefined image",o.image);const l=t[o.image],c=l.data;let h;Array.isArray(c)?(h=new _u,c.length===6&&(h.needsUpdate=!0)):(c&&c.data?h=new On:h=new Ai,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,GL)),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],NM),h.wrapT=i(o.wrap[1],NM)),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,UM)),o.magFilter!==void 0&&(h.magFilter=i(o.magFilter,UM)),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,r){let a;function o(u){return t[u]===void 0&&Je("ObjectLoader: Undefined geometry",u),t[u]}function l(u){if(u!==void 0){if(Array.isArray(u)){const p=[];for(let m=0,v=u.length;m<v;m++){const g=u[m];i[g]===void 0&&Je("ObjectLoader: Undefined material",g),p.push(i[g])}return p}return i[u]===void 0&&Je("ObjectLoader: Undefined material",u),i[u]}}function c(u){return n[u]===void 0&&Je("ObjectLoader: Undefined texture",u),n[u]}let h,d;switch(e.type){case"Scene":a=new ll,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new qe(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 fm(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new pm(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 wi(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 Zi(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 Lu(e.color,e.intensity);break;case"DirectionalLight":a=new tr(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new Ib(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new LM(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new Tb(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||"";break;case"HemisphereLight":a=new IM(e.color,e.groundColor,e.intensity);break;case"LightProbe":const u=new Pb().fromArray(e.sh);a=new kM(u,e.intensity);break;case"SkinnedMesh":h=o(e.geometry),d=l(e.material),a=new ZA(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 We(h,d);break;case"InstancedMesh":h=o(e.geometry),d=l(e.material);const p=e.count,m=e.instanceMatrix,v=e.instanceColor;a=new hi(h,d,p),a.instanceMatrix=new no(new Float32Array(m.array),16),v!==void 0&&(a.instanceColor=new no(new Float32Array(v.array),v.itemSize));break;case"BatchedMesh":h=o(e.geometry),d=l(e.material),a=new zE(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,A=null;return g.boundingBox!==void 0&&(f=new xt().fromJSON(g.boundingBox)),g.boundingSphere!==void 0&&(A=new cn().fromJSON(g.boundingSphere)),{...g,boundingBox:f,boundingSphere:A}}),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 cn().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(a.boundingBox=new xt().fromJSON(e.boundingBox));break;case"LOD":a=new SE;break;case"Line":a=new Ci(o(e.geometry),l(e.material));break;case"LineLoop":a=new nb(o(e.geometry),l(e.material));break;case"LineSegments":a=new Oi(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":a=new Xm(o(e.geometry),l(e.material));break;case"Sprite":a=new gu(l(e.material));break;case"Group":a=new Si;break;case"Bone":a=new Lm;break;default:a=new Pt}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 P().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 u=e.children;for(let p=0;p<u.length;p++)a.add(this.parseObject(u[p],t,i,n,r))}if(e.animations!==void 0){const u=e.animations;for(let p=0;p<u.length;p++){const m=u[p];a.animations.push(r[m])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);const u=e.levels;for(let p=0;p<u.length;p++){const m=u[p],v=a.getObjectByProperty("uuid",m.object);v!==void 0&&a.addLevel(v,m.distance,m.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?Je("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 Pt}})}}const GL={UVMapping:Of,CubeReflectionMapping:wr,CubeRefractionMapping:Wa,EquirectangularReflectionMapping:Dc,EquirectangularRefractionMapping:Od,CubeUVReflectionMapping:Rc},NM={RepeatWrapping:ln,ClampToEdgeWrapping:Bn,MirroredRepeatWrapping:Bc},UM={NearestFilter:Jt,NearestMipmapNearestFilter:Fd,NearestMipmapLinearFilter:Zo,LinearFilter:wt,LinearMipmapNearestFilter:Lc,LinearMipmapLinearFilter:$n},Db=new WeakMap;class zM extends dn{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&Je("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Je("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 r=this,a=Pr.get(`image-bitmap:${e}`);if(a!==void 0){if(r.manager.itemStart(e),a.then){a.then(c=>{if(Db.has(a)===!0)n&&n(Db.get(a)),r.manager.itemError(e),r.manager.itemEnd(e);else return t&&t(c),r.manager.itemEnd(e),c});return}return setTimeout(function(){t&&t(a),r.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(r.options,{colorSpaceConversion:"none"}))}).then(function(c){return Pr.add(`image-bitmap:${e}`,c),t&&t(c),r.manager.itemEnd(e),c}).catch(function(c){n&&n(c),Db.set(l,c),Pr.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});Pr.add(`image-bitmap:${e}`,l),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let gg;class Rb{static getContext(){return gg===void 0&&(gg=new(window.AudioContext||window.webkitAudioContext)),gg}static setContext(e){gg=e}}class VL extends dn{constructor(e){super(e)}load(e,t,i,n){const r=this,a=new gn(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);Rb.getContext().decodeAudioData(c,function(d){t(d)}).catch(o)}catch(c){o(c)}},i,n);function o(l){n?n(l):ft(l),r.manager.itemError(e)}}}const HM=new Ke,GM=new Ke,wl=new Ke;class WL{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new wi,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new wi,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,wl.copy(e.projectionMatrix);const n=t.eyeSep/2,r=n*t.near/t.focus,a=t.near*Math.tan(ol*t.fov*.5)/t.zoom;let o,l;GM.elements[12]=-n,HM.elements[12]=n,o=-a*t.aspect+r,l=a*t.aspect+r,wl.elements[0]=2*t.near/(l-o),wl.elements[8]=(l+o)/(l-o),this.cameraL.projectionMatrix.copy(wl),o=-a*t.aspect-r,l=a*t.aspect-r,wl.elements[0]=2*t.near/(l-o),wl.elements[8]=(l+o)/(l-o),this.cameraR.projectionMatrix.copy(wl)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(GM),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(HM)}}const fh=-90,mh=1;class VM extends Pt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new wi(fh,mh,e,t);n.layers=this.layers,this.add(n);const r=new wi(fh,mh,e,t);r.layers=this.layers,this.add(r);const a=new wi(fh,mh,e,t);a.layers=this.layers,this.add(a);const o=new wi(fh,mh,e,t);o.layers=this.layers,this.add(o);const l=new wi(fh,mh,e,t);l.layers=this.layers,this.add(l);const c=new wi(fh,mh,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,n,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===hs)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),r.up.set(0,0,-1),r.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===al)i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),r.up.set(0,0,1),r.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[r,a,o,l,c,h]=this.children,d=e.getRenderTarget(),u=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),m=e.xr.enabled;e.xr.enabled=!1;const v=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,r),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=v,e.setRenderTarget(i,5,n),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(d,u,p),e.xr.enabled=m,i.texture.needsPMREMUpdate=!0}}class WM extends wi{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Bb{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=QL.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 QL(){this._document.hidden===!1&&this.reset()}const El=new P,Lb=new Lt,jL=new P,Ml=new P,Sl=new P;class XL extends Pt{constructor(){super(),this.type="AudioListener",this.context=Rb.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._timer=new Bb}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(El,Lb,jL),Ml.set(0,0,-1).applyQuaternion(Lb),Sl.set(0,1,0).applyQuaternion(Lb),t.positionX){const i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(El.x,i),t.positionY.linearRampToValueAtTime(El.y,i),t.positionZ.linearRampToValueAtTime(El.z,i),t.forwardX.linearRampToValueAtTime(Ml.x,i),t.forwardY.linearRampToValueAtTime(Ml.y,i),t.forwardZ.linearRampToValueAtTime(Ml.z,i),t.upX.linearRampToValueAtTime(Sl.x,i),t.upY.linearRampToValueAtTime(Sl.y,i),t.upZ.linearRampToValueAtTime(Sl.z,i)}else t.setPosition(El.x,El.y,El.z),t.setOrientation(Ml.x,Ml.y,Ml.z,Sl.x,Sl.y,Sl.z)}}class QM extends Pt{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){Je("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){Je("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){Je("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){Je("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){Je("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?(Je("Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){Je("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"?(Je("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 Cl=new P,jM=new Lt,qL=new P,Tl=new P;class YL extends QM{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(Cl,jM,qL),Tl.set(0,0,1).applyQuaternion(jM);const t=this.panner;if(t.positionX){const i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Cl.x,i),t.positionY.linearRampToValueAtTime(Cl.y,i),t.positionZ.linearRampToValueAtTime(Cl.z,i),t.orientationX.linearRampToValueAtTime(Tl.x,i),t.orientationY.linearRampToValueAtTime(Tl.y,i),t.orientationZ.linearRampToValueAtTime(Tl.z,i)}else t.setPosition(Cl.x,Cl.y,Cl.z),t.setOrientation(Tl.x,Tl.y,Tl.z)}}class KL{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 XM{constructor(e,t,i){this.binding=e,this.valueSize=i;let n,r,a;switch(t){case"quaternion":n=this._slerp,r=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":n=this._select,r=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:n=this._lerp,r=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=r,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,r=e*n+n;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==n;++o)i[r+o]=i[o];a=t}else{a+=t;const o=t/a;this._mixBufferRegion(i,r,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,r=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const l=t*this._origIndex;this._mixBufferRegion(i,n,l,1-r,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 r=i,a=n;r!==a;++r)t[r]=t[n+r%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,r){if(n>=.5)for(let a=0;a!==r;++a)e[t+a]=e[i+a]}_slerp(e,t,i,n){Lt.slerpFlat(e,t,e,t,e,i,n)}_slerpAdditive(e,t,i,n,r){const a=this._workIndex*r;Lt.multiplyQuaternionsFlat(e,a,e,t,e,i),Lt.slerpFlat(e,t,e,t,e,a,n)}_lerp(e,t,i,n,r){const a=1-n;for(let o=0;o!==r;++o){const l=t+o;e[l]=e[l]*a+e[i+o]*n}}_lerpAdditive(e,t,i,n,r){for(let a=0;a!==r;++a){const o=t+a;e[o]=e[o]+e[i+a]*n}}}const kb="\\[\\]\\.:\\/",$L=new RegExp("["+kb+"]","g"),Ob="[^"+kb+"]",ZL="[^"+kb.replace("\\.","")+"]",JL=/((?:WC+[\/:])*)/.source.replace("WC",Ob),e5=/(WCOD+)?/.source.replace("WCOD",ZL),t5=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Ob),i5=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Ob),n5=new RegExp("^"+JL+e5+t5+i5+"$"),s5=["material","materials","bones","map"];class r5{constructor(e,t,i){const n=i||Qt.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_,r=i.length;n!==r;++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 Qt{constructor(e,t,i){this.path=t,this.parsedPath=i||Qt.parseTrackName(t),this.node=Qt.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 Qt.Composite(e,t,i):new Qt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace($L,"")}static parseTrackName(e){const t=n5.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 r=i.nodeName.substring(n+1);s5.indexOf(r)!==-1&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=r)}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(r){for(let a=0;a<r.length;a++){const o=r[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,r=i.length;n!==r;++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,r=i.length;n!==r;++n)i[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++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 r=t.propertyIndex;if(e||(e=Qt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Je("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let c=t.objectIndex;switch(i){case"materials":if(!e.material){ft("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){ft("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){ft("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){ft("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){ft("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){ft("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(c!==void 0){if(e[c]===void 0){ft("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;ft("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(r!==void 0){if(n==="morphTargetInfluences"){if(!e.geometry){ft("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){ft("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}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}}Qt.Composite=r5,Qt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Qt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Qt.prototype.GetterByBindingType=[Qt.prototype._getValue_direct,Qt.prototype._getValue_array,Qt.prototype._getValue_arrayElement,Qt.prototype._getValue_toArray],Qt.prototype.SetterByBindingTypeAndVersioning=[[Qt.prototype._setValue_direct,Qt.prototype._setValue_direct_setNeedsUpdate,Qt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Qt.prototype._setValue_array,Qt.prototype._setValue_array_setNeedsUpdate,Qt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Qt.prototype._setValue_arrayElement,Qt.prototype._setValue_arrayElement_setNeedsUpdate,Qt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Qt.prototype._setValue_fromArray,Qt.prototype._setValue_fromArray_setNeedsUpdate,Qt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class a5{constructor(){this.isAnimationObjectGroup=!0,this.uuid=ds(),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,r=this._bindings,a=r.length;let o,l=e.length,c=this.nCachedObjects_;for(let h=0,d=arguments.length;h!==d;++h){const u=arguments[h],p=u.uuid;let m=t[p];if(m===void 0){m=l++,t[p]=m,e.push(u);for(let v=0,g=a;v!==g;++v)r[v].push(new Qt(u,i[v],n[v]))}else if(m<c){o=e[m];const v=--c,g=e[v];t[g.uuid]=m,e[m]=g,t[p]=v,e[v]=u;for(let f=0,A=a;f!==A;++f){const b=r[f],y=b[v];let x=b[m];b[m]=y,x===void 0&&(x=new Qt(u,i[f],n[f])),b[v]=x}}else e[m]!==o&&ft("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 r=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>=r){const d=r++,u=e[d];t[u.uuid]=h,e[h]=u,t[c]=d,e[d]=l;for(let p=0,m=n;p!==m;++p){const v=i[p],g=v[d],f=v[h];v[h]=g,v[d]=f}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length;let r=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<r){const u=--r,p=e[u],m=--a,v=e[m];t[p.uuid]=d,e[d]=p,t[v.uuid]=u,e[u]=v,e.pop();for(let g=0,f=n;g!==f;++g){const A=i[g],b=A[u],y=A[m];A[d]=b,A[u]=y,A.pop()}}else{const u=--a,p=e[u];u>0&&(t[p.uuid]=d),e[d]=p,e.pop();for(let m=0,v=n;m!==v;++m){const g=i[m];g[d]=g[u],g.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const i=this._bindingsIndicesByPath;let n=i[e];const r=this._bindings;if(n!==void 0)return r[n];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,h=this.nCachedObjects_,d=new Array(c);n=r.length,i[e]=n,a.push(e),o.push(t),r.push(d);for(let u=h,p=l.length;u!==p;++u){const m=l[u];d[u]=new Qt(m,e,t)}return d}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const n=this._paths,r=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=e[o];t[c]=i,a[i]=l,a.pop(),r[i]=r[o],r.pop(),n[i]=n[o],n.pop()}}}class qM{constructor(e,t,i=null,n=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=n;const r=t.tracks,a=r.length,o=new Array(a),l={endingStart:nl,endingEnd:nl};for(let c=0;c!==a;++c){const h=r[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=Xw,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,r=e._clip.duration,a=r/n,o=n/r;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,r=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]=r,l[1]=r+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 r=this._startTime;if(r!==null){const l=(e-r)*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 xA:for(let h=0,d=l.length;h!==d;++h)l[h].evaluate(a),c[h].accumulateAdditive(o);break;case nm: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,r=this._loopCount;const a=i===qw;if(e===0)return r===-1?n:a&&(r&1)===1?t-n:n;if(i===jw){r===-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(r===-1&&(e>=0?(r=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,r+=Math.abs(o);const l=this.repetitions-r;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=r,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=n;if(a&&(r&1)===1)return t-n}return n}_setEndings(e,t,i){const n=this._interpolantSettings;i?(n.endingStart=sl,n.endingEnd=sl):(e?n.endingStart=this.zeroSlopeAtStart?sl:nl:n.endingStart=Jd,t?n.endingEnd=this.zeroSlopeAtEnd?sl:nl:n.endingEnd=Jd)}_scheduleFading(e,t,i){const n=this._mixer,r=n.time;let a=this._weightInterpolant;a===null&&(a=n._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=r,l[0]=t,o[1]=r+e,l[1]=i,this}}const o5=new Float32Array(1);class l5 extends Ys{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,r=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!==r;++d){const u=n[d],p=u.name;let m=h[p];if(m!==void 0)++m.referenceCount,a[d]=m;else{if(m=a[d],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,p));continue}const v=t&&t._propertyBindings[d].binding.parsedPath;m=new XM(Qt.create(i,p,v),u.ValueTypeName,u.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,p),a[d]=m}o[d].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,i)}const t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){const r=t[i];r.useCount++===0&&(this._lendBinding(r),r.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 r=t[i];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}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,r=this._actionsByClip;let a=r[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[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 r=e._clip.uuid,a=this._actionsByClip,o=a[r],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,u=(e._localRoot||this._root).uuid;delete d[u],l.length===0&&delete a[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){const r=t[i];--r.referenceCount===0&&this._removeInactiveBinding(r)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,n=this._nActiveActions++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,n=--this._nActiveActions,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_addInactiveBinding(e,t,i){const n=this._bindingsByRootAndName,r=this._bindings;let a=n[t];a===void 0&&(a={},n[t]=a),a[i]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,n=i.rootNode.uuid,r=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[r],Object.keys(o).length===0&&delete a[n]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,n=this._nActiveBindings++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,n=--this._nActiveBindings,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return i===void 0&&(i=new wb(new Float32Array(2),new Float32Array(2),1,o5),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,n=--this._nActiveControlInterpolants,r=t[n];e.__cacheIndex=n,t[n]=e,r.__cacheIndex=i,t[i]=r}clipAction(e,t,i){const n=t||this._root,r=n.uuid;let a=typeof e=="string"?uh.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=nm),l!==void 0){const d=l.actionByRoot[r];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 qM(this,a,t,i);return this._bindAction(h,c),this._addInactiveAction(h,o,r),h}existingAction(e,t){const i=t||this._root,n=i.uuid,r=typeof e=="string"?uh.findByName(i,e):e,a=r?r.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,r=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(n,e,r,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,r=n[i];if(r!==void 0){const a=r.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,r=n[t];if(r!==void 0)for(const a in r){const o=r[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}class c5 extends PA{constructor(e=1,t=1,i=1,n={}){super(e,t,n),this.isRenderTarget3D=!0,this.depth=i,this.texture=new au(null,e,t,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}}class Fb{constructor(e){this.value=e}clone(){return new Fb(this.value.clone===void 0?this.value:this.value.clone())}}let h5=0;class d5 extends Ys{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:h5++}),this.name="",this.usage=tu,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 r=Array.isArray(t[i])?t[i]:[t[i]];for(let a=0;a<r.length;a++)this.uniforms.push(r[a].clone())}return this}clone(){return new this.constructor().copy(this)}}class u5 extends th{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 p5{constructor(e,t,i,n,r,a=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=n,this.count=r,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 YM=new Ke;class fs{constructor(e,t,i=0,n=1/0){this.ray=new Cr(e,t),this.near=i,this.far=n,this.camera=null,this.layers=new cm,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):ft("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return YM.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(YM),this}intersectObject(e,t=!0,i=[]){return Nb(e,this,i,t),i.sort(KM),i}intersectObjects(e,t=!0,i=[]){for(let n=0,r=e.length;n<r;n++)Nb(e[n],this,i,t);return i.sort(KM),i}}function KM(s,e){return s.distance-e.distance}function Nb(s,e,t,i){let n=!0;if(s.layers.test(e.layers)&&s.raycast(e,t)===!1&&(n=!1),n===!0&&i===!0){const r=s.children;for(let a=0,o=r.length;a<o;a++)Nb(r[a],e,t,!0)}}class $M{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1,Je("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 gh{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=At(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(At(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class f5{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 Ub{constructor(e,t,i,n){Ub.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 r=this.elements;return r[0]=e,r[2]=t,r[1]=i,r[3]=n,this}}const ZM=new be;class m5{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=ZM.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,ZM).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 JM=new P,vg=new P,vh=new P,Ah=new P,zb=new P,g5=new P,v5=new P;class ms{constructor(e=new P,t=new P){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){JM.subVectors(e,this.start),vg.subVectors(this.end,this.start);const i=vg.dot(vg);let r=vg.dot(JM)/i;return t&&(r=At(r,0,1)),r}closestPointToPoint(e,t,i){const n=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(n).add(this.start)}distanceSqToLine3(e,t=g5,i=v5){const n=10000000000000001e-32;let r,a;const o=this.start,l=e.start,c=this.end,h=e.end;vh.subVectors(c,o),Ah.subVectors(h,l),zb.subVectors(o,l);const d=vh.dot(vh),u=Ah.dot(Ah),p=Ah.dot(zb);if(d<=n&&u<=n)return t.copy(o),i.copy(l),t.sub(i),t.dot(t);if(d<=n)r=0,a=p/u,a=At(a,0,1);else{const m=vh.dot(zb);if(u<=n)a=0,r=At(-m/d,0,1);else{const v=vh.dot(Ah),g=d*u-v*v;g!==0?r=At((v*p-m*u)/g,0,1):r=0,a=(v*r+p)/u,a<0?(a=0,r=At(-m/d,0,1)):a>1&&(a=1,r=At((v-m)/d,0,1))}}return t.copy(o).addScaledVector(vh,r),i.copy(l).addScaledVector(Ah,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 eS=new P;class A5 extends Pt{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new dt,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 it(n,3));const r=new bi({fog:!1,toneMapped:!1});this.cone=new Oi(i,r),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),eS.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(eS),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const po=new P,Ag=new Ke,Hb=new Ke;class b5 extends Oi{constructor(e){const t=tS(e),i=new dt,n=[],r=[];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),r.push(0,0,0),r.push(0,0,0))}i.setAttribute("position",new it(n,3)),i.setAttribute("color",new it(r,3));const a=new bi({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 qe(255),l=new qe(65280);this.setColors(o,l)}updateMatrixWorld(e){const t=this.bones,i=this.geometry,n=i.getAttribute("position");Hb.copy(this.root.matrixWorld).invert();for(let r=0,a=0;r<t.length;r++){const o=t[r];o.parent&&o.parent.isBone&&(Ag.multiplyMatrices(Hb,o.matrixWorld),po.setFromMatrixPosition(Ag),n.setXYZ(a,po.x,po.y,po.z),Ag.multiplyMatrices(Hb,o.parent.matrixWorld),po.setFromMatrixPosition(Ag),n.setXYZ(a+1,po.x,po.y,po.z),a+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}setColors(e,t){const n=this.geometry.getAttribute("color");for(let r=0;r<n.count;r+=2)n.setXYZ(r,e.r,e.g,e.b),n.setXYZ(r+1,t.r,t.g,t.b);return n.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}function tS(s){const e=[];s.isBone===!0&&e.push(s);for(let t=0;t<s.children.length;t++)e.push(...tS(s.children[t]));return e}class y5 extends We{constructor(e,t,i){const n=new ao(t,4,2),r=new Wt({wireframe:!0,fog:!1,toneMapped:!1});super(n,r),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 x5=new P,iS=new qe,nS=new qe;class _5 extends Pt{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const n=new ra(t);n.rotateY(Math.PI*.5),this.material=new Wt({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const r=n.getAttribute("position"),a=new Float32Array(r.count*3);n.setAttribute("color",new _t(a,3)),this.add(new We(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");iS.copy(this.light.color),nS.copy(this.light.groundColor);for(let i=0,n=t.count;i<n;i++){const r=i<n/2?iS:nS;t.setXYZ(i,r.r,r.g,r.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(x5.setFromMatrixPosition(this.light.matrixWorld).negate())}}class w5 extends Oi{constructor(e=10,t=10,i=4473924,n=8947848){i=new qe(i),n=new qe(n);const r=t/2,a=e/t,o=e/2,l=[],c=[];for(let u=0,p=0,m=-o;u<=t;u++,m+=a){l.push(-o,0,m,o,0,m),l.push(m,0,-o,m,0,o);const v=u===r?i:n;v.toArray(c,p),p+=3,v.toArray(c,p),p+=3,v.toArray(c,p),p+=3,v.toArray(c,p),p+=3}const h=new dt;h.setAttribute("position",new it(l,3)),h.setAttribute("color",new it(c,3));const d=new bi({vertexColors:!0,toneMapped:!1});super(h,d),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class E5 extends Oi{constructor(e=10,t=16,i=8,n=64,r=4473924,a=8947848){r=new qe(r),a=new qe(a);const o=[],l=[];if(t>1)for(let d=0;d<t;d++){const u=d/t*(Math.PI*2),p=Math.sin(u)*e,m=Math.cos(u)*e;o.push(0,0,0),o.push(p,0,m);const v=d&1?r:a;l.push(v.r,v.g,v.b),l.push(v.r,v.g,v.b)}for(let d=0;d<i;d++){const u=d&1?r:a,p=e-e/i*d;for(let m=0;m<n;m++){let v=m/n*(Math.PI*2),g=Math.sin(v)*p,f=Math.cos(v)*p;o.push(g,0,f),l.push(u.r,u.g,u.b),v=(m+1)/n*(Math.PI*2),g=Math.sin(v)*p,f=Math.cos(v)*p,o.push(g,0,f),l.push(u.r,u.g,u.b)}}const c=new dt;c.setAttribute("position",new it(o,3)),c.setAttribute("color",new it(l,3));const h=new bi({vertexColors:!0,toneMapped:!1});super(c,h),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const sS=new P,bg=new P,rS=new P;class M5 extends Pt{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 dt;n.setAttribute("position",new it([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const r=new bi({fog:!1,toneMapped:!1});this.lightPlane=new Ci(n,r),this.add(this.lightPlane),n=new dt,n.setAttribute("position",new it([0,0,0,0,0,1],3)),this.targetLine=new Ci(n,r),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),sS.setFromMatrixPosition(this.light.matrixWorld),bg.setFromMatrixPosition(this.light.target.matrixWorld),rS.subVectors(bg,sS),this.lightPlane.lookAt(bg),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(bg),this.targetLine.scale.z=rS.length()}}const yg=new P,Ii=new fg;class S5 extends Oi{constructor(e){const t=new dt,i=new bi({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],r=[],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(m,v){l(m),l(v)}function l(m){n.push(0,0,0),r.push(0,0,0),a[m]===void 0&&(a[m]=[]),a[m].push(n.length/3-1)}t.setAttribute("position",new it(n,3)),t.setAttribute("color",new it(r,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 qe(16755200),h=new qe(16711680),d=new qe(43775),u=new qe(16777215),p=new qe(3355443);this.setColors(c,h,d,u,p)}setColors(e,t,i,n,r){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,r.r,r.g,r.b),o.setXYZ(41,r.r,r.g,r.b),o.setXYZ(42,r.r,r.g,r.b),o.setXYZ(43,r.r,r.g,r.b),o.setXYZ(44,r.r,r.g,r.b),o.setXYZ(45,r.r,r.g,r.b),o.setXYZ(46,r.r,r.g,r.b),o.setXYZ(47,r.r,r.g,r.b),o.setXYZ(48,r.r,r.g,r.b),o.setXYZ(49,r.r,r.g,r.b),o.needsUpdate=!0,this}update(){const e=this.geometry,t=this.pointMap,i=1,n=1;let r,a;if(Ii.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)r=1,a=0;else if(this.camera.coordinateSystem===hs)r=-1,a=1;else if(this.camera.coordinateSystem===al)r=0,a=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);Fi("c",t,e,Ii,0,0,r),Fi("t",t,e,Ii,0,0,a),Fi("n1",t,e,Ii,-i,-n,r),Fi("n2",t,e,Ii,i,-n,r),Fi("n3",t,e,Ii,-i,n,r),Fi("n4",t,e,Ii,i,n,r),Fi("f1",t,e,Ii,-i,-n,a),Fi("f2",t,e,Ii,i,-n,a),Fi("f3",t,e,Ii,-i,n,a),Fi("f4",t,e,Ii,i,n,a),Fi("u1",t,e,Ii,i*.7,n*1.1,r),Fi("u2",t,e,Ii,-i*.7,n*1.1,r),Fi("u3",t,e,Ii,0,n*2,r),Fi("cf1",t,e,Ii,-i,0,a),Fi("cf2",t,e,Ii,i,0,a),Fi("cf3",t,e,Ii,0,-n,a),Fi("cf4",t,e,Ii,0,n,a),Fi("cn1",t,e,Ii,-i,0,r),Fi("cn2",t,e,Ii,i,0,r),Fi("cn3",t,e,Ii,0,-n,r),Fi("cn4",t,e,Ii,0,n,r),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Fi(s,e,t,i,n,r,a){yg.set(n,r,a).unproject(i);const o=e[s];if(o!==void 0){const l=t.getAttribute("position");for(let c=0,h=o.length;c<h;c++)l.setXYZ(o[c],yg.x,yg.y,yg.z)}}const xg=new xt;class C5 extends Oi{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),r=new dt;r.setIndex(new _t(i,1)),r.setAttribute("position",new _t(n,3)),super(r,new bi({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&xg.setFromObject(this.object),xg.isEmpty())return;const e=xg.min,t=xg.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 T5 extends Oi{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],r=new dt;r.setIndex(new _t(i,1)),r.setAttribute("position",new it(n,3)),super(r,new bi({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 I5 extends Ci{constructor(e,t=1,i=16776960){const n=i,r=[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 dt;a.setAttribute("position",new it(r,3)),a.computeBoundingSphere(),super(a,new bi({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 dt;l.setAttribute("position",new it(o,3)),l.computeBoundingSphere(),this.add(new We(l,new Wt({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 aS=new P;let _g,Gb;class P5 extends Pt{constructor(e=new P(0,0,1),t=new P(0,0,0),i=1,n=16776960,r=i*.2,a=r*.2){super(),this.type="ArrowHelper",_g===void 0&&(_g=new dt,_g.setAttribute("position",new it([0,0,0,0,1,0],3)),Gb=new wu(.5,1,5,1),Gb.translate(0,-.5,0)),this.position.copy(t),this.line=new Ci(_g,new bi({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new We(Gb,new Wt({color:n,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,r,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{aS.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(aS,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 oS extends Oi{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 dt;n.setAttribute("position",new it(t,3)),n.setAttribute("color",new it(i,3));const r=new bi({vertexColors:!0,toneMapped:!1});super(n,r),this.type="AxesHelper"}setColors(e,t,i){const n=new qe,r=this.geometry.attributes.color.array;return n.set(e),n.toArray(r,0),n.toArray(r,3),n.set(t),n.toArray(r,6),n.toArray(r,9),n.set(i),n.toArray(r,12),n.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class lS{constructor(){this.type="ShapePath",this.color=new qe,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Cu,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,r,a){return this.currentPath.bezierCurveTo(e,t,i,n,r,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(f){const A=[];for(let b=0,y=f.length;b<y;b++){const x=f[b],_=new sa;_.curves=x.curves,A.push(_)}return A}function i(f,A){const b=A.length;let y=!1;for(let x=b-1,_=0;_<b;x=_++){let M=A[x],E=A[_],w=E.x-M.x,T=E.y-M.y;if(Math.abs(T)>Number.EPSILON){if(T<0&&(M=A[_],w=-w,E=A[x],T=-T),f.y<M.y||f.y>E.y)continue;if(f.y===M.y){if(f.x===M.x)return!0}else{const R=T*(f.x-M.x)-w*(f.y-M.y);if(R===0)return!0;if(R<0)continue;y=!y}}else{if(f.y!==M.y)continue;if(E.x<=f.x&&f.x<=M.x||M.x<=f.x&&f.x<=E.x)return!0}}return y}const n=er.isClockWise,r=this.subPaths;if(r.length===0)return[];let a,o,l;const c=[];if(r.length===1)return o=r[0],l=new sa,l.curves=o.curves,c.push(l),c;let h=!n(r[0].getPoints());h=e?!h:h;const d=[],u=[];let p=[],m=0,v;u[m]=void 0,p[m]=[];for(let f=0,A=r.length;f<A;f++)o=r[f],v=o.getPoints(),a=n(v),a=e?!a:a,a?(!h&&u[m]&&m++,u[m]={s:new sa,p:v},u[m].s.curves=o.curves,h&&m++,p[m]=[]):p[m].push({h:o,p:v[0]});if(!u[0])return t(r);if(u.length>1){let f=!1,A=0;for(let b=0,y=u.length;b<y;b++)d[b]=[];for(let b=0,y=u.length;b<y;b++){const x=p[b];for(let _=0;_<x.length;_++){const M=x[_];let E=!0;for(let w=0;w<u.length;w++)i(M.p,u[w].p)&&(b!==w&&A++,E?(E=!1,d[w].push(M)):f=!0);E&&d[b].push(M)}}A>0&&f===!1&&(p=d)}let g;for(let f=0,A=u.length;f<A;f++){l=u[f].s,c.push(l),g=p[f];for(let b=0,y=g.length;b<y;b++)l.holes.push(g[b].h)}return c}}class wg extends Ys{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){Je("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function D5(s,e){const t=s.image&&s.image.width?s.image.width/s.image.height:1;return t>e?(s.repeat.x=1,s.repeat.y=t/e,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2):(s.repeat.x=e/t,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0),s}function R5(s,e){const t=s.image&&s.image.width?s.image.width/s.image.height:1;return t>e?(s.repeat.x=e/t,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0):(s.repeat.x=1,s.repeat.y=t/e,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2),s}function B5(s){return s.repeat.x=1,s.repeat.y=1,s.offset.x=0,s.offset.y=0,s}function Vb(s,e,t,i){const n=L5(i);switch(t){case bA:return s*e;case Sr:return s*e/n.components*n.byteLength;case zd:return s*e/n.components*n.byteLength;case Is:return s*e*2/n.components*n.byteLength;case zf:return s*e*2/n.components*n.byteLength;case Oc:return s*e*3/n.components*n.byteLength;case _i:return s*e*4/n.components*n.byteLength;case Hf:return s*e*4/n.components*n.byteLength;case Jo:case ja:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case Hd:case Xa:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Gf:case Fc:return Math.max(s,16)*Math.max(e,8)/4;case Gd:case el:return Math.max(s,8)*Math.max(e,8)/2;case Vd:case Nc:case Wd:case Qd:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case Uc:case jd:case Xd:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case qa:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Vf:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case Wf:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case Qf:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case tl:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case jf:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case Xf:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case qf:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case Yf:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case Kf:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case $f:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case Zf:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case Jf:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case em:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case il:case tm:case qd:return Math.ceil(s/4)*Math.ceil(e/4)*16;case Yd:case Kd:return Math.ceil(s/4)*Math.ceil(e/4)*8;case $d:case Zd:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function L5(s){switch(s){case bt:case vA:return{byteLength:1,components:1};case kc:case AA:case li:return{byteLength:2,components:1};case Nf:case Uf:return{byteLength:2,components:4};case Ts:case Ff:case xi:return{byteLength:4,components:1};case Nd:case Ud:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${s}.`)}class k5{static contain(e,t){return D5(e,t)}static cover(e,t){return R5(e,t)}static fill(e){return B5(e)}static getByteLength(e,t,i,n){return Vb(e,t,i,n)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ic}})),typeof window<"u"&&(window.__THREE__?Je("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ic);function cS(){let s=null,e=!1,t=null,i=null;function n(r,a){t(r,a),i=s.requestAnimationFrame(n)}return{start:function(){e!==!0&&t!==null&&(i=s.requestAnimationFrame(n),e=!0)},stop:function(){s.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){s=r}}}function O5(s){const e=new WeakMap;function t(o,l){const c=o.array,h=o.usage,d=c.byteLength,u=s.createBuffer();s.bindBuffer(l,u),s.bufferData(l,c,h),o.onUploadCallback();let p;if(c instanceof Float32Array)p=s.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)p=s.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?p=s.HALF_FLOAT:p=s.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=s.SHORT;else if(c instanceof Uint32Array)p=s.UNSIGNED_INT;else if(c instanceof Int32Array)p=s.INT;else if(c instanceof Int8Array)p=s.BYTE;else if(c instanceof Uint8Array)p=s.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:u,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,c){const h=l.array,d=l.updateRanges;if(s.bindBuffer(c,o),d.length===0)s.bufferSubData(c,0,h);else{d.sort((p,m)=>p.start-m.start);let u=0;for(let p=1;p<d.length;p++){const m=d[u],v=d[p];v.start<=m.start+m.count+1?m.count=Math.max(m.count,v.start+v.count-m.start):(++u,d[u]=v)}d.length=u+1;for(let p=0,m=d.length;p<m;p++){const v=d[p];s.bufferSubData(c,v.start*h.BYTES_PER_ELEMENT,h,v.start,v.count)}l.clearUpdateRanges()}l.onUploadCallback()}function n(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(s.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:r,update:a}}var F5=`#ifdef USE_ALPHAHASH
|
||
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
||
#endif`,N5=`#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`,U5=`#ifdef USE_ALPHAMAP
|
||
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
||
#endif`,z5=`#ifdef USE_ALPHAMAP
|
||
uniform sampler2D alphaMap;
|
||
#endif`,H5=`#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`,G5=`#ifdef USE_ALPHATEST
|
||
uniform float alphaTest;
|
||
#endif`,V5=`#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`,W5=`#ifdef USE_AOMAP
|
||
uniform sampler2D aoMap;
|
||
uniform float aoMapIntensity;
|
||
#endif`,Q5=`#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`,j5=`#ifdef USE_BATCHING
|
||
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
||
#endif`,X5=`vec3 transformed = vec3( position );
|
||
#ifdef USE_ALPHAHASH
|
||
vPosition = vec3( position );
|
||
#endif`,q5=`vec3 objectNormal = vec3( normal );
|
||
#ifdef USE_TANGENT
|
||
vec3 objectTangent = vec3( tangent.xyz );
|
||
#endif`,Y5=`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`,K5=`#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`,$5=`#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`,Z5=`#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`,J5=`#if NUM_CLIPPING_PLANES > 0
|
||
varying vec3 vClipPosition;
|
||
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
||
#endif`,ek=`#if NUM_CLIPPING_PLANES > 0
|
||
varying vec3 vClipPosition;
|
||
#endif`,tk=`#if NUM_CLIPPING_PLANES > 0
|
||
vClipPosition = - mvPosition.xyz;
|
||
#endif`,ik=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
||
diffuseColor *= vColor;
|
||
#endif`,nk=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
||
varying vec4 vColor;
|
||
#endif`,sk=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
||
varying vec4 vColor;
|
||
#endif`,rk=`#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`,ak=`#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`,ok=`#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`,lk=`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`,ck=`#ifdef USE_DISPLACEMENTMAP
|
||
uniform sampler2D displacementMap;
|
||
uniform float displacementScale;
|
||
uniform float displacementBias;
|
||
#endif`,hk=`#ifdef USE_DISPLACEMENTMAP
|
||
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
||
#endif`,dk=`#ifdef USE_EMISSIVEMAP
|
||
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
||
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
||
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
||
#endif
|
||
totalEmissiveRadiance *= emissiveColor.rgb;
|
||
#endif`,uk=`#ifdef USE_EMISSIVEMAP
|
||
uniform sampler2D emissiveMap;
|
||
#endif`,pk="gl_FragColor = linearToOutputTexel( gl_FragColor );",fk=`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 );
|
||
}`,mk=`#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`,gk=`#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`,vk=`#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`,Ak=`#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`,bk=`#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`,yk=`#ifdef USE_FOG
|
||
vFogDepth = - mvPosition.z;
|
||
#endif`,xk=`#ifdef USE_FOG
|
||
varying float vFogDepth;
|
||
#endif`,_k=`#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`,wk=`#ifdef USE_FOG
|
||
uniform vec3 fogColor;
|
||
varying float vFogDepth;
|
||
#ifdef FOG_EXP2
|
||
uniform float fogDensity;
|
||
#else
|
||
uniform float fogNear;
|
||
uniform float fogFar;
|
||
#endif
|
||
#endif`,Ek=`#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
|
||
}`,Mk=`#ifdef USE_LIGHTMAP
|
||
uniform sampler2D lightMap;
|
||
uniform float lightMapIntensity;
|
||
#endif`,Sk=`LambertMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;
|
||
material.specularStrength = specularStrength;`,Ck=`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`,Tk=`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`,Ik=`#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`,Pk=`ToonMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;`,Dk=`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`,Rk=`BlinnPhongMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;
|
||
material.specularColor = specular;
|
||
material.specularShininess = shininess;
|
||
material.specularStrength = specularStrength;`,Bk=`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`,Lk=`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`,kk=`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 );
|
||
}`,Ok=`
|
||
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`,Fk=`#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`,Nk=`#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`,Uk=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
||
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
||
#endif`,zk=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
||
uniform float logDepthBufFC;
|
||
varying float vFragDepth;
|
||
varying float vIsPerspective;
|
||
#endif`,Hk=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
||
varying float vFragDepth;
|
||
varying float vIsPerspective;
|
||
#endif`,Gk=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
||
vFragDepth = 1.0 + gl_Position.w;
|
||
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
||
#endif`,Vk=`#ifdef USE_MAP
|
||
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
||
#ifdef DECODE_VIDEO_TEXTURE
|
||
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
||
#endif
|
||
diffuseColor *= sampledDiffuseColor;
|
||
#endif`,Wk=`#ifdef USE_MAP
|
||
uniform sampler2D map;
|
||
#endif`,Qk=`#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`,jk=`#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`,Xk=`float metalnessFactor = metalness;
|
||
#ifdef USE_METALNESSMAP
|
||
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
||
metalnessFactor *= texelMetalness.b;
|
||
#endif`,qk=`#ifdef USE_METALNESSMAP
|
||
uniform sampler2D metalnessMap;
|
||
#endif`,Yk=`#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`,Kk=`#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`,$k=`#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`,Zk=`#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`,Jk=`#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`,e8=`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;`,t8=`#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`,i8=`#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#ifdef USE_TANGENT
|
||
varying vec3 vTangent;
|
||
varying vec3 vBitangent;
|
||
#endif
|
||
#endif`,n8=`#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#ifdef USE_TANGENT
|
||
varying vec3 vTangent;
|
||
varying vec3 vBitangent;
|
||
#endif
|
||
#endif`,s8=`#ifndef FLAT_SHADED
|
||
vNormal = normalize( transformedNormal );
|
||
#ifdef USE_TANGENT
|
||
vTangent = normalize( transformedTangent );
|
||
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
||
#endif
|
||
#endif`,r8=`#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`,a8=`#ifdef USE_CLEARCOAT
|
||
vec3 clearcoatNormal = nonPerturbedNormal;
|
||
#endif`,o8=`#ifdef USE_CLEARCOAT_NORMALMAP
|
||
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
||
clearcoatMapN.xy *= clearcoatNormalScale;
|
||
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
||
#endif`,l8=`#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`,c8=`#ifdef USE_IRIDESCENCEMAP
|
||
uniform sampler2D iridescenceMap;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
uniform sampler2D iridescenceThicknessMap;
|
||
#endif`,h8=`#ifdef OPAQUE
|
||
diffuseColor.a = 1.0;
|
||
#endif
|
||
#ifdef USE_TRANSMISSION
|
||
diffuseColor.a *= material.transmissionAlpha;
|
||
#endif
|
||
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,d8=`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
|
||
}`,u8=`#ifdef PREMULTIPLIED_ALPHA
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
#endif`,p8=`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;`,f8=`#ifdef DITHERING
|
||
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
||
#endif`,m8=`#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`,g8=`float roughnessFactor = roughness;
|
||
#ifdef USE_ROUGHNESSMAP
|
||
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
||
roughnessFactor *= texelRoughness.g;
|
||
#endif`,v8=`#ifdef USE_ROUGHNESSMAP
|
||
uniform sampler2D roughnessMap;
|
||
#endif`,A8=`#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`,b8=`#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`,y8=`#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`,x8=`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;
|
||
}`,_8=`#ifdef USE_SKINNING
|
||
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
||
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
||
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
||
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
||
#endif`,w8=`#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`,E8=`#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`,M8=`#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`,S8=`float specularStrength;
|
||
#ifdef USE_SPECULARMAP
|
||
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
||
specularStrength = texelSpecular.r;
|
||
#else
|
||
specularStrength = 1.0;
|
||
#endif`,C8=`#ifdef USE_SPECULARMAP
|
||
uniform sampler2D specularMap;
|
||
#endif`,T8=`#if defined( TONE_MAPPING )
|
||
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
||
#endif`,I8=`#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; }`,P8=`#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`,D8=`#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`,R8=`#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`,B8=`#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`,L8=`#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`,k8=`#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 Ct={alphahash_fragment:F5,alphahash_pars_fragment:N5,alphamap_fragment:U5,alphamap_pars_fragment:z5,alphatest_fragment:H5,alphatest_pars_fragment:G5,aomap_fragment:V5,aomap_pars_fragment:W5,batching_pars_vertex:Q5,batching_vertex:j5,begin_vertex:X5,beginnormal_vertex:q5,bsdfs:Y5,iridescence_fragment:K5,bumpmap_pars_fragment:$5,clipping_planes_fragment:Z5,clipping_planes_pars_fragment:J5,clipping_planes_pars_vertex:ek,clipping_planes_vertex:tk,color_fragment:ik,color_pars_fragment:nk,color_pars_vertex:sk,color_vertex:rk,common:ak,cube_uv_reflection_fragment:ok,defaultnormal_vertex:lk,displacementmap_pars_vertex:ck,displacementmap_vertex:hk,emissivemap_fragment:dk,emissivemap_pars_fragment:uk,colorspace_fragment:pk,colorspace_pars_fragment:fk,envmap_fragment:mk,envmap_common_pars_fragment:gk,envmap_pars_fragment:vk,envmap_pars_vertex:Ak,envmap_physical_pars_fragment:Ik,envmap_vertex:bk,fog_vertex:yk,fog_pars_vertex:xk,fog_fragment:_k,fog_pars_fragment:wk,gradientmap_pars_fragment:Ek,lightmap_pars_fragment:Mk,lights_lambert_fragment:Sk,lights_lambert_pars_fragment:Ck,lights_pars_begin:Tk,lights_toon_fragment:Pk,lights_toon_pars_fragment:Dk,lights_phong_fragment:Rk,lights_phong_pars_fragment:Bk,lights_physical_fragment:Lk,lights_physical_pars_fragment:kk,lights_fragment_begin:Ok,lights_fragment_maps:Fk,lights_fragment_end:Nk,logdepthbuf_fragment:Uk,logdepthbuf_pars_fragment:zk,logdepthbuf_pars_vertex:Hk,logdepthbuf_vertex:Gk,map_fragment:Vk,map_pars_fragment:Wk,map_particle_fragment:Qk,map_particle_pars_fragment:jk,metalnessmap_fragment:Xk,metalnessmap_pars_fragment:qk,morphinstance_vertex:Yk,morphcolor_vertex:Kk,morphnormal_vertex:$k,morphtarget_pars_vertex:Zk,morphtarget_vertex:Jk,normal_fragment_begin:e8,normal_fragment_maps:t8,normal_pars_fragment:i8,normal_pars_vertex:n8,normal_vertex:s8,normalmap_pars_fragment:r8,clearcoat_normal_fragment_begin:a8,clearcoat_normal_fragment_maps:o8,clearcoat_pars_fragment:l8,iridescence_pars_fragment:c8,opaque_fragment:h8,packing:d8,premultiplied_alpha_fragment:u8,project_vertex:p8,dithering_fragment:f8,dithering_pars_fragment:m8,roughnessmap_fragment:g8,roughnessmap_pars_fragment:v8,shadowmap_pars_fragment:A8,shadowmap_pars_vertex:b8,shadowmap_vertex:y8,shadowmask_pars_fragment:x8,skinbase_vertex:_8,skinning_pars_vertex:w8,skinning_vertex:E8,skinnormal_vertex:M8,specularmap_fragment:S8,specularmap_pars_fragment:C8,tonemapping_fragment:T8,tonemapping_pars_fragment:I8,transmission_fragment:P8,transmission_pars_fragment:D8,uv_pars_fragment:R8,uv_pars_vertex:B8,uv_vertex:L8,worldpos_vertex:k8,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>
|
||
}`},et={common:{diffuse:{value:new qe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new yt},alphaMap:{value:null},alphaMapTransform:{value:new yt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new yt}},envmap:{envMap:{value:null},envMapRotation:{value:new yt},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 yt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new yt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new yt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new yt},normalScale:{value:new be(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new yt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new yt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new yt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new yt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new qe(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 qe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new yt},alphaTest:{value:0},uvTransform:{value:new yt}},sprite:{diffuse:{value:new qe(16777215)},opacity:{value:1},center:{value:new be(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new yt},alphaMap:{value:null},alphaMapTransform:{value:new yt},alphaTest:{value:0}}},ir={basic:{uniforms:Fn([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.fog]),vertexShader:Ct.meshbasic_vert,fragmentShader:Ct.meshbasic_frag},lambert:{uniforms:Fn([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.fog,et.lights,{emissive:{value:new qe(0)},envMapIntensity:{value:1}}]),vertexShader:Ct.meshlambert_vert,fragmentShader:Ct.meshlambert_frag},phong:{uniforms:Fn([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.fog,et.lights,{emissive:{value:new qe(0)},specular:{value:new qe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ct.meshphong_vert,fragmentShader:Ct.meshphong_frag},standard:{uniforms:Fn([et.common,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.roughnessmap,et.metalnessmap,et.fog,et.lights,{emissive:{value:new qe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ct.meshphysical_vert,fragmentShader:Ct.meshphysical_frag},toon:{uniforms:Fn([et.common,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.gradientmap,et.fog,et.lights,{emissive:{value:new qe(0)}}]),vertexShader:Ct.meshtoon_vert,fragmentShader:Ct.meshtoon_frag},matcap:{uniforms:Fn([et.common,et.bumpmap,et.normalmap,et.displacementmap,et.fog,{matcap:{value:null}}]),vertexShader:Ct.meshmatcap_vert,fragmentShader:Ct.meshmatcap_frag},points:{uniforms:Fn([et.points,et.fog]),vertexShader:Ct.points_vert,fragmentShader:Ct.points_frag},dashed:{uniforms:Fn([et.common,et.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ct.linedashed_vert,fragmentShader:Ct.linedashed_frag},depth:{uniforms:Fn([et.common,et.displacementmap]),vertexShader:Ct.depth_vert,fragmentShader:Ct.depth_frag},normal:{uniforms:Fn([et.common,et.bumpmap,et.normalmap,et.displacementmap,{opacity:{value:1}}]),vertexShader:Ct.meshnormal_vert,fragmentShader:Ct.meshnormal_frag},sprite:{uniforms:Fn([et.sprite,et.fog]),vertexShader:Ct.sprite_vert,fragmentShader:Ct.sprite_frag},background:{uniforms:{uvTransform:{value:new yt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ct.background_vert,fragmentShader:Ct.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new yt}},vertexShader:Ct.backgroundCube_vert,fragmentShader:Ct.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ct.cube_vert,fragmentShader:Ct.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ct.equirect_vert,fragmentShader:Ct.equirect_frag},distance:{uniforms:Fn([et.common,et.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ct.distance_vert,fragmentShader:Ct.distance_frag},shadow:{uniforms:Fn([et.lights,et.fog,{color:{value:new qe(0)},opacity:{value:1}}]),vertexShader:Ct.shadow_vert,fragmentShader:Ct.shadow_frag}};ir.physical={uniforms:Fn([ir.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new yt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new yt},clearcoatNormalScale:{value:new be(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new yt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new yt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new yt},sheen:{value:0},sheenColor:{value:new qe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new yt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new yt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new yt},transmissionSamplerSize:{value:new be},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new yt},attenuationDistance:{value:0},attenuationColor:{value:new qe(0)},specularColor:{value:new qe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new yt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new yt},anisotropyVector:{value:new be},anisotropyMap:{value:null},anisotropyMapTransform:{value:new yt}}]),vertexShader:Ct.meshphysical_vert,fragmentShader:Ct.meshphysical_frag};const Eg={r:0,b:0,g:0},Il=new Yi,O8=new Ke;function F8(s,e,t,i,n,r){const a=new qe(0);let o=n===!0?0:1,l,c,h=null,d=0,u=null;function p(A){let b=A.isScene===!0?A.background:null;if(b&&b.isTexture){const y=A.backgroundBlurriness>0;b=e.get(b,y)}return b}function m(A){let b=!1;const y=p(A);y===null?g(a,o):y&&y.isColor&&(g(y,1),b=!0);const x=s.xr.getEnvironmentBlendMode();x==="additive"?t.buffers.color.setClear(0,0,0,1,r):x==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(s.autoClear||b)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function v(A,b){const y=p(b);y&&(y.isCubeTexture||y.mapping===Rc)?(c===void 0&&(c=new We(new fi(1,1,1),new mi({name:"BackgroundCubeMaterial",uniforms:dh(ir.backgroundCube.uniforms),vertexShader:ir.backgroundCube.vertexShader,fragmentShader:ir.backgroundCube.fragmentShader,side:an,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(x,_,M){this.matrixWorld.copyPosition(M.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),Il.copy(b.backgroundRotation),Il.x*=-1,Il.y*=-1,Il.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(Il.y*=-1,Il.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(O8.makeRotationFromEuler(Il)),c.material.toneMapped=It.getTransfer(y.colorSpace)!==Yt,(h!==y||d!==y.version||u!==s.toneMapping)&&(c.material.needsUpdate=!0,h=y,d=y.version,u=s.toneMapping),c.layers.enableAll(),A.unshift(c,c.geometry,c.material,0,0,null)):y&&y.isTexture&&(l===void 0&&(l=new We(new Ds(2,2),new mi({name:"BackgroundMaterial",uniforms:dh(ir.background.uniforms),vertexShader:ir.background.vertexShader,fragmentShader:ir.background.fragmentShader,side:Yn,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=It.getTransfer(y.colorSpace)!==Yt,y.matrixAutoUpdate===!0&&y.updateMatrix(),l.material.uniforms.uvTransform.value.copy(y.matrix),(h!==y||d!==y.version||u!==s.toneMapping)&&(l.material.needsUpdate=!0,h=y,d=y.version,u=s.toneMapping),l.layers.enableAll(),A.unshift(l,l.geometry,l.material,0,0,null))}function g(A,b){A.getRGB(Eg,gM(s)),t.buffers.color.setClear(Eg.r,Eg.g,Eg.b,b,r)}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(A,b=1){a.set(A),o=b,g(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(A){o=A,g(a,o)},render:m,addToRenderList:v,dispose:f}}function N8(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),i={},n=u(null);let r=n,a=!1;function o(R,D,L,I,O){let N=!1;const G=d(R,I,L,D);r!==G&&(r=G,c(r.object)),N=p(R,I,L,O),N&&m(R,I,L,O),O!==null&&e.update(O,s.ELEMENT_ARRAY_BUFFER),(N||a)&&(a=!1,y(R,D,L,I),O!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(O).buffer))}function l(){return s.createVertexArray()}function c(R){return s.bindVertexArray(R)}function h(R){return s.deleteVertexArray(R)}function d(R,D,L,I){const O=I.wireframe===!0;let N=i[D.id];N===void 0&&(N={},i[D.id]=N);const G=R.isInstancedMesh===!0?R.id:0;let V=N[G];V===void 0&&(V={},N[G]=V);let H=V[L.id];H===void 0&&(H={},V[L.id]=H);let J=H[O];return J===void 0&&(J=u(l()),H[O]=J),J}function u(R){const D=[],L=[],I=[];for(let O=0;O<t;O++)D[O]=0,L[O]=0,I[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:D,enabledAttributes:L,attributeDivisors:I,object:R,attributes:{},index:null}}function p(R,D,L,I){const O=r.attributes,N=D.attributes;let G=0;const V=L.getAttributes();for(const H in V)if(V[H].location>=0){const W=O[H];let X=N[H];if(X===void 0&&(H==="instanceMatrix"&&R.instanceMatrix&&(X=R.instanceMatrix),H==="instanceColor"&&R.instanceColor&&(X=R.instanceColor)),W===void 0||W.attribute!==X||X&&W.data!==X.data)return!0;G++}return r.attributesNum!==G||r.index!==I}function m(R,D,L,I){const O={},N=D.attributes;let G=0;const V=L.getAttributes();for(const H in V)if(V[H].location>=0){let W=N[H];W===void 0&&(H==="instanceMatrix"&&R.instanceMatrix&&(W=R.instanceMatrix),H==="instanceColor"&&R.instanceColor&&(W=R.instanceColor));const X={};X.attribute=W,W&&W.data&&(X.data=W.data),O[H]=X,G++}r.attributes=O,r.attributesNum=G,r.index=I}function v(){const R=r.newAttributes;for(let D=0,L=R.length;D<L;D++)R[D]=0}function g(R){f(R,0)}function f(R,D){const L=r.newAttributes,I=r.enabledAttributes,O=r.attributeDivisors;L[R]=1,I[R]===0&&(s.enableVertexAttribArray(R),I[R]=1),O[R]!==D&&(s.vertexAttribDivisor(R,D),O[R]=D)}function A(){const R=r.newAttributes,D=r.enabledAttributes;for(let L=0,I=D.length;L<I;L++)D[L]!==R[L]&&(s.disableVertexAttribArray(L),D[L]=0)}function b(R,D,L,I,O,N,G){G===!0?s.vertexAttribIPointer(R,D,L,O,N):s.vertexAttribPointer(R,D,L,I,O,N)}function y(R,D,L,I){v();const O=I.attributes,N=L.getAttributes(),G=D.defaultAttributeValues;for(const V in N){const H=N[V];if(H.location>=0){let J=O[V];if(J===void 0&&(V==="instanceMatrix"&&R.instanceMatrix&&(J=R.instanceMatrix),V==="instanceColor"&&R.instanceColor&&(J=R.instanceColor)),J!==void 0){const W=J.normalized,X=J.itemSize,me=e.get(J);if(me===void 0)continue;const Ee=me.buffer,Me=me.type,$=me.bytesPerElement,se=Me===s.INT||Me===s.UNSIGNED_INT||J.gpuType===Ff;if(J.isInterleavedBufferAttribute){const he=J.data,Te=he.stride,Le=J.offset;if(he.isInstancedInterleavedBuffer){for(let Oe=0;Oe<H.locationSize;Oe++)f(H.location+Oe,he.meshPerAttribute);R.isInstancedMesh!==!0&&I._maxInstanceCount===void 0&&(I._maxInstanceCount=he.meshPerAttribute*he.count)}else for(let Oe=0;Oe<H.locationSize;Oe++)g(H.location+Oe);s.bindBuffer(s.ARRAY_BUFFER,Ee);for(let Oe=0;Oe<H.locationSize;Oe++)b(H.location+Oe,X/H.locationSize,Me,W,Te*$,(Le+X/H.locationSize*Oe)*$,se)}else{if(J.isInstancedBufferAttribute){for(let he=0;he<H.locationSize;he++)f(H.location+he,J.meshPerAttribute);R.isInstancedMesh!==!0&&I._maxInstanceCount===void 0&&(I._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let he=0;he<H.locationSize;he++)g(H.location+he);s.bindBuffer(s.ARRAY_BUFFER,Ee);for(let he=0;he<H.locationSize;he++)b(H.location+he,X/H.locationSize,Me,W,X*$,X/H.locationSize*he*$,se)}}else if(G!==void 0){const W=G[V];if(W!==void 0)switch(W.length){case 2:s.vertexAttrib2fv(H.location,W);break;case 3:s.vertexAttrib3fv(H.location,W);break;case 4:s.vertexAttrib4fv(H.location,W);break;default:s.vertexAttrib1fv(H.location,W)}}}}A()}function x(){w();for(const R in i){const D=i[R];for(const L in D){const I=D[L];for(const O in I){const N=I[O];for(const G in N)h(N[G].object),delete N[G];delete I[O]}}delete i[R]}}function _(R){if(i[R.id]===void 0)return;const D=i[R.id];for(const L in D){const I=D[L];for(const O in I){const N=I[O];for(const G in N)h(N[G].object),delete N[G];delete I[O]}}delete i[R.id]}function M(R){for(const D in i){const L=i[D];for(const I in L){const O=L[I];if(O[R.id]===void 0)continue;const N=O[R.id];for(const G in N)h(N[G].object),delete N[G];delete O[R.id]}}}function E(R){for(const D in i){const L=i[D],I=R.isInstancedMesh===!0?R.id:0,O=L[I];if(O!==void 0){for(const N in O){const G=O[N];for(const V in G)h(G[V].object),delete G[V];delete O[N]}delete L[I],Object.keys(L).length===0&&delete i[D]}}}function w(){T(),a=!0,r!==n&&(r=n,c(r.object))}function T(){n.geometry=null,n.program=null,n.wireframe=!1}return{setup:o,reset:w,resetDefaultState:T,dispose:x,releaseStatesOfGeometry:_,releaseStatesOfObject:E,releaseStatesOfProgram:M,initAttributes:v,enableAttribute:g,disableUnusedAttributes:A}}function U8(s,e,t){let i;function n(c){i=c}function r(c,h){s.drawArrays(i,c,h),t.update(h,i,1)}function a(c,h,d){d!==0&&(s.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 m=0;m<d;m++)p+=h[m];t.update(p,i,1)}function l(c,h,d,u){if(d===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let m=0;m<c.length;m++)a(c[m],h[m],u[m]);else{p.multiDrawArraysInstancedWEBGL(i,c,0,h,0,u,0,d);let m=0;for(let v=0;v<d;v++)m+=h[v]*u[v];t.update(m,i,1)}}this.setMode=n,this.render=r,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function z8(s,e,t,i){let n;function r(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const M=e.get("EXT_texture_filter_anisotropic");n=s.getParameter(M.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function a(M){return!(M!==_i&&i.convert(M)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(M){const E=M===li&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(M!==bt&&i.convert(M)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&M!==xi&&!E)}function l(M){if(M==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";M="mediump"}return M==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(Je("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const d=t.logarithmicDepthBuffer===!0,u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),p=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),m=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=s.getParameter(s.MAX_TEXTURE_SIZE),g=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),f=s.getParameter(s.MAX_VERTEX_ATTRIBS),A=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),b=s.getParameter(s.MAX_VARYING_VECTORS),y=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),x=s.getParameter(s.MAX_SAMPLES),_=s.getParameter(s.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:p,maxVertexTextures:m,maxTextureSize:v,maxCubemapSize:g,maxAttributes:f,maxVertexUniforms:A,maxVaryings:b,maxFragmentUniforms:y,maxSamples:x,samples:_}}function H8(s){const e=this;let t=null,i=0,n=!1,r=!1;const a=new $t,o=new yt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){const p=d.length!==0||u||i!==0||n;return n=u,i=d.length,p},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){t=h(d,u,0)},this.setState=function(d,u,p){const m=d.clippingPlanes,v=d.clipIntersection,g=d.clipShadows,f=s.get(d);if(!n||m===null||m.length===0||r&&!g)r?h(null):c();else{const A=r?0:i,b=A*4;let y=f.clippingState||null;l.value=y,y=h(m,u,b,p);for(let x=0;x!==b;++x)y[x]=t[x];f.clippingState=y,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=A}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(d,u,p,m){const v=d!==null?d.length:0;let g=null;if(v!==0){if(g=l.value,m!==!0||g===null){const f=p+v*4,A=u.matrixWorldInverse;o.getNormalMatrix(A),(g===null||g.length<f)&&(g=new Float32Array(f));for(let b=0,y=p;b!==v;++b,y+=4)a.copy(d[b]).applyMatrix4(A,o),a.normal.toArray(g,y),g[y+3]=a.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,g}}const fo=4,hS=[.125,.215,.35,.446,.526,.582],Pl=20,G8=256,ku=new Zi,dS=new qe;let Wb=null,Qb=0,jb=0,Xb=!1;const V8=new P;class Ou{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,r={}){const{size:a=256,position:o=V8}=r;Wb=this._renderer.getRenderTarget(),Qb=this._renderer.getActiveCubeFace(),jb=this._renderer.getActiveMipmapLevel(),Xb=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=fS(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=pS(),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(Wb,Qb,jb),this._renderer.xr.enabled=Xb,e.scissorTest=!1,bh(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===wr||e.mapping===Wa?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Wb=this._renderer.getRenderTarget(),Qb=this._renderer.getActiveCubeFace(),jb=this._renderer.getActiveMipmapLevel(),Xb=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:wt,minFilter:wt,generateMipmaps:!1,type:li,format:_i,colorSpace:qi,depthBuffer:!1},n=uS(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=uS(e,t,i);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=W8(r)),this._blurMaterial=j8(r,e,t),this._ggxMaterial=Q8(r,e,t)}return n}_compileMaterial(e){const t=new We(new dt,e);this._renderer.compile(t,ku)}_sceneToCubeUV(e,t,i,n,r){const l=new wi(90,1,t,i),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],d=this._renderer,u=d.autoClear,p=d.toneMapping;d.getClearColor(dS),d.toneMapping=on,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(n),d.clearDepth(),d.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new We(new fi,new Wt({name:"PMREM.Background",side:an,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,g=v.material;let f=!1;const A=e.background;A?A.isColor&&(g.color.copy(A),e.background=null,f=!0):(g.color.copy(dS),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(r.x,r.y,r.z),l.lookAt(r.x+h[b],r.y,r.z)):y===1?(l.up.set(0,0,c[b]),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y+h[b],r.z)):(l.up.set(0,c[b],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y,r.z+h[b]));const x=this._cubeSize;bh(n,y*x,b>2?x:0,x,x),d.setRenderTarget(n),f&&d.render(v,l),d.render(e,l)}d.toneMapping=p,d.autoClear=u,e.background=A}_textureToCubeUV(e,t){const i=this._renderer,n=e.mapping===wr||e.mapping===Wa;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=fS()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=pS());const r=n?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;bh(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,ku)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const n=this._lodMeshes.length;for(let r=1;r<n;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=i}_applyGGXFilter(e,t,i){const n=this._renderer,r=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),u=0+c*1.25,p=d*u,{_lodMax:m}=this,v=this._sizeLods[i],g=3*v*(i>m-fo?i-m+fo:0),f=4*(this._cubeSize-v);l.envMap.value=e.texture,l.roughness.value=p,l.mipInt.value=m-t,bh(r,g,f,3*v,2*v),n.setRenderTarget(r),n.render(o,ku),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=m-i,bh(e,g,f,3*v,2*v),n.setRenderTarget(e),n.render(o,ku)}_blur(e,t,i,n,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,n,"latitudinal",r),this._halfBlur(a,e,i,i,n,"longitudinal",r)}_halfBlur(e,t,i,n,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&ft("blur direction must be either latitudinal or longitudinal!");const h=3,d=this._lodMeshes[n];d.material=c;const u=c.uniforms,p=this._sizeLods[i]-1,m=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*Pl-1),v=r/m,g=isFinite(r)?1+Math.floor(h*v):Pl;g>Pl&&Je(`sigmaRadians, ${r}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Pl}`);const f=[];let A=0;for(let M=0;M<Pl;++M){const E=M/v,w=Math.exp(-E*E/2);f.push(w),M===0?A+=w:M<g&&(A+=2*w)}for(let M=0;M<f.length;M++)f[M]=f[M]/A;u.envMap.value=e.texture,u.samples.value=g,u.weights.value=f,u.latitudinal.value=a==="latitudinal",o&&(u.poleAxis.value=o);const{_lodMax:b}=this;u.dTheta.value=m,u.mipInt.value=b-i;const y=this._sizeLods[n],x=3*y*(n>b-fo?n-b+fo:0),_=4*(this._cubeSize-y);bh(t,x,_,3*y,2*y),l.setRenderTarget(t),l.render(d,ku)}}function W8(s){const e=[],t=[],i=[];let n=s;const r=s-fo+1+hS.length;for(let a=0;a<r;a++){const o=Math.pow(2,n);e.push(o);let l=1/o;a>s-fo?l=hS[a-s+fo-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),h=-c,d=1+c,u=[h,h,d,h,d,d,h,h,d,d,h,d],p=6,m=6,v=3,g=2,f=1,A=new Float32Array(v*m*p),b=new Float32Array(g*m*p),y=new Float32Array(f*m*p);for(let _=0;_<p;_++){const M=_%3*2/3-1,E=_>2?0:-1,w=[M,E,0,M+2/3,E,0,M+2/3,E+1,0,M,E,0,M+2/3,E+1,0,M,E+1,0];A.set(w,v*m*_),b.set(u,g*m*_);const T=[_,_,_,_,_,_];y.set(T,f*m*_)}const x=new dt;x.setAttribute("position",new _t(A,v)),x.setAttribute("uv",new _t(b,g)),x.setAttribute("faceIndex",new _t(y,f)),i.push(new We(x,null)),n>fo&&n--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function uS(s,e,t){const i=new ki(s,e,t);return i.texture.mapping=Rc,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function bh(s,e,t,i,n){s.viewport.set(e,t,i,n),s.scissor.set(e,t,i,n)}function Q8(s,e,t){return new mi({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:G8,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Mg(),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:vi,depthTest:!1,depthWrite:!1})}function j8(s,e,t){const i=new Float32Array(Pl),n=new P(0,1,0);return new mi({name:"SphericalGaussianBlur",defines:{n:Pl,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:n}},vertexShader:Mg(),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:vi,depthTest:!1,depthWrite:!1})}function pS(){return new mi({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Mg(),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:vi,depthTest:!1,depthWrite:!1})}function fS(){return new mi({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Mg(),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:vi,depthTest:!1,depthWrite:!1})}function Mg(){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 qb extends ki{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 _u(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 fi(5,5,5),r=new mi({name:"CubemapFromEquirect",uniforms:dh(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:an,blending:vi});r.uniforms.tEquirect.value=t;const a=new We(n,r),o=t.minFilter;return t.minFilter===$n&&(t.minFilter=wt),new VM(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 r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,n);e.setRenderTarget(r)}}function X8(s){let e=new WeakMap,t=new WeakMap,i=null;function n(u,p=!1){return u==null?null:p?a(u):r(u)}function r(u){if(u&&u.isTexture){const p=u.mapping;if(p===Dc||p===Od)if(e.has(u)){const m=e.get(u).texture;return o(m,u.mapping)}else{const m=u.image;if(m&&m.height>0){const v=new qb(m.height);return v.fromEquirectangularTexture(s,u),e.set(u,v),u.addEventListener("dispose",c),o(v.texture,u.mapping)}else return null}}return u}function a(u){if(u&&u.isTexture){const p=u.mapping,m=p===Dc||p===Od,v=p===wr||p===Wa;if(m||v){let g=t.get(u);const f=g!==void 0?g.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==f)return i===null&&(i=new Ou(s)),g=m?i.fromEquirectangular(u,g):i.fromCubemap(u,g),g.texture.pmremVersion=u.pmremVersion,t.set(u,g),g.texture;if(g!==void 0)return g.texture;{const A=u.image;return m&&A&&A.height>0||v&&A&&l(A)?(i===null&&(i=new Ou(s)),g=m?i.fromEquirectangular(u):i.fromCubemap(u),g.texture.pmremVersion=u.pmremVersion,t.set(u,g),u.addEventListener("dispose",h),g.texture):null}}}return u}function o(u,p){return p===Dc?u.mapping=wr:p===Od&&(u.mapping=Wa),u}function l(u){let p=0;const m=6;for(let v=0;v<m;v++)u[v]!==void 0&&p++;return p===m}function c(u){const p=u.target;p.removeEventListener("dispose",c);const m=e.get(p);m!==void 0&&(e.delete(p),m.dispose())}function h(u){const p=u.target;p.removeEventListener("dispose",h);const m=t.get(p);m!==void 0&&(t.delete(p),m.dispose())}function d(){e=new WeakMap,t=new WeakMap,i!==null&&(i.dispose(),i=null)}return{get:n,dispose:d}}function q8(s){const e={};function t(i){if(e[i]!==void 0)return e[i];const n=s.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&&su("WebGLRenderer: "+i+" extension not supported."),n}}}function Y8(s,e,t,i){const n={},r=new WeakMap;function a(d){const u=d.target;u.index!==null&&e.remove(u.index);for(const m in u.attributes)e.remove(u.attributes[m]);u.removeEventListener("dispose",a),delete n[u.id];const p=r.get(u);p&&(e.remove(p),r.delete(u)),i.releaseStatesOfGeometry(u),u.isInstancedBufferGeometry===!0&&delete u._maxInstanceCount,t.memory.geometries--}function o(d,u){return n[u.id]===!0||(u.addEventListener("dispose",a),n[u.id]=!0,t.memory.geometries++),u}function l(d){const u=d.attributes;for(const p in u)e.update(u[p],s.ARRAY_BUFFER)}function c(d){const u=[],p=d.index,m=d.attributes.position;let v=0;if(m===void 0)return;if(p!==null){const A=p.array;v=p.version;for(let b=0,y=A.length;b<y;b+=3){const x=A[b+0],_=A[b+1],M=A[b+2];u.push(x,_,_,M,M,x)}}else{const A=m.array;v=m.version;for(let b=0,y=A.length/3-1;b<y;b+=3){const x=b+0,_=b+1,M=b+2;u.push(x,_,_,M,M,x)}}const g=new(m.count>=65535?GA:HA)(u,1);g.version=v;const f=r.get(d);f&&e.remove(f),r.set(d,g)}function h(d){const u=r.get(d);if(u){const p=d.index;p!==null&&u.version<p.version&&c(d)}else c(d);return r.get(d)}return{get:o,update:l,getWireframeAttribute:h}}function K8(s,e,t){let i;function n(u){i=u}let r,a;function o(u){r=u.type,a=u.bytesPerElement}function l(u,p){s.drawElements(i,p,r,u*a),t.update(p,i,1)}function c(u,p,m){m!==0&&(s.drawElementsInstanced(i,p,r,u*a,m),t.update(p,i,m))}function h(u,p,m){if(m===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,p,0,r,u,0,m);let g=0;for(let f=0;f<m;f++)g+=p[f];t.update(g,i,1)}function d(u,p,m,v){if(m===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let f=0;f<u.length;f++)c(u[f]/a,p[f],v[f]);else{g.multiDrawElementsInstancedWEBGL(i,p,0,r,u,0,v,0,m);let f=0;for(let A=0;A<m;A++)f+=p[A]*v[A];t.update(f,i,1)}}this.setMode=n,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=d}function $8(s){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(r,a,o){switch(t.calls++,a){case s.TRIANGLES:t.triangles+=o*(r/3);break;case s.LINES:t.lines+=o*(r/2);break;case s.LINE_STRIP:t.lines+=o*(r-1);break;case s.LINE_LOOP:t.lines+=o*r;break;case s.POINTS:t.points+=o*r;break;default:ft("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 Z8(s,e,t){const i=new WeakMap,n=new zt;function r(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 u=i.get(o);if(u===void 0||u.count!==d){let w=function(){M.dispose(),i.delete(o),o.removeEventListener("dispose",w)};u!==void 0&&u.texture.dispose();const p=o.morphAttributes.position!==void 0,m=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,g=o.morphAttributes.position||[],f=o.morphAttributes.normal||[],A=o.morphAttributes.color||[];let b=0;p===!0&&(b=1),m===!0&&(b=2),v===!0&&(b=3);let y=o.attributes.position.count*b,x=1;y>e.maxTextureSize&&(x=Math.ceil(y/e.maxTextureSize),y=e.maxTextureSize);const _=new Float32Array(y*x*4*d),M=new om(_,y,x,d);M.type=xi,M.needsUpdate=!0;const E=b*4;for(let T=0;T<d;T++){const R=g[T],D=f[T],L=A[T],I=y*x*4*T;for(let O=0;O<R.count;O++){const N=O*E;p===!0&&(n.fromBufferAttribute(R,O),_[I+N+0]=n.x,_[I+N+1]=n.y,_[I+N+2]=n.z,_[I+N+3]=0),m===!0&&(n.fromBufferAttribute(D,O),_[I+N+4]=n.x,_[I+N+5]=n.y,_[I+N+6]=n.z,_[I+N+7]=0),v===!0&&(n.fromBufferAttribute(L,O),_[I+N+8]=n.x,_[I+N+9]=n.y,_[I+N+10]=n.z,_[I+N+11]=L.itemSize===4?n.w:1)}}u={count:d,texture:M,size:new be(y,x)},i.set(o,u),o.addEventListener("dispose",w)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(s,"morphTexture",a.morphTexture,t);else{let p=0;for(let v=0;v<c.length;v++)p+=c[v];const m=o.morphTargetsRelative?1:1-p;l.getUniforms().setValue(s,"morphTargetBaseInfluence",m),l.getUniforms().setValue(s,"morphTargetInfluences",c)}l.getUniforms().setValue(s,"morphTargetsTexture",u.texture,t),l.getUniforms().setValue(s,"morphTargetsTextureSize",u.size)}return{update:r}}function J8(s,e,t,i,n){let r=new WeakMap;function a(c){const h=n.render.frame,d=c.geometry,u=e.get(c,d);if(r.get(u)!==h&&(e.update(u),r.set(u,h)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),r.get(c)!==h&&(t.update(c.instanceMatrix,s.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,s.ARRAY_BUFFER),r.set(c,h))),c.isSkinnedMesh){const p=c.skeleton;r.get(p)!==h&&(p.update(),r.set(p,h))}return u}function o(){r=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 eO={[Pf]:"LINEAR_TONE_MAPPING",[Df]:"REINHARD_TONE_MAPPING",[Rf]:"CINEON_TONE_MAPPING",[Yr]:"ACES_FILMIC_TONE_MAPPING",[Lf]:"AGX_TONE_MAPPING",[kf]:"NEUTRAL_TONE_MAPPING",[Bf]:"CUSTOM_TONE_MAPPING"};function tO(s,e,t,i,n){const r=new ki(e,t,{type:s,depthBuffer:i,stencilBuffer:n}),a=new ki(e,t,{type:li,depthBuffer:!1,stencilBuffer:!1}),o=new dt;o.setAttribute("position",new it([-1,3,0,-1,-1,0,3,-1,0],3)),o.setAttribute("uv",new it([0,2,0,0,2,0],2));const l=new hg({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 We(o,l),h=new Zi(-1,1,1,-1,0,1);let d=null,u=null,p=!1,m,v=null,g=[],f=!1;this.setSize=function(A,b){r.setSize(A,b),a.setSize(A,b);for(let y=0;y<g.length;y++){const x=g[y];x.setSize&&x.setSize(A,b)}},this.setEffects=function(A){g=A,f=g.length>0&&g[0].isRenderPass===!0;const b=r.width,y=r.height;for(let x=0;x<g.length;x++){const _=g[x];_.setSize&&_.setSize(b,y)}},this.begin=function(A,b){if(p||A.toneMapping===on&&g.length===0)return!1;if(v=b,b!==null){const y=b.width,x=b.height;(r.width!==y||r.height!==x)&&this.setSize(y,x)}return f===!1&&A.setRenderTarget(r),m=A.toneMapping,A.toneMapping=on,!0},this.hasRenderPass=function(){return f},this.end=function(A,b){A.toneMapping=m,p=!0;let y=r,x=a;for(let _=0;_<g.length;_++){const M=g[_];if(M.enabled!==!1&&(M.render(A,x,y,b),M.needsSwap!==!1)){const E=y;y=x,x=E}}if(d!==A.outputColorSpace||u!==A.toneMapping){d=A.outputColorSpace,u=A.toneMapping,l.defines={},It.getTransfer(d)===Yt&&(l.defines.SRGB_TRANSFER="");const _=eO[u];_&&(l.defines[_]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=y.texture,A.setRenderTarget(v),A.render(c,h),v=null,p=!1},this.isCompositing=function(){return p},this.dispose=function(){r.dispose(),a.dispose(),o.dispose(),l.dispose()}}const mS=new Ai,Yb=new so(1,1),gS=new om,vS=new au,AS=new _u,bS=[],yS=[],xS=new Float32Array(16),_S=new Float32Array(9),wS=new Float32Array(4);function yh(s,e,t){const i=s[0];if(i<=0||i>0)return s;const n=e*t;let r=bS[n];if(r===void 0&&(r=new Float32Array(n),bS[n]=r),e!==0){i.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,s[a].toArray(r,o)}return r}function Ji(s,e){if(s.length!==e.length)return!1;for(let t=0,i=s.length;t<i;t++)if(s[t]!==e[t])return!1;return!0}function en(s,e){for(let t=0,i=e.length;t<i;t++)s[t]=e[t]}function Sg(s,e){let t=yS[e];t===void 0&&(t=new Int32Array(e),yS[e]=t);for(let i=0;i!==e;++i)t[i]=s.allocateTextureUnit();return t}function iO(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function nO(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ji(t,e))return;s.uniform2fv(this.addr,e),en(t,e)}}function sO(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.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)&&(s.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Ji(t,e))return;s.uniform3fv(this.addr,e),en(t,e)}}function rO(s,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)&&(s.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(Ji(t,e))return;s.uniform4fv(this.addr,e),en(t,e)}}function aO(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(Ji(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),en(t,e)}else{if(Ji(t,i))return;wS.set(i),s.uniformMatrix2fv(this.addr,!1,wS),en(t,i)}}function oO(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(Ji(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),en(t,e)}else{if(Ji(t,i))return;_S.set(i),s.uniformMatrix3fv(this.addr,!1,_S),en(t,i)}}function lO(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(Ji(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),en(t,e)}else{if(Ji(t,i))return;xS.set(i),s.uniformMatrix4fv(this.addr,!1,xS),en(t,i)}}function cO(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function hO(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ji(t,e))return;s.uniform2iv(this.addr,e),en(t,e)}}function dO(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Ji(t,e))return;s.uniform3iv(this.addr,e),en(t,e)}}function uO(s,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)&&(s.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(Ji(t,e))return;s.uniform4iv(this.addr,e),en(t,e)}}function pO(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function fO(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ji(t,e))return;s.uniform2uiv(this.addr,e),en(t,e)}}function mO(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Ji(t,e))return;s.uniform3uiv(this.addr,e),en(t,e)}}function gO(s,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)&&(s.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(Ji(t,e))return;s.uniform4uiv(this.addr,e),en(t,e)}}function vO(s,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(s.uniform1i(this.addr,n),i[0]=n);let r;this.type===s.SAMPLER_2D_SHADOW?(Yb.compareFunction=t.isReversedDepthBuffer()?am:rm,r=Yb):r=mS,t.setTexture2D(e||r,n)}function AO(s,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(s.uniform1i(this.addr,n),i[0]=n),t.setTexture3D(e||vS,n)}function bO(s,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(s.uniform1i(this.addr,n),i[0]=n),t.setTextureCube(e||AS,n)}function yO(s,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(s.uniform1i(this.addr,n),i[0]=n),t.setTexture2DArray(e||gS,n)}function xO(s){switch(s){case 5126:return iO;case 35664:return nO;case 35665:return sO;case 35666:return rO;case 35674:return aO;case 35675:return oO;case 35676:return lO;case 5124:case 35670:return cO;case 35667:case 35671:return hO;case 35668:case 35672:return dO;case 35669:case 35673:return uO;case 5125:return pO;case 36294:return fO;case 36295:return mO;case 36296:return gO;case 35678:case 36198:case 36298:case 36306:case 35682:return vO;case 35679:case 36299:case 36307:return AO;case 35680:case 36300:case 36308:case 36293:return bO;case 36289:case 36303:case 36311:case 36292:return yO}}function _O(s,e){s.uniform1fv(this.addr,e)}function wO(s,e){const t=yh(e,this.size,2);s.uniform2fv(this.addr,t)}function EO(s,e){const t=yh(e,this.size,3);s.uniform3fv(this.addr,t)}function MO(s,e){const t=yh(e,this.size,4);s.uniform4fv(this.addr,t)}function SO(s,e){const t=yh(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function CO(s,e){const t=yh(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function TO(s,e){const t=yh(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function IO(s,e){s.uniform1iv(this.addr,e)}function PO(s,e){s.uniform2iv(this.addr,e)}function DO(s,e){s.uniform3iv(this.addr,e)}function RO(s,e){s.uniform4iv(this.addr,e)}function BO(s,e){s.uniform1uiv(this.addr,e)}function LO(s,e){s.uniform2uiv(this.addr,e)}function kO(s,e){s.uniform3uiv(this.addr,e)}function OO(s,e){s.uniform4uiv(this.addr,e)}function FO(s,e,t){const i=this.cache,n=e.length,r=Sg(t,n);Ji(i,r)||(s.uniform1iv(this.addr,r),en(i,r));let a;this.type===s.SAMPLER_2D_SHADOW?a=Yb:a=mS;for(let o=0;o!==n;++o)t.setTexture2D(e[o]||a,r[o])}function NO(s,e,t){const i=this.cache,n=e.length,r=Sg(t,n);Ji(i,r)||(s.uniform1iv(this.addr,r),en(i,r));for(let a=0;a!==n;++a)t.setTexture3D(e[a]||vS,r[a])}function UO(s,e,t){const i=this.cache,n=e.length,r=Sg(t,n);Ji(i,r)||(s.uniform1iv(this.addr,r),en(i,r));for(let a=0;a!==n;++a)t.setTextureCube(e[a]||AS,r[a])}function zO(s,e,t){const i=this.cache,n=e.length,r=Sg(t,n);Ji(i,r)||(s.uniform1iv(this.addr,r),en(i,r));for(let a=0;a!==n;++a)t.setTexture2DArray(e[a]||gS,r[a])}function HO(s){switch(s){case 5126:return _O;case 35664:return wO;case 35665:return EO;case 35666:return MO;case 35674:return SO;case 35675:return CO;case 35676:return TO;case 5124:case 35670:return IO;case 35667:case 35671:return PO;case 35668:case 35672:return DO;case 35669:case 35673:return RO;case 5125:return BO;case 36294:return LO;case 36295:return kO;case 36296:return OO;case 35678:case 36198:case 36298:case 36306:case 35682:return FO;case 35679:case 36299:case 36307:return NO;case 35680:case 36300:case 36308:case 36293:return UO;case 36289:case 36303:case 36311:case 36292:return zO}}class GO{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=xO(t.type)}}class VO{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=HO(t.type)}}class WO{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const n=this.seq;for(let r=0,a=n.length;r!==a;++r){const o=n[r];o.setValue(e,t[o.id],i)}}}const Kb=/(\w+)(\])?(\[|\.)?/g;function ES(s,e){s.seq.push(e),s.map[e.id]=e}function QO(s,e,t){const i=s.name,n=i.length;for(Kb.lastIndex=0;;){const r=Kb.exec(i),a=Kb.lastIndex;let o=r[1];const l=r[2]==="]",c=r[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===n){ES(t,c===void 0?new GO(o,s,e):new VO(o,s,e));break}else{let d=t.map[o];d===void 0&&(d=new WO(o),ES(t,d)),t=d}}}class Cg{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);QO(o,l,this)}const n=[],r=[];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):r.push(a);n.length>0&&(this.seq=n.concat(r))}setValue(e,t,i,n){const r=this.map[t];r!==void 0&&r.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 r=0,a=t.length;r!==a;++r){const o=t[r],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,n)}}static seqWithValue(e,t){const i=[];for(let n=0,r=e.length;n!==r;++n){const a=e[n];a.id in t&&i.push(a)}return i}}function MS(s,e,t){const i=s.createShader(e);return s.shaderSource(i,t),s.compileShader(i),i}const jO=37297;let XO=0;function qO(s,e){const t=s.split(`
|
||
`),i=[],n=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=n;a<r;a++){const o=a+1;i.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return i.join(`
|
||
`)}const SS=new yt;function YO(s){It._getMatrix(SS,It.workingColorSpace,s);const e=`mat3( ${SS.elements.map(t=>t.toFixed(4))} )`;switch(It.getTransfer(s)){case eu:return[e,"LinearTransferOETF"];case Yt:return[e,"sRGBTransferOETF"];default:return Je("WebGLProgram: Unsupported color space: ",s),[e,"LinearTransferOETF"]}}function CS(s,e,t){const i=s.getShaderParameter(e,s.COMPILE_STATUS),r=(s.getShaderInfoLog(e)||"").trim();if(i&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
|
||
|
||
`+r+`
|
||
|
||
`+qO(s.getShaderSource(e),o)}else return r}function KO(s,e){const t=YO(e);return[`vec4 ${s}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
||
`)}const $O={[Pf]:"Linear",[Df]:"Reinhard",[Rf]:"Cineon",[Yr]:"ACESFilmic",[Lf]:"AgX",[kf]:"Neutral",[Bf]:"Custom"};function ZO(s,e){const t=$O[e];return t===void 0?(Je("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+s+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+s+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Tg=new P;function JO(){It.getLuminanceCoefficients(Tg);const s=Tg.x.toFixed(4),e=Tg.y.toFixed(4),t=Tg.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${s}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
||
`)}function eF(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Fu).join(`
|
||
`)}function tF(s){const e=[];for(const t in s){const i=s[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
|
||
`)}function iF(s,e){const t={},i=s.getProgramParameter(e,s.ACTIVE_ATTRIBUTES);for(let n=0;n<i;n++){const r=s.getActiveAttrib(e,n),a=r.name;let o=1;r.type===s.FLOAT_MAT2&&(o=2),r.type===s.FLOAT_MAT3&&(o=3),r.type===s.FLOAT_MAT4&&(o=4),t[a]={type:r.type,location:s.getAttribLocation(e,a),locationSize:o}}return t}function Fu(s){return s!==""}function TS(s,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return s.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 IS(s,e){return s.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const nF=/^[ \t]*#include +<([\w\d./]+)>/gm;function $b(s){return s.replace(nF,rF)}const sF=new Map;function rF(s,e){let t=Ct[e];if(t===void 0){const i=sF.get(e);if(i!==void 0)t=Ct[i],Je('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return $b(t)}const aF=/#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 PS(s){return s.replace(aF,oF)}function oF(s,e,t,i){let n="";for(let r=parseInt(e);r<parseInt(t);r++)n+=i.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return n}function DS(s){let e=`precision ${s.precision} float;
|
||
precision ${s.precision} int;
|
||
precision ${s.precision} sampler2D;
|
||
precision ${s.precision} samplerCube;
|
||
precision ${s.precision} sampler3D;
|
||
precision ${s.precision} sampler2DArray;
|
||
precision ${s.precision} sampler2DShadow;
|
||
precision ${s.precision} samplerCubeShadow;
|
||
precision ${s.precision} sampler2DArrayShadow;
|
||
precision ${s.precision} isampler2D;
|
||
precision ${s.precision} isampler3D;
|
||
precision ${s.precision} isamplerCube;
|
||
precision ${s.precision} isampler2DArray;
|
||
precision ${s.precision} usampler2D;
|
||
precision ${s.precision} usampler3D;
|
||
precision ${s.precision} usamplerCube;
|
||
precision ${s.precision} usampler2DArray;
|
||
`;return s.precision==="highp"?e+=`
|
||
#define HIGH_PRECISION`:s.precision==="mediump"?e+=`
|
||
#define MEDIUM_PRECISION`:s.precision==="lowp"&&(e+=`
|
||
#define LOW_PRECISION`),e}const lF={[Rd]:"SHADOWMAP_TYPE_PCF",[Pc]:"SHADOWMAP_TYPE_VSM"};function cF(s){return lF[s.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const hF={[wr]:"ENVMAP_TYPE_CUBE",[Wa]:"ENVMAP_TYPE_CUBE",[Rc]:"ENVMAP_TYPE_CUBE_UV"};function dF(s){return s.envMap===!1?"ENVMAP_TYPE_CUBE":hF[s.envMapMode]||"ENVMAP_TYPE_CUBE"}const uF={[Wa]:"ENVMAP_MODE_REFRACTION"};function pF(s){return s.envMap===!1?"ENVMAP_MODE_REFLECTION":uF[s.envMapMode]||"ENVMAP_MODE_REFLECTION"}const fF={[kd]:"ENVMAP_BLENDING_MULTIPLY",[Vw]:"ENVMAP_BLENDING_MIX",[Ww]:"ENVMAP_BLENDING_ADD"};function mF(s){return s.envMap===!1?"ENVMAP_BLENDING_NONE":fF[s.combine]||"ENVMAP_BLENDING_NONE"}function gF(s){const e=s.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 vF(s,e,t,i){const n=s.getContext(),r=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=cF(t),c=dF(t),h=pF(t),d=mF(t),u=gF(t),p=eF(t),m=tF(r),v=n.createProgram();let g,f,A=t.glslVersion?"#version "+t.glslVersion+`
|
||
`:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(Fu).join(`
|
||
`),g.length>0&&(g+=`
|
||
`),f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(Fu).join(`
|
||
`),f.length>0&&(f+=`
|
||
`)):(g=[DS(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,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(Fu).join(`
|
||
`),f=[DS(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,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:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.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!==on?"#define TONE_MAPPING":"",t.toneMapping!==on?Ct.tonemapping_pars_fragment:"",t.toneMapping!==on?ZO("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ct.colorspace_pars_fragment,KO("linearToOutputTexel",t.outputColorSpace),JO(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
||
`].filter(Fu).join(`
|
||
`)),a=$b(a),a=TS(a,t),a=IS(a,t),o=$b(o),o=TS(o,t),o=IS(o,t),a=PS(a),o=PS(o),t.isRawShaderMaterial!==!0&&(A=`#version 300 es
|
||
`,g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
||
`)+`
|
||
`+g,f=["#define varying in",t.glslVersion===EA?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===EA?"":"#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=A+g+a,y=A+f+o,x=MS(n,n.VERTEX_SHADER,b),_=MS(n,n.FRAGMENT_SHADER,y);n.attachShader(v,x),n.attachShader(v,_),t.index0AttributeName!==void 0?n.bindAttribLocation(v,0,t.index0AttributeName):t.morphTargets===!0&&n.bindAttribLocation(v,0,"position"),n.linkProgram(v);function M(R){if(s.debug.checkShaderErrors){const D=n.getProgramInfoLog(v)||"",L=n.getShaderInfoLog(x)||"",I=n.getShaderInfoLog(_)||"",O=D.trim(),N=L.trim(),G=I.trim();let V=!0,H=!0;if(n.getProgramParameter(v,n.LINK_STATUS)===!1)if(V=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(n,v,x,_);else{const J=CS(n,x,"vertex"),W=CS(n,_,"fragment");ft("THREE.WebGLProgram: Shader Error "+n.getError()+" - VALIDATE_STATUS "+n.getProgramParameter(v,n.VALIDATE_STATUS)+`
|
||
|
||
Material Name: `+R.name+`
|
||
Material Type: `+R.type+`
|
||
|
||
Program Info Log: `+O+`
|
||
`+J+`
|
||
`+W)}else O!==""?Je("WebGLProgram: Program Info Log:",O):(N===""||G==="")&&(H=!1);H&&(R.diagnostics={runnable:V,programLog:O,vertexShader:{log:N,prefix:g},fragmentShader:{log:G,prefix:f}})}n.deleteShader(x),n.deleteShader(_),E=new Cg(n,v),w=iF(n,v)}let E;this.getUniforms=function(){return E===void 0&&M(this),E};let w;this.getAttributes=function(){return w===void 0&&M(this),w};let T=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return T===!1&&(T=n.getProgramParameter(v,jO)),T},this.destroy=function(){i.releaseStatesOfProgram(this),n.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=XO++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=x,this.fragmentShader=_,this}let AF=0;class bF{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,n=this._getShaderStage(t),r=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return a.has(n)===!1&&(a.add(n),n.usedTimes++),a.has(r)===!1&&(a.add(r),r.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 yF(e),t.set(e,i)),i}}class yF{constructor(e){this.id=AF++,this.code=e,this.usedTimes=0}}function xF(s,e,t,i,n,r){const a=new cm,o=new bF,l=new Set,c=[],h=new Map,d=i.logarithmicDepthBuffer;let u=i.precision;const p={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 m(E){return l.add(E),E===0?"uv":`uv${E}`}function v(E,w,T,R,D){const L=R.fog,I=D.geometry,O=E.isMeshStandardMaterial||E.isMeshLambertMaterial||E.isMeshPhongMaterial?R.environment:null,N=E.isMeshStandardMaterial||E.isMeshLambertMaterial&&!E.envMap||E.isMeshPhongMaterial&&!E.envMap,G=e.get(E.envMap||O,N),V=G&&G.mapping===Rc?G.image.height:null,H=p[E.type];E.precision!==null&&(u=i.getMaxPrecision(E.precision),u!==E.precision&&Je("WebGLProgram.getParameters:",E.precision,"not supported, using",u,"instead."));const J=I.morphAttributes.position||I.morphAttributes.normal||I.morphAttributes.color,W=J!==void 0?J.length:0;let X=0;I.morphAttributes.position!==void 0&&(X=1),I.morphAttributes.normal!==void 0&&(X=2),I.morphAttributes.color!==void 0&&(X=3);let me,Ee,Me,$;if(H){const ut=ir[H];me=ut.vertexShader,Ee=ut.fragmentShader}else me=E.vertexShader,Ee=E.fragmentShader,o.update(E),Me=o.getVertexShaderID(E),$=o.getFragmentShaderID(E);const se=s.getRenderTarget(),he=s.state.buffers.depth.getReversed(),Te=D.isInstancedMesh===!0,Le=D.isBatchedMesh===!0,Oe=!!E.map,tt=!!E.matcap,Ye=!!G,B=!!E.aoMap,re=!!E.lightMap,ee=!!E.bumpMap,Q=!!E.normalMap,k=!!E.displacementMap,ie=!!E.emissiveMap,fe=!!E.metalnessMap,xe=!!E.roughnessMap,te=E.anisotropy>0,C=E.clearcoat>0,S=E.dispersion>0,F=E.iridescence>0,q=E.sheen>0,K=E.transmission>0,Y=te&&!!E.anisotropyMap,ye=C&&!!E.clearcoatMap,pe=C&&!!E.clearcoatNormalMap,Ue=C&&!!E.clearcoatRoughnessMap,He=F&&!!E.iridescenceMap,oe=F&&!!E.iridescenceThicknessMap,we=q&&!!E.sheenColorMap,Ve=q&&!!E.sheenRoughnessMap,Fe=!!E.specularMap,Ie=!!E.specularColorMap,$e=!!E.specularIntensityMap,z=K&&!!E.transmissionMap,_e=K&&!!E.thicknessMap,ve=!!E.gradientMap,Be=!!E.alphaMap,ge=E.alphaTest>0,ne=!!E.alphaHash,ze=!!E.extensions;let je=on;E.toneMapped&&(se===null||se.isXRRenderTarget===!0)&&(je=s.toneMapping);const vt={shaderID:H,shaderType:E.type,shaderName:E.name,vertexShader:me,fragmentShader:Ee,defines:E.defines,customVertexShaderID:Me,customFragmentShaderID:$,isRawShaderMaterial:E.isRawShaderMaterial===!0,glslVersion:E.glslVersion,precision:u,batching:Le,batchingColor:Le&&D._colorsTexture!==null,instancing:Te,instancingColor:Te&&D.instanceColor!==null,instancingMorph:Te&&D.morphTexture!==null,outputColorSpace:se===null?s.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:qi,alphaToCoverage:!!E.alphaToCoverage,map:Oe,matcap:tt,envMap:Ye,envMapMode:Ye&&G.mapping,envMapCubeUVHeight:V,aoMap:B,lightMap:re,bumpMap:ee,normalMap:Q,displacementMap:k,emissiveMap:ie,normalMapObjectSpace:Q&&E.normalMapType===$w,normalMapTangentSpace:Q&&E.normalMapType===Ya,metalnessMap:fe,roughnessMap:xe,anisotropy:te,anisotropyMap:Y,clearcoat:C,clearcoatMap:ye,clearcoatNormalMap:pe,clearcoatRoughnessMap:Ue,dispersion:S,iridescence:F,iridescenceMap:He,iridescenceThicknessMap:oe,sheen:q,sheenColorMap:we,sheenRoughnessMap:Ve,specularMap:Fe,specularColorMap:Ie,specularIntensityMap:$e,transmission:K,transmissionMap:z,thicknessMap:_e,gradientMap:ve,opaque:E.transparent===!1&&E.blending===Ko&&E.alphaToCoverage===!1,alphaMap:Be,alphaTest:ge,alphaHash:ne,combine:E.combine,mapUv:Oe&&m(E.map.channel),aoMapUv:B&&m(E.aoMap.channel),lightMapUv:re&&m(E.lightMap.channel),bumpMapUv:ee&&m(E.bumpMap.channel),normalMapUv:Q&&m(E.normalMap.channel),displacementMapUv:k&&m(E.displacementMap.channel),emissiveMapUv:ie&&m(E.emissiveMap.channel),metalnessMapUv:fe&&m(E.metalnessMap.channel),roughnessMapUv:xe&&m(E.roughnessMap.channel),anisotropyMapUv:Y&&m(E.anisotropyMap.channel),clearcoatMapUv:ye&&m(E.clearcoatMap.channel),clearcoatNormalMapUv:pe&&m(E.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ue&&m(E.clearcoatRoughnessMap.channel),iridescenceMapUv:He&&m(E.iridescenceMap.channel),iridescenceThicknessMapUv:oe&&m(E.iridescenceThicknessMap.channel),sheenColorMapUv:we&&m(E.sheenColorMap.channel),sheenRoughnessMapUv:Ve&&m(E.sheenRoughnessMap.channel),specularMapUv:Fe&&m(E.specularMap.channel),specularColorMapUv:Ie&&m(E.specularColorMap.channel),specularIntensityMapUv:$e&&m(E.specularIntensityMap.channel),transmissionMapUv:z&&m(E.transmissionMap.channel),thicknessMapUv:_e&&m(E.thicknessMap.channel),alphaMapUv:Be&&m(E.alphaMap.channel),vertexTangents:!!I.attributes.tangent&&(Q||te),vertexColors:E.vertexColors,vertexAlphas:E.vertexColors===!0&&!!I.attributes.color&&I.attributes.color.itemSize===4,pointsUvs:D.isPoints===!0&&!!I.attributes.uv&&(Oe||Be),fog:!!L,useFog:E.fog===!0,fogExp2:!!L&&L.isFogExp2,flatShading:E.wireframe===!1&&(E.flatShading===!0||I.attributes.normal===void 0&&Q===!1&&(E.isMeshLambertMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isMeshPhysicalMaterial)),sizeAttenuation:E.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:he,skinning:D.isSkinnedMesh===!0,morphTargets:I.morphAttributes.position!==void 0,morphNormals:I.morphAttributes.normal!==void 0,morphColors:I.morphAttributes.color!==void 0,morphTargetsCount:W,morphTextureStride:X,numDirLights:w.directional.length,numPointLights:w.point.length,numSpotLights:w.spot.length,numSpotLightMaps:w.spotLightMap.length,numRectAreaLights:w.rectArea.length,numHemiLights:w.hemi.length,numDirLightShadows:w.directionalShadowMap.length,numPointLightShadows:w.pointShadowMap.length,numSpotLightShadows:w.spotShadowMap.length,numSpotLightShadowsWithMaps:w.numSpotLightShadowsWithMaps,numLightProbes:w.numLightProbes,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:E.dithering,shadowMapEnabled:s.shadowMap.enabled&&T.length>0,shadowMapType:s.shadowMap.type,toneMapping:je,decodeVideoTexture:Oe&&E.map.isVideoTexture===!0&&It.getTransfer(E.map.colorSpace)===Yt,decodeVideoTextureEmissive:ie&&E.emissiveMap.isVideoTexture===!0&&It.getTransfer(E.emissiveMap.colorSpace)===Yt,premultipliedAlpha:E.premultipliedAlpha,doubleSided:E.side===qt,flipSided:E.side===an,useDepthPacking:E.depthPacking>=0,depthPacking:E.depthPacking||0,index0AttributeName:E.index0AttributeName,extensionClipCullDistance:ze&&E.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ze&&E.extensions.multiDraw===!0||Le)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:E.customProgramCacheKey()};return vt.vertexUv1s=l.has(1),vt.vertexUv2s=l.has(2),vt.vertexUv3s=l.has(3),l.clear(),vt}function g(E){const w=[];if(E.shaderID?w.push(E.shaderID):(w.push(E.customVertexShaderID),w.push(E.customFragmentShaderID)),E.defines!==void 0)for(const T in E.defines)w.push(T),w.push(E.defines[T]);return E.isRawShaderMaterial===!1&&(f(w,E),A(w,E),w.push(s.outputColorSpace)),w.push(E.customProgramCacheKey),w.join()}function f(E,w){E.push(w.precision),E.push(w.outputColorSpace),E.push(w.envMapMode),E.push(w.envMapCubeUVHeight),E.push(w.mapUv),E.push(w.alphaMapUv),E.push(w.lightMapUv),E.push(w.aoMapUv),E.push(w.bumpMapUv),E.push(w.normalMapUv),E.push(w.displacementMapUv),E.push(w.emissiveMapUv),E.push(w.metalnessMapUv),E.push(w.roughnessMapUv),E.push(w.anisotropyMapUv),E.push(w.clearcoatMapUv),E.push(w.clearcoatNormalMapUv),E.push(w.clearcoatRoughnessMapUv),E.push(w.iridescenceMapUv),E.push(w.iridescenceThicknessMapUv),E.push(w.sheenColorMapUv),E.push(w.sheenRoughnessMapUv),E.push(w.specularMapUv),E.push(w.specularColorMapUv),E.push(w.specularIntensityMapUv),E.push(w.transmissionMapUv),E.push(w.thicknessMapUv),E.push(w.combine),E.push(w.fogExp2),E.push(w.sizeAttenuation),E.push(w.morphTargetsCount),E.push(w.morphAttributeCount),E.push(w.numDirLights),E.push(w.numPointLights),E.push(w.numSpotLights),E.push(w.numSpotLightMaps),E.push(w.numHemiLights),E.push(w.numRectAreaLights),E.push(w.numDirLightShadows),E.push(w.numPointLightShadows),E.push(w.numSpotLightShadows),E.push(w.numSpotLightShadowsWithMaps),E.push(w.numLightProbes),E.push(w.shadowMapType),E.push(w.toneMapping),E.push(w.numClippingPlanes),E.push(w.numClipIntersection),E.push(w.depthPacking)}function A(E,w){a.disableAll(),w.instancing&&a.enable(0),w.instancingColor&&a.enable(1),w.instancingMorph&&a.enable(2),w.matcap&&a.enable(3),w.envMap&&a.enable(4),w.normalMapObjectSpace&&a.enable(5),w.normalMapTangentSpace&&a.enable(6),w.clearcoat&&a.enable(7),w.iridescence&&a.enable(8),w.alphaTest&&a.enable(9),w.vertexColors&&a.enable(10),w.vertexAlphas&&a.enable(11),w.vertexUv1s&&a.enable(12),w.vertexUv2s&&a.enable(13),w.vertexUv3s&&a.enable(14),w.vertexTangents&&a.enable(15),w.anisotropy&&a.enable(16),w.alphaHash&&a.enable(17),w.batching&&a.enable(18),w.dispersion&&a.enable(19),w.batchingColor&&a.enable(20),w.gradientMap&&a.enable(21),E.push(a.mask),a.disableAll(),w.fog&&a.enable(0),w.useFog&&a.enable(1),w.flatShading&&a.enable(2),w.logarithmicDepthBuffer&&a.enable(3),w.reversedDepthBuffer&&a.enable(4),w.skinning&&a.enable(5),w.morphTargets&&a.enable(6),w.morphNormals&&a.enable(7),w.morphColors&&a.enable(8),w.premultipliedAlpha&&a.enable(9),w.shadowMapEnabled&&a.enable(10),w.doubleSided&&a.enable(11),w.flipSided&&a.enable(12),w.useDepthPacking&&a.enable(13),w.dithering&&a.enable(14),w.transmission&&a.enable(15),w.sheen&&a.enable(16),w.opaque&&a.enable(17),w.pointsUvs&&a.enable(18),w.decodeVideoTexture&&a.enable(19),w.decodeVideoTextureEmissive&&a.enable(20),w.alphaToCoverage&&a.enable(21),E.push(a.mask)}function b(E){const w=p[E.type];let T;if(w){const R=ir[w];T=Mn.clone(R.uniforms)}else T=E.uniforms;return T}function y(E,w){let T=h.get(w);return T!==void 0?++T.usedTimes:(T=new vF(s,w,E,n),c.push(T),h.set(w,T)),T}function x(E){if(--E.usedTimes===0){const w=c.indexOf(E);c[w]=c[c.length-1],c.pop(),h.delete(E.cacheKey),E.destroy()}}function _(E){o.remove(E)}function M(){o.dispose()}return{getParameters:v,getProgramCacheKey:g,getUniforms:b,acquireProgram:y,releaseProgram:x,releaseShaderCache:_,programs:c,dispose:M}}function _F(){let s=new WeakMap;function e(a){return s.has(a)}function t(a){let o=s.get(a);return o===void 0&&(o={},s.set(a,o)),o}function i(a){s.delete(a)}function n(a,o,l){s.get(a)[o]=l}function r(){s=new WeakMap}return{has:e,get:t,remove:i,update:n,dispose:r}}function wF(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.materialVariant!==e.materialVariant?s.materialVariant-e.materialVariant:s.z!==e.z?s.z-e.z:s.id-e.id}function RS(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function BS(){const s=[];let e=0;const t=[],i=[],n=[];function r(){e=0,t.length=0,i.length=0,n.length=0}function a(u){let p=0;return u.isInstancedMesh&&(p+=2),u.isSkinnedMesh&&(p+=1),p}function o(u,p,m,v,g,f){let A=s[e];return A===void 0?(A={id:u.id,object:u,geometry:p,material:m,materialVariant:a(u),groupOrder:v,renderOrder:u.renderOrder,z:g,group:f},s[e]=A):(A.id=u.id,A.object=u,A.geometry=p,A.material=m,A.materialVariant=a(u),A.groupOrder=v,A.renderOrder=u.renderOrder,A.z=g,A.group=f),e++,A}function l(u,p,m,v,g,f){const A=o(u,p,m,v,g,f);m.transmission>0?i.push(A):m.transparent===!0?n.push(A):t.push(A)}function c(u,p,m,v,g,f){const A=o(u,p,m,v,g,f);m.transmission>0?i.unshift(A):m.transparent===!0?n.unshift(A):t.unshift(A)}function h(u,p){t.length>1&&t.sort(u||wF),i.length>1&&i.sort(p||RS),n.length>1&&n.sort(p||RS)}function d(){for(let u=e,p=s.length;u<p;u++){const m=s[u];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:t,transmissive:i,transparent:n,init:r,push:l,unshift:c,finish:d,sort:h}}function EF(){let s=new WeakMap;function e(i,n){const r=s.get(i);let a;return r===void 0?(a=new BS,s.set(i,[a])):n>=r.length?(a=new BS,r.push(a)):a=r[n],a}function t(){s=new WeakMap}return{get:e,dispose:t}}function MF(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new P,color:new qe};break;case"SpotLight":t={position:new P,direction:new P,color:new qe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new P,color:new qe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new P,skyColor:new qe,groundColor:new qe};break;case"RectAreaLight":t={color:new qe,position:new P,halfWidth:new P,halfHeight:new P};break}return s[e.id]=t,t}}}function SF(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[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 s[e.id]=t,t}}}let CF=0;function TF(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function IF(s){const e=new MF,t=SF(),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 P);const n=new P,r=new Ke,a=new Ke;function o(c){let h=0,d=0,u=0;for(let w=0;w<9;w++)i.probe[w].set(0,0,0);let p=0,m=0,v=0,g=0,f=0,A=0,b=0,y=0,x=0,_=0,M=0;c.sort(TF);for(let w=0,T=c.length;w<T;w++){const R=c[w],D=R.color,L=R.intensity,I=R.distance;let O=null;if(R.shadow&&R.shadow.map&&(R.shadow.map.texture.format===Is?O=R.shadow.map.texture:O=R.shadow.map.depthTexture||R.shadow.map.texture),R.isAmbientLight)h+=D.r*L,d+=D.g*L,u+=D.b*L;else if(R.isLightProbe){for(let N=0;N<9;N++)i.probe[N].addScaledVector(R.sh.coefficients[N],L);M++}else if(R.isDirectionalLight){const N=e.get(R);if(N.color.copy(R.color).multiplyScalar(R.intensity),R.castShadow){const G=R.shadow,V=t.get(R);V.shadowIntensity=G.intensity,V.shadowBias=G.bias,V.shadowNormalBias=G.normalBias,V.shadowRadius=G.radius,V.shadowMapSize=G.mapSize,i.directionalShadow[p]=V,i.directionalShadowMap[p]=O,i.directionalShadowMatrix[p]=R.shadow.matrix,A++}i.directional[p]=N,p++}else if(R.isSpotLight){const N=e.get(R);N.position.setFromMatrixPosition(R.matrixWorld),N.color.copy(D).multiplyScalar(L),N.distance=I,N.coneCos=Math.cos(R.angle),N.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),N.decay=R.decay,i.spot[v]=N;const G=R.shadow;if(R.map&&(i.spotLightMap[x]=R.map,x++,G.updateMatrices(R),R.castShadow&&_++),i.spotLightMatrix[v]=G.matrix,R.castShadow){const V=t.get(R);V.shadowIntensity=G.intensity,V.shadowBias=G.bias,V.shadowNormalBias=G.normalBias,V.shadowRadius=G.radius,V.shadowMapSize=G.mapSize,i.spotShadow[v]=V,i.spotShadowMap[v]=O,y++}v++}else if(R.isRectAreaLight){const N=e.get(R);N.color.copy(D).multiplyScalar(L),N.halfWidth.set(R.width*.5,0,0),N.halfHeight.set(0,R.height*.5,0),i.rectArea[g]=N,g++}else if(R.isPointLight){const N=e.get(R);if(N.color.copy(R.color).multiplyScalar(R.intensity),N.distance=R.distance,N.decay=R.decay,R.castShadow){const G=R.shadow,V=t.get(R);V.shadowIntensity=G.intensity,V.shadowBias=G.bias,V.shadowNormalBias=G.normalBias,V.shadowRadius=G.radius,V.shadowMapSize=G.mapSize,V.shadowCameraNear=G.camera.near,V.shadowCameraFar=G.camera.far,i.pointShadow[m]=V,i.pointShadowMap[m]=O,i.pointShadowMatrix[m]=R.shadow.matrix,b++}i.point[m]=N,m++}else if(R.isHemisphereLight){const N=e.get(R);N.skyColor.copy(R.color).multiplyScalar(L),N.groundColor.copy(R.groundColor).multiplyScalar(L),i.hemi[f]=N,f++}}g>0&&(s.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=et.LTC_FLOAT_1,i.rectAreaLTC2=et.LTC_FLOAT_2):(i.rectAreaLTC1=et.LTC_HALF_1,i.rectAreaLTC2=et.LTC_HALF_2)),i.ambient[0]=h,i.ambient[1]=d,i.ambient[2]=u;const E=i.hash;(E.directionalLength!==p||E.pointLength!==m||E.spotLength!==v||E.rectAreaLength!==g||E.hemiLength!==f||E.numDirectionalShadows!==A||E.numPointShadows!==b||E.numSpotShadows!==y||E.numSpotMaps!==x||E.numLightProbes!==M)&&(i.directional.length=p,i.spot.length=v,i.rectArea.length=g,i.point.length=m,i.hemi.length=f,i.directionalShadow.length=A,i.directionalShadowMap.length=A,i.pointShadow.length=b,i.pointShadowMap.length=b,i.spotShadow.length=y,i.spotShadowMap.length=y,i.directionalShadowMatrix.length=A,i.pointShadowMatrix.length=b,i.spotLightMatrix.length=y+x-_,i.spotLightMap.length=x,i.numSpotLightShadowsWithMaps=_,i.numLightProbes=M,E.directionalLength=p,E.pointLength=m,E.spotLength=v,E.rectAreaLength=g,E.hemiLength=f,E.numDirectionalShadows=A,E.numPointShadows=b,E.numSpotShadows=y,E.numSpotMaps=x,E.numLightProbes=M,i.version=CF++)}function l(c,h){let d=0,u=0,p=0,m=0,v=0;const g=h.matrixWorldInverse;for(let f=0,A=c.length;f<A;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[p];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),p++}else if(b.isRectAreaLight){const y=i.rectArea[m];y.position.setFromMatrixPosition(b.matrixWorld),y.position.applyMatrix4(g),a.identity(),r.copy(b.matrixWorld),r.premultiply(g),a.extractRotation(r),y.halfWidth.set(b.width*.5,0,0),y.halfHeight.set(0,b.height*.5,0),y.halfWidth.applyMatrix4(a),y.halfHeight.applyMatrix4(a),m++}else if(b.isPointLight){const y=i.point[u];y.position.setFromMatrixPosition(b.matrixWorld),y.position.applyMatrix4(g),u++}else if(b.isHemisphereLight){const y=i.hemi[v];y.direction.setFromMatrixPosition(b.matrixWorld),y.direction.transformDirection(g),v++}}}return{setup:o,setupView:l,state:i}}function LS(s){const e=new IF(s),t=[],i=[];function n(h){c.camera=h,t.length=0,i.length=0}function r(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:r,pushShadow:a}}function PF(s){let e=new WeakMap;function t(n,r=0){const a=e.get(n);let o;return a===void 0?(o=new LS(s),e.set(n,[o])):r>=a.length?(o=new LS(s),a.push(o)):o=a[r],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const DF=`void main() {
|
||
gl_Position = vec4( position, 1.0 );
|
||
}`,RF=`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 );
|
||
}`,BF=[new P(1,0,0),new P(-1,0,0),new P(0,1,0),new P(0,-1,0),new P(0,0,1),new P(0,0,-1)],LF=[new P(0,-1,0),new P(0,-1,0),new P(0,0,1),new P(0,0,-1),new P(0,-1,0),new P(0,-1,0)],kS=new Ke,Nu=new P,Zb=new P;function kF(s,e,t){let i=new oh;const n=new be,r=new be,a=new zt,o=new bb,l=new yb,c={},h=t.maxTextureSize,d={[Yn]:an,[an]:Yn,[qt]:qt},u=new mi({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new be},radius:{value:4}},vertexShader:DF,fragmentShader:RF}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const m=new dt;m.setAttribute("position",new _t(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new We(m,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Rd;let f=this.type;this.render=function(_,M,E){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||_.length===0)return;this.type===Tw&&(Je("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Rd);const w=s.getRenderTarget(),T=s.getActiveCubeFace(),R=s.getActiveMipmapLevel(),D=s.state;D.setBlending(vi),D.buffers.depth.getReversed()===!0?D.buffers.color.setClear(0,0,0,0):D.buffers.color.setClear(1,1,1,1),D.buffers.depth.setTest(!0),D.setScissorTest(!1);const L=f!==this.type;L&&M.traverse(function(I){I.material&&(Array.isArray(I.material)?I.material.forEach(O=>O.needsUpdate=!0):I.material.needsUpdate=!0)});for(let I=0,O=_.length;I<O;I++){const N=_[I],G=N.shadow;if(G===void 0){Je("WebGLShadowMap:",N,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;n.copy(G.mapSize);const V=G.getFrameExtents();n.multiply(V),r.copy(G.mapSize),(n.x>h||n.y>h)&&(n.x>h&&(r.x=Math.floor(h/V.x),n.x=r.x*V.x,G.mapSize.x=r.x),n.y>h&&(r.y=Math.floor(h/V.y),n.y=r.y*V.y,G.mapSize.y=r.y));const H=s.state.buffers.depth.getReversed();if(G.camera._reversedDepth=H,G.map===null||L===!0){if(G.map!==null&&(G.map.depthTexture!==null&&(G.map.depthTexture.dispose(),G.map.depthTexture=null),G.map.dispose()),this.type===Pc){if(N.isPointLight){Je("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}G.map=new ki(n.x,n.y,{format:Is,type:li,minFilter:wt,magFilter:wt,generateMipmaps:!1}),G.map.texture.name=N.name+".shadowMap",G.map.depthTexture=new so(n.x,n.y,xi),G.map.depthTexture.name=N.name+".shadowMapDepth",G.map.depthTexture.format=Er,G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Jt,G.map.depthTexture.magFilter=Jt}else N.isPointLight?(G.map=new qb(n.x),G.map.depthTexture=new $E(n.x,Ts)):(G.map=new ki(n.x,n.y),G.map.depthTexture=new so(n.x,n.y,Ts)),G.map.depthTexture.name=N.name+".shadowMap",G.map.depthTexture.format=Er,this.type===Rd?(G.map.depthTexture.compareFunction=H?am:rm,G.map.depthTexture.minFilter=wt,G.map.depthTexture.magFilter=wt):(G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Jt,G.map.depthTexture.magFilter=Jt);G.camera.updateProjectionMatrix()}const J=G.map.isWebGLCubeRenderTarget?6:1;for(let W=0;W<J;W++){if(G.map.isWebGLCubeRenderTarget)s.setRenderTarget(G.map,W),s.clear();else{W===0&&(s.setRenderTarget(G.map),s.clear());const X=G.getViewport(W);a.set(r.x*X.x,r.y*X.y,r.x*X.z,r.y*X.w),D.viewport(a)}if(N.isPointLight){const X=G.camera,me=G.matrix,Ee=N.distance||X.far;Ee!==X.far&&(X.far=Ee,X.updateProjectionMatrix()),Nu.setFromMatrixPosition(N.matrixWorld),X.position.copy(Nu),Zb.copy(X.position),Zb.add(BF[W]),X.up.copy(LF[W]),X.lookAt(Zb),X.updateMatrixWorld(),me.makeTranslation(-Nu.x,-Nu.y,-Nu.z),kS.multiplyMatrices(X.projectionMatrix,X.matrixWorldInverse),G._frustum.setFromProjectionMatrix(kS,X.coordinateSystem,X.reversedDepth)}else G.updateMatrices(N);i=G.getFrustum(),y(M,E,G.camera,N,this.type)}G.isPointLightShadow!==!0&&this.type===Pc&&A(G,E),G.needsUpdate=!1}f=this.type,g.needsUpdate=!1,s.setRenderTarget(w,T,R)};function A(_,M){const E=e.update(v);u.defines.VSM_SAMPLES!==_.blurSamples&&(u.defines.VSM_SAMPLES=_.blurSamples,p.defines.VSM_SAMPLES=_.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),_.mapPass===null&&(_.mapPass=new ki(n.x,n.y,{format:Is,type:li})),u.uniforms.shadow_pass.value=_.map.depthTexture,u.uniforms.resolution.value=_.mapSize,u.uniforms.radius.value=_.radius,s.setRenderTarget(_.mapPass),s.clear(),s.renderBufferDirect(M,null,E,u,v,null),p.uniforms.shadow_pass.value=_.mapPass.texture,p.uniforms.resolution.value=_.mapSize,p.uniforms.radius.value=_.radius,s.setRenderTarget(_.map),s.clear(),s.renderBufferDirect(M,null,E,p,v,null)}function b(_,M,E,w){let T=null;const R=E.isPointLight===!0?_.customDistanceMaterial:_.customDepthMaterial;if(R!==void 0)T=R;else if(T=E.isPointLight===!0?l:o,s.localClippingEnabled&&M.clipShadows===!0&&Array.isArray(M.clippingPlanes)&&M.clippingPlanes.length!==0||M.displacementMap&&M.displacementScale!==0||M.alphaMap&&M.alphaTest>0||M.map&&M.alphaTest>0||M.alphaToCoverage===!0){const D=T.uuid,L=M.uuid;let I=c[D];I===void 0&&(I={},c[D]=I);let O=I[L];O===void 0&&(O=T.clone(),I[L]=O,M.addEventListener("dispose",x)),T=O}if(T.visible=M.visible,T.wireframe=M.wireframe,w===Pc?T.side=M.shadowSide!==null?M.shadowSide:M.side:T.side=M.shadowSide!==null?M.shadowSide:d[M.side],T.alphaMap=M.alphaMap,T.alphaTest=M.alphaToCoverage===!0?.5:M.alphaTest,T.map=M.map,T.clipShadows=M.clipShadows,T.clippingPlanes=M.clippingPlanes,T.clipIntersection=M.clipIntersection,T.displacementMap=M.displacementMap,T.displacementScale=M.displacementScale,T.displacementBias=M.displacementBias,T.wireframeLinewidth=M.wireframeLinewidth,T.linewidth=M.linewidth,E.isPointLight===!0&&T.isMeshDistanceMaterial===!0){const D=s.properties.get(T);D.light=E}return T}function y(_,M,E,w,T){if(_.visible===!1)return;if(_.layers.test(M.layers)&&(_.isMesh||_.isLine||_.isPoints)&&(_.castShadow||_.receiveShadow&&T===Pc)&&(!_.frustumCulled||i.intersectsObject(_))){_.modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,_.matrixWorld);const L=e.update(_),I=_.material;if(Array.isArray(I)){const O=L.groups;for(let N=0,G=O.length;N<G;N++){const V=O[N],H=I[V.materialIndex];if(H&&H.visible){const J=b(_,H,w,T);_.onBeforeShadow(s,_,M,E,L,J,V),s.renderBufferDirect(E,null,L,J,_,V),_.onAfterShadow(s,_,M,E,L,J,V)}}}else if(I.visible){const O=b(_,I,w,T);_.onBeforeShadow(s,_,M,E,L,O,null),s.renderBufferDirect(E,null,L,O,_,null),_.onAfterShadow(s,_,M,E,L,O,null)}}const D=_.children;for(let L=0,I=D.length;L<I;L++)y(D[L],M,E,w,T)}function x(_){_.target.removeEventListener("dispose",x);for(const E in c){const w=c[E],T=_.target.uuid;T in w&&(w[T].dispose(),delete w[T])}}}function OF(s,e){function t(){let z=!1;const _e=new zt;let ve=null;const Be=new zt(0,0,0,0);return{setMask:function(ge){ve!==ge&&!z&&(s.colorMask(ge,ge,ge,ge),ve=ge)},setLocked:function(ge){z=ge},setClear:function(ge,ne,ze,je,vt){vt===!0&&(ge*=je,ne*=je,ze*=je),_e.set(ge,ne,ze,je),Be.equals(_e)===!1&&(s.clearColor(ge,ne,ze,je),Be.copy(_e))},reset:function(){z=!1,ve=null,Be.set(-1,0,0,0)}}}function i(){let z=!1,_e=!1,ve=null,Be=null,ge=null;return{setReversed:function(ne){if(_e!==ne){const ze=e.get("EXT_clip_control");ne?ze.clipControlEXT(ze.LOWER_LEFT_EXT,ze.ZERO_TO_ONE_EXT):ze.clipControlEXT(ze.LOWER_LEFT_EXT,ze.NEGATIVE_ONE_TO_ONE_EXT),_e=ne;const je=ge;ge=null,this.setClear(je)}},getReversed:function(){return _e},setTest:function(ne){ne?se(s.DEPTH_TEST):he(s.DEPTH_TEST)},setMask:function(ne){ve!==ne&&!z&&(s.depthMask(ne),ve=ne)},setFunc:function(ne){if(_e&&(ne=K4[ne]),Be!==ne){switch(ne){case wf:s.depthFunc(s.NEVER);break;case Ef:s.depthFunc(s.ALWAYS);break;case Mf:s.depthFunc(s.LESS);break;case $o:s.depthFunc(s.LEQUAL);break;case Sf:s.depthFunc(s.EQUAL);break;case Cf:s.depthFunc(s.GEQUAL);break;case Tf:s.depthFunc(s.GREATER);break;case If:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}Be=ne}},setLocked:function(ne){z=ne},setClear:function(ne){ge!==ne&&(ge=ne,_e&&(ne=1-ne),s.clearDepth(ne))},reset:function(){z=!1,ve=null,Be=null,ge=null,_e=!1}}}function n(){let z=!1,_e=null,ve=null,Be=null,ge=null,ne=null,ze=null,je=null,vt=null;return{setTest:function(ut){z||(ut?se(s.STENCIL_TEST):he(s.STENCIL_TEST))},setMask:function(ut){_e!==ut&&!z&&(s.stencilMask(ut),_e=ut)},setFunc:function(ut,Xi,Ht){(ve!==ut||Be!==Xi||ge!==Ht)&&(s.stencilFunc(ut,Xi,Ht),ve=ut,Be=Xi,ge=Ht)},setOp:function(ut,Xi,Ht){(ne!==ut||ze!==Xi||je!==Ht)&&(s.stencilOp(ut,Xi,Ht),ne=ut,ze=Xi,je=Ht)},setLocked:function(ut){z=ut},setClear:function(ut){vt!==ut&&(s.clearStencil(ut),vt=ut)},reset:function(){z=!1,_e=null,ve=null,Be=null,ge=null,ne=null,ze=null,je=null,vt=null}}}const r=new t,a=new i,o=new n,l=new WeakMap,c=new WeakMap;let h={},d={},u=new WeakMap,p=[],m=null,v=!1,g=null,f=null,A=null,b=null,y=null,x=null,_=null,M=new qe(0,0,0),E=0,w=!1,T=null,R=null,D=null,L=null,I=null;const O=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let N=!1,G=0;const V=s.getParameter(s.VERSION);V.indexOf("WebGL")!==-1?(G=parseFloat(/^WebGL (\d)/.exec(V)[1]),N=G>=1):V.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(V)[1]),N=G>=2);let H=null,J={};const W=s.getParameter(s.SCISSOR_BOX),X=s.getParameter(s.VIEWPORT),me=new zt().fromArray(W),Ee=new zt().fromArray(X);function Me(z,_e,ve,Be){const ge=new Uint8Array(4),ne=s.createTexture();s.bindTexture(z,ne),s.texParameteri(z,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(z,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let ze=0;ze<ve;ze++)z===s.TEXTURE_3D||z===s.TEXTURE_2D_ARRAY?s.texImage3D(_e,0,s.RGBA,1,1,Be,0,s.RGBA,s.UNSIGNED_BYTE,ge):s.texImage2D(_e+ze,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,ge);return ne}const $={};$[s.TEXTURE_2D]=Me(s.TEXTURE_2D,s.TEXTURE_2D,1),$[s.TEXTURE_CUBE_MAP]=Me(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),$[s.TEXTURE_2D_ARRAY]=Me(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),$[s.TEXTURE_3D]=Me(s.TEXTURE_3D,s.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),se(s.DEPTH_TEST),a.setFunc($o),ee(!1),Q(pA),se(s.CULL_FACE),B(vi);function se(z){h[z]!==!0&&(s.enable(z),h[z]=!0)}function he(z){h[z]!==!1&&(s.disable(z),h[z]=!1)}function Te(z,_e){return d[z]!==_e?(s.bindFramebuffer(z,_e),d[z]=_e,z===s.DRAW_FRAMEBUFFER&&(d[s.FRAMEBUFFER]=_e),z===s.FRAMEBUFFER&&(d[s.DRAW_FRAMEBUFFER]=_e),!0):!1}function Le(z,_e){let ve=p,Be=!1;if(z){ve=u.get(_e),ve===void 0&&(ve=[],u.set(_e,ve));const ge=z.textures;if(ve.length!==ge.length||ve[0]!==s.COLOR_ATTACHMENT0){for(let ne=0,ze=ge.length;ne<ze;ne++)ve[ne]=s.COLOR_ATTACHMENT0+ne;ve.length=ge.length,Be=!0}}else ve[0]!==s.BACK&&(ve[0]=s.BACK,Be=!0);Be&&s.drawBuffers(ve)}function Oe(z){return m!==z?(s.useProgram(z),m=z,!0):!1}const tt={[Kn]:s.FUNC_ADD,[Iw]:s.FUNC_SUBTRACT,[Pw]:s.FUNC_REVERSE_SUBTRACT};tt[Dw]=s.MIN,tt[Rw]=s.MAX;const Ye={[Va]:s.ZERO,[Bw]:s.ONE,[Lw]:s.SRC_COLOR,[xf]:s.SRC_ALPHA,[Nw]:s.SRC_ALPHA_SATURATE,[Ld]:s.DST_COLOR,[Bd]:s.DST_ALPHA,[kw]:s.ONE_MINUS_SRC_COLOR,[_f]:s.ONE_MINUS_SRC_ALPHA,[Fw]:s.ONE_MINUS_DST_COLOR,[Ow]:s.ONE_MINUS_DST_ALPHA,[Uw]:s.CONSTANT_COLOR,[zw]:s.ONE_MINUS_CONSTANT_COLOR,[Hw]:s.CONSTANT_ALPHA,[Gw]:s.ONE_MINUS_CONSTANT_ALPHA};function B(z,_e,ve,Be,ge,ne,ze,je,vt,ut){if(z===vi){v===!0&&(he(s.BLEND),v=!1);return}if(v===!1&&(se(s.BLEND),v=!0),z!==yf){if(z!==g||ut!==w){if((f!==Kn||y!==Kn)&&(s.blendEquation(s.FUNC_ADD),f=Kn,y=Kn),ut)switch(z){case Ko:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case bf:s.blendFunc(s.ONE,s.ONE);break;case fA:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case mA:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:ft("WebGLState: Invalid blending: ",z);break}else switch(z){case Ko:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case bf:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case fA:ft("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case mA:ft("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ft("WebGLState: Invalid blending: ",z);break}A=null,b=null,x=null,_=null,M.set(0,0,0),E=0,g=z,w=ut}return}ge=ge||_e,ne=ne||ve,ze=ze||Be,(_e!==f||ge!==y)&&(s.blendEquationSeparate(tt[_e],tt[ge]),f=_e,y=ge),(ve!==A||Be!==b||ne!==x||ze!==_)&&(s.blendFuncSeparate(Ye[ve],Ye[Be],Ye[ne],Ye[ze]),A=ve,b=Be,x=ne,_=ze),(je.equals(M)===!1||vt!==E)&&(s.blendColor(je.r,je.g,je.b,vt),M.copy(je),E=vt),g=z,w=!1}function re(z,_e){z.side===qt?he(s.CULL_FACE):se(s.CULL_FACE);let ve=z.side===an;_e&&(ve=!ve),ee(ve),z.blending===Ko&&z.transparent===!1?B(vi):B(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),r.setMask(z.colorWrite);const Be=z.stencilWrite;o.setTest(Be),Be&&(o.setMask(z.stencilWriteMask),o.setFunc(z.stencilFunc,z.stencilRef,z.stencilFuncMask),o.setOp(z.stencilFail,z.stencilZFail,z.stencilZPass)),ie(z.polygonOffset,z.polygonOffsetFactor,z.polygonOffsetUnits),z.alphaToCoverage===!0?se(s.SAMPLE_ALPHA_TO_COVERAGE):he(s.SAMPLE_ALPHA_TO_COVERAGE)}function ee(z){T!==z&&(z?s.frontFace(s.CW):s.frontFace(s.CCW),T=z)}function Q(z){z!==Sw?(se(s.CULL_FACE),z!==R&&(z===pA?s.cullFace(s.BACK):z===Cw?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):he(s.CULL_FACE),R=z}function k(z){z!==D&&(N&&s.lineWidth(z),D=z)}function ie(z,_e,ve){z?(se(s.POLYGON_OFFSET_FILL),(L!==_e||I!==ve)&&(L=_e,I=ve,a.getReversed()&&(_e=-_e),s.polygonOffset(_e,ve))):he(s.POLYGON_OFFSET_FILL)}function fe(z){z?se(s.SCISSOR_TEST):he(s.SCISSOR_TEST)}function xe(z){z===void 0&&(z=s.TEXTURE0+O-1),H!==z&&(s.activeTexture(z),H=z)}function te(z,_e,ve){ve===void 0&&(H===null?ve=s.TEXTURE0+O-1:ve=H);let Be=J[ve];Be===void 0&&(Be={type:void 0,texture:void 0},J[ve]=Be),(Be.type!==z||Be.texture!==_e)&&(H!==ve&&(s.activeTexture(ve),H=ve),s.bindTexture(z,_e||$[z]),Be.type=z,Be.texture=_e)}function C(){const z=J[H];z!==void 0&&z.type!==void 0&&(s.bindTexture(z.type,null),z.type=void 0,z.texture=void 0)}function S(){try{s.compressedTexImage2D(...arguments)}catch(z){ft("WebGLState:",z)}}function F(){try{s.compressedTexImage3D(...arguments)}catch(z){ft("WebGLState:",z)}}function q(){try{s.texSubImage2D(...arguments)}catch(z){ft("WebGLState:",z)}}function K(){try{s.texSubImage3D(...arguments)}catch(z){ft("WebGLState:",z)}}function Y(){try{s.compressedTexSubImage2D(...arguments)}catch(z){ft("WebGLState:",z)}}function ye(){try{s.compressedTexSubImage3D(...arguments)}catch(z){ft("WebGLState:",z)}}function pe(){try{s.texStorage2D(...arguments)}catch(z){ft("WebGLState:",z)}}function Ue(){try{s.texStorage3D(...arguments)}catch(z){ft("WebGLState:",z)}}function He(){try{s.texImage2D(...arguments)}catch(z){ft("WebGLState:",z)}}function oe(){try{s.texImage3D(...arguments)}catch(z){ft("WebGLState:",z)}}function we(z){me.equals(z)===!1&&(s.scissor(z.x,z.y,z.z,z.w),me.copy(z))}function Ve(z){Ee.equals(z)===!1&&(s.viewport(z.x,z.y,z.z,z.w),Ee.copy(z))}function Fe(z,_e){let ve=c.get(_e);ve===void 0&&(ve=new WeakMap,c.set(_e,ve));let Be=ve.get(z);Be===void 0&&(Be=s.getUniformBlockIndex(_e,z.name),ve.set(z,Be))}function Ie(z,_e){const Be=c.get(_e).get(z);l.get(_e)!==Be&&(s.uniformBlockBinding(_e,Be,z.__bindingPointIndex),l.set(_e,Be))}function $e(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),a.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),h={},H=null,J={},d={},u=new WeakMap,p=[],m=null,v=!1,g=null,f=null,A=null,b=null,y=null,x=null,_=null,M=new qe(0,0,0),E=0,w=!1,T=null,R=null,D=null,L=null,I=null,me.set(0,0,s.canvas.width,s.canvas.height),Ee.set(0,0,s.canvas.width,s.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:se,disable:he,bindFramebuffer:Te,drawBuffers:Le,useProgram:Oe,setBlending:B,setMaterial:re,setFlipSided:ee,setCullFace:Q,setLineWidth:k,setPolygonOffset:ie,setScissorTest:fe,activeTexture:xe,bindTexture:te,unbindTexture:C,compressedTexImage2D:S,compressedTexImage3D:F,texImage2D:He,texImage3D:oe,updateUBOMapping:Fe,uniformBlockBinding:Ie,texStorage2D:pe,texStorage3D:Ue,texSubImage2D:q,texSubImage3D:K,compressedTexSubImage2D:Y,compressedTexSubImage3D:ye,scissor:we,viewport:Ve,reset:$e}}function FF(s,e,t,i,n,r,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 u=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(C,S){return p?new OffscreenCanvas(C,S):iu("canvas")}function v(C,S,F){let q=1;const K=te(C);if((K.width>F||K.height>F)&&(q=F/Math.max(K.width,K.height)),q<1)if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&C instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&C instanceof ImageBitmap||typeof VideoFrame<"u"&&C instanceof VideoFrame){const Y=Math.floor(q*K.width),ye=Math.floor(q*K.height);d===void 0&&(d=m(Y,ye));const pe=S?m(Y,ye):d;return pe.width=Y,pe.height=ye,pe.getContext("2d").drawImage(C,0,0,Y,ye),Je("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+Y+"x"+ye+")."),pe}else return"data"in C&&Je("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),C;return C}function g(C){return C.generateMipmaps}function f(C){s.generateMipmap(C)}function A(C){return C.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:C.isWebGL3DRenderTarget?s.TEXTURE_3D:C.isWebGLArrayRenderTarget||C.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function b(C,S,F,q,K=!1){if(C!==null){if(s[C]!==void 0)return s[C];Je("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+C+"'")}let Y=S;if(S===s.RED&&(F===s.FLOAT&&(Y=s.R32F),F===s.HALF_FLOAT&&(Y=s.R16F),F===s.UNSIGNED_BYTE&&(Y=s.R8)),S===s.RED_INTEGER&&(F===s.UNSIGNED_BYTE&&(Y=s.R8UI),F===s.UNSIGNED_SHORT&&(Y=s.R16UI),F===s.UNSIGNED_INT&&(Y=s.R32UI),F===s.BYTE&&(Y=s.R8I),F===s.SHORT&&(Y=s.R16I),F===s.INT&&(Y=s.R32I)),S===s.RG&&(F===s.FLOAT&&(Y=s.RG32F),F===s.HALF_FLOAT&&(Y=s.RG16F),F===s.UNSIGNED_BYTE&&(Y=s.RG8)),S===s.RG_INTEGER&&(F===s.UNSIGNED_BYTE&&(Y=s.RG8UI),F===s.UNSIGNED_SHORT&&(Y=s.RG16UI),F===s.UNSIGNED_INT&&(Y=s.RG32UI),F===s.BYTE&&(Y=s.RG8I),F===s.SHORT&&(Y=s.RG16I),F===s.INT&&(Y=s.RG32I)),S===s.RGB_INTEGER&&(F===s.UNSIGNED_BYTE&&(Y=s.RGB8UI),F===s.UNSIGNED_SHORT&&(Y=s.RGB16UI),F===s.UNSIGNED_INT&&(Y=s.RGB32UI),F===s.BYTE&&(Y=s.RGB8I),F===s.SHORT&&(Y=s.RGB16I),F===s.INT&&(Y=s.RGB32I)),S===s.RGBA_INTEGER&&(F===s.UNSIGNED_BYTE&&(Y=s.RGBA8UI),F===s.UNSIGNED_SHORT&&(Y=s.RGBA16UI),F===s.UNSIGNED_INT&&(Y=s.RGBA32UI),F===s.BYTE&&(Y=s.RGBA8I),F===s.SHORT&&(Y=s.RGBA16I),F===s.INT&&(Y=s.RGBA32I)),S===s.RGB&&(F===s.UNSIGNED_INT_5_9_9_9_REV&&(Y=s.RGB9_E5),F===s.UNSIGNED_INT_10F_11F_11F_REV&&(Y=s.R11F_G11F_B10F)),S===s.RGBA){const ye=K?eu:It.getTransfer(q);F===s.FLOAT&&(Y=s.RGBA32F),F===s.HALF_FLOAT&&(Y=s.RGBA16F),F===s.UNSIGNED_BYTE&&(Y=ye===Yt?s.SRGB8_ALPHA8:s.RGBA8),F===s.UNSIGNED_SHORT_4_4_4_4&&(Y=s.RGBA4),F===s.UNSIGNED_SHORT_5_5_5_1&&(Y=s.RGB5_A1)}return(Y===s.R16F||Y===s.R32F||Y===s.RG16F||Y===s.RG32F||Y===s.RGBA16F||Y===s.RGBA32F)&&e.get("EXT_color_buffer_float"),Y}function y(C,S){let F;return C?S===null||S===Ts||S===Qa?F=s.DEPTH24_STENCIL8:S===xi?F=s.DEPTH32F_STENCIL8:S===kc&&(F=s.DEPTH24_STENCIL8,Je("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):S===null||S===Ts||S===Qa?F=s.DEPTH_COMPONENT24:S===xi?F=s.DEPTH_COMPONENT32F:S===kc&&(F=s.DEPTH_COMPONENT16),F}function x(C,S){return g(C)===!0||C.isFramebufferTexture&&C.minFilter!==Jt&&C.minFilter!==wt?Math.log2(Math.max(S.width,S.height))+1:C.mipmaps!==void 0&&C.mipmaps.length>0?C.mipmaps.length:C.isCompressedTexture&&Array.isArray(C.image)?S.mipmaps.length:1}function _(C){const S=C.target;S.removeEventListener("dispose",_),E(S),S.isVideoTexture&&h.delete(S)}function M(C){const S=C.target;S.removeEventListener("dispose",M),T(S)}function E(C){const S=i.get(C);if(S.__webglInit===void 0)return;const F=C.source,q=u.get(F);if(q){const K=q[S.__cacheKey];K.usedTimes--,K.usedTimes===0&&w(C),Object.keys(q).length===0&&u.delete(F)}i.remove(C)}function w(C){const S=i.get(C);s.deleteTexture(S.__webglTexture);const F=C.source,q=u.get(F);delete q[S.__cacheKey],a.memory.textures--}function T(C){const S=i.get(C);if(C.depthTexture&&(C.depthTexture.dispose(),i.remove(C.depthTexture)),C.isWebGLCubeRenderTarget)for(let q=0;q<6;q++){if(Array.isArray(S.__webglFramebuffer[q]))for(let K=0;K<S.__webglFramebuffer[q].length;K++)s.deleteFramebuffer(S.__webglFramebuffer[q][K]);else s.deleteFramebuffer(S.__webglFramebuffer[q]);S.__webglDepthbuffer&&s.deleteRenderbuffer(S.__webglDepthbuffer[q])}else{if(Array.isArray(S.__webglFramebuffer))for(let q=0;q<S.__webglFramebuffer.length;q++)s.deleteFramebuffer(S.__webglFramebuffer[q]);else s.deleteFramebuffer(S.__webglFramebuffer);if(S.__webglDepthbuffer&&s.deleteRenderbuffer(S.__webglDepthbuffer),S.__webglMultisampledFramebuffer&&s.deleteFramebuffer(S.__webglMultisampledFramebuffer),S.__webglColorRenderbuffer)for(let q=0;q<S.__webglColorRenderbuffer.length;q++)S.__webglColorRenderbuffer[q]&&s.deleteRenderbuffer(S.__webglColorRenderbuffer[q]);S.__webglDepthRenderbuffer&&s.deleteRenderbuffer(S.__webglDepthRenderbuffer)}const F=C.textures;for(let q=0,K=F.length;q<K;q++){const Y=i.get(F[q]);Y.__webglTexture&&(s.deleteTexture(Y.__webglTexture),a.memory.textures--),i.remove(F[q])}i.remove(C)}let R=0;function D(){R=0}function L(){const C=R;return C>=n.maxTextures&&Je("WebGLTextures: Trying to use "+C+" texture units while this GPU supports only "+n.maxTextures),R+=1,C}function I(C){const S=[];return S.push(C.wrapS),S.push(C.wrapT),S.push(C.wrapR||0),S.push(C.magFilter),S.push(C.minFilter),S.push(C.anisotropy),S.push(C.internalFormat),S.push(C.format),S.push(C.type),S.push(C.generateMipmaps),S.push(C.premultiplyAlpha),S.push(C.flipY),S.push(C.unpackAlignment),S.push(C.colorSpace),S.join()}function O(C,S){const F=i.get(C);if(C.isVideoTexture&&fe(C),C.isRenderTargetTexture===!1&&C.isExternalTexture!==!0&&C.version>0&&F.__version!==C.version){const q=C.image;if(q===null)Je("WebGLRenderer: Texture marked for update but no image data found.");else if(q.complete===!1)Je("WebGLRenderer: Texture marked for update but image is incomplete");else{$(F,C,S);return}}else C.isExternalTexture&&(F.__webglTexture=C.sourceTexture?C.sourceTexture:null);t.bindTexture(s.TEXTURE_2D,F.__webglTexture,s.TEXTURE0+S)}function N(C,S){const F=i.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&F.__version!==C.version){$(F,C,S);return}else C.isExternalTexture&&(F.__webglTexture=C.sourceTexture?C.sourceTexture:null);t.bindTexture(s.TEXTURE_2D_ARRAY,F.__webglTexture,s.TEXTURE0+S)}function G(C,S){const F=i.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&F.__version!==C.version){$(F,C,S);return}t.bindTexture(s.TEXTURE_3D,F.__webglTexture,s.TEXTURE0+S)}function V(C,S){const F=i.get(C);if(C.isCubeDepthTexture!==!0&&C.version>0&&F.__version!==C.version){se(F,C,S);return}t.bindTexture(s.TEXTURE_CUBE_MAP,F.__webglTexture,s.TEXTURE0+S)}const H={[ln]:s.REPEAT,[Bn]:s.CLAMP_TO_EDGE,[Bc]:s.MIRRORED_REPEAT},J={[Jt]:s.NEAREST,[Fd]:s.NEAREST_MIPMAP_NEAREST,[Zo]:s.NEAREST_MIPMAP_LINEAR,[wt]:s.LINEAR,[Lc]:s.LINEAR_MIPMAP_NEAREST,[$n]:s.LINEAR_MIPMAP_LINEAR},W={[Zw]:s.NEVER,[nE]:s.ALWAYS,[Jw]:s.LESS,[rm]:s.LEQUAL,[eE]:s.EQUAL,[am]:s.GEQUAL,[tE]:s.GREATER,[iE]:s.NOTEQUAL};function X(C,S){if(S.type===xi&&e.has("OES_texture_float_linear")===!1&&(S.magFilter===wt||S.magFilter===Lc||S.magFilter===Zo||S.magFilter===$n||S.minFilter===wt||S.minFilter===Lc||S.minFilter===Zo||S.minFilter===$n)&&Je("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(C,s.TEXTURE_WRAP_S,H[S.wrapS]),s.texParameteri(C,s.TEXTURE_WRAP_T,H[S.wrapT]),(C===s.TEXTURE_3D||C===s.TEXTURE_2D_ARRAY)&&s.texParameteri(C,s.TEXTURE_WRAP_R,H[S.wrapR]),s.texParameteri(C,s.TEXTURE_MAG_FILTER,J[S.magFilter]),s.texParameteri(C,s.TEXTURE_MIN_FILTER,J[S.minFilter]),S.compareFunction&&(s.texParameteri(C,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(C,s.TEXTURE_COMPARE_FUNC,W[S.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(S.magFilter===Jt||S.minFilter!==Zo&&S.minFilter!==$n||S.type===xi&&e.has("OES_texture_float_linear")===!1)return;if(S.anisotropy>1||i.get(S).__currentAnisotropy){const F=e.get("EXT_texture_filter_anisotropic");s.texParameterf(C,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,n.getMaxAnisotropy())),i.get(S).__currentAnisotropy=S.anisotropy}}}function me(C,S){let F=!1;C.__webglInit===void 0&&(C.__webglInit=!0,S.addEventListener("dispose",_));const q=S.source;let K=u.get(q);K===void 0&&(K={},u.set(q,K));const Y=I(S);if(Y!==C.__cacheKey){K[Y]===void 0&&(K[Y]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,F=!0),K[Y].usedTimes++;const ye=K[C.__cacheKey];ye!==void 0&&(K[C.__cacheKey].usedTimes--,ye.usedTimes===0&&w(S)),C.__cacheKey=Y,C.__webglTexture=K[Y].texture}return F}function Ee(C,S,F){return Math.floor(Math.floor(C/F)/S)}function Me(C,S,F,q){const Y=C.updateRanges;if(Y.length===0)t.texSubImage2D(s.TEXTURE_2D,0,0,0,S.width,S.height,F,q,S.data);else{Y.sort((oe,we)=>oe.start-we.start);let ye=0;for(let oe=1;oe<Y.length;oe++){const we=Y[ye],Ve=Y[oe],Fe=we.start+we.count,Ie=Ee(Ve.start,S.width,4),$e=Ee(we.start,S.width,4);Ve.start<=Fe+1&&Ie===$e&&Ee(Ve.start+Ve.count-1,S.width,4)===Ie?we.count=Math.max(we.count,Ve.start+Ve.count-we.start):(++ye,Y[ye]=Ve)}Y.length=ye+1;const pe=s.getParameter(s.UNPACK_ROW_LENGTH),Ue=s.getParameter(s.UNPACK_SKIP_PIXELS),He=s.getParameter(s.UNPACK_SKIP_ROWS);s.pixelStorei(s.UNPACK_ROW_LENGTH,S.width);for(let oe=0,we=Y.length;oe<we;oe++){const Ve=Y[oe],Fe=Math.floor(Ve.start/4),Ie=Math.ceil(Ve.count/4),$e=Fe%S.width,z=Math.floor(Fe/S.width),_e=Ie,ve=1;s.pixelStorei(s.UNPACK_SKIP_PIXELS,$e),s.pixelStorei(s.UNPACK_SKIP_ROWS,z),t.texSubImage2D(s.TEXTURE_2D,0,$e,z,_e,ve,F,q,S.data)}C.clearUpdateRanges(),s.pixelStorei(s.UNPACK_ROW_LENGTH,pe),s.pixelStorei(s.UNPACK_SKIP_PIXELS,Ue),s.pixelStorei(s.UNPACK_SKIP_ROWS,He)}}function $(C,S,F){let q=s.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(q=s.TEXTURE_2D_ARRAY),S.isData3DTexture&&(q=s.TEXTURE_3D);const K=me(C,S),Y=S.source;t.bindTexture(q,C.__webglTexture,s.TEXTURE0+F);const ye=i.get(Y);if(Y.version!==ye.__version||K===!0){t.activeTexture(s.TEXTURE0+F);const pe=It.getPrimaries(It.workingColorSpace),Ue=S.colorSpace===qs?null:It.getPrimaries(S.colorSpace),He=S.colorSpace===qs||pe===Ue?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,S.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,S.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,He);let oe=v(S.image,!1,n.maxTextureSize);oe=xe(S,oe);const we=r.convert(S.format,S.colorSpace),Ve=r.convert(S.type);let Fe=b(S.internalFormat,we,Ve,S.colorSpace,S.isVideoTexture);X(q,S);let Ie;const $e=S.mipmaps,z=S.isVideoTexture!==!0,_e=ye.__version===void 0||K===!0,ve=Y.dataReady,Be=x(S,oe);if(S.isDepthTexture)Fe=y(S.format===Mr,S.type),_e&&(z?t.texStorage2D(s.TEXTURE_2D,1,Fe,oe.width,oe.height):t.texImage2D(s.TEXTURE_2D,0,Fe,oe.width,oe.height,0,we,Ve,null));else if(S.isDataTexture)if($e.length>0){z&&_e&&t.texStorage2D(s.TEXTURE_2D,Be,Fe,$e[0].width,$e[0].height);for(let ge=0,ne=$e.length;ge<ne;ge++)Ie=$e[ge],z?ve&&t.texSubImage2D(s.TEXTURE_2D,ge,0,0,Ie.width,Ie.height,we,Ve,Ie.data):t.texImage2D(s.TEXTURE_2D,ge,Fe,Ie.width,Ie.height,0,we,Ve,Ie.data);S.generateMipmaps=!1}else z?(_e&&t.texStorage2D(s.TEXTURE_2D,Be,Fe,oe.width,oe.height),ve&&Me(S,oe,we,Ve)):t.texImage2D(s.TEXTURE_2D,0,Fe,oe.width,oe.height,0,we,Ve,oe.data);else if(S.isCompressedTexture)if(S.isCompressedArrayTexture){z&&_e&&t.texStorage3D(s.TEXTURE_2D_ARRAY,Be,Fe,$e[0].width,$e[0].height,oe.depth);for(let ge=0,ne=$e.length;ge<ne;ge++)if(Ie=$e[ge],S.format!==_i)if(we!==null)if(z){if(ve)if(S.layerUpdates.size>0){const ze=Vb(Ie.width,Ie.height,S.format,S.type);for(const je of S.layerUpdates){const vt=Ie.data.subarray(je*ze/Ie.data.BYTES_PER_ELEMENT,(je+1)*ze/Ie.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,ge,0,0,je,Ie.width,Ie.height,1,we,vt)}S.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,ge,0,0,0,Ie.width,Ie.height,oe.depth,we,Ie.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,ge,Fe,Ie.width,Ie.height,oe.depth,0,Ie.data,0,0);else Je("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else z?ve&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,ge,0,0,0,Ie.width,Ie.height,oe.depth,we,Ve,Ie.data):t.texImage3D(s.TEXTURE_2D_ARRAY,ge,Fe,Ie.width,Ie.height,oe.depth,0,we,Ve,Ie.data)}else{z&&_e&&t.texStorage2D(s.TEXTURE_2D,Be,Fe,$e[0].width,$e[0].height);for(let ge=0,ne=$e.length;ge<ne;ge++)Ie=$e[ge],S.format!==_i?we!==null?z?ve&&t.compressedTexSubImage2D(s.TEXTURE_2D,ge,0,0,Ie.width,Ie.height,we,Ie.data):t.compressedTexImage2D(s.TEXTURE_2D,ge,Fe,Ie.width,Ie.height,0,Ie.data):Je("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):z?ve&&t.texSubImage2D(s.TEXTURE_2D,ge,0,0,Ie.width,Ie.height,we,Ve,Ie.data):t.texImage2D(s.TEXTURE_2D,ge,Fe,Ie.width,Ie.height,0,we,Ve,Ie.data)}else if(S.isDataArrayTexture)if(z){if(_e&&t.texStorage3D(s.TEXTURE_2D_ARRAY,Be,Fe,oe.width,oe.height,oe.depth),ve)if(S.layerUpdates.size>0){const ge=Vb(oe.width,oe.height,S.format,S.type);for(const ne of S.layerUpdates){const ze=oe.data.subarray(ne*ge/oe.data.BYTES_PER_ELEMENT,(ne+1)*ge/oe.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,ne,oe.width,oe.height,1,we,Ve,ze)}S.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,oe.width,oe.height,oe.depth,we,Ve,oe.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,Fe,oe.width,oe.height,oe.depth,0,we,Ve,oe.data);else if(S.isData3DTexture)z?(_e&&t.texStorage3D(s.TEXTURE_3D,Be,Fe,oe.width,oe.height,oe.depth),ve&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,oe.width,oe.height,oe.depth,we,Ve,oe.data)):t.texImage3D(s.TEXTURE_3D,0,Fe,oe.width,oe.height,oe.depth,0,we,Ve,oe.data);else if(S.isFramebufferTexture){if(_e)if(z)t.texStorage2D(s.TEXTURE_2D,Be,Fe,oe.width,oe.height);else{let ge=oe.width,ne=oe.height;for(let ze=0;ze<Be;ze++)t.texImage2D(s.TEXTURE_2D,ze,Fe,ge,ne,0,we,Ve,null),ge>>=1,ne>>=1}}else if($e.length>0){if(z&&_e){const ge=te($e[0]);t.texStorage2D(s.TEXTURE_2D,Be,Fe,ge.width,ge.height)}for(let ge=0,ne=$e.length;ge<ne;ge++)Ie=$e[ge],z?ve&&t.texSubImage2D(s.TEXTURE_2D,ge,0,0,we,Ve,Ie):t.texImage2D(s.TEXTURE_2D,ge,Fe,we,Ve,Ie);S.generateMipmaps=!1}else if(z){if(_e){const ge=te(oe);t.texStorage2D(s.TEXTURE_2D,Be,Fe,ge.width,ge.height)}ve&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,we,Ve,oe)}else t.texImage2D(s.TEXTURE_2D,0,Fe,we,Ve,oe);g(S)&&f(q),ye.__version=Y.version,S.onUpdate&&S.onUpdate(S)}C.__version=S.version}function se(C,S,F){if(S.image.length!==6)return;const q=me(C,S),K=S.source;t.bindTexture(s.TEXTURE_CUBE_MAP,C.__webglTexture,s.TEXTURE0+F);const Y=i.get(K);if(K.version!==Y.__version||q===!0){t.activeTexture(s.TEXTURE0+F);const ye=It.getPrimaries(It.workingColorSpace),pe=S.colorSpace===qs?null:It.getPrimaries(S.colorSpace),Ue=S.colorSpace===qs||ye===pe?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,S.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,S.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ue);const He=S.isCompressedTexture||S.image[0].isCompressedTexture,oe=S.image[0]&&S.image[0].isDataTexture,we=[];for(let ne=0;ne<6;ne++)!He&&!oe?we[ne]=v(S.image[ne],!0,n.maxCubemapSize):we[ne]=oe?S.image[ne].image:S.image[ne],we[ne]=xe(S,we[ne]);const Ve=we[0],Fe=r.convert(S.format,S.colorSpace),Ie=r.convert(S.type),$e=b(S.internalFormat,Fe,Ie,S.colorSpace),z=S.isVideoTexture!==!0,_e=Y.__version===void 0||q===!0,ve=K.dataReady;let Be=x(S,Ve);X(s.TEXTURE_CUBE_MAP,S);let ge;if(He){z&&_e&&t.texStorage2D(s.TEXTURE_CUBE_MAP,Be,$e,Ve.width,Ve.height);for(let ne=0;ne<6;ne++){ge=we[ne].mipmaps;for(let ze=0;ze<ge.length;ze++){const je=ge[ze];S.format!==_i?Fe!==null?z?ve&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ze,0,0,je.width,je.height,Fe,je.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ze,$e,je.width,je.height,0,je.data):Je("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):z?ve&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ze,0,0,je.width,je.height,Fe,Ie,je.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ze,$e,je.width,je.height,0,Fe,Ie,je.data)}}}else{if(ge=S.mipmaps,z&&_e){ge.length>0&&Be++;const ne=te(we[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,Be,$e,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(oe){z?ve&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,we[ne].width,we[ne].height,Fe,Ie,we[ne].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,$e,we[ne].width,we[ne].height,0,Fe,Ie,we[ne].data);for(let ze=0;ze<ge.length;ze++){const vt=ge[ze].image[ne].image;z?ve&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ze+1,0,0,vt.width,vt.height,Fe,Ie,vt.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ze+1,$e,vt.width,vt.height,0,Fe,Ie,vt.data)}}else{z?ve&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Fe,Ie,we[ne]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,$e,Fe,Ie,we[ne]);for(let ze=0;ze<ge.length;ze++){const je=ge[ze];z?ve&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ze+1,0,0,Fe,Ie,je.image[ne]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ze+1,$e,Fe,Ie,je.image[ne])}}}g(S)&&f(s.TEXTURE_CUBE_MAP),Y.__version=K.version,S.onUpdate&&S.onUpdate(S)}C.__version=S.version}function he(C,S,F,q,K,Y){const ye=r.convert(F.format,F.colorSpace),pe=r.convert(F.type),Ue=b(F.internalFormat,ye,pe,F.colorSpace),He=i.get(S),oe=i.get(F);if(oe.__renderTarget=S,!He.__hasExternalTextures){const we=Math.max(1,S.width>>Y),Ve=Math.max(1,S.height>>Y);K===s.TEXTURE_3D||K===s.TEXTURE_2D_ARRAY?t.texImage3D(K,Y,Ue,we,Ve,S.depth,0,ye,pe,null):t.texImage2D(K,Y,Ue,we,Ve,0,ye,pe,null)}t.bindFramebuffer(s.FRAMEBUFFER,C),ie(S)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,q,K,oe.__webglTexture,0,k(S)):(K===s.TEXTURE_2D||K>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,q,K,oe.__webglTexture,Y),t.bindFramebuffer(s.FRAMEBUFFER,null)}function Te(C,S,F){if(s.bindRenderbuffer(s.RENDERBUFFER,C),S.depthBuffer){const q=S.depthTexture,K=q&&q.isDepthTexture?q.type:null,Y=y(S.stencilBuffer,K),ye=S.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;ie(S)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,k(S),Y,S.width,S.height):F?s.renderbufferStorageMultisample(s.RENDERBUFFER,k(S),Y,S.width,S.height):s.renderbufferStorage(s.RENDERBUFFER,Y,S.width,S.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,ye,s.RENDERBUFFER,C)}else{const q=S.textures;for(let K=0;K<q.length;K++){const Y=q[K],ye=r.convert(Y.format,Y.colorSpace),pe=r.convert(Y.type),Ue=b(Y.internalFormat,ye,pe,Y.colorSpace);ie(S)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,k(S),Ue,S.width,S.height):F?s.renderbufferStorageMultisample(s.RENDERBUFFER,k(S),Ue,S.width,S.height):s.renderbufferStorage(s.RENDERBUFFER,Ue,S.width,S.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function Le(C,S,F){const q=S.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(s.FRAMEBUFFER,C),!(S.depthTexture&&S.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const K=i.get(S.depthTexture);if(K.__renderTarget=S,(!K.__webglTexture||S.depthTexture.image.width!==S.width||S.depthTexture.image.height!==S.height)&&(S.depthTexture.image.width=S.width,S.depthTexture.image.height=S.height,S.depthTexture.needsUpdate=!0),q){if(K.__webglInit===void 0&&(K.__webglInit=!0,S.depthTexture.addEventListener("dispose",_)),K.__webglTexture===void 0){K.__webglTexture=s.createTexture(),t.bindTexture(s.TEXTURE_CUBE_MAP,K.__webglTexture),X(s.TEXTURE_CUBE_MAP,S.depthTexture);const He=r.convert(S.depthTexture.format),oe=r.convert(S.depthTexture.type);let we;S.depthTexture.format===Er?we=s.DEPTH_COMPONENT24:S.depthTexture.format===Mr&&(we=s.DEPTH24_STENCIL8);for(let Ve=0;Ve<6;Ve++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,0,we,S.width,S.height,0,He,oe,null)}}else O(S.depthTexture,0);const Y=K.__webglTexture,ye=k(S),pe=q?s.TEXTURE_CUBE_MAP_POSITIVE_X+F:s.TEXTURE_2D,Ue=S.depthTexture.format===Mr?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;if(S.depthTexture.format===Er)ie(S)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Ue,pe,Y,0,ye):s.framebufferTexture2D(s.FRAMEBUFFER,Ue,pe,Y,0);else if(S.depthTexture.format===Mr)ie(S)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Ue,pe,Y,0,ye):s.framebufferTexture2D(s.FRAMEBUFFER,Ue,pe,Y,0);else throw new Error("Unknown depthTexture format")}function Oe(C){const S=i.get(C),F=C.isWebGLCubeRenderTarget===!0;if(S.__boundDepthTexture!==C.depthTexture){const q=C.depthTexture;if(S.__depthDisposeCallback&&S.__depthDisposeCallback(),q){const K=()=>{delete S.__boundDepthTexture,delete S.__depthDisposeCallback,q.removeEventListener("dispose",K)};q.addEventListener("dispose",K),S.__depthDisposeCallback=K}S.__boundDepthTexture=q}if(C.depthTexture&&!S.__autoAllocateDepthBuffer)if(F)for(let q=0;q<6;q++)Le(S.__webglFramebuffer[q],C,q);else{const q=C.texture.mipmaps;q&&q.length>0?Le(S.__webglFramebuffer[0],C,0):Le(S.__webglFramebuffer,C,0)}else if(F){S.__webglDepthbuffer=[];for(let q=0;q<6;q++)if(t.bindFramebuffer(s.FRAMEBUFFER,S.__webglFramebuffer[q]),S.__webglDepthbuffer[q]===void 0)S.__webglDepthbuffer[q]=s.createRenderbuffer(),Te(S.__webglDepthbuffer[q],C,!1);else{const K=C.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Y=S.__webglDepthbuffer[q];s.bindRenderbuffer(s.RENDERBUFFER,Y),s.framebufferRenderbuffer(s.FRAMEBUFFER,K,s.RENDERBUFFER,Y)}}else{const q=C.texture.mipmaps;if(q&&q.length>0?t.bindFramebuffer(s.FRAMEBUFFER,S.__webglFramebuffer[0]):t.bindFramebuffer(s.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer===void 0)S.__webglDepthbuffer=s.createRenderbuffer(),Te(S.__webglDepthbuffer,C,!1);else{const K=C.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Y=S.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,Y),s.framebufferRenderbuffer(s.FRAMEBUFFER,K,s.RENDERBUFFER,Y)}}t.bindFramebuffer(s.FRAMEBUFFER,null)}function tt(C,S,F){const q=i.get(C);S!==void 0&&he(q.__webglFramebuffer,C,C.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),F!==void 0&&Oe(C)}function Ye(C){const S=C.texture,F=i.get(C),q=i.get(S);C.addEventListener("dispose",M);const K=C.textures,Y=C.isWebGLCubeRenderTarget===!0,ye=K.length>1;if(ye||(q.__webglTexture===void 0&&(q.__webglTexture=s.createTexture()),q.__version=S.version,a.memory.textures++),Y){F.__webglFramebuffer=[];for(let pe=0;pe<6;pe++)if(S.mipmaps&&S.mipmaps.length>0){F.__webglFramebuffer[pe]=[];for(let Ue=0;Ue<S.mipmaps.length;Ue++)F.__webglFramebuffer[pe][Ue]=s.createFramebuffer()}else F.__webglFramebuffer[pe]=s.createFramebuffer()}else{if(S.mipmaps&&S.mipmaps.length>0){F.__webglFramebuffer=[];for(let pe=0;pe<S.mipmaps.length;pe++)F.__webglFramebuffer[pe]=s.createFramebuffer()}else F.__webglFramebuffer=s.createFramebuffer();if(ye)for(let pe=0,Ue=K.length;pe<Ue;pe++){const He=i.get(K[pe]);He.__webglTexture===void 0&&(He.__webglTexture=s.createTexture(),a.memory.textures++)}if(C.samples>0&&ie(C)===!1){F.__webglMultisampledFramebuffer=s.createFramebuffer(),F.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let pe=0;pe<K.length;pe++){const Ue=K[pe];F.__webglColorRenderbuffer[pe]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,F.__webglColorRenderbuffer[pe]);const He=r.convert(Ue.format,Ue.colorSpace),oe=r.convert(Ue.type),we=b(Ue.internalFormat,He,oe,Ue.colorSpace,C.isXRRenderTarget===!0),Ve=k(C);s.renderbufferStorageMultisample(s.RENDERBUFFER,Ve,we,C.width,C.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+pe,s.RENDERBUFFER,F.__webglColorRenderbuffer[pe])}s.bindRenderbuffer(s.RENDERBUFFER,null),C.depthBuffer&&(F.__webglDepthRenderbuffer=s.createRenderbuffer(),Te(F.__webglDepthRenderbuffer,C,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(Y){t.bindTexture(s.TEXTURE_CUBE_MAP,q.__webglTexture),X(s.TEXTURE_CUBE_MAP,S);for(let pe=0;pe<6;pe++)if(S.mipmaps&&S.mipmaps.length>0)for(let Ue=0;Ue<S.mipmaps.length;Ue++)he(F.__webglFramebuffer[pe][Ue],C,S,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+pe,Ue);else he(F.__webglFramebuffer[pe],C,S,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0);g(S)&&f(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ye){for(let pe=0,Ue=K.length;pe<Ue;pe++){const He=K[pe],oe=i.get(He);let we=s.TEXTURE_2D;(C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)&&(we=C.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(we,oe.__webglTexture),X(we,He),he(F.__webglFramebuffer,C,He,s.COLOR_ATTACHMENT0+pe,we,0),g(He)&&f(we)}t.unbindTexture()}else{let pe=s.TEXTURE_2D;if((C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)&&(pe=C.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(pe,q.__webglTexture),X(pe,S),S.mipmaps&&S.mipmaps.length>0)for(let Ue=0;Ue<S.mipmaps.length;Ue++)he(F.__webglFramebuffer[Ue],C,S,s.COLOR_ATTACHMENT0,pe,Ue);else he(F.__webglFramebuffer,C,S,s.COLOR_ATTACHMENT0,pe,0);g(S)&&f(pe),t.unbindTexture()}C.depthBuffer&&Oe(C)}function B(C){const S=C.textures;for(let F=0,q=S.length;F<q;F++){const K=S[F];if(g(K)){const Y=A(C),ye=i.get(K).__webglTexture;t.bindTexture(Y,ye),f(Y),t.unbindTexture()}}}const re=[],ee=[];function Q(C){if(C.samples>0){if(ie(C)===!1){const S=C.textures,F=C.width,q=C.height;let K=s.COLOR_BUFFER_BIT;const Y=C.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,ye=i.get(C),pe=S.length>1;if(pe)for(let He=0;He<S.length;He++)t.bindFramebuffer(s.FRAMEBUFFER,ye.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+He,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,ye.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+He,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,ye.__webglMultisampledFramebuffer);const Ue=C.texture.mipmaps;Ue&&Ue.length>0?t.bindFramebuffer(s.DRAW_FRAMEBUFFER,ye.__webglFramebuffer[0]):t.bindFramebuffer(s.DRAW_FRAMEBUFFER,ye.__webglFramebuffer);for(let He=0;He<S.length;He++){if(C.resolveDepthBuffer&&(C.depthBuffer&&(K|=s.DEPTH_BUFFER_BIT),C.stencilBuffer&&C.resolveStencilBuffer&&(K|=s.STENCIL_BUFFER_BIT)),pe){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,ye.__webglColorRenderbuffer[He]);const oe=i.get(S[He]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,oe,0)}s.blitFramebuffer(0,0,F,q,0,0,F,q,K,s.NEAREST),l===!0&&(re.length=0,ee.length=0,re.push(s.COLOR_ATTACHMENT0+He),C.depthBuffer&&C.resolveDepthBuffer===!1&&(re.push(Y),ee.push(Y),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,ee)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,re))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),pe)for(let He=0;He<S.length;He++){t.bindFramebuffer(s.FRAMEBUFFER,ye.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+He,s.RENDERBUFFER,ye.__webglColorRenderbuffer[He]);const oe=i.get(S[He]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,ye.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+He,s.TEXTURE_2D,oe,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,ye.__webglMultisampledFramebuffer)}else if(C.depthBuffer&&C.resolveDepthBuffer===!1&&l){const S=C.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[S])}}}function k(C){return Math.min(n.maxSamples,C.samples)}function ie(C){const S=i.get(C);return C.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function fe(C){const S=a.render.frame;h.get(C)!==S&&(h.set(C,S),C.update())}function xe(C,S){const F=C.colorSpace,q=C.format,K=C.type;return C.isCompressedTexture===!0||C.isVideoTexture===!0||F!==qi&&F!==qs&&(It.getTransfer(F)===Yt?(q!==_i||K!==bt)&&Je("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ft("WebGLTextures: Unsupported texture color space:",F)),S}function te(C){return typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement?(c.width=C.naturalWidth||C.width,c.height=C.naturalHeight||C.height):typeof VideoFrame<"u"&&C instanceof VideoFrame?(c.width=C.displayWidth,c.height=C.displayHeight):(c.width=C.width,c.height=C.height),c}this.allocateTextureUnit=L,this.resetTextureUnits=D,this.setTexture2D=O,this.setTexture2DArray=N,this.setTexture3D=G,this.setTextureCube=V,this.rebindTextures=tt,this.setupRenderTarget=Ye,this.updateRenderTargetMipmap=B,this.updateMultisampleRenderTarget=Q,this.setupDepthRenderbuffer=Oe,this.setupFrameBufferTexture=he,this.useMultisampledRTT=ie,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function OS(s,e){function t(i,n=qs){let r;const a=It.getTransfer(n);if(i===bt)return s.UNSIGNED_BYTE;if(i===Nf)return s.UNSIGNED_SHORT_4_4_4_4;if(i===Uf)return s.UNSIGNED_SHORT_5_5_5_1;if(i===Nd)return s.UNSIGNED_INT_5_9_9_9_REV;if(i===Ud)return s.UNSIGNED_INT_10F_11F_11F_REV;if(i===vA)return s.BYTE;if(i===AA)return s.SHORT;if(i===kc)return s.UNSIGNED_SHORT;if(i===Ff)return s.INT;if(i===Ts)return s.UNSIGNED_INT;if(i===xi)return s.FLOAT;if(i===li)return s.HALF_FLOAT;if(i===bA)return s.ALPHA;if(i===Oc)return s.RGB;if(i===_i)return s.RGBA;if(i===Er)return s.DEPTH_COMPONENT;if(i===Mr)return s.DEPTH_STENCIL;if(i===Sr)return s.RED;if(i===zd)return s.RED_INTEGER;if(i===Is)return s.RG;if(i===zf)return s.RG_INTEGER;if(i===Hf)return s.RGBA_INTEGER;if(i===Jo||i===ja||i===Hd||i===Xa)if(a===Yt)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===Jo)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===ja)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Hd)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Xa)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===Jo)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===ja)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Hd)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Xa)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Gd||i===Gf||i===el||i===Fc)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===Gd)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Gf)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===el)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Fc)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Vd||i===Nc||i===Uc||i===Wd||i===Qd||i===jd||i===Xd)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===Vd||i===Nc)return a===Yt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Uc)return a===Yt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===Wd)return r.COMPRESSED_R11_EAC;if(i===Qd)return r.COMPRESSED_SIGNED_R11_EAC;if(i===jd)return r.COMPRESSED_RG11_EAC;if(i===Xd)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===qa||i===Vf||i===Wf||i===Qf||i===tl||i===jf||i===Xf||i===qf||i===Yf||i===Kf||i===$f||i===Zf||i===Jf||i===em)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===qa)return a===Yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Vf)return a===Yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Wf)return a===Yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Qf)return a===Yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===tl)return a===Yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===jf)return a===Yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Xf)return a===Yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===qf)return a===Yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Yf)return a===Yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Kf)return a===Yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===$f)return a===Yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Zf)return a===Yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Jf)return a===Yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===em)return a===Yt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===il||i===tm||i===qd)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===il)return a===Yt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===tm)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===qd)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Yd||i===Kd||i===$d||i===Zd)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===Yd)return r.COMPRESSED_RED_RGTC1_EXT;if(i===Kd)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===$d)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Zd)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Qa?s.UNSIGNED_INT_24_8:s[i]!==void 0?s[i]:null}return{convert:t}}const NF=`
|
||
void main() {
|
||
|
||
gl_Position = vec4( position, 1.0 );
|
||
|
||
}`,UF=`
|
||
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 zF{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new rb(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 mi({vertexShader:NF,fragmentShader:UF,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new We(new Ds(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class HF extends Ys{constructor(e,t){super();const i=this;let n=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,d=null,u=null,p=null,m=null;const v=typeof XRWebGLBinding<"u",g=new zF,f={},A=t.getContextAttributes();let b=null,y=null;const x=[],_=[],M=new be;let E=null;const w=new wi;w.viewport=new zt;const T=new wi;T.viewport=new zt;const R=[w,T],D=new WM;let L=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let se=x[$];return se===void 0&&(se=new dm,x[$]=se),se.getTargetRaySpace()},this.getControllerGrip=function($){let se=x[$];return se===void 0&&(se=new dm,x[$]=se),se.getGripSpace()},this.getHand=function($){let se=x[$];return se===void 0&&(se=new dm,x[$]=se),se.getHandSpace()};function O($){const se=_.indexOf($.inputSource);if(se===-1)return;const he=x[se];he!==void 0&&(he.update($.inputSource,$.frame,c||a),he.dispatchEvent({type:$.type,data:$.inputSource}))}function N(){n.removeEventListener("select",O),n.removeEventListener("selectstart",O),n.removeEventListener("selectend",O),n.removeEventListener("squeeze",O),n.removeEventListener("squeezestart",O),n.removeEventListener("squeezeend",O),n.removeEventListener("end",N),n.removeEventListener("inputsourceschange",G);for(let $=0;$<x.length;$++){const se=_[$];se!==null&&(_[$]=null,x[$].disconnect(se))}L=null,I=null,g.reset();for(const $ in f)delete f[$];e.setRenderTarget(b),p=null,u=null,d=null,n=null,y=null,Me.stop(),i.isPresenting=!1,e.setPixelRatio(E),e.setSize(M.width,M.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function($){r=$,i.isPresenting===!0&&Je("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function($){o=$,i.isPresenting===!0&&Je("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function($){c=$},this.getBaseLayer=function(){return u!==null?u:p},this.getBinding=function(){return d===null&&v&&(d=new XRWebGLBinding(n,t)),d},this.getFrame=function(){return m},this.getSession=function(){return n},this.setSession=async function($){if(n=$,n!==null){if(b=e.getRenderTarget(),n.addEventListener("select",O),n.addEventListener("selectstart",O),n.addEventListener("selectend",O),n.addEventListener("squeeze",O),n.addEventListener("squeezestart",O),n.addEventListener("squeezeend",O),n.addEventListener("end",N),n.addEventListener("inputsourceschange",G),A.xrCompatible!==!0&&await t.makeXRCompatible(),E=e.getPixelRatio(),e.getSize(M),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let he=null,Te=null,Le=null;A.depth&&(Le=A.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,he=A.stencil?Mr:Er,Te=A.stencil?Qa:Ts);const Oe={colorFormat:t.RGBA8,depthFormat:Le,scaleFactor:r};d=this.getBinding(),u=d.createProjectionLayer(Oe),n.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),y=new ki(u.textureWidth,u.textureHeight,{format:_i,type:bt,depthTexture:new so(u.textureWidth,u.textureHeight,Te,void 0,void 0,void 0,void 0,void 0,void 0,he),stencilBuffer:A.stencil,colorSpace:e.outputColorSpace,samples:A.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{const he={antialias:A.antialias,alpha:!0,depth:A.depth,stencil:A.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(n,t,he),n.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),y=new ki(p.framebufferWidth,p.framebufferHeight,{format:_i,type:bt,colorSpace:e.outputColorSpace,stencilBuffer:A.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await n.requestReferenceSpace(o),Me.setContext(n),Me.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function G($){for(let se=0;se<$.removed.length;se++){const he=$.removed[se],Te=_.indexOf(he);Te>=0&&(_[Te]=null,x[Te].disconnect(he))}for(let se=0;se<$.added.length;se++){const he=$.added[se];let Te=_.indexOf(he);if(Te===-1){for(let Oe=0;Oe<x.length;Oe++)if(Oe>=_.length){_.push(he),Te=Oe;break}else if(_[Oe]===null){_[Oe]=he,Te=Oe;break}if(Te===-1)break}const Le=x[Te];Le&&Le.connect(he)}}const V=new P,H=new P;function J($,se,he){V.setFromMatrixPosition(se.matrixWorld),H.setFromMatrixPosition(he.matrixWorld);const Te=V.distanceTo(H),Le=se.projectionMatrix.elements,Oe=he.projectionMatrix.elements,tt=Le[14]/(Le[10]-1),Ye=Le[14]/(Le[10]+1),B=(Le[9]+1)/Le[5],re=(Le[9]-1)/Le[5],ee=(Le[8]-1)/Le[0],Q=(Oe[8]+1)/Oe[0],k=tt*ee,ie=tt*Q,fe=Te/(-ee+Q),xe=fe*-ee;if(se.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(xe),$.translateZ(fe),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert(),Le[10]===-1)$.projectionMatrix.copy(se.projectionMatrix),$.projectionMatrixInverse.copy(se.projectionMatrixInverse);else{const te=tt+fe,C=Ye+fe,S=k-xe,F=ie+(Te-xe),q=B*Ye/C*te,K=re*Ye/C*te;$.projectionMatrix.makePerspective(S,F,q,K,te,C),$.projectionMatrixInverse.copy($.projectionMatrix).invert()}}function W($,se){se===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(se.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(n===null)return;let se=$.near,he=$.far;g.texture!==null&&(g.depthNear>0&&(se=g.depthNear),g.depthFar>0&&(he=g.depthFar)),D.near=T.near=w.near=se,D.far=T.far=w.far=he,(L!==D.near||I!==D.far)&&(n.updateRenderState({depthNear:D.near,depthFar:D.far}),L=D.near,I=D.far),D.layers.mask=$.layers.mask|6,w.layers.mask=D.layers.mask&-5,T.layers.mask=D.layers.mask&-3;const Te=$.parent,Le=D.cameras;W(D,Te);for(let Oe=0;Oe<Le.length;Oe++)W(Le[Oe],Te);Le.length===2?J(D,w,T):D.projectionMatrix.copy(w.projectionMatrix),X($,D,Te)};function X($,se,he){he===null?$.matrix.copy(se.matrixWorld):($.matrix.copy(he.matrixWorld),$.matrix.invert(),$.matrix.multiply(se.matrixWorld)),$.matrix.decompose($.position,$.quaternion,$.scale),$.updateMatrixWorld(!0),$.projectionMatrix.copy(se.projectionMatrix),$.projectionMatrixInverse.copy(se.projectionMatrixInverse),$.isPerspectiveCamera&&($.fov=Vc*2*Math.atan(1/$.projectionMatrix.elements[5]),$.zoom=1)}this.getCamera=function(){return D},this.getFoveation=function(){if(!(u===null&&p===null))return l},this.setFoveation=function($){l=$,u!==null&&(u.fixedFoveation=$),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=$)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(D)},this.getCameraTexture=function($){return f[$]};let me=null;function Ee($,se){if(h=se.getViewerPose(c||a),m=se,h!==null){const he=h.views;p!==null&&(e.setRenderTargetFramebuffer(y,p.framebuffer),e.setRenderTarget(y));let Te=!1;he.length!==D.cameras.length&&(D.cameras.length=0,Te=!0);for(let Ye=0;Ye<he.length;Ye++){const B=he[Ye];let re=null;if(p!==null)re=p.getViewport(B);else{const Q=d.getViewSubImage(u,B);re=Q.viewport,Ye===0&&(e.setRenderTargetTextures(y,Q.colorTexture,Q.depthStencilTexture),e.setRenderTarget(y))}let ee=R[Ye];ee===void 0&&(ee=new wi,ee.layers.enable(Ye),ee.viewport=new zt,R[Ye]=ee),ee.matrix.fromArray(B.transform.matrix),ee.matrix.decompose(ee.position,ee.quaternion,ee.scale),ee.projectionMatrix.fromArray(B.projectionMatrix),ee.projectionMatrixInverse.copy(ee.projectionMatrix).invert(),ee.viewport.set(re.x,re.y,re.width,re.height),Ye===0&&(D.matrix.copy(ee.matrix),D.matrix.decompose(D.position,D.quaternion,D.scale)),Te===!0&&D.cameras.push(ee)}const Le=n.enabledFeatures;if(Le&&Le.includes("depth-sensing")&&n.depthUsage=="gpu-optimized"&&v){d=i.getBinding();const Ye=d.getDepthInformation(he[0]);Ye&&Ye.isValid&&Ye.texture&&g.init(Ye,n.renderState)}if(Le&&Le.includes("camera-access")&&v){e.state.unbindTexture(),d=i.getBinding();for(let Ye=0;Ye<he.length;Ye++){const B=he[Ye].camera;if(B){let re=f[B];re||(re=new rb,f[B]=re);const ee=d.getCameraImage(B);re.sourceTexture=ee}}}}for(let he=0;he<x.length;he++){const Te=_[he],Le=x[he];Te!==null&&Le!==void 0&&Le.update(Te,se,c||a)}me&&me($,se),se.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:se}),m=null}const Me=new cS;Me.setAnimationLoop(Ee),this.setAnimationLoop=function($){me=$},this.dispose=function(){}}}const Dl=new Yi,GF=new Ke;function VF(s,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,gM(s)),f.isFog?(g.fogNear.value=f.near,g.fogFar.value=f.far):f.isFogExp2&&(g.fogDensity.value=f.density)}function n(g,f,A,b,y){f.isMeshBasicMaterial?r(g,f):f.isMeshLambertMaterial?(r(g,f),f.envMap&&(g.envMapIntensity.value=f.envMapIntensity)):f.isMeshToonMaterial?(r(g,f),d(g,f)):f.isMeshPhongMaterial?(r(g,f),h(g,f),f.envMap&&(g.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(r(g,f),u(g,f),f.isMeshPhysicalMaterial&&p(g,f,y)):f.isMeshMatcapMaterial?(r(g,f),m(g,f)):f.isMeshDepthMaterial?r(g,f):f.isMeshDistanceMaterial?(r(g,f),v(g,f)):f.isMeshNormalMaterial?r(g,f):f.isLineBasicMaterial?(a(g,f),f.isLineDashedMaterial&&o(g,f)):f.isPointsMaterial?l(g,f,A,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 r(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===an&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,t(f.normalMap,g.normalMapTransform),g.normalScale.value.copy(f.normalScale),f.side===an&&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 A=e.get(f),b=A.envMap,y=A.envMapRotation;b&&(g.envMap.value=b,Dl.copy(y),Dl.x*=-1,Dl.y*=-1,Dl.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(Dl.y*=-1,Dl.z*=-1),g.envMapRotation.value.setFromMatrix4(GF.makeRotationFromEuler(Dl)),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,A,b){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.size.value=f.size*A,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 u(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 p(g,f,A){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===an&&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=A.texture,g.transmissionSamplerSize.value.set(A.width,A.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 m(g,f){f.matcap&&(g.matcap.value=f.matcap)}function v(g,f){const A=e.get(f).light;g.referencePosition.value.setFromMatrixPosition(A.matrixWorld),g.nearDistance.value=A.shadow.camera.near,g.farDistance.value=A.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function WF(s,e,t,i){let n={},r={},a=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function l(A,b){const y=b.program;i.uniformBlockBinding(A,y)}function c(A,b){let y=n[A.id];y===void 0&&(m(A),y=h(A),n[A.id]=y,A.addEventListener("dispose",g));const x=b.program;i.updateUBOMapping(A,x);const _=e.render.frame;r[A.id]!==_&&(u(A),r[A.id]=_)}function h(A){const b=d();A.__bindingPointIndex=b;const y=s.createBuffer(),x=A.__size,_=A.usage;return s.bindBuffer(s.UNIFORM_BUFFER,y),s.bufferData(s.UNIFORM_BUFFER,x,_),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,b,y),y}function d(){for(let A=0;A<o;A++)if(a.indexOf(A)===-1)return a.push(A),A;return ft("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(A){const b=n[A.id],y=A.uniforms,x=A.__cache;s.bindBuffer(s.UNIFORM_BUFFER,b);for(let _=0,M=y.length;_<M;_++){const E=Array.isArray(y[_])?y[_]:[y[_]];for(let w=0,T=E.length;w<T;w++){const R=E[w];if(p(R,_,w,x)===!0){const D=R.__offset,L=Array.isArray(R.value)?R.value:[R.value];let I=0;for(let O=0;O<L.length;O++){const N=L[O],G=v(N);typeof N=="number"||typeof N=="boolean"?(R.__data[0]=N,s.bufferSubData(s.UNIFORM_BUFFER,D+I,R.__data)):N.isMatrix3?(R.__data[0]=N.elements[0],R.__data[1]=N.elements[1],R.__data[2]=N.elements[2],R.__data[3]=0,R.__data[4]=N.elements[3],R.__data[5]=N.elements[4],R.__data[6]=N.elements[5],R.__data[7]=0,R.__data[8]=N.elements[6],R.__data[9]=N.elements[7],R.__data[10]=N.elements[8],R.__data[11]=0):(N.toArray(R.__data,I),I+=G.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,D,R.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function p(A,b,y,x){const _=A.value,M=b+"_"+y;if(x[M]===void 0)return typeof _=="number"||typeof _=="boolean"?x[M]=_:x[M]=_.clone(),!0;{const E=x[M];if(typeof _=="number"||typeof _=="boolean"){if(E!==_)return x[M]=_,!0}else if(E.equals(_)===!1)return E.copy(_),!0}return!1}function m(A){const b=A.uniforms;let y=0;const x=16;for(let M=0,E=b.length;M<E;M++){const w=Array.isArray(b[M])?b[M]:[b[M]];for(let T=0,R=w.length;T<R;T++){const D=w[T],L=Array.isArray(D.value)?D.value:[D.value];for(let I=0,O=L.length;I<O;I++){const N=L[I],G=v(N),V=y%x,H=V%G.boundary,J=V+H;y+=H,J!==0&&x-J<G.storage&&(y+=x-J),D.__data=new Float32Array(G.storage/Float32Array.BYTES_PER_ELEMENT),D.__offset=y,y+=G.storage}}}const _=y%x;return _>0&&(y+=x-_),A.__size=y,A.__cache={},this}function v(A){const b={boundary:0,storage:0};return typeof A=="number"||typeof A=="boolean"?(b.boundary=4,b.storage=4):A.isVector2?(b.boundary=8,b.storage=8):A.isVector3||A.isColor?(b.boundary=16,b.storage=12):A.isVector4?(b.boundary=16,b.storage=16):A.isMatrix3?(b.boundary=48,b.storage=48):A.isMatrix4?(b.boundary=64,b.storage=64):A.isTexture?Je("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Je("WebGLRenderer: Unsupported uniform value type.",A),b}function g(A){const b=A.target;b.removeEventListener("dispose",g);const y=a.indexOf(b.__bindingPointIndex);a.splice(y,1),s.deleteBuffer(n[b.id]),delete n[b.id],delete r[b.id]}function f(){for(const A in n)s.deleteBuffer(n[A]);a=[],n={},r={}}return{bind:l,update:c,dispose:f}}const QF=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 Rr=null;function jF(){return Rr===null&&(Rr=new On(QF,16,16,Is,li),Rr.name="DFG_LUT",Rr.minFilter=wt,Rr.magFilter=wt,Rr.wrapS=Bn,Rr.wrapT=Bn,Rr.generateMipmaps=!1,Rr.needsUpdate=!0),Rr}class Uu{constructor(e={}){const{canvas:t=rE(),context:i=null,depth:n=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:p=bt}=e;this.isWebGLRenderer=!0;let m;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=i.getContextAttributes().alpha}else m=a;const v=p,g=new Set([Hf,zf,zd]),f=new Set([bt,Ts,kc,Qa,Nf,Uf]),A=new Uint32Array(4),b=new Int32Array(4);let y=null,x=null;const _=[],M=[];let E=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=on,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const w=this;let T=!1;this._outputColorSpace=ci;let R=0,D=0,L=null,I=-1,O=null;const N=new zt,G=new zt;let V=null;const H=new qe(0);let J=0,W=t.width,X=t.height,me=1,Ee=null,Me=null;const $=new zt(0,0,W,X),se=new zt(0,0,W,X);let he=!1;const Te=new oh;let Le=!1,Oe=!1;const tt=new Ke,Ye=new P,B=new zt,re={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ee=!1;function Q(){return L===null?me:1}let k=i;function ie(j,Ae){return t.getContext(j,Ae)}try{const j={alpha:!0,depth:n,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ic}`),t.addEventListener("webglcontextlost",ze,!1),t.addEventListener("webglcontextrestored",je,!1),t.addEventListener("webglcontextcreationerror",vt,!1),k===null){const Ae="webgl2";if(k=ie(Ae,j),k===null)throw ie(Ae)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(j){throw ft("WebGLRenderer: "+j.message),j}let fe,xe,te,C,S,F,q,K,Y,ye,pe,Ue,He,oe,we,Ve,Fe,Ie,$e,z,_e,ve,Be;function ge(){fe=new q8(k),fe.init(),_e=new OS(k,fe),xe=new z8(k,fe,e,_e),te=new OF(k,fe),xe.reversedDepthBuffer&&u&&te.buffers.depth.setReversed(!0),C=new $8(k),S=new _F,F=new FF(k,fe,te,S,xe,_e,C),q=new X8(w),K=new O5(k),ve=new N8(k,K),Y=new Y8(k,K,C,ve),ye=new J8(k,Y,K,ve,C),Ie=new Z8(k,xe,F),we=new H8(S),pe=new xF(w,q,fe,xe,ve,we),Ue=new VF(w,S),He=new EF,oe=new PF(fe),Fe=new F8(w,q,te,ye,m,l),Ve=new kF(w,ye,xe),Be=new WF(k,C,xe,te),$e=new U8(k,fe,C),z=new K8(k,fe,C),C.programs=pe.programs,w.capabilities=xe,w.extensions=fe,w.properties=S,w.renderLists=He,w.shadowMap=Ve,w.state=te,w.info=C}ge(),v!==bt&&(E=new tO(v,t.width,t.height,n,r));const ne=new HF(w,k);this.xr=ne,this.getContext=function(){return k},this.getContextAttributes=function(){return k.getContextAttributes()},this.forceContextLoss=function(){const j=fe.get("WEBGL_lose_context");j&&j.loseContext()},this.forceContextRestore=function(){const j=fe.get("WEBGL_lose_context");j&&j.restoreContext()},this.getPixelRatio=function(){return me},this.setPixelRatio=function(j){j!==void 0&&(me=j,this.setSize(W,X,!1))},this.getSize=function(j){return j.set(W,X)},this.setSize=function(j,Ae,Re=!0){if(ne.isPresenting){Je("WebGLRenderer: Can't change size while VR device is presenting.");return}W=j,X=Ae,t.width=Math.floor(j*me),t.height=Math.floor(Ae*me),Re===!0&&(t.style.width=j+"px",t.style.height=Ae+"px"),E!==null&&E.setSize(t.width,t.height),this.setViewport(0,0,j,Ae)},this.getDrawingBufferSize=function(j){return j.set(W*me,X*me).floor()},this.setDrawingBufferSize=function(j,Ae,Re){W=j,X=Ae,me=Re,t.width=Math.floor(j*Re),t.height=Math.floor(Ae*Re),this.setViewport(0,0,j,Ae)},this.setEffects=function(j){if(v===bt){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(j){for(let Ae=0;Ae<j.length;Ae++)if(j[Ae].isOutputPass===!0){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}E.setEffects(j||[])},this.getCurrentViewport=function(j){return j.copy(N)},this.getViewport=function(j){return j.copy($)},this.setViewport=function(j,Ae,Re,Ce){j.isVector4?$.set(j.x,j.y,j.z,j.w):$.set(j,Ae,Re,Ce),te.viewport(N.copy($).multiplyScalar(me).round())},this.getScissor=function(j){return j.copy(se)},this.setScissor=function(j,Ae,Re,Ce){j.isVector4?se.set(j.x,j.y,j.z,j.w):se.set(j,Ae,Re,Ce),te.scissor(G.copy(se).multiplyScalar(me).round())},this.getScissorTest=function(){return he},this.setScissorTest=function(j){te.setScissorTest(he=j)},this.setOpaqueSort=function(j){Ee=j},this.setTransparentSort=function(j){Me=j},this.getClearColor=function(j){return j.copy(Fe.getClearColor())},this.setClearColor=function(){Fe.setClearColor(...arguments)},this.getClearAlpha=function(){return Fe.getClearAlpha()},this.setClearAlpha=function(){Fe.setClearAlpha(...arguments)},this.clear=function(j=!0,Ae=!0,Re=!0){let Ce=0;if(j){let Se=!1;if(L!==null){const st=L.texture.format;Se=g.has(st)}if(Se){const st=L.texture.type,U=f.has(st),Z=Fe.getClearColor(),le=Fe.getClearAlpha(),ce=Z.r,ae=Z.g,Ge=Z.b;U?(A[0]=ce,A[1]=ae,A[2]=Ge,A[3]=le,k.clearBufferuiv(k.COLOR,0,A)):(b[0]=ce,b[1]=ae,b[2]=Ge,b[3]=le,k.clearBufferiv(k.COLOR,0,b))}else Ce|=k.COLOR_BUFFER_BIT}Ae&&(Ce|=k.DEPTH_BUFFER_BIT),Re&&(Ce|=k.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Ce!==0&&k.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",ze,!1),t.removeEventListener("webglcontextrestored",je,!1),t.removeEventListener("webglcontextcreationerror",vt,!1),Fe.dispose(),He.dispose(),oe.dispose(),S.dispose(),q.dispose(),ye.dispose(),ve.dispose(),Be.dispose(),pe.dispose(),ne.dispose(),ne.removeEventListener("sessionstart",ff),ne.removeEventListener("sessionend",sA),Ga.stop()};function ze(j){j.preventDefault(),nu("WebGLRenderer: Context Lost."),T=!0}function je(){nu("WebGLRenderer: Context Restored."),T=!1;const j=C.autoReset,Ae=Ve.enabled,Re=Ve.autoUpdate,Ce=Ve.needsUpdate,Se=Ve.type;ge(),C.autoReset=j,Ve.enabled=Ae,Ve.autoUpdate=Re,Ve.needsUpdate=Ce,Ve.type=Se}function vt(j){ft("WebGLRenderer: A WebGL context could not be created. Reason: ",j.statusMessage)}function ut(j){const Ae=j.target;Ae.removeEventListener("dispose",ut),Xi(Ae)}function Xi(j){Ht(j),S.remove(j)}function Ht(j){const Ae=S.get(j).programs;Ae!==void 0&&(Ae.forEach(function(Re){pe.releaseProgram(Re)}),j.isShaderMaterial&&pe.releaseShaderCache(j))}this.renderBufferDirect=function(j,Ae,Re,Ce,Se,st){Ae===null&&(Ae=re);const U=Se.isMesh&&Se.matrixWorld.determinant()<0,Z=aA(j,Ae,Re,Ce,Se);te.setMaterial(Ce,U);let le=Re.index,ce=1;if(Ce.wireframe===!0){if(le=Y.getWireframeAttribute(Re),le===void 0)return;ce=2}const ae=Re.drawRange,Ge=Re.attributes.position;let ke=ae.start*ce,Qe=(ae.start+ae.count)*ce;st!==null&&(ke=Math.max(ke,st.start*ce),Qe=Math.min(Qe,(st.start+st.count)*ce)),le!==null?(ke=Math.max(ke,0),Qe=Math.min(Qe,le.count)):Ge!=null&&(ke=Math.max(ke,0),Qe=Math.min(Qe,Ge.count));const Ze=Qe-ke;if(Ze<0||Ze===1/0)return;ve.setup(Se,Ce,Z,Re,le);let at,rt=$e;if(le!==null&&(at=K.get(le),rt=z,rt.setIndex(at)),Se.isMesh)Ce.wireframe===!0?(te.setLineWidth(Ce.wireframeLinewidth*Q()),rt.setMode(k.LINES)):rt.setMode(k.TRIANGLES);else if(Se.isLine){let ht=Ce.linewidth;ht===void 0&&(ht=1),te.setLineWidth(ht*Q()),Se.isLineSegments?rt.setMode(k.LINES):Se.isLineLoop?rt.setMode(k.LINE_LOOP):rt.setMode(k.LINE_STRIP)}else Se.isPoints?rt.setMode(k.POINTS):Se.isSprite&&rt.setMode(k.TRIANGLES);if(Se.isBatchedMesh)if(Se._multiDrawInstances!==null)su("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),rt.renderMultiDrawInstances(Se._multiDrawStarts,Se._multiDrawCounts,Se._multiDrawCount,Se._multiDrawInstances);else if(fe.get("WEBGL_multi_draw"))rt.renderMultiDraw(Se._multiDrawStarts,Se._multiDrawCounts,Se._multiDrawCount);else{const ht=Se._multiDrawStarts,Xe=Se._multiDrawCounts,Rt=Se._multiDrawCount,mt=le?K.get(le).bytesPerElement:1,Vt=S.get(Ce).currentProgram.getUniforms();for(let Nt=0;Nt<Rt;Nt++)Vt.setValue(k,"_gl_DrawID",Nt),rt.render(ht[Nt]/mt,Xe[Nt])}else if(Se.isInstancedMesh)rt.renderInstances(ke,Ze,Se.count);else if(Re.isInstancedBufferGeometry){const ht=Re._maxInstanceCount!==void 0?Re._maxInstanceCount:1/0,Xe=Math.min(Re.instanceCount,ht);rt.renderInstances(ke,Ze,Xe)}else rt.render(ke,Ze)};function pf(j,Ae,Re){j.transparent===!0&&j.side===qt&&j.forceSinglePass===!1?(j.side=an,j.needsUpdate=!0,js(j,Ae,Re),j.side=Yn,j.needsUpdate=!0,js(j,Ae,Re),j.side=qt):js(j,Ae,Re)}this.compile=function(j,Ae,Re=null){Re===null&&(Re=j),x=oe.get(Re),x.init(Ae),M.push(x),Re.traverseVisible(function(Se){Se.isLight&&Se.layers.test(Ae.layers)&&(x.pushLight(Se),Se.castShadow&&x.pushShadow(Se))}),j!==Re&&j.traverseVisible(function(Se){Se.isLight&&Se.layers.test(Ae.layers)&&(x.pushLight(Se),Se.castShadow&&x.pushShadow(Se))}),x.setupLights();const Ce=new Set;return j.traverse(function(Se){if(!(Se.isMesh||Se.isPoints||Se.isLine||Se.isSprite))return;const st=Se.material;if(st)if(Array.isArray(st))for(let U=0;U<st.length;U++){const Z=st[U];pf(Z,Re,Se),Ce.add(Z)}else pf(st,Re,Se),Ce.add(st)}),x=M.pop(),Ce},this.compileAsync=function(j,Ae,Re=null){const Ce=this.compile(j,Ae,Re);return new Promise(Se=>{function st(){if(Ce.forEach(function(U){S.get(U).currentProgram.isReady()&&Ce.delete(U)}),Ce.size===0){Se(j);return}setTimeout(st,10)}fe.get("KHR_parallel_shader_compile")!==null?st():setTimeout(st,10)})};let Sd=null;function nA(j){Sd&&Sd(j)}function ff(){Ga.stop()}function sA(){Ga.start()}const Ga=new cS;Ga.setAnimationLoop(nA),typeof self<"u"&&Ga.setContext(self),this.setAnimationLoop=function(j){Sd=j,ne.setAnimationLoop(j),j===null?Ga.stop():Ga.start()},ne.addEventListener("sessionstart",ff),ne.addEventListener("sessionend",sA),this.render=function(j,Ae){if(Ae!==void 0&&Ae.isCamera!==!0){ft("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;const Re=ne.enabled===!0&&ne.isPresenting===!0,Ce=E!==null&&(L===null||Re)&&E.begin(w,L);if(j.matrixWorldAutoUpdate===!0&&j.updateMatrixWorld(),Ae.parent===null&&Ae.matrixWorldAutoUpdate===!0&&Ae.updateMatrixWorld(),ne.enabled===!0&&ne.isPresenting===!0&&(E===null||E.isCompositing()===!1)&&(ne.cameraAutoUpdate===!0&&ne.updateCamera(Ae),Ae=ne.getCamera()),j.isScene===!0&&j.onBeforeRender(w,j,Ae,L),x=oe.get(j,M.length),x.init(Ae),M.push(x),tt.multiplyMatrices(Ae.projectionMatrix,Ae.matrixWorldInverse),Te.setFromProjectionMatrix(tt,hs,Ae.reversedDepth),Oe=this.localClippingEnabled,Le=we.init(this.clippingPlanes,Oe),y=He.get(j,_.length),y.init(),_.push(y),ne.enabled===!0&&ne.isPresenting===!0){const U=w.xr.getDepthSensingMesh();U!==null&&Cd(U,Ae,-1/0,w.sortObjects)}Cd(j,Ae,0,w.sortObjects),y.finish(),w.sortObjects===!0&&y.sort(Ee,Me),ee=ne.enabled===!1||ne.isPresenting===!1||ne.hasDepthSensing()===!1,ee&&Fe.addToRenderList(y,j),this.info.render.frame++,Le===!0&&we.beginShadows();const Se=x.state.shadowsArray;if(Ve.render(Se,j,Ae),Le===!0&&we.endShadows(),this.info.autoReset===!0&&this.info.reset(),(Ce&&E.hasRenderPass())===!1){const U=y.opaque,Z=y.transmissive;if(x.setupLights(),Ae.isArrayCamera){const le=Ae.cameras;if(Z.length>0)for(let ce=0,ae=le.length;ce<ae;ce++){const Ge=le[ce];rA(U,Z,j,Ge)}ee&&Fe.render(j);for(let ce=0,ae=le.length;ce<ae;ce++){const Ge=le[ce];Td(y,j,Ge,Ge.viewport)}}else Z.length>0&&rA(U,Z,j,Ae),ee&&Fe.render(j),Td(y,j,Ae)}L!==null&&D===0&&(F.updateMultisampleRenderTarget(L),F.updateRenderTargetMipmap(L)),Ce&&E.end(w),j.isScene===!0&&j.onAfterRender(w,j,Ae),ve.resetDefaultState(),I=-1,O=null,M.pop(),M.length>0?(x=M[M.length-1],Le===!0&&we.setGlobalState(w.clippingPlanes,x.state.camera)):x=null,_.pop(),_.length>0?y=_[_.length-1]:y=null};function Cd(j,Ae,Re,Ce){if(j.visible===!1)return;if(j.layers.test(Ae.layers)){if(j.isGroup)Re=j.renderOrder;else if(j.isLOD)j.autoUpdate===!0&&j.update(Ae);else if(j.isLight)x.pushLight(j),j.castShadow&&x.pushShadow(j);else if(j.isSprite){if(!j.frustumCulled||Te.intersectsSprite(j)){Ce&&B.setFromMatrixPosition(j.matrixWorld).applyMatrix4(tt);const U=ye.update(j),Z=j.material;Z.visible&&y.push(j,U,Z,Re,B.z,null)}}else if((j.isMesh||j.isLine||j.isPoints)&&(!j.frustumCulled||Te.intersectsObject(j))){const U=ye.update(j),Z=j.material;if(Ce&&(j.boundingSphere!==void 0?(j.boundingSphere===null&&j.computeBoundingSphere(),B.copy(j.boundingSphere.center)):(U.boundingSphere===null&&U.computeBoundingSphere(),B.copy(U.boundingSphere.center)),B.applyMatrix4(j.matrixWorld).applyMatrix4(tt)),Array.isArray(Z)){const le=U.groups;for(let ce=0,ae=le.length;ce<ae;ce++){const Ge=le[ce],ke=Z[Ge.materialIndex];ke&&ke.visible&&y.push(j,U,ke,Re,B.z,Ge)}}else Z.visible&&y.push(j,U,Z,Re,B.z,null)}}const st=j.children;for(let U=0,Z=st.length;U<Z;U++)Cd(st[U],Ae,Re,Ce)}function Td(j,Ae,Re,Ce){const{opaque:Se,transmissive:st,transparent:U}=j;x.setupLightsView(Re),Le===!0&&we.setGlobalState(w.clippingPlanes,Re),Ce&&te.viewport(N.copy(Ce)),Se.length>0&&Sc(Se,Ae,Re),st.length>0&&Sc(st,Ae,Re),U.length>0&&Sc(U,Ae,Re),te.buffers.depth.setTest(!0),te.buffers.depth.setMask(!0),te.buffers.color.setMask(!0),te.setPolygonOffset(!1)}function rA(j,Ae,Re,Ce){if((Re.isScene===!0?Re.overrideMaterial:null)!==null)return;if(x.state.transmissionRenderTarget[Ce.id]===void 0){const ke=fe.has("EXT_color_buffer_half_float")||fe.has("EXT_color_buffer_float");x.state.transmissionRenderTarget[Ce.id]=new ki(1,1,{generateMipmaps:!0,type:ke?li:bt,minFilter:$n,samples:Math.max(4,xe.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:It.workingColorSpace})}const st=x.state.transmissionRenderTarget[Ce.id],U=Ce.viewport||N;st.setSize(U.z*w.transmissionResolutionScale,U.w*w.transmissionResolutionScale);const Z=w.getRenderTarget(),le=w.getActiveCubeFace(),ce=w.getActiveMipmapLevel();w.setRenderTarget(st),w.getClearColor(H),J=w.getClearAlpha(),J<1&&w.setClearColor(16777215,.5),w.clear(),ee&&Fe.render(Re);const ae=w.toneMapping;w.toneMapping=on;const Ge=Ce.viewport;if(Ce.viewport!==void 0&&(Ce.viewport=void 0),x.setupLightsView(Ce),Le===!0&&we.setGlobalState(w.clippingPlanes,Ce),Sc(j,Re,Ce),F.updateMultisampleRenderTarget(st),F.updateRenderTargetMipmap(st),fe.has("WEBGL_multisampled_render_to_texture")===!1){let ke=!1;for(let Qe=0,Ze=Ae.length;Qe<Ze;Qe++){const at=Ae[Qe],{object:rt,geometry:ht,material:Xe,group:Rt}=at;if(Xe.side===qt&&rt.layers.test(Ce.layers)){const mt=Xe.side;Xe.side=an,Xe.needsUpdate=!0,mf(rt,Re,Ce,ht,Xe,Rt),Xe.side=mt,Xe.needsUpdate=!0,ke=!0}}ke===!0&&(F.updateMultisampleRenderTarget(st),F.updateRenderTargetMipmap(st))}w.setRenderTarget(Z,le,ce),w.setClearColor(H,J),Ge!==void 0&&(Ce.viewport=Ge),w.toneMapping=ae}function Sc(j,Ae,Re){const Ce=Ae.isScene===!0?Ae.overrideMaterial:null;for(let Se=0,st=j.length;Se<st;Se++){const U=j[Se],{object:Z,geometry:le,group:ce}=U;let ae=U.material;ae.allowOverride===!0&&Ce!==null&&(ae=Ce),Z.layers.test(Re.layers)&&mf(Z,Ae,Re,le,ae,ce)}}function mf(j,Ae,Re,Ce,Se,st){j.onBeforeRender(w,Ae,Re,Ce,Se,st),j.modelViewMatrix.multiplyMatrices(Re.matrixWorldInverse,j.matrixWorld),j.normalMatrix.getNormalMatrix(j.modelViewMatrix),Se.onBeforeRender(w,Ae,Re,Ce,j,st),Se.transparent===!0&&Se.side===qt&&Se.forceSinglePass===!1?(Se.side=an,Se.needsUpdate=!0,w.renderBufferDirect(Re,Ae,Ce,Se,j,st),Se.side=Yn,Se.needsUpdate=!0,w.renderBufferDirect(Re,Ae,Ce,Se,j,st),Se.side=qt):w.renderBufferDirect(Re,Ae,Ce,Se,j,st),j.onAfterRender(w,Ae,Re,Ce,Se,st)}function js(j,Ae,Re){Ae.isScene!==!0&&(Ae=re);const Ce=S.get(j),Se=x.state.lights,st=x.state.shadowsArray,U=Se.state.version,Z=pe.getParameters(j,Se.state,st,Ae,Re),le=pe.getProgramCacheKey(Z);let ce=Ce.programs;Ce.environment=j.isMeshStandardMaterial||j.isMeshLambertMaterial||j.isMeshPhongMaterial?Ae.environment:null,Ce.fog=Ae.fog;const ae=j.isMeshStandardMaterial||j.isMeshLambertMaterial&&!j.envMap||j.isMeshPhongMaterial&&!j.envMap;Ce.envMap=q.get(j.envMap||Ce.environment,ae),Ce.envMapRotation=Ce.environment!==null&&j.envMap===null?Ae.environmentRotation:j.envMapRotation,ce===void 0&&(j.addEventListener("dispose",ut),ce=new Map,Ce.programs=ce);let Ge=ce.get(le);if(Ge!==void 0){if(Ce.currentProgram===Ge&&Ce.lightsStateVersion===U)return gf(j,Z),Ge}else Z.uniforms=pe.getUniforms(j),j.onBeforeCompile(Z,w),Ge=pe.acquireProgram(Z,le),ce.set(le,Ge),Ce.uniforms=Z.uniforms;const ke=Ce.uniforms;return(!j.isShaderMaterial&&!j.isRawShaderMaterial||j.clipping===!0)&&(ke.clippingPlanes=we.uniform),gf(j,Z),Ce.needsLights=oA(j),Ce.lightsStateVersion=U,Ce.needsLights&&(ke.ambientLightColor.value=Se.state.ambient,ke.lightProbe.value=Se.state.probe,ke.directionalLights.value=Se.state.directional,ke.directionalLightShadows.value=Se.state.directionalShadow,ke.spotLights.value=Se.state.spot,ke.spotLightShadows.value=Se.state.spotShadow,ke.rectAreaLights.value=Se.state.rectArea,ke.ltc_1.value=Se.state.rectAreaLTC1,ke.ltc_2.value=Se.state.rectAreaLTC2,ke.pointLights.value=Se.state.point,ke.pointLightShadows.value=Se.state.pointShadow,ke.hemisphereLights.value=Se.state.hemi,ke.directionalShadowMatrix.value=Se.state.directionalShadowMatrix,ke.spotLightMatrix.value=Se.state.spotLightMatrix,ke.spotLightMap.value=Se.state.spotLightMap,ke.pointShadowMatrix.value=Se.state.pointShadowMatrix),Ce.currentProgram=Ge,Ce.uniformsList=null,Ge}function Cc(j){if(j.uniformsList===null){const Ae=j.currentProgram.getUniforms();j.uniformsList=Cg.seqWithValue(Ae.seq,j.uniforms)}return j.uniformsList}function gf(j,Ae){const Re=S.get(j);Re.outputColorSpace=Ae.outputColorSpace,Re.batching=Ae.batching,Re.batchingColor=Ae.batchingColor,Re.instancing=Ae.instancing,Re.instancingColor=Ae.instancingColor,Re.instancingMorph=Ae.instancingMorph,Re.skinning=Ae.skinning,Re.morphTargets=Ae.morphTargets,Re.morphNormals=Ae.morphNormals,Re.morphColors=Ae.morphColors,Re.morphTargetsCount=Ae.morphTargetsCount,Re.numClippingPlanes=Ae.numClippingPlanes,Re.numIntersection=Ae.numClipIntersection,Re.vertexAlphas=Ae.vertexAlphas,Re.vertexTangents=Ae.vertexTangents,Re.toneMapping=Ae.toneMapping}function aA(j,Ae,Re,Ce,Se){Ae.isScene!==!0&&(Ae=re),F.resetTextureUnits();const st=Ae.fog,U=Ce.isMeshStandardMaterial||Ce.isMeshLambertMaterial||Ce.isMeshPhongMaterial?Ae.environment:null,Z=L===null?w.outputColorSpace:L.isXRRenderTarget===!0?L.texture.colorSpace:qi,le=Ce.isMeshStandardMaterial||Ce.isMeshLambertMaterial&&!Ce.envMap||Ce.isMeshPhongMaterial&&!Ce.envMap,ce=q.get(Ce.envMap||U,le),ae=Ce.vertexColors===!0&&!!Re.attributes.color&&Re.attributes.color.itemSize===4,Ge=!!Re.attributes.tangent&&(!!Ce.normalMap||Ce.anisotropy>0),ke=!!Re.morphAttributes.position,Qe=!!Re.morphAttributes.normal,Ze=!!Re.morphAttributes.color;let at=on;Ce.toneMapped&&(L===null||L.isXRRenderTarget===!0)&&(at=w.toneMapping);const rt=Re.morphAttributes.position||Re.morphAttributes.normal||Re.morphAttributes.color,ht=rt!==void 0?rt.length:0,Xe=S.get(Ce),Rt=x.state.lights;if(Le===!0&&(Oe===!0||j!==O)){const Xt=j===O&&Ce.id===I;we.setState(Ce,j,Xt)}let mt=!1;Ce.version===Xe.__version?(Xe.needsLights&&Xe.lightsStateVersion!==Rt.state.version||Xe.outputColorSpace!==Z||Se.isBatchedMesh&&Xe.batching===!1||!Se.isBatchedMesh&&Xe.batching===!0||Se.isBatchedMesh&&Xe.batchingColor===!0&&Se.colorTexture===null||Se.isBatchedMesh&&Xe.batchingColor===!1&&Se.colorTexture!==null||Se.isInstancedMesh&&Xe.instancing===!1||!Se.isInstancedMesh&&Xe.instancing===!0||Se.isSkinnedMesh&&Xe.skinning===!1||!Se.isSkinnedMesh&&Xe.skinning===!0||Se.isInstancedMesh&&Xe.instancingColor===!0&&Se.instanceColor===null||Se.isInstancedMesh&&Xe.instancingColor===!1&&Se.instanceColor!==null||Se.isInstancedMesh&&Xe.instancingMorph===!0&&Se.morphTexture===null||Se.isInstancedMesh&&Xe.instancingMorph===!1&&Se.morphTexture!==null||Xe.envMap!==ce||Ce.fog===!0&&Xe.fog!==st||Xe.numClippingPlanes!==void 0&&(Xe.numClippingPlanes!==we.numPlanes||Xe.numIntersection!==we.numIntersection)||Xe.vertexAlphas!==ae||Xe.vertexTangents!==Ge||Xe.morphTargets!==ke||Xe.morphNormals!==Qe||Xe.morphColors!==Ze||Xe.toneMapping!==at||Xe.morphTargetsCount!==ht)&&(mt=!0):(mt=!0,Xe.__version=Ce.version);let Vt=Xe.currentProgram;mt===!0&&(Vt=js(Ce,Ae,Se));let Nt=!1,lt=!1,Mi=!1;const Ut=Vt.getUniforms(),ti=Xe.uniforms;if(te.useProgram(Vt.program)&&(Nt=!0,lt=!0,Mi=!0),Ce.id!==I&&(I=Ce.id,lt=!0),Nt||O!==j){te.buffers.depth.getReversed()&&j.reversedDepth!==!0&&(j._reversedDepth=!0,j.updateProjectionMatrix()),Ut.setValue(k,"projectionMatrix",j.projectionMatrix),Ut.setValue(k,"viewMatrix",j.matrixWorldInverse);const os=Ut.map.cameraPosition;os!==void 0&&os.setValue(k,Ye.setFromMatrixPosition(j.matrixWorld)),xe.logarithmicDepthBuffer&&Ut.setValue(k,"logDepthBufFC",2/(Math.log(j.far+1)/Math.LN2)),(Ce.isMeshPhongMaterial||Ce.isMeshToonMaterial||Ce.isMeshLambertMaterial||Ce.isMeshBasicMaterial||Ce.isMeshStandardMaterial||Ce.isShaderMaterial)&&Ut.setValue(k,"isOrthographic",j.isOrthographicCamera===!0),O!==j&&(O=j,lt=!0,Mi=!0)}if(Xe.needsLights&&(Rt.state.directionalShadowMap.length>0&&Ut.setValue(k,"directionalShadowMap",Rt.state.directionalShadowMap,F),Rt.state.spotShadowMap.length>0&&Ut.setValue(k,"spotShadowMap",Rt.state.spotShadowMap,F),Rt.state.pointShadowMap.length>0&&Ut.setValue(k,"pointShadowMap",Rt.state.pointShadowMap,F)),Se.isSkinnedMesh){Ut.setOptional(k,Se,"bindMatrix"),Ut.setOptional(k,Se,"bindMatrixInverse");const Xt=Se.skeleton;Xt&&(Xt.boneTexture===null&&Xt.computeBoneTexture(),Ut.setValue(k,"boneTexture",Xt.boneTexture,F))}Se.isBatchedMesh&&(Ut.setOptional(k,Se,"batchingTexture"),Ut.setValue(k,"batchingTexture",Se._matricesTexture,F),Ut.setOptional(k,Se,"batchingIdTexture"),Ut.setValue(k,"batchingIdTexture",Se._indirectTexture,F),Ut.setOptional(k,Se,"batchingColorTexture"),Se._colorsTexture!==null&&Ut.setValue(k,"batchingColorTexture",Se._colorsTexture,F));const Xn=Re.morphAttributes;if((Xn.position!==void 0||Xn.normal!==void 0||Xn.color!==void 0)&&Ie.update(Se,Re,Vt),(lt||Xe.receiveShadow!==Se.receiveShadow)&&(Xe.receiveShadow=Se.receiveShadow,Ut.setValue(k,"receiveShadow",Se.receiveShadow)),(Ce.isMeshStandardMaterial||Ce.isMeshLambertMaterial||Ce.isMeshPhongMaterial)&&Ce.envMap===null&&Ae.environment!==null&&(ti.envMapIntensity.value=Ae.environmentIntensity),ti.dfgLUT!==void 0&&(ti.dfgLUT.value=jF()),lt&&(Ut.setValue(k,"toneMappingExposure",w.toneMappingExposure),Xe.needsLights&&Id(ti,Mi),st&&Ce.fog===!0&&Ue.refreshFogUniforms(ti,st),Ue.refreshMaterialUniforms(ti,Ce,me,X,x.state.transmissionRenderTarget[j.id]),Cg.upload(k,Cc(Xe),ti,F)),Ce.isShaderMaterial&&Ce.uniformsNeedUpdate===!0&&(Cg.upload(k,Cc(Xe),ti,F),Ce.uniformsNeedUpdate=!1),Ce.isSpriteMaterial&&Ut.setValue(k,"center",Se.center),Ut.setValue(k,"modelViewMatrix",Se.modelViewMatrix),Ut.setValue(k,"normalMatrix",Se.normalMatrix),Ut.setValue(k,"modelMatrix",Se.matrixWorld),Ce.isShaderMaterial||Ce.isRawShaderMaterial){const Xt=Ce.uniformsGroups;for(let os=0,Zt=Xt.length;os<Zt;os++){const bn=Xt[os];Be.update(bn,Vt),Be.bind(bn,Vt)}}return Vt}function Id(j,Ae){j.ambientLightColor.needsUpdate=Ae,j.lightProbe.needsUpdate=Ae,j.directionalLights.needsUpdate=Ae,j.directionalLightShadows.needsUpdate=Ae,j.pointLights.needsUpdate=Ae,j.pointLightShadows.needsUpdate=Ae,j.spotLights.needsUpdate=Ae,j.spotLightShadows.needsUpdate=Ae,j.rectAreaLights.needsUpdate=Ae,j.hemisphereLights.needsUpdate=Ae}function oA(j){return j.isMeshLambertMaterial||j.isMeshToonMaterial||j.isMeshPhongMaterial||j.isMeshStandardMaterial||j.isShadowMaterial||j.isShaderMaterial&&j.lights===!0}this.getActiveCubeFace=function(){return R},this.getActiveMipmapLevel=function(){return D},this.getRenderTarget=function(){return L},this.setRenderTargetTextures=function(j,Ae,Re){const Ce=S.get(j);Ce.__autoAllocateDepthBuffer=j.resolveDepthBuffer===!1,Ce.__autoAllocateDepthBuffer===!1&&(Ce.__useRenderToTexture=!1),S.get(j.texture).__webglTexture=Ae,S.get(j.depthTexture).__webglTexture=Ce.__autoAllocateDepthBuffer?void 0:Re,Ce.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(j,Ae){const Re=S.get(j);Re.__webglFramebuffer=Ae,Re.__useDefaultFramebuffer=Ae===void 0};const Pd=k.createFramebuffer();this.setRenderTarget=function(j,Ae=0,Re=0){L=j,R=Ae,D=Re;let Ce=null,Se=!1,st=!1;if(j){const Z=S.get(j);if(Z.__useDefaultFramebuffer!==void 0){te.bindFramebuffer(k.FRAMEBUFFER,Z.__webglFramebuffer),N.copy(j.viewport),G.copy(j.scissor),V=j.scissorTest,te.viewport(N),te.scissor(G),te.setScissorTest(V),I=-1;return}else if(Z.__webglFramebuffer===void 0)F.setupRenderTarget(j);else if(Z.__hasExternalTextures)F.rebindTextures(j,S.get(j.texture).__webglTexture,S.get(j.depthTexture).__webglTexture);else if(j.depthBuffer){const ae=j.depthTexture;if(Z.__boundDepthTexture!==ae){if(ae!==null&&S.has(ae)&&(j.width!==ae.image.width||j.height!==ae.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");F.setupDepthRenderbuffer(j)}}const le=j.texture;(le.isData3DTexture||le.isDataArrayTexture||le.isCompressedArrayTexture)&&(st=!0);const ce=S.get(j).__webglFramebuffer;j.isWebGLCubeRenderTarget?(Array.isArray(ce[Ae])?Ce=ce[Ae][Re]:Ce=ce[Ae],Se=!0):j.samples>0&&F.useMultisampledRTT(j)===!1?Ce=S.get(j).__webglMultisampledFramebuffer:Array.isArray(ce)?Ce=ce[Re]:Ce=ce,N.copy(j.viewport),G.copy(j.scissor),V=j.scissorTest}else N.copy($).multiplyScalar(me).floor(),G.copy(se).multiplyScalar(me).floor(),V=he;if(Re!==0&&(Ce=Pd),te.bindFramebuffer(k.FRAMEBUFFER,Ce)&&te.drawBuffers(j,Ce),te.viewport(N),te.scissor(G),te.setScissorTest(V),Se){const Z=S.get(j.texture);k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,k.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Z.__webglTexture,Re)}else if(st){const Z=Ae;for(let le=0;le<j.textures.length;le++){const ce=S.get(j.textures[le]);k.framebufferTextureLayer(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0+le,ce.__webglTexture,Re,Z)}}else if(j!==null&&Re!==0){const Z=S.get(j.texture);k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,k.TEXTURE_2D,Z.__webglTexture,Re)}I=-1},this.readRenderTargetPixels=function(j,Ae,Re,Ce,Se,st,U,Z=0){if(!(j&&j.isWebGLRenderTarget)){ft("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let le=S.get(j).__webglFramebuffer;if(j.isWebGLCubeRenderTarget&&U!==void 0&&(le=le[U]),le){te.bindFramebuffer(k.FRAMEBUFFER,le);try{const ce=j.textures[Z],ae=ce.format,Ge=ce.type;if(j.textures.length>1&&k.readBuffer(k.COLOR_ATTACHMENT0+Z),!xe.textureFormatReadable(ae)){ft("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!xe.textureTypeReadable(Ge)){ft("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ae>=0&&Ae<=j.width-Ce&&Re>=0&&Re<=j.height-Se&&k.readPixels(Ae,Re,Ce,Se,_e.convert(ae),_e.convert(Ge),st)}finally{const ce=L!==null?S.get(L).__webglFramebuffer:null;te.bindFramebuffer(k.FRAMEBUFFER,ce)}}},this.readRenderTargetPixelsAsync=async function(j,Ae,Re,Ce,Se,st,U,Z=0){if(!(j&&j.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let le=S.get(j).__webglFramebuffer;if(j.isWebGLCubeRenderTarget&&U!==void 0&&(le=le[U]),le)if(Ae>=0&&Ae<=j.width-Ce&&Re>=0&&Re<=j.height-Se){te.bindFramebuffer(k.FRAMEBUFFER,le);const ce=j.textures[Z],ae=ce.format,Ge=ce.type;if(j.textures.length>1&&k.readBuffer(k.COLOR_ATTACHMENT0+Z),!xe.textureFormatReadable(ae))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!xe.textureTypeReadable(Ge))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const ke=k.createBuffer();k.bindBuffer(k.PIXEL_PACK_BUFFER,ke),k.bufferData(k.PIXEL_PACK_BUFFER,st.byteLength,k.STREAM_READ),k.readPixels(Ae,Re,Ce,Se,_e.convert(ae),_e.convert(Ge),0);const Qe=L!==null?S.get(L).__webglFramebuffer:null;te.bindFramebuffer(k.FRAMEBUFFER,Qe);const Ze=k.fenceSync(k.SYNC_GPU_COMMANDS_COMPLETE,0);return k.flush(),await Y4(k,Ze,4),k.bindBuffer(k.PIXEL_PACK_BUFFER,ke),k.getBufferSubData(k.PIXEL_PACK_BUFFER,0,st),k.deleteBuffer(ke),k.deleteSync(Ze),st}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(j,Ae=null,Re=0){const Ce=Math.pow(2,-Re),Se=Math.floor(j.image.width*Ce),st=Math.floor(j.image.height*Ce),U=Ae!==null?Ae.x:0,Z=Ae!==null?Ae.y:0;F.setTexture2D(j,0),k.copyTexSubImage2D(k.TEXTURE_2D,Re,0,0,U,Z,Se,st),te.unbindTexture()};const lA=k.createFramebuffer(),cA=k.createFramebuffer();this.copyTextureToTexture=function(j,Ae,Re=null,Ce=null,Se=0,st=0){let U,Z,le,ce,ae,Ge,ke,Qe,Ze;const at=j.isCompressedTexture?j.mipmaps[st]:j.image;if(Re!==null)U=Re.max.x-Re.min.x,Z=Re.max.y-Re.min.y,le=Re.isBox3?Re.max.z-Re.min.z:1,ce=Re.min.x,ae=Re.min.y,Ge=Re.isBox3?Re.min.z:0;else{const ti=Math.pow(2,-Se);U=Math.floor(at.width*ti),Z=Math.floor(at.height*ti),j.isDataArrayTexture?le=at.depth:j.isData3DTexture?le=Math.floor(at.depth*ti):le=1,ce=0,ae=0,Ge=0}Ce!==null?(ke=Ce.x,Qe=Ce.y,Ze=Ce.z):(ke=0,Qe=0,Ze=0);const rt=_e.convert(Ae.format),ht=_e.convert(Ae.type);let Xe;Ae.isData3DTexture?(F.setTexture3D(Ae,0),Xe=k.TEXTURE_3D):Ae.isDataArrayTexture||Ae.isCompressedArrayTexture?(F.setTexture2DArray(Ae,0),Xe=k.TEXTURE_2D_ARRAY):(F.setTexture2D(Ae,0),Xe=k.TEXTURE_2D),k.pixelStorei(k.UNPACK_FLIP_Y_WEBGL,Ae.flipY),k.pixelStorei(k.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ae.premultiplyAlpha),k.pixelStorei(k.UNPACK_ALIGNMENT,Ae.unpackAlignment);const Rt=k.getParameter(k.UNPACK_ROW_LENGTH),mt=k.getParameter(k.UNPACK_IMAGE_HEIGHT),Vt=k.getParameter(k.UNPACK_SKIP_PIXELS),Nt=k.getParameter(k.UNPACK_SKIP_ROWS),lt=k.getParameter(k.UNPACK_SKIP_IMAGES);k.pixelStorei(k.UNPACK_ROW_LENGTH,at.width),k.pixelStorei(k.UNPACK_IMAGE_HEIGHT,at.height),k.pixelStorei(k.UNPACK_SKIP_PIXELS,ce),k.pixelStorei(k.UNPACK_SKIP_ROWS,ae),k.pixelStorei(k.UNPACK_SKIP_IMAGES,Ge);const Mi=j.isDataArrayTexture||j.isData3DTexture,Ut=Ae.isDataArrayTexture||Ae.isData3DTexture;if(j.isDepthTexture){const ti=S.get(j),Xn=S.get(Ae),Xt=S.get(ti.__renderTarget),os=S.get(Xn.__renderTarget);te.bindFramebuffer(k.READ_FRAMEBUFFER,Xt.__webglFramebuffer),te.bindFramebuffer(k.DRAW_FRAMEBUFFER,os.__webglFramebuffer);for(let Zt=0;Zt<le;Zt++)Mi&&(k.framebufferTextureLayer(k.READ_FRAMEBUFFER,k.COLOR_ATTACHMENT0,S.get(j).__webglTexture,Se,Ge+Zt),k.framebufferTextureLayer(k.DRAW_FRAMEBUFFER,k.COLOR_ATTACHMENT0,S.get(Ae).__webglTexture,st,Ze+Zt)),k.blitFramebuffer(ce,ae,U,Z,ke,Qe,U,Z,k.DEPTH_BUFFER_BIT,k.NEAREST);te.bindFramebuffer(k.READ_FRAMEBUFFER,null),te.bindFramebuffer(k.DRAW_FRAMEBUFFER,null)}else if(Se!==0||j.isRenderTargetTexture||S.has(j)){const ti=S.get(j),Xn=S.get(Ae);te.bindFramebuffer(k.READ_FRAMEBUFFER,lA),te.bindFramebuffer(k.DRAW_FRAMEBUFFER,cA);for(let Xt=0;Xt<le;Xt++)Mi?k.framebufferTextureLayer(k.READ_FRAMEBUFFER,k.COLOR_ATTACHMENT0,ti.__webglTexture,Se,Ge+Xt):k.framebufferTexture2D(k.READ_FRAMEBUFFER,k.COLOR_ATTACHMENT0,k.TEXTURE_2D,ti.__webglTexture,Se),Ut?k.framebufferTextureLayer(k.DRAW_FRAMEBUFFER,k.COLOR_ATTACHMENT0,Xn.__webglTexture,st,Ze+Xt):k.framebufferTexture2D(k.DRAW_FRAMEBUFFER,k.COLOR_ATTACHMENT0,k.TEXTURE_2D,Xn.__webglTexture,st),Se!==0?k.blitFramebuffer(ce,ae,U,Z,ke,Qe,U,Z,k.COLOR_BUFFER_BIT,k.NEAREST):Ut?k.copyTexSubImage3D(Xe,st,ke,Qe,Ze+Xt,ce,ae,U,Z):k.copyTexSubImage2D(Xe,st,ke,Qe,ce,ae,U,Z);te.bindFramebuffer(k.READ_FRAMEBUFFER,null),te.bindFramebuffer(k.DRAW_FRAMEBUFFER,null)}else Ut?j.isDataTexture||j.isData3DTexture?k.texSubImage3D(Xe,st,ke,Qe,Ze,U,Z,le,rt,ht,at.data):Ae.isCompressedArrayTexture?k.compressedTexSubImage3D(Xe,st,ke,Qe,Ze,U,Z,le,rt,at.data):k.texSubImage3D(Xe,st,ke,Qe,Ze,U,Z,le,rt,ht,at):j.isDataTexture?k.texSubImage2D(k.TEXTURE_2D,st,ke,Qe,U,Z,rt,ht,at.data):j.isCompressedTexture?k.compressedTexSubImage2D(k.TEXTURE_2D,st,ke,Qe,at.width,at.height,rt,at.data):k.texSubImage2D(k.TEXTURE_2D,st,ke,Qe,U,Z,rt,ht,at);k.pixelStorei(k.UNPACK_ROW_LENGTH,Rt),k.pixelStorei(k.UNPACK_IMAGE_HEIGHT,mt),k.pixelStorei(k.UNPACK_SKIP_PIXELS,Vt),k.pixelStorei(k.UNPACK_SKIP_ROWS,Nt),k.pixelStorei(k.UNPACK_SKIP_IMAGES,lt),st===0&&Ae.generateMipmaps&&k.generateMipmap(Xe),te.unbindTexture()},this.initRenderTarget=function(j){S.get(j).__webglFramebuffer===void 0&&F.setupRenderTarget(j)},this.initTexture=function(j){j.isCubeTexture?F.setTextureCube(j,0):j.isData3DTexture?F.setTexture3D(j,0):j.isDataArrayTexture||j.isCompressedArrayTexture?F.setTexture2DArray(j,0):F.setTexture2D(j,0),te.unbindTexture()},this.resetState=function(){R=0,D=0,L=null,te.reset(),ve.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return hs}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=It._getDrawingBufferColorSpace(e),t.unpackColorSpace=It._getUnpackColorSpace()}}const XF=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Yr,AddEquation:Kn,AddOperation:Ww,AdditiveAnimationBlendMode:xA,AdditiveBlending:bf,AgXToneMapping:Lf,AlphaFormat:bA,AlwaysCompare:nE,AlwaysDepth:Ef,AlwaysStencilFunc:wA,AmbientLight:Lu,AnimationAction:qM,AnimationClip:uh,AnimationLoader:kL,AnimationMixer:l5,AnimationObjectGroup:a5,AnimationUtils:DL,ArcCurve:JE,ArrayCamera:WM,ArrowHelper:P5,AttachedBindMode:gA,Audio:QM,AudioAnalyser:KL,AudioContext:Rb,AudioListener:XL,AudioLoader:VL,AxesHelper:oS,BackSide:an,BasicDepthPacking:Kw,BasicShadowMap:r4,BatchedMesh:zE,BezierInterpolant:EM,Bone:Lm,BooleanKeyframeTrack:Al,Box2:m5,Box3:xt,Box3Helper:T5,BoxGeometry:fi,BoxHelper:C5,BufferAttribute:_t,BufferGeometry:dt,BufferGeometryLoader:FM,ByteType:vA,Cache:Pr,Camera:fg,CameraHelper:S5,CanvasTexture:KE,CapsuleGeometry:qm,CatmullRomCurve3:eM,CineonToneMapping:Rf,CircleGeometry:Ym,ClampToEdgeWrapping:Bn,Clock:$M,Color:qe,ColorKeyframeTrack:Eb,ColorManagement:It,Compatibility:W4,CompressedArrayTexture:qE,CompressedCubeTexture:YE,CompressedTexture:lh,CompressedTextureLoader:OL,ConeGeometry:wu,ConstantAlphaFactor:Hw,ConstantColorFactor:Uw,Controls:wg,CubeCamera:VM,CubeDepthTexture:$E,CubeReflectionMapping:wr,CubeRefractionMapping:Wa,CubeTexture:_u,CubeTextureLoader:FL,CubeUVReflectionMapping:Rc,CubicBezierCurve:db,CubicBezierCurve3:iM,CubicInterpolant:_M,CullFaceBack:pA,CullFaceFront:Cw,CullFaceFrontBack:s4,CullFaceNone:Sw,Curve:Js,CurvePath:sM,CustomBlending:yf,CustomToneMapping:Bf,CylinderGeometry:$i,Cylindrical:f5,Data3DTexture:au,DataArrayTexture:om,DataTexture:On,DataTextureLoader:TM,DataUtils:hu,DecrementStencilOp:x4,DecrementWrapStencilOp:w4,DefaultLoadingManager:CM,DepthFormat:Er,DepthStencilFormat:Mr,DepthTexture:so,DetachedBindMode:Qw,DirectionalLight:tr,DirectionalLightHelper:M5,DiscreteInterpolant:wM,DodecahedronGeometry:Km,DoubleSide:qt,DstAlphaFactor:Bd,DstColorFactor:Ld,DynamicCopyUsage:N4,DynamicDrawUsage:R4,DynamicReadUsage:k4,EdgesGeometry:ZE,EllipseCurve:Eu,EqualCompare:eE,EqualDepth:Sf,EqualStencilFunc:C4,EquirectangularReflectionMapping:Dc,EquirectangularRefractionMapping:Od,Euler:Yi,EventDispatcher:Ys,ExternalTexture:rb,ExtrudeGeometry:hh,FileLoader:gn,Float16BufferAttribute:RB,Float32BufferAttribute:it,FloatType:xi,Fog:fm,FogExp2:pm,FramebufferTexture:$B,FrontSide:Yn,Frustum:oh,FrustumArray:Fm,GLBufferAttribute:p5,GLSL1:z4,GLSL3:EA,GreaterCompare:tE,GreaterDepth:Tf,GreaterEqualCompare:am,GreaterEqualDepth:Cf,GreaterEqualStencilFunc:D4,GreaterStencilFunc:I4,GridHelper:w5,Group:Si,HalfFloatType:li,HemisphereLight:IM,HemisphereLightHelper:_5,IcosahedronGeometry:sg,ImageBitmapLoader:zM,ImageLoader:Bu,ImageUtils:uE,IncrementStencilOp:y4,IncrementWrapStencilOp:_4,InstancedBufferAttribute:no,InstancedBufferGeometry:OM,InstancedInterleavedBuffer:u5,InstancedMesh:hi,Int16BufferAttribute:PB,Int32BufferAttribute:DB,Int8BufferAttribute:CB,IntType:Ff,InterleavedBuffer:th,InterleavedBufferAttribute:ia,Interpolant:vl,InterpolateBezier:yA,InterpolateDiscrete:zc,InterpolateLinear:Hc,InterpolateSmooth:im,InterpolationSamplingMode:V4,InterpolationSamplingType:G4,InvertStencilOp:E4,KeepStencilOp:rl,KeyframeTrack:Bs,LOD:SE,LatheGeometry:rg,Layers:cm,LessCompare:Jw,LessDepth:Mf,LessEqualCompare:rm,LessEqualDepth:$o,LessEqualStencilFunc:T4,LessStencilFunc:S4,Light:co,LightProbe:kM,Line:Ci,Line3:ms,LineBasicMaterial:bi,LineCurve:ub,LineCurve3:nM,LineDashedMaterial:yM,LineLoop:nb,LineSegments:Oi,LinearFilter:wt,LinearInterpolant:wb,LinearMipMapLinearFilter:h4,LinearMipMapNearestFilter:c4,LinearMipmapLinearFilter:$n,LinearMipmapNearestFilter:Lc,LinearSRGBColorSpace:qi,LinearToneMapping:Pf,LinearTransfer:eu,Loader:dn,LoaderUtils:uo,LoadingManager:Mb,LoopOnce:jw,LoopPingPong:qw,LoopRepeat:Xw,MOUSE:ls,Material:Ki,MaterialBlending:a4,MaterialLoader:mg,MathUtils:Bt,Matrix2:Ub,Matrix3:yt,Matrix4:Ke,MaxEquation:Rw,Mesh:We,MeshBasicMaterial:Wt,MeshDepthMaterial:bb,MeshDistanceMaterial:yb,MeshLambertMaterial:Ab,MeshMatcapMaterial:bM,MeshNormalMaterial:dg,MeshPhongMaterial:vM,MeshPhysicalMaterial:Rs,MeshStandardMaterial:oo,MeshToonMaterial:AM,MinEquation:Dw,MirroredRepeatWrapping:Bc,MixOperation:Vw,MultiplyBlending:mA,MultiplyOperation:kd,NearestFilter:Jt,NearestMipMapLinearFilter:l4,NearestMipMapNearestFilter:o4,NearestMipmapLinearFilter:Zo,NearestMipmapNearestFilter:Fd,NeutralToneMapping:kf,NeverCompare:Zw,NeverDepth:wf,NeverStencilFunc:M4,NoBlending:vi,NoColorSpace:qs,NoNormalPacking:m4,NoToneMapping:on,NormalAnimationBlendMode:nm,NormalBlending:Ko,NormalGAPacking:v4,NormalRGPacking:g4,NotEqualCompare:iE,NotEqualDepth:If,NotEqualStencilFunc:P4,NumberKeyframeTrack:bl,Object3D:Pt,ObjectLoader:HL,ObjectSpaceNormalMap:$w,OctahedronGeometry:ra,OneFactor:Bw,OneMinusConstantAlphaFactor:Gw,OneMinusConstantColorFactor:zw,OneMinusDstAlphaFactor:Ow,OneMinusDstColorFactor:Fw,OneMinusSrcAlphaFactor:_f,OneMinusSrcColorFactor:kw,OrthographicCamera:Zi,PCFShadowMap:Rd,PCFSoftShadowMap:Tw,PMREMGenerator:Ou,Path:Cu,PerspectiveCamera:wi,Plane:$t,PlaneGeometry:Ds,PlaneHelper:I5,PointLight:Ib,PointLightHelper:y5,Points:Xm,PointsMaterial:Wm,PolarGridHelper:E5,PolyhedronGeometry:ro,PositionalAudio:YL,PropertyBinding:Qt,PropertyMixer:XM,QuadraticBezierCurve:pb,QuadraticBezierCurve3:fb,Quaternion:Lt,QuaternionKeyframeTrack:yl,QuaternionLinearInterpolant:MM,R11_EAC_Format:Wd,RED_GREEN_RGTC2_Format:$d,RED_RGTC1_Format:Yd,REVISION:Ic,RG11_EAC_Format:jd,RGBADepthPacking:u4,RGBAFormat:_i,RGBAIntegerFormat:Hf,RGBA_ASTC_10x10_Format:Zf,RGBA_ASTC_10x5_Format:Yf,RGBA_ASTC_10x6_Format:Kf,RGBA_ASTC_10x8_Format:$f,RGBA_ASTC_12x10_Format:Jf,RGBA_ASTC_12x12_Format:em,RGBA_ASTC_4x4_Format:qa,RGBA_ASTC_5x4_Format:Vf,RGBA_ASTC_5x5_Format:Wf,RGBA_ASTC_6x5_Format:Qf,RGBA_ASTC_6x6_Format:tl,RGBA_ASTC_8x5_Format:jf,RGBA_ASTC_8x6_Format:Xf,RGBA_ASTC_8x8_Format:qf,RGBA_BPTC_Format:il,RGBA_ETC2_EAC_Format:Uc,RGBA_PVRTC_2BPPV1_Format:Fc,RGBA_PVRTC_4BPPV1_Format:el,RGBA_S3TC_DXT1_Format:ja,RGBA_S3TC_DXT3_Format:Hd,RGBA_S3TC_DXT5_Format:Xa,RGBDepthPacking:p4,RGBFormat:Oc,RGBIntegerFormat:d4,RGB_BPTC_SIGNED_Format:tm,RGB_BPTC_UNSIGNED_Format:qd,RGB_ETC1_Format:Vd,RGB_ETC2_Format:Nc,RGB_PVRTC_2BPPV1_Format:Gf,RGB_PVRTC_4BPPV1_Format:Gd,RGB_S3TC_DXT1_Format:Jo,RGDepthPacking:f4,RGFormat:Is,RGIntegerFormat:zf,RawShaderMaterial:hg,Ray:Cr,Raycaster:fs,RectAreaLight:LM,RedFormat:Sr,RedIntegerFormat:zd,ReinhardToneMapping:Df,RenderTarget:PA,RenderTarget3D:c5,RepeatWrapping:ln,ReplaceStencilOp:b4,ReverseSubtractEquation:Pw,RingGeometry:ag,SIGNED_R11_EAC_Format:Qd,SIGNED_RED_GREEN_RGTC2_Format:Zd,SIGNED_RED_RGTC1_Format:Kd,SIGNED_RG11_EAC_Format:Xd,SRGBColorSpace:ci,SRGBTransfer:Yt,Scene:ll,ShaderChunk:Ct,ShaderLib:ir,ShaderMaterial:mi,ShadowMaterial:mM,Shape:sa,ShapeGeometry:Ru,ShapePath:lS,ShapeUtils:er,ShortType:AA,Skeleton:vu,SkeletonHelper:b5,SkinnedMesh:ZA,Source:$a,Sphere:cn,SphereGeometry:ao,Spherical:gh,SphericalHarmonics3:Pb,SplineCurve:mb,SpotLight:Tb,SpotLightHelper:A5,Sprite:gu,SpriteMaterial:bm,SrcAlphaFactor:xf,SrcAlphaSaturateFactor:Nw,SrcColorFactor:Lw,StaticCopyUsage:F4,StaticDrawUsage:tu,StaticReadUsage:L4,StereoCamera:WL,StreamCopyUsage:U4,StreamDrawUsage:B4,StreamReadUsage:O4,StringKeyframeTrack:xl,SubtractEquation:Iw,SubtractiveBlending:fA,TOUCH:cs,TangentSpaceNormalMap:Ya,TetrahedronGeometry:og,Texture:Ai,TextureLoader:lo,TextureUtils:k5,Timer:Bb,TimestampQuery:H4,TorusGeometry:aa,TorusKnotGeometry:lg,Triangle:ii,TriangleFanDrawMode:sm,TriangleStripDrawMode:_A,TrianglesDrawMode:Yw,TubeGeometry:cg,UVMapping:Of,Uint16BufferAttribute:HA,Uint32BufferAttribute:GA,Uint8BufferAttribute:TB,Uint8ClampedBufferAttribute:IB,Uniform:Fb,UniformsGroup:d5,UniformsLib:et,UniformsUtils:Mn,UnsignedByteType:bt,UnsignedInt101111Type:Ud,UnsignedInt248Type:Qa,UnsignedInt5999Type:Nd,UnsignedIntType:Ts,UnsignedShort4444Type:Nf,UnsignedShort5551Type:Uf,UnsignedShortType:kc,VSMShadowMap:Pc,Vector2:be,Vector3:P,Vector4:zt,VectorKeyframeTrack:_l,VideoFrameTexture:KB,VideoTexture:XE,WebGL3DRenderTarget:vB,WebGLArrayRenderTarget:gB,WebGLCoordinateSystem:hs,WebGLCubeRenderTarget:qb,WebGLRenderTarget:ki,WebGLRenderer:Uu,WebGLUtils:OS,WebGPUCoordinateSystem:al,WebXRController:dm,WireframeGeometry:uM,WrapAroundEnding:Jd,ZeroCurvatureEnding:nl,ZeroFactor:Va,ZeroSlopeEnding:sl,ZeroStencilOp:A4,createCanvasElement:rE,error:ft,getConsoleFunction:q4,log:nu,setConsoleFunction:X4,warn:Je,warnOnce:su},Symbol.toStringTag,{value:"Module"}));class qF{engine;scene;constructor(e){this.engine=e,this.scene=new ll;let t=new Si;t.name="groupEdge",this.scene.add(t)}}class Kt{constructor(e,t,i){this.camera=e,this.renderer=t,this.scene=i,this.raycaster=new fs}raycaster;worldToScreenNormalized(e){const t=e.clone();return t.project(this.camera),new be(t.x,t.y)}worldToScreen(e){const t=new P;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,r=e/i*2-1,a=-(t/n*2-1);return new be(r,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 r=i||this.scene.children,a=this.raycaster.intersectObjects(r,!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 r=new P;return this.raycaster.ray.at(i,r),r}updateCamera(e){this.camera=e}updateRenderer(e){this.renderer=e}updateScene(e){this.scene=e}}var Ig=(s=>(s.PERSPECTIVE="perspective",s.ORTHOGRAPHIC="orthographic",s))(Ig||{});class Br{static MIN_VISIBLE_HEIGHT=1e-4;static MIN_CAMERA_DISTANCE=1e-4;engine;perspectiveCamera;orthographicCamera;constructor(e){this.engine=e,this.perspectiveCamera=new wi(60,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 Zi(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),Br.MIN_CAMERA_DISTANCE),n=Bt.degToRad(e.getEffectiveFOV()*.5);return Math.max(2*i*Math.tan(n),Br.MIN_VISIBLE_HEIGHT)}getOrthographicVisibleHeight(e=this.orthographicCamera){return Math.max((e.top-e.bottom)/e.zoom,Br.MIN_VISIBLE_HEIGHT)}setOrthographicVisibleHeight(e,t=this.orthographicCamera){const i=Math.max(e,Br.MIN_VISIBLE_HEIGHT),n=this.getCameraAspect(),r=i*.5,a=r*n;t.left=-a,t.right=a,t.top=r,t.bottom=-r}getViewDirection(e,t,i){const n=new P().subVectors(e,t);return n.lengthSq()>Br.MIN_CAMERA_DISTANCE?n.normalize():new P(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 Kt(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,r=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=Bt.degToRad(n*.5),h=Bt.degToRad(r*.5),d=Math.tan(c)/Math.tan(h),u=l*d,p=new P().subVectors(o,a).normalize();i.position.copy(a).add(p.multiplyScalar(u))}}i.fov=r,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(),r=e.up.clone(),a=this.perspectiveCamera,o=this.getViewDirection(t,i,n),l=e instanceof Zi?this.getOrthographicVisibleHeight(e):this.getPerspectiveVisibleHeight(e,i),c=Bt.degToRad(a.getEffectiveFOV()*.5),h=Math.max(l/(2*Math.tan(c)),Br.MIN_CAMERA_DISTANCE);a.near=e.near,a.far=e.far,a.aspect=this.getCameraAspect(),a.up.copy(r),a.position.copy(i).add(o.multiplyScalar(h)),a.lookAt(i),this.engine.camera=a,this.applySwitchedCamera(a,i)}switchToOrthographicCamera(){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(),r=e.up.clone(),a=this.orthographicCamera,o=this.getViewDirection(t,i,n),l=e instanceof wi?this.getPerspectiveVisibleHeight(e,i):this.getOrthographicVisibleHeight(e),c=Bt.degToRad(e.getEffectiveFOV()*.5),h=Math.max(l/(2*Math.tan(c)),Br.MIN_CAMERA_DISTANCE);a.near=e.near,a.far=e.far,a.zoom=1,this.setOrthographicVisibleHeight(l,a),a.up.copy(r);const d=this.engine.octreeBox?.getBoundingBox?.(),u=d?d.max.distanceTo(d.min)*.8:h,p=Math.max(u,Br.MIN_CAMERA_DISTANCE);a.position.copy(i).add(o.clone().multiplyScalar(p)),a.quaternion.copy(n),this.engine.camera=a,this.applySwitchedCamera(a,i)}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 P(t.x,t.y,t.z).normalize(),r=new P(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 P().subVectors(l.max,l.min);i=Math.max(c.x,c.y,c.z)*1.2}else i=50}const a=r.clone().add(n.clone().negate().multiplyScalar(i)),o=this.engine.camera;o&&(o.position.copy(a),o.lookAt(r),this.engine.controls?.target&&this.engine.controls.target.copy(r),this.engine.controls?.update&&this.engine.controls.update(),o.updateMatrix(),o.updateMatrixWorld(!0))}}class YF{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,r=globalThis.screen.width,a=globalThis.screen.height,o=r<=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 Jb="181",KF=0,FS=1,$F=2,NS=1,US=2,la=3,mo=0,es=1,ca=2,ha=0,xh=1,zS=2,HS=3,GS=4,ZF=5,Rl=100,JF=101,eN=102,tN=103,iN=104,nN=200,sN=201,rN=202,aN=203,ey=204,ty=205,oN=206,lN=207,cN=208,hN=209,dN=210,uN=211,pN=212,fN=213,mN=214,iy=0,ny=1,sy=2,_h=3,ry=4,ay=5,oy=6,ly=7,VS=0,gN=1,vN=2,go=0,AN=1,bN=2,yN=3,xN=4,_N=5,wN=6,EN=7,WS=300,wh=301,Eh=302,cy=303,hy=304,Pg=306,dy=1e3,da=1001,uy=1002,gs=1003,MN=1004,Dg=1005,Ls=1006,py=1007,Bl=1008,ua=1009,QS=1010,jS=1011,zu=1012,fy=1013,Ll=1014,pa=1015,Mh=1016,my=1017,gy=1018,Hu=1020,XS=35902,qS=35899,YS=1021,KS=1022,nr=1023,Gu=1026,Vu=1027,$S=1028,vy=1029,Ay=1030,by=1031,yy=1033,Rg=33776,Bg=33777,Lg=33778,kg=33779,xy=35840,_y=35841,wy=35842,Ey=35843,My=36196,Sy=37492,Cy=37496,Ty=37808,Iy=37809,Py=37810,Dy=37811,Ry=37812,By=37813,Ly=37814,ky=37815,Oy=37816,Fy=37817,Ny=37818,Uy=37819,zy=37820,Hy=37821,Gy=36492,Vy=36494,Wy=36495,Qy=36283,jy=36284,Xy=36285,qy=36286,SN=3200,CN=3201,TN=0,IN=1,vo="",vs="srgb",Sh="srgb-linear",Og="linear",ni="srgb",Ch=7680,ZS=519,PN=512,DN=513,RN=514,JS=515,BN=516,LN=517,kN=518,ON=519,eC=35044,tC="300 es",Lr=2e3,Fg=2001;function iC(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}function Ng(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function FN(){const s=Ng("canvas");return s.style.display="block",s}const nC={};function sC(...s){const e="THREE."+s.shift();console.log(e,...s)}function Mt(...s){const e="THREE."+s.shift();console.warn(e,...s)}function Ni(...s){const e="THREE."+s.shift();console.error(e,...s)}function Wu(...s){const e=s.join(" ");e in nC||(nC[e]=!0,Mt(...s))}function NN(s,e,t){return new Promise(function(i,n){function r(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:n();break;case s.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}class Th{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 r=n.indexOf(t);r!==-1&&n.splice(r,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 r=0,a=n.length;r<a;r++)n[r].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"],Yy=Math.PI/180,Ky=180/Math.PI;function Qu(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Sn[s&255]+Sn[s>>8&255]+Sn[s>>16&255]+Sn[s>>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 Gt(s,e,t){return Math.max(e,Math.min(t,s))}function UN(s,e){return(s%e+e)%e}function $y(s,e,t){return(1-t)*s+t*e}function ju(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function ts(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}class si{constructor(e=0,t=0){si.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=Gt(this.x,e.x,t.x),this.y=Gt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Gt(this.x,e,t),this.y=Gt(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Gt(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(Gt(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),r=this.x-e.x,a=this.y-e.y;return this.x=r*i-a*n+e.x,this.y=r*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 Xu{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,r,a,o){let l=i[n+0],c=i[n+1],h=i[n+2],d=i[n+3],u=r[a+0],p=r[a+1],m=r[a+2],v=r[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]=u,e[t+1]=p,e[t+2]=m,e[t+3]=v;return}if(d!==v||l!==u||c!==p||h!==m){let g=l*u+c*p+h*m+d*v;g<0&&(u=-u,p=-p,m=-m,v=-v,g=-g);let f=1-o;if(g<.9995){const A=Math.acos(g),b=Math.sin(A);f=Math.sin(f*A)/b,o=Math.sin(o*A)/b,l=l*f+u*o,c=c*f+p*o,h=h*f+m*o,d=d*f+v*o}else{l=l*f+u*o,c=c*f+p*o,h=h*f+m*o,d=d*f+v*o;const A=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=A,c*=A,h*=A,d*=A}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,n,r,a){const o=i[n],l=i[n+1],c=i[n+2],h=i[n+3],d=r[a],u=r[a+1],p=r[a+2],m=r[a+3];return e[t]=o*m+h*d+l*p-c*u,e[t+1]=l*m+h*u+c*d-o*p,e[t+2]=c*m+h*p+o*u-l*d,e[t+3]=h*m-o*d-l*u-c*p,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,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),h=o(n/2),d=o(r/2),u=l(i/2),p=l(n/2),m=l(r/2);switch(a){case"XYZ":this._x=u*h*d+c*p*m,this._y=c*p*d-u*h*m,this._z=c*h*m+u*p*d,this._w=c*h*d-u*p*m;break;case"YXZ":this._x=u*h*d+c*p*m,this._y=c*p*d-u*h*m,this._z=c*h*m-u*p*d,this._w=c*h*d+u*p*m;break;case"ZXY":this._x=u*h*d-c*p*m,this._y=c*p*d+u*h*m,this._z=c*h*m+u*p*d,this._w=c*h*d-u*p*m;break;case"ZYX":this._x=u*h*d-c*p*m,this._y=c*p*d+u*h*m,this._z=c*h*m-u*p*d,this._w=c*h*d+u*p*m;break;case"YZX":this._x=u*h*d+c*p*m,this._y=c*p*d+u*h*m,this._z=c*h*m-u*p*d,this._w=c*h*d-u*p*m;break;case"XZY":this._x=u*h*d-c*p*m,this._y=c*p*d-u*h*m,this._z=c*h*m+u*p*d,this._w=c*h*d+u*p*m;break;default:Mt("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],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],d=t[10],u=i+o+d;if(u>0){const p=.5/Math.sqrt(u+1);this._w=.25/p,this._x=(h-l)*p,this._y=(r-c)*p,this._z=(a-n)*p}else if(i>o&&i>d){const p=2*Math.sqrt(1+i-o-d);this._w=(h-l)/p,this._x=.25*p,this._y=(n+a)/p,this._z=(r+c)/p}else if(o>d){const p=2*Math.sqrt(1+o-i-d);this._w=(r-c)/p,this._x=(n+a)/p,this._y=.25*p,this._z=(l+h)/p}else{const p=2*Math.sqrt(1+d-i-o);this._w=(a-n)/p,this._x=(r+c)/p,this._y=(l+h)/p,this._z=.25*p}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(Gt(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,r=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-r*l,this._y=n*h+a*l+r*o-i*c,this._z=r*h+a*c+i*l-n*o,this._w=a*h-i*o-n*l-r*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,r=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,n=-n,r=-r,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+r*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+r*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),r=Math.sqrt(i);return this.set(n*Math.sin(e),n*Math.cos(e),r*Math.sin(t),r*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 Ne{constructor(e=0,t=0,i=0){Ne.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(rC.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(rC.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*n,this.y=r[1]*t+r[4]*i+r[7]*n,this.z=r[2]*t+r[5]*i+r[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,r=e.elements,a=1/(r[3]*t+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*n+r[12])*a,this.y=(r[1]*t+r[5]*i+r[9]*n+r[13])*a,this.z=(r[2]*t+r[6]*i+r[10]*n+r[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,n=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*n-o*i),h=2*(o*t-r*n),d=2*(r*i-a*t);return this.x=t+l*c+a*d-o*h,this.y=i+l*h+o*c-r*d,this.z=n+l*d+r*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,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*n,this.y=r[1]*t+r[5]*i+r[9]*n,this.z=r[2]*t+r[6]*i+r[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=Gt(this.x,e.x,t.x),this.y=Gt(this.y,e.y,t.y),this.z=Gt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Gt(this.x,e,t),this.y=Gt(this.y,e,t),this.z=Gt(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Gt(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,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=n*l-r*o,this.y=r*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 Zy.copy(this).projectOnVector(e),this.sub(Zy)}reflect(e){return this.sub(Zy.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(Gt(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 Zy=new Ne,rC=new Xu;class Tt{constructor(e,t,i,n,r,a,o,l,c){Tt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,n,r,a,o,l,c)}set(e,t,i,n,r,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=n,h[2]=o,h[3]=t,h[4]=r,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,r=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],h=i[4],d=i[7],u=i[2],p=i[5],m=i[8],v=n[0],g=n[3],f=n[6],A=n[1],b=n[4],y=n[7],x=n[2],_=n[5],M=n[8];return r[0]=a*v+o*A+l*x,r[3]=a*g+o*b+l*_,r[6]=a*f+o*y+l*M,r[1]=c*v+h*A+d*x,r[4]=c*g+h*b+d*_,r[7]=c*f+h*y+d*M,r[2]=u*v+p*A+m*x,r[5]=u*g+p*b+m*_,r[8]=u*f+p*y+m*M,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],r=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*r*h+i*o*l+n*r*c-n*a*l}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=h*a-o*c,u=o*l-h*r,p=c*r-a*l,m=t*d+i*u+n*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/m;return e[0]=d*v,e[1]=(n*c-h*i)*v,e[2]=(o*i-n*a)*v,e[3]=u*v,e[4]=(h*t-n*l)*v,e[5]=(n*r-o*t)*v,e[6]=p*v,e[7]=(i*l-c*t)*v,e[8]=(a*t-i*r)*v,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,r,a,o){const l=Math.cos(r),c=Math.sin(r);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(Jy.makeScale(e,t)),this}rotate(e){return this.premultiply(Jy.makeRotation(-e)),this}translate(e,t){return this.premultiply(Jy.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 Jy=new Tt,aC=new Tt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),oC=new Tt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function zN(){const s={enabled:!0,workingColorSpace:Sh,spaces:{},convert:function(n,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===ni&&(n.r=fa(n.r),n.g=fa(n.g),n.b=fa(n.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(n.applyMatrix3(this.spaces[r].toXYZ),n.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ni&&(n.r=Ih(n.r),n.g=Ih(n.g),n.b=Ih(n.b))),n},workingToColorSpace:function(n,r){return this.convert(n,this.workingColorSpace,r)},colorSpaceToWorking:function(n,r){return this.convert(n,r,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===vo?Og:this.spaces[n].transfer},getToneMappingMode:function(n){return this.spaces[n].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(n,r=this.workingColorSpace){return n.fromArray(this.spaces[r].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,r,a){return n.copy(this.spaces[r].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,r){return Wu("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(n,r)},toWorkingColorSpace:function(n,r){return Wu("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(n,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return s.define({[Sh]:{primaries:e,whitePoint:i,transfer:Og,toXYZ:aC,fromXYZ:oC,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:vs},outputColorSpaceConfig:{drawingBufferColorSpace:vs}},[vs]:{primaries:e,whitePoint:i,transfer:ni,toXYZ:aC,fromXYZ:oC,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:vs}}}),s}const jt=zN();function fa(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Ih(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let Ph;class HN{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{Ph===void 0&&(Ph=Ng("canvas")),Ph.width=e.width,Ph.height=e.height;const n=Ph.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),i=Ph}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=Ng("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),r=n.data;for(let a=0;a<r.length;a++)r[a]=fa(r[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(fa(t[i]/255)*255):t[i]=fa(t[i]);return{data:t,width:e.width,height:e.height}}else return Mt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let GN=0;class ex{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:GN++}),this.uuid=Qu(),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 r;if(Array.isArray(n)){r=[];for(let a=0,o=n.length;a<o;a++)n[a].isDataTexture?r.push(tx(n[a].image)):r.push(tx(n[a]))}else r=tx(n);i.url=r}return t||(e.images[this.uuid]=i),i}}function tx(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?HN.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(Mt("Texture: Unable to serialize Texture."),{})}let VN=0;const ix=new Ne;class Nn extends Th{constructor(e=Nn.DEFAULT_IMAGE,t=Nn.DEFAULT_MAPPING,i=da,n=da,r=Ls,a=Bl,o=nr,l=ua,c=Nn.DEFAULT_ANISOTROPY,h=vo){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:VN++}),this.uuid=Qu(),this.name="",this.source=new ex(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new si(0,0),this.repeat=new si(1,1),this.center=new si(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Tt,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(ix).x}get height(){return this.source.getSize(ix).y}get depth(){return this.source.getSize(ix).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){Mt(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){Mt(`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!==WS)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case dy:e.x=e.x-Math.floor(e.x);break;case da:e.x=e.x<0?0:1;break;case uy: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 dy:e.y=e.y-Math.floor(e.y);break;case da:e.y=e.y<0?0:1;break;case uy: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++}}Nn.DEFAULT_IMAGE=null,Nn.DEFAULT_MAPPING=WS,Nn.DEFAULT_ANISOTROPY=1;class Ui{constructor(e=0,t=0,i=0,n=1){Ui.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,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*n+a[12]*r,this.y=a[1]*t+a[5]*i+a[9]*n+a[13]*r,this.z=a[2]*t+a[6]*i+a[10]*n+a[14]*r,this.w=a[3]*t+a[7]*i+a[11]*n+a[15]*r,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,r;const a=e.elements,o=a[0],l=a[4],c=a[8],h=a[1],d=a[5],u=a[9],p=a[2],m=a[6],v=a[10];if(Math.abs(l-h)<.01&&Math.abs(c-p)<.01&&Math.abs(u-m)<.01){if(Math.abs(l+h)<.1&&Math.abs(c+p)<.1&&Math.abs(u+m)<.1&&Math.abs(o+d+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const f=(o+1)/2,A=(d+1)/2,b=(v+1)/2,y=(l+h)/4,x=(c+p)/4,_=(u+m)/4;return f>A&&f>b?f<.01?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(f),n=y/i,r=x/i):A>b?A<.01?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(A),i=y/n,r=_/n):b<.01?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(b),i=x/r,n=_/r),this.set(i,n,r,t),this}let g=Math.sqrt((m-u)*(m-u)+(c-p)*(c-p)+(h-l)*(h-l));return Math.abs(g)<.001&&(g=1),this.x=(m-u)/g,this.y=(c-p)/g,this.z=(h-l)/g,this.w=Math.acos((o+d+v-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=Gt(this.x,e.x,t.x),this.y=Gt(this.y,e.y,t.y),this.z=Gt(this.z,e.z,t.z),this.w=Gt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Gt(this.x,e,t),this.y=Gt(this.y,e,t),this.z=Gt(this.z,e,t),this.w=Gt(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Gt(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 WN extends Th{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ls,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 Ui(0,0,e,t),this.scissorTest=!1,this.viewport=new Ui(0,0,e,t);const n={width:e,height:t,depth:i.depth},r=new Nn(n);this.textures=[];const a=i.count;for(let o=0;o<a;o++)this.textures[o]=r.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:Ls,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,r=this.textures.length;n<r;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 ex(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 kl extends WN{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class lC extends Nn{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=gs,this.minFilter=gs,this.wrapR=da,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class QN extends Nn{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=gs,this.minFilter=gs,this.wrapR=da,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class qu{constructor(e=new Ne(1/0,1/0,1/0),t=new Ne(-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(sr.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(sr.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=sr.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 r=i.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,sr):sr.fromBufferAttribute(r,a),sr.applyMatrix4(e.matrixWorld),this.expandByPoint(sr);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Ug.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Ug.copy(i.boundingBox)),Ug.applyMatrix4(e.matrixWorld),this.union(Ug)}const n=e.children;for(let r=0,a=n.length;r<a;r++)this.expandByObject(n[r],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,sr),sr.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(Yu),zg.subVectors(this.max,Yu),Dh.subVectors(e.a,Yu),Rh.subVectors(e.b,Yu),Bh.subVectors(e.c,Yu),Ao.subVectors(Rh,Dh),bo.subVectors(Bh,Rh),Ol.subVectors(Dh,Bh);let t=[0,-Ao.z,Ao.y,0,-bo.z,bo.y,0,-Ol.z,Ol.y,Ao.z,0,-Ao.x,bo.z,0,-bo.x,Ol.z,0,-Ol.x,-Ao.y,Ao.x,0,-bo.y,bo.x,0,-Ol.y,Ol.x,0];return!nx(t,Dh,Rh,Bh,zg)||(t=[1,0,0,0,1,0,0,0,1],!nx(t,Dh,Rh,Bh,zg))?!1:(Hg.crossVectors(Ao,bo),t=[Hg.x,Hg.y,Hg.z],nx(t,Dh,Rh,Bh,zg))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,sr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(sr).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:(ma[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ma[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ma[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ma[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ma[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ma[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ma[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ma[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ma),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 ma=[new Ne,new Ne,new Ne,new Ne,new Ne,new Ne,new Ne,new Ne],sr=new Ne,Ug=new qu,Dh=new Ne,Rh=new Ne,Bh=new Ne,Ao=new Ne,bo=new Ne,Ol=new Ne,Yu=new Ne,zg=new Ne,Hg=new Ne,Fl=new Ne;function nx(s,e,t,i,n){for(let r=0,a=s.length-3;r<=a;r+=3){Fl.fromArray(s,r);const o=n.x*Math.abs(Fl.x)+n.y*Math.abs(Fl.y)+n.z*Math.abs(Fl.z),l=e.dot(Fl),c=t.dot(Fl),h=i.dot(Fl);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const jN=new qu,Ku=new Ne,sx=new Ne;class rx{constructor(e=new Ne,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):jN.setFromPoints(e).getCenter(i);let n=0;for(let r=0,a=e.length;r<a;r++)n=Math.max(n,i.distanceToSquared(e[r]));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;Ku.subVectors(e,this.center);const t=Ku.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),n=(i-this.radius)*.5;this.center.addScaledVector(Ku,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):(sx.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ku.copy(e.center).add(sx)),this.expandByPoint(Ku.copy(e.center).sub(sx))),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 ga=new Ne,ax=new Ne,Gg=new Ne,yo=new Ne,ox=new Ne,Vg=new Ne,lx=new Ne;class XN{constructor(e=new Ne,t=new Ne(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,ga)),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=ga.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ga.copy(this.origin).addScaledVector(this.direction,t),ga.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){ax.copy(e).add(t).multiplyScalar(.5),Gg.copy(t).sub(e).normalize(),yo.copy(this.origin).sub(ax);const r=e.distanceTo(t)*.5,a=-this.direction.dot(Gg),o=yo.dot(this.direction),l=-yo.dot(Gg),c=yo.lengthSq(),h=Math.abs(1-a*a);let d,u,p,m;if(h>0)if(d=a*l-o,u=a*o-l,m=r*h,d>=0)if(u>=-m)if(u<=m){const v=1/h;d*=v,u*=v,p=d*(d+a*u+2*o)+u*(a*d+u+2*l)+c}else u=r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*l)+c;else u=-r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*l)+c;else u<=-m?(d=Math.max(0,-(-a*r+o)),u=d>0?-r:Math.min(Math.max(-r,-l),r),p=-d*d+u*(u+2*l)+c):u<=m?(d=0,u=Math.min(Math.max(-r,-l),r),p=u*(u+2*l)+c):(d=Math.max(0,-(a*r+o)),u=d>0?r:Math.min(Math.max(-r,-l),r),p=-d*d+u*(u+2*l)+c);else u=a>0?-r:r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),n&&n.copy(ax).addScaledVector(Gg,u),p}intersectSphere(e,t){ga.subVectors(e.center,this.origin);const i=ga.dot(this.direction),n=ga.dot(ga)-i*i,r=e.radius*e.radius;if(n>r)return null;const a=Math.sqrt(r-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,r,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return c>=0?(i=(e.min.x-u.x)*c,n=(e.max.x-u.x)*c):(i=(e.max.x-u.x)*c,n=(e.min.x-u.x)*c),h>=0?(r=(e.min.y-u.y)*h,a=(e.max.y-u.y)*h):(r=(e.max.y-u.y)*h,a=(e.min.y-u.y)*h),i>a||r>n||((r>i||isNaN(i))&&(i=r),(a<n||isNaN(n))&&(n=a),d>=0?(o=(e.min.z-u.z)*d,l=(e.max.z-u.z)*d):(o=(e.max.z-u.z)*d,l=(e.min.z-u.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,ga)!==null}intersectTriangle(e,t,i,n,r){ox.subVectors(t,e),Vg.subVectors(i,e),lx.crossVectors(ox,Vg);let a=this.direction.dot(lx),o;if(a>0){if(n)return null;o=1}else if(a<0)o=-1,a=-a;else return null;yo.subVectors(this.origin,e);const l=o*this.direction.dot(Vg.crossVectors(yo,Vg));if(l<0)return null;const c=o*this.direction.dot(ox.cross(yo));if(c<0||l+c>a)return null;const h=-o*yo.dot(lx);return h<0?null:this.at(h/a,r)}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 tn{constructor(e,t,i,n,r,a,o,l,c,h,d,u,p,m,v,g){tn.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,r,a,o,l,c,h,d,u,p,m,v,g)}set(e,t,i,n,r,a,o,l,c,h,d,u,p,m,v,g){const f=this.elements;return f[0]=e,f[4]=t,f[8]=i,f[12]=n,f[1]=r,f[5]=a,f[9]=o,f[13]=l,f[2]=c,f[6]=h,f[10]=d,f[14]=u,f[3]=p,f[7]=m,f[11]=v,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 tn().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/Lh.setFromMatrixColumn(e,0).length(),r=1/Lh.setFromMatrixColumn(e,1).length(),a=1/Lh.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]*r,t[5]=i[5]*r,t[6]=i[6]*r,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,r=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(n),c=Math.sin(n),h=Math.cos(r),d=Math.sin(r);if(e.order==="XYZ"){const u=a*h,p=a*d,m=o*h,v=o*d;t[0]=l*h,t[4]=-l*d,t[8]=c,t[1]=p+m*c,t[5]=u-v*c,t[9]=-o*l,t[2]=v-u*c,t[6]=m+p*c,t[10]=a*l}else if(e.order==="YXZ"){const u=l*h,p=l*d,m=c*h,v=c*d;t[0]=u+v*o,t[4]=m*o-p,t[8]=a*c,t[1]=a*d,t[5]=a*h,t[9]=-o,t[2]=p*o-m,t[6]=v+u*o,t[10]=a*l}else if(e.order==="ZXY"){const u=l*h,p=l*d,m=c*h,v=c*d;t[0]=u-v*o,t[4]=-a*d,t[8]=m+p*o,t[1]=p+m*o,t[5]=a*h,t[9]=v-u*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const u=a*h,p=a*d,m=o*h,v=o*d;t[0]=l*h,t[4]=m*c-p,t[8]=u*c+v,t[1]=l*d,t[5]=v*c+u,t[9]=p*c-m,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const u=a*l,p=a*c,m=o*l,v=o*c;t[0]=l*h,t[4]=v-u*d,t[8]=m*d+p,t[1]=d,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=p*d+m,t[10]=u-v*d}else if(e.order==="XZY"){const u=a*l,p=a*c,m=o*l,v=o*c;t[0]=l*h,t[4]=-d,t[8]=c*h,t[1]=u*d+v,t[5]=a*h,t[9]=p*d-m,t[2]=m*d-p,t[6]=o*h,t[10]=v*d+u}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(qN,e,YN)}lookAt(e,t,i){const n=this.elements;return As.subVectors(e,t),As.lengthSq()===0&&(As.z=1),As.normalize(),xo.crossVectors(i,As),xo.lengthSq()===0&&(Math.abs(i.z)===1?As.x+=1e-4:As.z+=1e-4,As.normalize(),xo.crossVectors(i,As)),xo.normalize(),Wg.crossVectors(As,xo),n[0]=xo.x,n[4]=Wg.x,n[8]=As.x,n[1]=xo.y,n[5]=Wg.y,n[9]=As.y,n[2]=xo.z,n[6]=Wg.z,n[10]=As.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,r=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],h=i[1],d=i[5],u=i[9],p=i[13],m=i[2],v=i[6],g=i[10],f=i[14],A=i[3],b=i[7],y=i[11],x=i[15],_=n[0],M=n[4],E=n[8],w=n[12],T=n[1],R=n[5],D=n[9],L=n[13],I=n[2],O=n[6],N=n[10],G=n[14],V=n[3],H=n[7],J=n[11],W=n[15];return r[0]=a*_+o*T+l*I+c*V,r[4]=a*M+o*R+l*O+c*H,r[8]=a*E+o*D+l*N+c*J,r[12]=a*w+o*L+l*G+c*W,r[1]=h*_+d*T+u*I+p*V,r[5]=h*M+d*R+u*O+p*H,r[9]=h*E+d*D+u*N+p*J,r[13]=h*w+d*L+u*G+p*W,r[2]=m*_+v*T+g*I+f*V,r[6]=m*M+v*R+g*O+f*H,r[10]=m*E+v*D+g*N+f*J,r[14]=m*w+v*L+g*G+f*W,r[3]=A*_+b*T+y*I+x*V,r[7]=A*M+b*R+y*O+x*H,r[11]=A*E+b*D+y*N+x*J,r[15]=A*w+b*L+y*G+x*W,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],r=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],d=e[6],u=e[10],p=e[14],m=e[3],v=e[7],g=e[11],f=e[15];return m*(+r*l*d-n*c*d-r*o*u+i*c*u+n*o*p-i*l*p)+v*(+t*l*p-t*c*u+r*a*u-n*a*p+n*c*h-r*l*h)+g*(+t*c*d-t*o*p-r*a*d+i*a*p+r*o*h-i*c*h)+f*(-n*o*h-t*l*d+t*o*u+n*a*d-i*a*u+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],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=e[9],u=e[10],p=e[11],m=e[12],v=e[13],g=e[14],f=e[15],A=d*g*c-v*u*c+v*l*p-o*g*p-d*l*f+o*u*f,b=m*u*c-h*g*c-m*l*p+a*g*p+h*l*f-a*u*f,y=h*v*c-m*d*c+m*o*p-a*v*p-h*o*f+a*d*f,x=m*d*l-h*v*l-m*o*u+a*v*u+h*o*g-a*d*g,_=t*A+i*b+n*y+r*x;if(_===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const M=1/_;return e[0]=A*M,e[1]=(v*u*r-d*g*r-v*n*p+i*g*p+d*n*f-i*u*f)*M,e[2]=(o*g*r-v*l*r+v*n*c-i*g*c-o*n*f+i*l*f)*M,e[3]=(d*l*r-o*u*r-d*n*c+i*u*c+o*n*p-i*l*p)*M,e[4]=b*M,e[5]=(h*g*r-m*u*r+m*n*p-t*g*p-h*n*f+t*u*f)*M,e[6]=(m*l*r-a*g*r-m*n*c+t*g*c+a*n*f-t*l*f)*M,e[7]=(a*u*r-h*l*r+h*n*c-t*u*c-a*n*p+t*l*p)*M,e[8]=y*M,e[9]=(m*d*r-h*v*r-m*i*p+t*v*p+h*i*f-t*d*f)*M,e[10]=(a*v*r-m*o*r+m*i*c-t*v*c-a*i*f+t*o*f)*M,e[11]=(h*o*r-a*d*r-h*i*c+t*d*c+a*i*p-t*o*p)*M,e[12]=x*M,e[13]=(h*v*n-m*d*n+m*i*u-t*v*u-h*i*g+t*d*g)*M,e[14]=(m*o*n-a*v*n-m*i*l+t*v*l+a*i*g-t*o*g)*M,e[15]=(a*d*n-h*o*n+h*i*l-t*d*l-a*i*u+t*o*u)*M,this}scale(e){const t=this.elements,i=e.x,n=e.y,r=e.z;return t[0]*=i,t[4]*=n,t[8]*=r,t[1]*=i,t[5]*=n,t[9]*=r,t[2]*=i,t[6]*=n,t[10]*=r,t[3]*=i,t[7]*=n,t[11]*=r,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),r=1-i,a=e.x,o=e.y,l=e.z,c=r*a,h=r*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,r*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,r,a){return this.set(1,i,r,0,e,1,a,0,t,n,1,0,0,0,0,1),this}compose(e,t,i){const n=this.elements,r=t._x,a=t._y,o=t._z,l=t._w,c=r+r,h=a+a,d=o+o,u=r*c,p=r*h,m=r*d,v=a*h,g=a*d,f=o*d,A=l*c,b=l*h,y=l*d,x=i.x,_=i.y,M=i.z;return n[0]=(1-(v+f))*x,n[1]=(p+y)*x,n[2]=(m-b)*x,n[3]=0,n[4]=(p-y)*_,n[5]=(1-(u+f))*_,n[6]=(g+A)*_,n[7]=0,n[8]=(m+b)*M,n[9]=(g-A)*M,n[10]=(1-(u+v))*M,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 r=Lh.set(n[0],n[1],n[2]).length();const a=Lh.set(n[4],n[5],n[6]).length(),o=Lh.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),e.x=n[12],e.y=n[13],e.z=n[14],rr.copy(this);const l=1/r,c=1/a,h=1/o;return rr.elements[0]*=l,rr.elements[1]*=l,rr.elements[2]*=l,rr.elements[4]*=c,rr.elements[5]*=c,rr.elements[6]*=c,rr.elements[8]*=h,rr.elements[9]*=h,rr.elements[10]*=h,t.setFromRotationMatrix(rr),i.x=r,i.y=a,i.z=o,this}makePerspective(e,t,i,n,r,a,o=Lr,l=!1){const c=this.elements,h=2*r/(t-e),d=2*r/(i-n),u=(t+e)/(t-e),p=(i+n)/(i-n);let m,v;if(l)m=r/(a-r),v=a*r/(a-r);else if(o===Lr)m=-(a+r)/(a-r),v=-2*a*r/(a-r);else if(o===Fg)m=-a/(a-r),v=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=d,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=v,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,n,r,a,o=Lr,l=!1){const c=this.elements,h=2/(t-e),d=2/(i-n),u=-(t+e)/(t-e),p=-(i+n)/(i-n);let m,v;if(l)m=1/(a-r),v=a/(a-r);else if(o===Lr)m=-2/(a-r),v=-(a+r)/(a-r);else if(o===Fg)m=-1/(a-r),v=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=u,c[1]=0,c[5]=d,c[9]=0,c[13]=p,c[2]=0,c[6]=0,c[10]=m,c[14]=v,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 Lh=new Ne,rr=new tn,qN=new Ne(0,0,0),YN=new Ne(1,1,1),xo=new Ne,Wg=new Ne,As=new Ne,cC=new tn,hC=new Xu;class Nl{constructor(e=0,t=0,i=0,n=Nl.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,r=n[0],a=n[4],o=n[8],l=n[1],c=n[5],h=n[9],d=n[2],u=n[6],p=n[10];switch(t){case"XYZ":this._y=Math.asin(Gt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Gt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(Gt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-Gt(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,p),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Gt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Gt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,p),this._y=0);break;default:Mt("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return cC.makeRotationFromQuaternion(e),this.setFromRotationMatrix(cC,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return hC.setFromEuler(this),this.setFromQuaternion(hC,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}}Nl.DEFAULT_ORDER="XYZ";class dC{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 KN=0;const uC=new Ne,kh=new Xu,va=new tn,Qg=new Ne,$u=new Ne,$N=new Ne,ZN=new Xu,pC=new Ne(1,0,0),fC=new Ne(0,1,0),mC=new Ne(0,0,1),gC={type:"added"},JN={type:"removed"},Oh={type:"childadded",child:null},cx={type:"childremoved",child:null};class ks extends Th{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:KN++}),this.uuid=Qu(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ks.DEFAULT_UP.clone();const e=new Ne,t=new Nl,i=new Xu,n=new Ne(1,1,1);function r(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(r),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 tn},normalMatrix:{value:new Tt}}),this.matrix=new tn,this.matrixWorld=new tn,this.matrixAutoUpdate=ks.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ks.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new dC,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 kh.setFromAxisAngle(e,t),this.quaternion.multiply(kh),this}rotateOnWorldAxis(e,t){return kh.setFromAxisAngle(e,t),this.quaternion.premultiply(kh),this}rotateX(e){return this.rotateOnAxis(pC,e)}rotateY(e){return this.rotateOnAxis(fC,e)}rotateZ(e){return this.rotateOnAxis(mC,e)}translateOnAxis(e,t){return uC.copy(e).applyQuaternion(this.quaternion),this.position.add(uC.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(pC,e)}translateY(e){return this.translateOnAxis(fC,e)}translateZ(e){return this.translateOnAxis(mC,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(va.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Qg.copy(e):Qg.set(e,t,i);const n=this.parent;this.updateWorldMatrix(!0,!1),$u.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?va.lookAt($u,Qg,this.up):va.lookAt(Qg,$u,this.up),this.quaternion.setFromRotationMatrix(va),n&&(va.extractRotation(n.matrixWorld),kh.setFromRotationMatrix(va),this.quaternion.premultiply(kh.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Ni("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(gC),Oh.child=e,this.dispatchEvent(Oh),Oh.child=null):Ni("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(JN),cx.child=e,this.dispatchEvent(cx),cx.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),va.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),va.multiply(e.parent.matrixWorld)),e.applyMatrix4(va),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(gC),Oh.child=e,this.dispatchEvent(Oh),Oh.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 r=this.children[i].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const n=this.children;for(let r=0,a=n.length;r<a;r++)n[r].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($u,e,$N),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose($u,ZN,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 r=0,a=n.length;r<a;r++)n[r].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 r(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=r(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];r(e.shapes,d)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(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(r(e.materials,this.material[l]));n.material=o}else n.material=r(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(r(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),u=a(e.skeletons),p=a(e.animations),m=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),u.length>0&&(i.skeletons=u),p.length>0&&(i.animations=p),m.length>0&&(i.nodes=m)}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}}ks.DEFAULT_UP=new Ne(0,1,0),ks.DEFAULT_MATRIX_AUTO_UPDATE=!0,ks.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const ar=new Ne,Aa=new Ne,hx=new Ne,ba=new Ne,Fh=new Ne,Nh=new Ne,vC=new Ne,dx=new Ne,ux=new Ne,px=new Ne,fx=new Ui,mx=new Ui,gx=new Ui;class or{constructor(e=new Ne,t=new Ne,i=new Ne){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,n){n.subVectors(i,t),ar.subVectors(e,t),n.cross(ar);const r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(e,t,i,n,r){ar.subVectors(n,t),Aa.subVectors(i,t),hx.subVectors(e,t);const a=ar.dot(ar),o=ar.dot(Aa),l=ar.dot(hx),c=Aa.dot(Aa),h=Aa.dot(hx),d=a*c-o*o;if(d===0)return r.set(0,0,0),null;const u=1/d,p=(c*l-o*h)*u,m=(a*h-o*l)*u;return r.set(1-p-m,m,p)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,ba)===null?!1:ba.x>=0&&ba.y>=0&&ba.x+ba.y<=1}static getInterpolation(e,t,i,n,r,a,o,l){return this.getBarycoord(e,t,i,n,ba)===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(r,ba.x),l.addScaledVector(a,ba.y),l.addScaledVector(o,ba.z),l)}static getInterpolatedAttribute(e,t,i,n,r,a){return fx.setScalar(0),mx.setScalar(0),gx.setScalar(0),fx.fromBufferAttribute(e,t),mx.fromBufferAttribute(e,i),gx.fromBufferAttribute(e,n),a.setScalar(0),a.addScaledVector(fx,r.x),a.addScaledVector(mx,r.y),a.addScaledVector(gx,r.z),a}static isFrontFacing(e,t,i,n){return ar.subVectors(i,t),Aa.subVectors(e,t),ar.cross(Aa).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 ar.subVectors(this.c,this.b),Aa.subVectors(this.a,this.b),ar.cross(Aa).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return or.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return or.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,n,r){return or.getInterpolation(e,this.a,this.b,this.c,t,i,n,r)}containsPoint(e){return or.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return or.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,n=this.b,r=this.c;let a,o;Fh.subVectors(n,i),Nh.subVectors(r,i),dx.subVectors(e,i);const l=Fh.dot(dx),c=Nh.dot(dx);if(l<=0&&c<=0)return t.copy(i);ux.subVectors(e,n);const h=Fh.dot(ux),d=Nh.dot(ux);if(h>=0&&d<=h)return t.copy(n);const u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(i).addScaledVector(Fh,a);px.subVectors(e,r);const p=Fh.dot(px),m=Nh.dot(px);if(m>=0&&p<=m)return t.copy(r);const v=p*c-l*m;if(v<=0&&c>=0&&m<=0)return o=c/(c-m),t.copy(i).addScaledVector(Nh,o);const g=h*m-p*d;if(g<=0&&d-h>=0&&p-m>=0)return vC.subVectors(r,n),o=(d-h)/(d-h+(p-m)),t.copy(n).addScaledVector(vC,o);const f=1/(g+v+u);return a=v*f,o=u*f,t.copy(i).addScaledVector(Fh,a).addScaledVector(Nh,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const AC={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},_o={h:0,s:0,l:0},jg={h:0,s:0,l:0};function vx(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class ri{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=vs){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,jt.colorSpaceToWorking(this,t),this}setRGB(e,t,i,n=jt.workingColorSpace){return this.r=e,this.g=t,this.b=i,jt.colorSpaceToWorking(this,n),this}setHSL(e,t,i,n=jt.workingColorSpace){if(e=UN(e,1),t=Gt(t,0,1),i=Gt(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,a=2*i-r;this.r=vx(a,r,e+1/3),this.g=vx(a,r,e),this.b=vx(a,r,e-1/3)}return jt.colorSpaceToWorking(this,n),this}setStyle(e,t=vs){function i(r){r!==void 0&&parseFloat(r)<1&&Mt("Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=n[1],o=n[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Mt("Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=n[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Mt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=vs){const i=AC[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Mt("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=fa(e.r),this.g=fa(e.g),this.b=fa(e.b),this}copyLinearToSRGB(e){return this.r=Ih(e.r),this.g=Ih(e.g),this.b=Ih(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=vs){return jt.workingToColorSpace(Cn.copy(this),e),Math.round(Gt(Cn.r*255,0,255))*65536+Math.round(Gt(Cn.g*255,0,255))*256+Math.round(Gt(Cn.b*255,0,255))}getHexString(e=vs){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=jt.workingColorSpace){jt.workingToColorSpace(Cn.copy(this),t);const i=Cn.r,n=Cn.g,r=Cn.b,a=Math.max(i,n,r),o=Math.min(i,n,r);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-r)/d+(n<r?6:0);break;case n:l=(r-i)/d+2;break;case r:l=(i-n)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=jt.workingColorSpace){return jt.workingToColorSpace(Cn.copy(this),t),e.r=Cn.r,e.g=Cn.g,e.b=Cn.b,e}getStyle(e=vs){jt.workingToColorSpace(Cn.copy(this),e);const t=Cn.r,i=Cn.g,n=Cn.b;return e!==vs?`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(_o),this.setHSL(_o.h+e,_o.s+t,_o.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(_o),e.getHSL(jg);const i=$y(_o.h,jg.h,t),n=$y(_o.s,jg.s,t),r=$y(_o.l,jg.l,t);return this.setHSL(i,n,r),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,r=e.elements;return this.r=r[0]*t+r[3]*i+r[6]*n,this.g=r[1]*t+r[4]*i+r[7]*n,this.b=r[2]*t+r[5]*i+r[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 Cn=new ri;ri.NAMES=AC;let eU=0;class Xg extends Th{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:eU++}),this.uuid=Qu(),this.name="",this.type="Material",this.blending=xh,this.side=mo,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ey,this.blendDst=ty,this.blendEquation=Rl,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ri(0,0,0),this.blendAlpha=0,this.depthFunc=_h,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ZS,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ch,this.stencilZFail=Ch,this.stencilZPass=Ch,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){Mt(`Material: parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){Mt(`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!==xh&&(i.blending=this.blending),this.side!==mo&&(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!==ey&&(i.blendSrc=this.blendSrc),this.blendDst!==ty&&(i.blendDst=this.blendDst),this.blendEquation!==Rl&&(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!==_h&&(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!==ZS&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ch&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Ch&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Ch&&(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(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=n(e.textures),a=n(e.images);r.length>0&&(i.textures=r),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 r=0;r!==n;++r)i[r]=t[r].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 bC extends Xg{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ri(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 Nl,this.combine=VS,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 Vi=new Ne,qg=new si;let tU=0;class kr{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:tU++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=eC,this.updateRanges=[],this.gpuType=pa,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,r=this.itemSize;n<r;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++)qg.fromBufferAttribute(this,t),qg.applyMatrix3(e),this.setXY(t,qg.x,qg.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Vi.fromBufferAttribute(this,t),Vi.applyMatrix3(e),this.setXYZ(t,Vi.x,Vi.y,Vi.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Vi.fromBufferAttribute(this,t),Vi.applyMatrix4(e),this.setXYZ(t,Vi.x,Vi.y,Vi.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Vi.fromBufferAttribute(this,t),Vi.applyNormalMatrix(e),this.setXYZ(t,Vi.x,Vi.y,Vi.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Vi.fromBufferAttribute(this,t),Vi.transformDirection(e),this.setXYZ(t,Vi.x,Vi.y,Vi.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=ju(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=ts(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=ju(t,this.array)),t}setX(e,t){return this.normalized&&(t=ts(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=ju(t,this.array)),t}setY(e,t){return this.normalized&&(t=ts(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=ju(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ts(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=ju(t,this.array)),t}setW(e,t){return this.normalized&&(t=ts(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=ts(t,this.array),i=ts(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=ts(t,this.array),i=ts(i,this.array),n=ts(n,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this}setXYZW(e,t,i,n,r){return e*=this.itemSize,this.normalized&&(t=ts(t,this.array),i=ts(i,this.array),n=ts(n,this.array),r=ts(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this.array[e+3]=r,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!==eC&&(e.usage=this.usage),e}}class yC extends kr{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class xC extends kr{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class Ul extends kr{constructor(e,t,i){super(new Float32Array(e),t,i)}}let iU=0;const Os=new tn,Ax=new ks,Uh=new Ne,bs=new qu,Zu=new qu,un=new Ne;class wo extends Th{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:iU++}),this.uuid=Qu(),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(iC(e)?xC:yC)(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 r=new Tt().getNormalMatrix(e);i.applyNormalMatrix(r),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 Os.makeRotationFromQuaternion(e),this.applyMatrix4(Os),this}rotateX(e){return Os.makeRotationX(e),this.applyMatrix4(Os),this}rotateY(e){return Os.makeRotationY(e),this.applyMatrix4(Os),this}rotateZ(e){return Os.makeRotationZ(e),this.applyMatrix4(Os),this}translate(e,t,i){return Os.makeTranslation(e,t,i),this.applyMatrix4(Os),this}scale(e,t,i){return Os.makeScale(e,t,i),this.applyMatrix4(Os),this}lookAt(e){return Ax.lookAt(e),Ax.updateMatrix(),this.applyMatrix4(Ax.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Uh).negate(),this.translate(Uh.x,Uh.y,Uh.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let n=0,r=e.length;n<r;n++){const a=e[n];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Ul(i,3))}else{const i=Math.min(e.length,t.count);for(let n=0;n<i;n++){const r=e[n];t.setXYZ(n,r.x,r.y,r.z||0)}e.length>t.count&&Mt("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 qu);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ni("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Ne(-1/0,-1/0,-1/0),new Ne(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,n=t.length;i<n;i++){const r=t[i];bs.setFromBufferAttribute(r),this.morphTargetsRelative?(un.addVectors(this.boundingBox.min,bs.min),this.boundingBox.expandByPoint(un),un.addVectors(this.boundingBox.max,bs.max),this.boundingBox.expandByPoint(un)):(this.boundingBox.expandByPoint(bs.min),this.boundingBox.expandByPoint(bs.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ni('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 rx);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ni("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new Ne,1/0);return}if(e){const i=this.boundingSphere.center;if(bs.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];Zu.setFromBufferAttribute(o),this.morphTargetsRelative?(un.addVectors(bs.min,Zu.min),bs.expandByPoint(un),un.addVectors(bs.max,Zu.max),bs.expandByPoint(un)):(bs.expandByPoint(Zu.min),bs.expandByPoint(Zu.max))}bs.getCenter(i);let n=0;for(let r=0,a=e.count;r<a;r++)un.fromBufferAttribute(e,r),n=Math.max(n,i.distanceToSquared(un));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)un.fromBufferAttribute(o,c),l&&(Uh.fromBufferAttribute(e,c),un.add(Uh)),n=Math.max(n,i.distanceToSquared(un))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&Ni('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){Ni("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,n=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new kr(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let E=0;E<i.count;E++)o[E]=new Ne,l[E]=new Ne;const c=new Ne,h=new Ne,d=new Ne,u=new si,p=new si,m=new si,v=new Ne,g=new Ne;function f(E,w,T){c.fromBufferAttribute(i,E),h.fromBufferAttribute(i,w),d.fromBufferAttribute(i,T),u.fromBufferAttribute(r,E),p.fromBufferAttribute(r,w),m.fromBufferAttribute(r,T),h.sub(c),d.sub(c),p.sub(u),m.sub(u);const R=1/(p.x*m.y-m.x*p.y);isFinite(R)&&(v.copy(h).multiplyScalar(m.y).addScaledVector(d,-p.y).multiplyScalar(R),g.copy(d).multiplyScalar(p.x).addScaledVector(h,-m.x).multiplyScalar(R),o[E].add(v),o[w].add(v),o[T].add(v),l[E].add(g),l[w].add(g),l[T].add(g))}let A=this.groups;A.length===0&&(A=[{start:0,count:e.count}]);for(let E=0,w=A.length;E<w;++E){const T=A[E],R=T.start,D=T.count;for(let L=R,I=R+D;L<I;L+=3)f(e.getX(L+0),e.getX(L+1),e.getX(L+2))}const b=new Ne,y=new Ne,x=new Ne,_=new Ne;function M(E){x.fromBufferAttribute(n,E),_.copy(x);const w=o[E];b.copy(w),b.sub(x.multiplyScalar(x.dot(w))).normalize(),y.crossVectors(_,w);const T=y.dot(l[E])<0?-1:1;a.setXYZW(E,b.x,b.y,b.z,T)}for(let E=0,w=A.length;E<w;++E){const T=A[E],R=T.start,D=T.count;for(let L=R,I=R+D;L<I;L+=3)M(e.getX(L+0)),M(e.getX(L+1)),M(e.getX(L+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 kr(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let u=0,p=i.count;u<p;u++)i.setXYZ(u,0,0,0);const n=new Ne,r=new Ne,a=new Ne,o=new Ne,l=new Ne,c=new Ne,h=new Ne,d=new Ne;if(e)for(let u=0,p=e.count;u<p;u+=3){const m=e.getX(u+0),v=e.getX(u+1),g=e.getX(u+2);n.fromBufferAttribute(t,m),r.fromBufferAttribute(t,v),a.fromBufferAttribute(t,g),h.subVectors(a,r),d.subVectors(n,r),h.cross(d),o.fromBufferAttribute(i,m),l.fromBufferAttribute(i,v),c.fromBufferAttribute(i,g),o.add(h),l.add(h),c.add(h),i.setXYZ(m,o.x,o.y,o.z),i.setXYZ(v,l.x,l.y,l.z),i.setXYZ(g,c.x,c.y,c.z)}else for(let u=0,p=t.count;u<p;u+=3)n.fromBufferAttribute(t,u+0),r.fromBufferAttribute(t,u+1),a.fromBufferAttribute(t,u+2),h.subVectors(a,r),d.subVectors(n,r),h.cross(d),i.setXYZ(u+0,h.x,h.y,h.z),i.setXYZ(u+1,h.x,h.y,h.z),i.setXYZ(u+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++)un.fromBufferAttribute(e,t),un.normalize(),e.setXYZ(t,un.x,un.y,un.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,d=o.normalized,u=new c.constructor(l.length*h);let p=0,m=0;for(let v=0,g=l.length;v<g;v++){o.isInterleavedBufferAttribute?p=l[v]*o.data.stride+o.offset:p=l[v]*h;for(let f=0;f<h;f++)u[m++]=c[p++]}return new kr(u,h,d)}if(this.index===null)return Mt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new wo,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 r=this.morphAttributes;for(const o in r){const l=[],c=r[o];for(let h=0,d=c.length;h<d;h++){const u=c[h],p=e(u,i);l.push(p)}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 r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let d=0,u=c.length;d<u;d++){const p=c[d];h.push(p.toJSON(e.data))}h.length>0&&(n[l]=h,r=!0)}r&&(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 r=e.morphAttributes;for(const c in r){const h=[],d=r[c];for(let u=0,p=d.length;u<p;u++)h.push(d[u].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 _C=new tn,zl=new XN,Yg=new rx,wC=new Ne,Kg=new Ne,$g=new Ne,Zg=new Ne,bx=new Ne,Jg=new Ne,EC=new Ne,e0=new Ne;class Eo extends ks{constructor(e=new wo,t=new bC){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,r=i.length;n<r;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,r=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(n,e);const o=this.morphTargetInfluences;if(r&&o){Jg.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const h=o[l],d=r[l];h!==0&&(bx.fromBufferAttribute(d,e),a?Jg.addScaledVector(bx,h):Jg.addScaledVector(bx.sub(t),h))}t.add(Jg)}return t}raycast(e,t){const i=this.geometry,n=this.material,r=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Yg.copy(i.boundingSphere),Yg.applyMatrix4(r),zl.copy(e.ray).recast(e.near),!(Yg.containsPoint(zl.origin)===!1&&(zl.intersectSphere(Yg,wC)===null||zl.origin.distanceToSquared(wC)>(e.far-e.near)**2))&&(_C.copy(r).invert(),zl.copy(e.ray).applyMatrix4(_C),!(i.boundingBox!==null&&zl.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,zl)))}_computeIntersections(e,t,i){let n;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,p=r.drawRange;if(o!==null)if(Array.isArray(a))for(let m=0,v=u.length;m<v;m++){const g=u[m],f=a[g.materialIndex],A=Math.max(g.start,p.start),b=Math.min(o.count,Math.min(g.start+g.count,p.start+p.count));for(let y=A,x=b;y<x;y+=3){const _=o.getX(y),M=o.getX(y+1),E=o.getX(y+2);n=t0(this,f,e,i,c,h,d,_,M,E),n&&(n.faceIndex=Math.floor(y/3),n.face.materialIndex=g.materialIndex,t.push(n))}}else{const m=Math.max(0,p.start),v=Math.min(o.count,p.start+p.count);for(let g=m,f=v;g<f;g+=3){const A=o.getX(g),b=o.getX(g+1),y=o.getX(g+2);n=t0(this,a,e,i,c,h,d,A,b,y),n&&(n.faceIndex=Math.floor(g/3),t.push(n))}}else if(l!==void 0)if(Array.isArray(a))for(let m=0,v=u.length;m<v;m++){const g=u[m],f=a[g.materialIndex],A=Math.max(g.start,p.start),b=Math.min(l.count,Math.min(g.start+g.count,p.start+p.count));for(let y=A,x=b;y<x;y+=3){const _=y,M=y+1,E=y+2;n=t0(this,f,e,i,c,h,d,_,M,E),n&&(n.faceIndex=Math.floor(y/3),n.face.materialIndex=g.materialIndex,t.push(n))}}else{const m=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let g=m,f=v;g<f;g+=3){const A=g,b=g+1,y=g+2;n=t0(this,a,e,i,c,h,d,A,b,y),n&&(n.faceIndex=Math.floor(g/3),t.push(n))}}}}function nU(s,e,t,i,n,r,a,o){let l;if(e.side===es?l=i.intersectTriangle(a,r,n,!0,o):l=i.intersectTriangle(n,r,a,e.side===mo,o),l===null)return null;e0.copy(o),e0.applyMatrix4(s.matrixWorld);const c=t.ray.origin.distanceTo(e0);return c<t.near||c>t.far?null:{distance:c,point:e0.clone(),object:s}}function t0(s,e,t,i,n,r,a,o,l,c){s.getVertexPosition(o,Kg),s.getVertexPosition(l,$g),s.getVertexPosition(c,Zg);const h=nU(s,e,t,i,Kg,$g,Zg,EC);if(h){const d=new Ne;or.getBarycoord(EC,Kg,$g,Zg,d),n&&(h.uv=or.getInterpolatedAttribute(n,o,l,c,d,new si)),r&&(h.uv1=or.getInterpolatedAttribute(r,o,l,c,d,new si)),a&&(h.normal=or.getInterpolatedAttribute(a,o,l,c,d,new Ne),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new Ne,materialIndex:0};or.getNormal(Kg,$g,Zg,u.normal),h.face=u,h.barycoord=d}return h}class Ju extends wo{constructor(e=1,t=1,i=1,n=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:n,heightSegments:r,depthSegments:a};const o=this;n=Math.floor(n),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],h=[],d=[];let u=0,p=0;m("z","y","x",-1,-1,i,t,e,a,r,0),m("z","y","x",1,-1,i,t,-e,a,r,1),m("x","z","y",1,1,e,i,t,n,a,2),m("x","z","y",1,-1,e,i,-t,n,a,3),m("x","y","z",1,-1,e,t,i,n,r,4),m("x","y","z",-1,-1,e,t,-i,n,r,5),this.setIndex(l),this.setAttribute("position",new Ul(c,3)),this.setAttribute("normal",new Ul(h,3)),this.setAttribute("uv",new Ul(d,2));function m(v,g,f,A,b,y,x,_,M,E,w){const T=y/M,R=x/E,D=y/2,L=x/2,I=_/2,O=M+1,N=E+1;let G=0,V=0;const H=new Ne;for(let J=0;J<N;J++){const W=J*R-L;for(let X=0;X<O;X++){const me=X*T-D;H[v]=me*A,H[g]=W*b,H[f]=I,c.push(H.x,H.y,H.z),H[v]=0,H[g]=0,H[f]=_>0?1:-1,h.push(H.x,H.y,H.z),d.push(X/M),d.push(1-J/E),G+=1}}for(let J=0;J<E;J++)for(let W=0;W<M;W++){const X=u+W+O*J,me=u+W+O*(J+1),Ee=u+(W+1)+O*(J+1),Me=u+(W+1)+O*J;l.push(X,me,Me),l.push(me,Ee,Me),V+=6}o.addGroup(p,V,w),p+=V,u+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ju(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function zh(s){const e={};for(const t in s){e[t]={};for(const i in s[t]){const n=s[t][i];n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)?n.isRenderTargetTexture?(Mt("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(s){const e={};for(let t=0;t<s.length;t++){const i=zh(s[t]);for(const n in i)e[n]=i[n]}return e}function sU(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function MC(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:jt.workingColorSpace}const rU={clone:zh,merge:Un};var aU=`void main() {
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,oU=`void main() {
|
||
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
||
}`;class ya extends Xg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=aU,this.fragmentShader=oU,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=zh(e.uniforms),this.uniformsGroups=sU(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 r=this.uniforms[n].value;r&&r.isTexture?t.uniforms[n]={type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[n]={type:"c",value:r.getHex()}:r&&r.isVector2?t.uniforms[n]={type:"v2",value:r.toArray()}:r&&r.isVector3?t.uniforms[n]={type:"v3",value:r.toArray()}:r&&r.isVector4?t.uniforms[n]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?t.uniforms[n]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?t.uniforms[n]={type:"m4",value:r.toArray()}:t.uniforms[n]={value:r}}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 SC extends ks{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new tn,this.projectionMatrix=new tn,this.projectionMatrixInverse=new tn,this.coordinateSystem=Lr,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 Mo=new Ne,CC=new si,TC=new si;class lr extends SC{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=Ky*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Yy*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Ky*2*Math.atan(Math.tan(Yy*.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){Mo.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Mo.x,Mo.y).multiplyScalar(-e/Mo.z),Mo.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Mo.x,Mo.y).multiplyScalar(-e/Mo.z)}getViewSize(e,t){return this.getViewBounds(e,CC,TC),t.subVectors(TC,CC)}setViewOffset(e,t,i,n,r,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=r,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(Yy*.5*this.fov)/this.zoom,i=2*t,n=this.aspect*i,r=-.5*n;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*n/l,t-=a.offsetY*i/c,n*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+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 Hh=-90,Gh=1;class lU extends ks{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new lr(Hh,Gh,e,t);n.layers=this.layers,this.add(n);const r=new lr(Hh,Gh,e,t);r.layers=this.layers,this.add(r);const a=new lr(Hh,Gh,e,t);a.layers=this.layers,this.add(a);const o=new lr(Hh,Gh,e,t);o.layers=this.layers,this.add(o);const l=new lr(Hh,Gh,e,t);l.layers=this.layers,this.add(l);const c=new lr(Hh,Gh,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,n,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===Lr)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),r.up.set(0,0,-1),r.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===Fg)i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),r.up.set(0,0,1),r.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[r,a,o,l,c,h]=this.children,d=e.getRenderTarget(),u=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),m=e.xr.enabled;e.xr.enabled=!1;const v=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,n),e.render(t,r),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=v,e.setRenderTarget(i,5,n),e.render(t,h),e.setRenderTarget(d,u,p),e.xr.enabled=m,i.texture.needsPMREMUpdate=!0}}class IC extends Nn{constructor(e=[],t=wh,i,n,r,a,o,l,c,h){super(e,t,i,n,r,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class cU extends kl{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 IC(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 Ju(5,5,5),r=new ya({name:"CubemapFromEquirect",uniforms:zh(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:es,blending:ha});r.uniforms.tEquirect.value=t;const a=new Eo(n,r),o=t.minFilter;return t.minFilter===Bl&&(t.minFilter=Ls),new lU(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 r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,n);e.setRenderTarget(r)}}let i0=class extends ks{constructor(){super(),this.isGroup=!0,this.type="Group"}};const hU={type:"move"};class yx{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new i0,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 i0,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ne,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ne),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new i0,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ne,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ne),this._grip}dispatchEvent(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,r=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 v of e.hand.values()){const g=t.getJointPose(v,i),f=this._getHandJoint(c,v);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"],u=h.position.distanceTo(d.position),p=.02,m=.005;c.inputState.pinching&&u>p+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=p-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(n=t.getPose(e.targetRaySpace,i),n===null&&r!==null&&(n=r),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(hU)))}return o!==null&&(o.visible=n!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new i0;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class dU extends Nn{constructor(e=null,t=1,i=1,n,r,a,o,l,c=gs,h=gs,d,u){super(null,a,o,l,c,h,n,r,d,u),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const xx=new Ne,uU=new Ne,pU=new Tt;class Hl{constructor(e=new Ne(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=xx.subVectors(i,t).cross(uU.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(xx),n=this.normal.dot(i);if(n===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/n;return r<0||r>1?null:t.copy(e.start).addScaledVector(i,r)}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||pU.getNormalMatrix(e),n=this.coplanarPoint(xx).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),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 Gl=new rx,fU=new si(.5,.5),n0=new Ne;class PC{constructor(e=new Hl,t=new Hl,i=new Hl,n=new Hl,r=new Hl,a=new Hl){this.planes=[e,t,i,n,r,a]}set(e,t,i,n,r,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(r),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=Lr,i=!1){const n=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],h=r[4],d=r[5],u=r[6],p=r[7],m=r[8],v=r[9],g=r[10],f=r[11],A=r[12],b=r[13],y=r[14],x=r[15];if(n[0].setComponents(c-a,p-h,f-m,x-A).normalize(),n[1].setComponents(c+a,p+h,f+m,x+A).normalize(),n[2].setComponents(c+o,p+d,f+v,x+b).normalize(),n[3].setComponents(c-o,p-d,f-v,x-b).normalize(),i)n[4].setComponents(l,u,g,y).normalize(),n[5].setComponents(c-l,p-u,f-g,x-y).normalize();else if(n[4].setComponents(c-l,p-u,f-g,x-y).normalize(),t===Lr)n[5].setComponents(c+l,p+u,f+g,x+y).normalize();else if(t===Fg)n[5].setComponents(l,u,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(),Gl.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Gl.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Gl)}intersectsSprite(e){Gl.center.set(0,0,0);const t=fU.distanceTo(e.center);return Gl.radius=.7071067811865476+t,Gl.applyMatrix4(e.matrixWorld),this.intersectsSphere(Gl)}intersectsSphere(e){const t=this.planes,i=e.center,n=-e.radius;for(let r=0;r<6;r++)if(t[r].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(n0.x=n.normal.x>0?e.max.x:e.min.x,n0.y=n.normal.y>0?e.max.y:e.min.y,n0.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(n0)<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 DC extends Nn{constructor(e,t,i=Ll,n,r,a,o=gs,l=gs,c,h=Gu,d=1){if(h!==Gu&&h!==Vu)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const u={width:e,height:t,depth:d};super(u,n,r,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 ex(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 RC extends Nn{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class s0 extends wo{constructor(e=1,t=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:n};const r=e/2,a=t/2,o=Math.floor(i),l=Math.floor(n),c=o+1,h=l+1,d=e/o,u=t/l,p=[],m=[],v=[],g=[];for(let f=0;f<h;f++){const A=f*u-a;for(let b=0;b<c;b++){const y=b*d-r;m.push(y,-A,0),v.push(0,0,1),g.push(b/o),g.push(1-f/l)}}for(let f=0;f<l;f++)for(let A=0;A<o;A++){const b=A+c*f,y=A+c*(f+1),x=A+1+c*(f+1),_=A+1+c*f;p.push(b,y,_),p.push(y,x,_)}this.setIndex(p),this.setAttribute("position",new Ul(m,3)),this.setAttribute("normal",new Ul(v,3)),this.setAttribute("uv",new Ul(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new s0(e.width,e.height,e.widthSegments,e.heightSegments)}}class mU extends Xg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=SN,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 gU extends Xg{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 vU extends SC{constructor(e=-1,t=1,i=1,n=-1,r=.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=r,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,r,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=r,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 r=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;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,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 AU extends lr{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}function BC(s,e,t,i){const n=bU(i);switch(t){case YS:return s*e;case $S:return s*e/n.components*n.byteLength;case vy:return s*e/n.components*n.byteLength;case Ay:return s*e*2/n.components*n.byteLength;case by:return s*e*2/n.components*n.byteLength;case KS:return s*e*3/n.components*n.byteLength;case nr:return s*e*4/n.components*n.byteLength;case yy:return s*e*4/n.components*n.byteLength;case Rg:case Bg:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case Lg:case kg:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case _y:case Ey:return Math.max(s,16)*Math.max(e,8)/4;case xy:case wy:return Math.max(s,8)*Math.max(e,8)/2;case My:case Sy:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case Cy:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Ty:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Iy:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case Py:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case Dy:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case Ry:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case By:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case Ly:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case ky:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case Oy:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case Fy:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case Ny:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case Uy:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case zy:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case Hy:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case Gy:case Vy:case Wy:return Math.ceil(s/4)*Math.ceil(e/4)*16;case Qy:case jy:return Math.ceil(s/4)*Math.ceil(e/4)*8;case Xy:case qy:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function bU(s){switch(s){case ua:case QS:return{byteLength:1,components:1};case zu:case jS:case Mh:return{byteLength:2,components:1};case my:case gy:return{byteLength:2,components:4};case Ll:case fy:case pa:return{byteLength:4,components:1};case XS:case qS:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${s}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Jb}})),typeof window<"u"&&(window.__THREE__?Mt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Jb);function LC(){let s=null,e=!1,t=null,i=null;function n(r,a){t(r,a),i=s.requestAnimationFrame(n)}return{start:function(){e!==!0&&t!==null&&(i=s.requestAnimationFrame(n),e=!0)},stop:function(){s.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){s=r}}}function yU(s){const e=new WeakMap;function t(o,l){const c=o.array,h=o.usage,d=c.byteLength,u=s.createBuffer();s.bindBuffer(l,u),s.bufferData(l,c,h),o.onUploadCallback();let p;if(c instanceof Float32Array)p=s.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)p=s.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?p=s.HALF_FLOAT:p=s.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=s.SHORT;else if(c instanceof Uint32Array)p=s.UNSIGNED_INT;else if(c instanceof Int32Array)p=s.INT;else if(c instanceof Int8Array)p=s.BYTE;else if(c instanceof Uint8Array)p=s.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:u,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,c){const h=l.array,d=l.updateRanges;if(s.bindBuffer(c,o),d.length===0)s.bufferSubData(c,0,h);else{d.sort((p,m)=>p.start-m.start);let u=0;for(let p=1;p<d.length;p++){const m=d[u],v=d[p];v.start<=m.start+m.count+1?m.count=Math.max(m.count,v.start+v.count-m.start):(++u,d[u]=v)}d.length=u+1;for(let p=0,m=d.length;p<m;p++){const v=d[p];s.bufferSubData(c,v.start*h.BYTES_PER_ELEMENT,h,v.start,v.count)}l.clearUpdateRanges()}l.onUploadCallback()}function n(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(s.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:r,update:a}}var xU=`#ifdef USE_ALPHAHASH
|
||
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
||
#endif`,_U=`#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`,wU=`#ifdef USE_ALPHAMAP
|
||
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
||
#endif`,EU=`#ifdef USE_ALPHAMAP
|
||
uniform sampler2D alphaMap;
|
||
#endif`,MU=`#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`,SU=`#ifdef USE_ALPHATEST
|
||
uniform float alphaTest;
|
||
#endif`,CU=`#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`,TU=`#ifdef USE_AOMAP
|
||
uniform sampler2D aoMap;
|
||
uniform float aoMapIntensity;
|
||
#endif`,IU=`#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`,PU=`#ifdef USE_BATCHING
|
||
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
||
#endif`,DU=`vec3 transformed = vec3( position );
|
||
#ifdef USE_ALPHAHASH
|
||
vPosition = vec3( position );
|
||
#endif`,RU=`vec3 objectNormal = vec3( normal );
|
||
#ifdef USE_TANGENT
|
||
vec3 objectTangent = vec3( tangent.xyz );
|
||
#endif`,BU=`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`,LU=`#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`,kU=`#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`,OU=`#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`,FU=`#if NUM_CLIPPING_PLANES > 0
|
||
varying vec3 vClipPosition;
|
||
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
||
#endif`,NU=`#if NUM_CLIPPING_PLANES > 0
|
||
varying vec3 vClipPosition;
|
||
#endif`,UU=`#if NUM_CLIPPING_PLANES > 0
|
||
vClipPosition = - mvPosition.xyz;
|
||
#endif`,zU=`#if defined( USE_COLOR_ALPHA )
|
||
diffuseColor *= vColor;
|
||
#elif defined( USE_COLOR )
|
||
diffuseColor.rgb *= vColor;
|
||
#endif`,HU=`#if defined( USE_COLOR_ALPHA )
|
||
varying vec4 vColor;
|
||
#elif defined( USE_COLOR )
|
||
varying vec3 vColor;
|
||
#endif`,GU=`#if defined( USE_COLOR_ALPHA )
|
||
varying vec4 vColor;
|
||
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
||
varying vec3 vColor;
|
||
#endif`,VU=`#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`,WU=`#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`,QU=`#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`,jU=`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`,XU=`#ifdef USE_DISPLACEMENTMAP
|
||
uniform sampler2D displacementMap;
|
||
uniform float displacementScale;
|
||
uniform float displacementBias;
|
||
#endif`,qU=`#ifdef USE_DISPLACEMENTMAP
|
||
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
||
#endif`,YU=`#ifdef USE_EMISSIVEMAP
|
||
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
||
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
||
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
||
#endif
|
||
totalEmissiveRadiance *= emissiveColor.rgb;
|
||
#endif`,KU=`#ifdef USE_EMISSIVEMAP
|
||
uniform sampler2D emissiveMap;
|
||
#endif`,$U="gl_FragColor = linearToOutputTexel( gl_FragColor );",ZU=`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 );
|
||
}`,JU=`#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`,e6=`#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`,t6=`#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`,i6=`#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`,n6=`#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`,s6=`#ifdef USE_FOG
|
||
vFogDepth = - mvPosition.z;
|
||
#endif`,r6=`#ifdef USE_FOG
|
||
varying float vFogDepth;
|
||
#endif`,a6=`#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`,o6=`#ifdef USE_FOG
|
||
uniform vec3 fogColor;
|
||
varying float vFogDepth;
|
||
#ifdef FOG_EXP2
|
||
uniform float fogDensity;
|
||
#else
|
||
uniform float fogNear;
|
||
uniform float fogFar;
|
||
#endif
|
||
#endif`,l6=`#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
|
||
}`,c6=`#ifdef USE_LIGHTMAP
|
||
uniform sampler2D lightMap;
|
||
uniform float lightMapIntensity;
|
||
#endif`,h6=`LambertMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;
|
||
material.specularStrength = specularStrength;`,d6=`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`,u6=`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`,p6=`#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`,f6=`ToonMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;`,m6=`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`,g6=`BlinnPhongMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;
|
||
material.specularColor = specular;
|
||
material.specularShininess = shininess;
|
||
material.specularStrength = specularStrength;`,v6=`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`,A6=`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`,b6=`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 );
|
||
}`,y6=`
|
||
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`,x6=`#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`,_6=`#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`,w6=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
||
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
||
#endif`,E6=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
||
uniform float logDepthBufFC;
|
||
varying float vFragDepth;
|
||
varying float vIsPerspective;
|
||
#endif`,M6=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
||
varying float vFragDepth;
|
||
varying float vIsPerspective;
|
||
#endif`,S6=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
||
vFragDepth = 1.0 + gl_Position.w;
|
||
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
||
#endif`,C6=`#ifdef USE_MAP
|
||
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
||
#ifdef DECODE_VIDEO_TEXTURE
|
||
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
||
#endif
|
||
diffuseColor *= sampledDiffuseColor;
|
||
#endif`,T6=`#ifdef USE_MAP
|
||
uniform sampler2D map;
|
||
#endif`,I6=`#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`,P6=`#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`,D6=`float metalnessFactor = metalness;
|
||
#ifdef USE_METALNESSMAP
|
||
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
||
metalnessFactor *= texelMetalness.b;
|
||
#endif`,R6=`#ifdef USE_METALNESSMAP
|
||
uniform sampler2D metalnessMap;
|
||
#endif`,B6=`#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`,L6=`#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`,k6=`#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`,O6=`#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`,F6=`#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`,N6=`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;`,U6=`#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`,z6=`#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#ifdef USE_TANGENT
|
||
varying vec3 vTangent;
|
||
varying vec3 vBitangent;
|
||
#endif
|
||
#endif`,H6=`#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#ifdef USE_TANGENT
|
||
varying vec3 vTangent;
|
||
varying vec3 vBitangent;
|
||
#endif
|
||
#endif`,G6=`#ifndef FLAT_SHADED
|
||
vNormal = normalize( transformedNormal );
|
||
#ifdef USE_TANGENT
|
||
vTangent = normalize( transformedTangent );
|
||
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
||
#endif
|
||
#endif`,V6=`#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`,W6=`#ifdef USE_CLEARCOAT
|
||
vec3 clearcoatNormal = nonPerturbedNormal;
|
||
#endif`,Q6=`#ifdef USE_CLEARCOAT_NORMALMAP
|
||
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
||
clearcoatMapN.xy *= clearcoatNormalScale;
|
||
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
||
#endif`,j6=`#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`,X6=`#ifdef USE_IRIDESCENCEMAP
|
||
uniform sampler2D iridescenceMap;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
uniform sampler2D iridescenceThicknessMap;
|
||
#endif`,q6=`#ifdef OPAQUE
|
||
diffuseColor.a = 1.0;
|
||
#endif
|
||
#ifdef USE_TRANSMISSION
|
||
diffuseColor.a *= material.transmissionAlpha;
|
||
#endif
|
||
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Y6=`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 );
|
||
}`,K6=`#ifdef PREMULTIPLIED_ALPHA
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
#endif`,$6=`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;`,Z6=`#ifdef DITHERING
|
||
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
||
#endif`,J6=`#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`,e9=`float roughnessFactor = roughness;
|
||
#ifdef USE_ROUGHNESSMAP
|
||
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
||
roughnessFactor *= texelRoughness.g;
|
||
#endif`,t9=`#ifdef USE_ROUGHNESSMAP
|
||
uniform sampler2D roughnessMap;
|
||
#endif`,i9=`#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`,n9=`#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`,s9=`#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`,r9=`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;
|
||
}`,a9=`#ifdef USE_SKINNING
|
||
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
||
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
||
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
||
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
||
#endif`,o9=`#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`,l9=`#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`,c9=`#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`,h9=`float specularStrength;
|
||
#ifdef USE_SPECULARMAP
|
||
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
||
specularStrength = texelSpecular.r;
|
||
#else
|
||
specularStrength = 1.0;
|
||
#endif`,d9=`#ifdef USE_SPECULARMAP
|
||
uniform sampler2D specularMap;
|
||
#endif`,u9=`#if defined( TONE_MAPPING )
|
||
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
||
#endif`,p9=`#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; }`,f9=`#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`,m9=`#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`,g9=`#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`,v9=`#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`,A9=`#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`,b9=`#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 y9=`varying vec2 vUv;
|
||
uniform mat3 uvTransform;
|
||
void main() {
|
||
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
||
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
||
}`,x9=`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>
|
||
}`,_9=`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
gl_Position.z = gl_Position.w;
|
||
}`,w9=`#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>
|
||
}`,E9=`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
gl_Position.z = gl_Position.w;
|
||
}`,M9=`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>
|
||
}`,S9=`#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;
|
||
}`,C9=`#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
|
||
}`,T9=`#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;
|
||
}`,I9=`#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 );
|
||
}`,P9=`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
}`,D9=`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>
|
||
}`,R9=`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>
|
||
}`,B9=`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>
|
||
}`,L9=`#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>
|
||
}`,k9=`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>
|
||
}`,O9=`#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>
|
||
}`,F9=`#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>
|
||
}`,N9=`#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;
|
||
}`,U9=`#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>
|
||
}`,z9=`#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
|
||
}`,H9=`#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
|
||
}`,G9=`#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>
|
||
}`,V9=`#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>
|
||
}`,W9=`#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
|
||
}`,Q9=`#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>
|
||
}`,j9=`#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>
|
||
}`,X9=`#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>
|
||
}`,q9=`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>
|
||
}`,Y9=`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>
|
||
}`,K9=`#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>
|
||
}`,$9=`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>
|
||
}`,Z9=`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>
|
||
}`,J9=`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>
|
||
}`,Dt={alphahash_fragment:xU,alphahash_pars_fragment:_U,alphamap_fragment:wU,alphamap_pars_fragment:EU,alphatest_fragment:MU,alphatest_pars_fragment:SU,aomap_fragment:CU,aomap_pars_fragment:TU,batching_pars_vertex:IU,batching_vertex:PU,begin_vertex:DU,beginnormal_vertex:RU,bsdfs:BU,iridescence_fragment:LU,bumpmap_pars_fragment:kU,clipping_planes_fragment:OU,clipping_planes_pars_fragment:FU,clipping_planes_pars_vertex:NU,clipping_planes_vertex:UU,color_fragment:zU,color_pars_fragment:HU,color_pars_vertex:GU,color_vertex:VU,common:WU,cube_uv_reflection_fragment:QU,defaultnormal_vertex:jU,displacementmap_pars_vertex:XU,displacementmap_vertex:qU,emissivemap_fragment:YU,emissivemap_pars_fragment:KU,colorspace_fragment:$U,colorspace_pars_fragment:ZU,envmap_fragment:JU,envmap_common_pars_fragment:e6,envmap_pars_fragment:t6,envmap_pars_vertex:i6,envmap_physical_pars_fragment:p6,envmap_vertex:n6,fog_vertex:s6,fog_pars_vertex:r6,fog_fragment:a6,fog_pars_fragment:o6,gradientmap_pars_fragment:l6,lightmap_pars_fragment:c6,lights_lambert_fragment:h6,lights_lambert_pars_fragment:d6,lights_pars_begin:u6,lights_toon_fragment:f6,lights_toon_pars_fragment:m6,lights_phong_fragment:g6,lights_phong_pars_fragment:v6,lights_physical_fragment:A6,lights_physical_pars_fragment:b6,lights_fragment_begin:y6,lights_fragment_maps:x6,lights_fragment_end:_6,logdepthbuf_fragment:w6,logdepthbuf_pars_fragment:E6,logdepthbuf_pars_vertex:M6,logdepthbuf_vertex:S6,map_fragment:C6,map_pars_fragment:T6,map_particle_fragment:I6,map_particle_pars_fragment:P6,metalnessmap_fragment:D6,metalnessmap_pars_fragment:R6,morphinstance_vertex:B6,morphcolor_vertex:L6,morphnormal_vertex:k6,morphtarget_pars_vertex:O6,morphtarget_vertex:F6,normal_fragment_begin:N6,normal_fragment_maps:U6,normal_pars_fragment:z6,normal_pars_vertex:H6,normal_vertex:G6,normalmap_pars_fragment:V6,clearcoat_normal_fragment_begin:W6,clearcoat_normal_fragment_maps:Q6,clearcoat_pars_fragment:j6,iridescence_pars_fragment:X6,opaque_fragment:q6,packing:Y6,premultiplied_alpha_fragment:K6,project_vertex:$6,dithering_fragment:Z6,dithering_pars_fragment:J6,roughnessmap_fragment:e9,roughnessmap_pars_fragment:t9,shadowmap_pars_fragment:i9,shadowmap_pars_vertex:n9,shadowmap_vertex:s9,shadowmask_pars_fragment:r9,skinbase_vertex:a9,skinning_pars_vertex:o9,skinning_vertex:l9,skinnormal_vertex:c9,specularmap_fragment:h9,specularmap_pars_fragment:d9,tonemapping_fragment:u9,tonemapping_pars_fragment:p9,transmission_fragment:f9,transmission_pars_fragment:m9,uv_pars_fragment:g9,uv_pars_vertex:v9,uv_vertex:A9,worldpos_vertex:b9,background_vert:y9,background_frag:x9,backgroundCube_vert:_9,backgroundCube_frag:w9,cube_vert:E9,cube_frag:M9,depth_vert:S9,depth_frag:C9,distanceRGBA_vert:T9,distanceRGBA_frag:I9,equirect_vert:P9,equirect_frag:D9,linedashed_vert:R9,linedashed_frag:B9,meshbasic_vert:L9,meshbasic_frag:k9,meshlambert_vert:O9,meshlambert_frag:F9,meshmatcap_vert:N9,meshmatcap_frag:U9,meshnormal_vert:z9,meshnormal_frag:H9,meshphong_vert:G9,meshphong_frag:V9,meshphysical_vert:W9,meshphysical_frag:Q9,meshtoon_vert:j9,meshtoon_frag:X9,points_vert:q9,points_frag:Y9,shadow_vert:K9,shadow_frag:$9,sprite_vert:Z9,sprite_frag:J9},nt={common:{diffuse:{value:new ri(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Tt},alphaMap:{value:null},alphaMapTransform:{value:new Tt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Tt}},envmap:{envMap:{value:null},envMapRotation:{value:new Tt},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 Tt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Tt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Tt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Tt},normalScale:{value:new si(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Tt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Tt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Tt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Tt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ri(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 ri(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Tt},alphaTest:{value:0},uvTransform:{value:new Tt}},sprite:{diffuse:{value:new ri(16777215)},opacity:{value:1},center:{value:new si(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Tt},alphaMap:{value:null},alphaMapTransform:{value:new Tt},alphaTest:{value:0}}},Or={basic:{uniforms:Un([nt.common,nt.specularmap,nt.envmap,nt.aomap,nt.lightmap,nt.fog]),vertexShader:Dt.meshbasic_vert,fragmentShader:Dt.meshbasic_frag},lambert:{uniforms:Un([nt.common,nt.specularmap,nt.envmap,nt.aomap,nt.lightmap,nt.emissivemap,nt.bumpmap,nt.normalmap,nt.displacementmap,nt.fog,nt.lights,{emissive:{value:new ri(0)}}]),vertexShader:Dt.meshlambert_vert,fragmentShader:Dt.meshlambert_frag},phong:{uniforms:Un([nt.common,nt.specularmap,nt.envmap,nt.aomap,nt.lightmap,nt.emissivemap,nt.bumpmap,nt.normalmap,nt.displacementmap,nt.fog,nt.lights,{emissive:{value:new ri(0)},specular:{value:new ri(1118481)},shininess:{value:30}}]),vertexShader:Dt.meshphong_vert,fragmentShader:Dt.meshphong_frag},standard:{uniforms:Un([nt.common,nt.envmap,nt.aomap,nt.lightmap,nt.emissivemap,nt.bumpmap,nt.normalmap,nt.displacementmap,nt.roughnessmap,nt.metalnessmap,nt.fog,nt.lights,{emissive:{value:new ri(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Dt.meshphysical_vert,fragmentShader:Dt.meshphysical_frag},toon:{uniforms:Un([nt.common,nt.aomap,nt.lightmap,nt.emissivemap,nt.bumpmap,nt.normalmap,nt.displacementmap,nt.gradientmap,nt.fog,nt.lights,{emissive:{value:new ri(0)}}]),vertexShader:Dt.meshtoon_vert,fragmentShader:Dt.meshtoon_frag},matcap:{uniforms:Un([nt.common,nt.bumpmap,nt.normalmap,nt.displacementmap,nt.fog,{matcap:{value:null}}]),vertexShader:Dt.meshmatcap_vert,fragmentShader:Dt.meshmatcap_frag},points:{uniforms:Un([nt.points,nt.fog]),vertexShader:Dt.points_vert,fragmentShader:Dt.points_frag},dashed:{uniforms:Un([nt.common,nt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Dt.linedashed_vert,fragmentShader:Dt.linedashed_frag},depth:{uniforms:Un([nt.common,nt.displacementmap]),vertexShader:Dt.depth_vert,fragmentShader:Dt.depth_frag},normal:{uniforms:Un([nt.common,nt.bumpmap,nt.normalmap,nt.displacementmap,{opacity:{value:1}}]),vertexShader:Dt.meshnormal_vert,fragmentShader:Dt.meshnormal_frag},sprite:{uniforms:Un([nt.sprite,nt.fog]),vertexShader:Dt.sprite_vert,fragmentShader:Dt.sprite_frag},background:{uniforms:{uvTransform:{value:new Tt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Dt.background_vert,fragmentShader:Dt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Tt}},vertexShader:Dt.backgroundCube_vert,fragmentShader:Dt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Dt.cube_vert,fragmentShader:Dt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Dt.equirect_vert,fragmentShader:Dt.equirect_frag},distanceRGBA:{uniforms:Un([nt.common,nt.displacementmap,{referencePosition:{value:new Ne},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Dt.distanceRGBA_vert,fragmentShader:Dt.distanceRGBA_frag},shadow:{uniforms:Un([nt.lights,nt.fog,{color:{value:new ri(0)},opacity:{value:1}}]),vertexShader:Dt.shadow_vert,fragmentShader:Dt.shadow_frag}};Or.physical={uniforms:Un([Or.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Tt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Tt},clearcoatNormalScale:{value:new si(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Tt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Tt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Tt},sheen:{value:0},sheenColor:{value:new ri(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Tt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Tt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Tt},transmissionSamplerSize:{value:new si},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Tt},attenuationDistance:{value:0},attenuationColor:{value:new ri(0)},specularColor:{value:new ri(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Tt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Tt},anisotropyVector:{value:new si},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Tt}}]),vertexShader:Dt.meshphysical_vert,fragmentShader:Dt.meshphysical_frag};const r0={r:0,b:0,g:0},Vl=new Nl,ez=new tn;function tz(s,e,t,i,n,r,a){const o=new ri(0);let l=r===!0?0:1,c,h,d=null,u=0,p=null;function m(b){let y=b.isScene===!0?b.background:null;return y&&y.isTexture&&(y=(b.backgroundBlurriness>0?t:e).get(y)),y}function v(b){let y=!1;const x=m(b);x===null?f(o,l):x&&x.isColor&&(f(x,1),y=!0);const _=s.xr.getEnvironmentBlendMode();_==="additive"?i.buffers.color.setClear(0,0,0,1,a):_==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,a),(s.autoClear||y)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function g(b,y){const x=m(y);x&&(x.isCubeTexture||x.mapping===Pg)?(h===void 0&&(h=new Eo(new Ju(1,1,1),new ya({name:"BackgroundCubeMaterial",uniforms:zh(Or.backgroundCube.uniforms),vertexShader:Or.backgroundCube.vertexShader,fragmentShader:Or.backgroundCube.fragmentShader,side:es,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(_,M,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(h)),Vl.copy(y.backgroundRotation),Vl.x*=-1,Vl.y*=-1,Vl.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(Vl.y*=-1,Vl.z*=-1),h.material.uniforms.envMap.value=x,h.material.uniforms.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(ez.makeRotationFromEuler(Vl)),h.material.toneMapped=jt.getTransfer(x.colorSpace)!==ni,(d!==x||u!==x.version||p!==s.toneMapping)&&(h.material.needsUpdate=!0,d=x,u=x.version,p=s.toneMapping),h.layers.enableAll(),b.unshift(h,h.geometry,h.material,0,0,null)):x&&x.isTexture&&(c===void 0&&(c=new Eo(new s0(2,2),new ya({name:"BackgroundMaterial",uniforms:zh(Or.background.uniforms),vertexShader:Or.background.vertexShader,fragmentShader:Or.background.fragmentShader,side:mo,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=x,c.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,c.material.toneMapped=jt.getTransfer(x.colorSpace)!==ni,x.matrixAutoUpdate===!0&&x.updateMatrix(),c.material.uniforms.uvTransform.value.copy(x.matrix),(d!==x||u!==x.version||p!==s.toneMapping)&&(c.material.needsUpdate=!0,d=x,u=x.version,p=s.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null))}function f(b,y){b.getRGB(r0,MC(s)),i.buffers.color.setClear(r0.r,r0.g,r0.b,y,a)}function A(){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:v,addToRenderList:g,dispose:A}}function iz(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),i={},n=u(null);let r=n,a=!1;function o(T,R,D,L,I){let O=!1;const N=d(L,D,R);r!==N&&(r=N,c(r.object)),O=p(T,L,D,I),O&&m(T,L,D,I),I!==null&&e.update(I,s.ELEMENT_ARRAY_BUFFER),(O||a)&&(a=!1,y(T,R,D,L),I!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(I).buffer))}function l(){return s.createVertexArray()}function c(T){return s.bindVertexArray(T)}function h(T){return s.deleteVertexArray(T)}function d(T,R,D){const L=D.wireframe===!0;let I=i[T.id];I===void 0&&(I={},i[T.id]=I);let O=I[R.id];O===void 0&&(O={},I[R.id]=O);let N=O[L];return N===void 0&&(N=u(l()),O[L]=N),N}function u(T){const R=[],D=[],L=[];for(let I=0;I<t;I++)R[I]=0,D[I]=0,L[I]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:R,enabledAttributes:D,attributeDivisors:L,object:T,attributes:{},index:null}}function p(T,R,D,L){const I=r.attributes,O=R.attributes;let N=0;const G=D.getAttributes();for(const V in G)if(G[V].location>=0){const H=I[V];let J=O[V];if(J===void 0&&(V==="instanceMatrix"&&T.instanceMatrix&&(J=T.instanceMatrix),V==="instanceColor"&&T.instanceColor&&(J=T.instanceColor)),H===void 0||H.attribute!==J||J&&H.data!==J.data)return!0;N++}return r.attributesNum!==N||r.index!==L}function m(T,R,D,L){const I={},O=R.attributes;let N=0;const G=D.getAttributes();for(const V in G)if(G[V].location>=0){let H=O[V];H===void 0&&(V==="instanceMatrix"&&T.instanceMatrix&&(H=T.instanceMatrix),V==="instanceColor"&&T.instanceColor&&(H=T.instanceColor));const J={};J.attribute=H,H&&H.data&&(J.data=H.data),I[V]=J,N++}r.attributes=I,r.attributesNum=N,r.index=L}function v(){const T=r.newAttributes;for(let R=0,D=T.length;R<D;R++)T[R]=0}function g(T){f(T,0)}function f(T,R){const D=r.newAttributes,L=r.enabledAttributes,I=r.attributeDivisors;D[T]=1,L[T]===0&&(s.enableVertexAttribArray(T),L[T]=1),I[T]!==R&&(s.vertexAttribDivisor(T,R),I[T]=R)}function A(){const T=r.newAttributes,R=r.enabledAttributes;for(let D=0,L=R.length;D<L;D++)R[D]!==T[D]&&(s.disableVertexAttribArray(D),R[D]=0)}function b(T,R,D,L,I,O,N){N===!0?s.vertexAttribIPointer(T,R,D,I,O):s.vertexAttribPointer(T,R,D,L,I,O)}function y(T,R,D,L){v();const I=L.attributes,O=D.getAttributes(),N=R.defaultAttributeValues;for(const G in O){const V=O[G];if(V.location>=0){let H=I[G];if(H===void 0&&(G==="instanceMatrix"&&T.instanceMatrix&&(H=T.instanceMatrix),G==="instanceColor"&&T.instanceColor&&(H=T.instanceColor)),H!==void 0){const J=H.normalized,W=H.itemSize,X=e.get(H);if(X===void 0)continue;const me=X.buffer,Ee=X.type,Me=X.bytesPerElement,$=Ee===s.INT||Ee===s.UNSIGNED_INT||H.gpuType===fy;if(H.isInterleavedBufferAttribute){const se=H.data,he=se.stride,Te=H.offset;if(se.isInstancedInterleavedBuffer){for(let Le=0;Le<V.locationSize;Le++)f(V.location+Le,se.meshPerAttribute);T.isInstancedMesh!==!0&&L._maxInstanceCount===void 0&&(L._maxInstanceCount=se.meshPerAttribute*se.count)}else for(let Le=0;Le<V.locationSize;Le++)g(V.location+Le);s.bindBuffer(s.ARRAY_BUFFER,me);for(let Le=0;Le<V.locationSize;Le++)b(V.location+Le,W/V.locationSize,Ee,J,he*Me,(Te+W/V.locationSize*Le)*Me,$)}else{if(H.isInstancedBufferAttribute){for(let se=0;se<V.locationSize;se++)f(V.location+se,H.meshPerAttribute);T.isInstancedMesh!==!0&&L._maxInstanceCount===void 0&&(L._maxInstanceCount=H.meshPerAttribute*H.count)}else for(let se=0;se<V.locationSize;se++)g(V.location+se);s.bindBuffer(s.ARRAY_BUFFER,me);for(let se=0;se<V.locationSize;se++)b(V.location+se,W/V.locationSize,Ee,J,W*Me,W/V.locationSize*se*Me,$)}}else if(N!==void 0){const J=N[G];if(J!==void 0)switch(J.length){case 2:s.vertexAttrib2fv(V.location,J);break;case 3:s.vertexAttrib3fv(V.location,J);break;case 4:s.vertexAttrib4fv(V.location,J);break;default:s.vertexAttrib1fv(V.location,J)}}}}A()}function x(){E();for(const T in i){const R=i[T];for(const D in R){const L=R[D];for(const I in L)h(L[I].object),delete L[I];delete R[D]}delete i[T]}}function _(T){if(i[T.id]===void 0)return;const R=i[T.id];for(const D in R){const L=R[D];for(const I in L)h(L[I].object),delete L[I];delete R[D]}delete i[T.id]}function M(T){for(const R in i){const D=i[R];if(D[T.id]===void 0)continue;const L=D[T.id];for(const I in L)h(L[I].object),delete L[I];delete D[T.id]}}function E(){w(),a=!0,r!==n&&(r=n,c(r.object))}function w(){n.geometry=null,n.program=null,n.wireframe=!1}return{setup:o,reset:E,resetDefaultState:w,dispose:x,releaseStatesOfGeometry:_,releaseStatesOfProgram:M,initAttributes:v,enableAttribute:g,disableUnusedAttributes:A}}function nz(s,e,t){let i;function n(c){i=c}function r(c,h){s.drawArrays(i,c,h),t.update(h,i,1)}function a(c,h,d){d!==0&&(s.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 p=0;p<d;p++)u+=h[p];t.update(u,i,1)}function l(c,h,d,u){if(d===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let m=0;m<c.length;m++)a(c[m],h[m],u[m]);else{p.multiDrawArraysInstancedWEBGL(i,c,0,h,0,u,0,d);let m=0;for(let v=0;v<d;v++)m+=h[v]*u[v];t.update(m,i,1)}}this.setMode=n,this.render=r,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function sz(s,e,t,i){let n;function r(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const M=e.get("EXT_texture_filter_anisotropic");n=s.getParameter(M.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function a(M){return!(M!==nr&&i.convert(M)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(M){const E=M===Mh&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(M!==ua&&i.convert(M)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&M!==pa&&!E)}function l(M){if(M==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";M="mediump"}return M==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(Mt("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const d=t.logarithmicDepthBuffer===!0,u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),p=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),m=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=s.getParameter(s.MAX_TEXTURE_SIZE),g=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),f=s.getParameter(s.MAX_VERTEX_ATTRIBS),A=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),b=s.getParameter(s.MAX_VARYING_VECTORS),y=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),x=m>0,_=s.getParameter(s.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:p,maxVertexTextures:m,maxTextureSize:v,maxCubemapSize:g,maxAttributes:f,maxVertexUniforms:A,maxVaryings:b,maxFragmentUniforms:y,vertexTextures:x,maxSamples:_}}function rz(s){const e=this;let t=null,i=0,n=!1,r=!1;const a=new Hl,o=new Tt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){const p=d.length!==0||u||i!==0||n;return n=u,i=d.length,p},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){t=h(d,u,0)},this.setState=function(d,u,p){const m=d.clippingPlanes,v=d.clipIntersection,g=d.clipShadows,f=s.get(d);if(!n||m===null||m.length===0||r&&!g)r?h(null):c();else{const A=r?0:i,b=A*4;let y=f.clippingState||null;l.value=y,y=h(m,u,b,p);for(let x=0;x!==b;++x)y[x]=t[x];f.clippingState=y,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=A}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(d,u,p,m){const v=d!==null?d.length:0;let g=null;if(v!==0){if(g=l.value,m!==!0||g===null){const f=p+v*4,A=u.matrixWorldInverse;o.getNormalMatrix(A),(g===null||g.length<f)&&(g=new Float32Array(f));for(let b=0,y=p;b!==v;++b,y+=4)a.copy(d[b]).applyMatrix4(A,o),a.normal.toArray(g,y),g[y+3]=a.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,g}}function az(s){let e=new WeakMap;function t(a,o){return o===cy?a.mapping=wh:o===hy&&(a.mapping=Eh),a}function i(a){if(a&&a.isTexture){const o=a.mapping;if(o===cy||o===hy)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 cU(l.height);return c.fromEquirectangularTexture(s,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 r(){e=new WeakMap}return{get:i,dispose:r}}const So=4,kC=[.125,.215,.35,.446,.526,.582],Wl=20,oz=256,ep=new vU,OC=new ri;let _x=null,wx=0,Ex=0,Mx=!1;const lz=new Ne;class FC{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,r={}){const{size:a=256,position:o=lz}=r;_x=this._renderer.getRenderTarget(),wx=this._renderer.getActiveCubeFace(),Ex=this._renderer.getActiveMipmapLevel(),Mx=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=zC(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=UC(),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(_x,wx,Ex),this._renderer.xr.enabled=Mx,e.scissorTest=!1,Vh(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===wh||e.mapping===Eh?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),_x=this._renderer.getRenderTarget(),wx=this._renderer.getActiveCubeFace(),Ex=this._renderer.getActiveMipmapLevel(),Mx=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:Ls,minFilter:Ls,generateMipmaps:!1,type:Mh,format:nr,colorSpace:Sh,depthBuffer:!1},n=NC(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=NC(e,t,i);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=cz(r)),this._blurMaterial=dz(r,e,t),this._ggxMaterial=hz(r,e,t)}return n}_compileMaterial(e){const t=new Eo(new wo,e);this._renderer.compile(t,ep)}_sceneToCubeUV(e,t,i,n,r){const a=new lr(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(OC),c.toneMapping=go,c.autoClear=!1,c.state.buffers.depth.getReversed()&&(c.setRenderTarget(n),c.clearDepth(),c.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Eo(new Ju,new bC({name:"PMREM.Background",side:es,depthWrite:!1,depthTest:!1})));const u=this._backgroundBox,p=u.material;let m=!1;const v=e.background;v?v.isColor&&(p.color.copy(v),e.background=null,m=!0):(p.color.copy(OC),m=!0);for(let g=0;g<6;g++){const f=g%3;f===0?(a.up.set(0,o[g],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[g],r.y,r.z)):f===1?(a.up.set(0,0,o[g]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[g],r.z)):(a.up.set(0,o[g],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[g]));const A=this._cubeSize;Vh(n,f*A,g>2?A:0,A,A),c.setRenderTarget(n),m&&c.render(u,a),c.render(e,a)}c.toneMapping=d,c.autoClear=h,e.background=v}_textureToCubeUV(e,t){const i=this._renderer,n=e.mapping===wh||e.mapping===Eh;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=zC()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=UC());const r=n?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;Vh(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,ep)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const n=this._lodMeshes.length;for(let r=1;r<n;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=i}_applyGGXFilter(e,t,i){const n=this._renderer,r=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),u=.05+c*.95,p=d*u,{_lodMax:m}=this,v=this._sizeLods[i],g=3*v*(i>m-So?i-m+So:0),f=4*(this._cubeSize-v);l.envMap.value=e.texture,l.roughness.value=p,l.mipInt.value=m-t,Vh(r,g,f,3*v,2*v),n.setRenderTarget(r),n.render(o,ep),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=m-i,Vh(e,g,f,3*v,2*v),n.setRenderTarget(e),n.render(o,ep)}_blur(e,t,i,n,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,n,"latitudinal",r),this._halfBlur(a,e,i,i,n,"longitudinal",r)}_halfBlur(e,t,i,n,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Ni("blur direction must be either latitudinal or longitudinal!");const h=3,d=this._lodMeshes[n];d.material=c;const u=c.uniforms,p=this._sizeLods[i]-1,m=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*Wl-1),v=r/m,g=isFinite(r)?1+Math.floor(h*v):Wl;g>Wl&&Mt(`sigmaRadians, ${r}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Wl}`);const f=[];let A=0;for(let M=0;M<Wl;++M){const E=M/v,w=Math.exp(-E*E/2);f.push(w),M===0?A+=w:M<g&&(A+=2*w)}for(let M=0;M<f.length;M++)f[M]=f[M]/A;u.envMap.value=e.texture,u.samples.value=g,u.weights.value=f,u.latitudinal.value=a==="latitudinal",o&&(u.poleAxis.value=o);const{_lodMax:b}=this;u.dTheta.value=m,u.mipInt.value=b-i;const y=this._sizeLods[n],x=3*y*(n>b-So?n-b+So:0),_=4*(this._cubeSize-y);Vh(t,x,_,3*y,2*y),l.setRenderTarget(t),l.render(d,ep)}}function cz(s){const e=[],t=[],i=[];let n=s;const r=s-So+1+kC.length;for(let a=0;a<r;a++){const o=Math.pow(2,n);e.push(o);let l=1/o;a>s-So?l=kC[a-s+So-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),h=-c,d=1+c,u=[h,h,d,h,d,d,h,h,d,d,h,d],p=6,m=6,v=3,g=2,f=1,A=new Float32Array(v*m*p),b=new Float32Array(g*m*p),y=new Float32Array(f*m*p);for(let _=0;_<p;_++){const M=_%3*2/3-1,E=_>2?0:-1,w=[M,E,0,M+2/3,E,0,M+2/3,E+1,0,M,E,0,M+2/3,E+1,0,M,E+1,0];A.set(w,v*m*_),b.set(u,g*m*_);const T=[_,_,_,_,_,_];y.set(T,f*m*_)}const x=new wo;x.setAttribute("position",new kr(A,v)),x.setAttribute("uv",new kr(b,g)),x.setAttribute("faceIndex",new kr(y,f)),i.push(new Eo(x,null)),n>So&&n--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function NC(s,e,t){const i=new kl(s,e,t);return i.texture.mapping=Pg,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Vh(s,e,t,i,n){s.viewport.set(e,t,i,n),s.scissor.set(e,t,i,n)}function hz(s,e,t){return new ya({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:oz,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:a0(),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:ha,depthTest:!1,depthWrite:!1})}function dz(s,e,t){const i=new Float32Array(Wl),n=new Ne(0,1,0);return new ya({name:"SphericalGaussianBlur",defines:{n:Wl,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:n}},vertexShader:a0(),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:ha,depthTest:!1,depthWrite:!1})}function UC(){return new ya({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:a0(),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:ha,depthTest:!1,depthWrite:!1})}function zC(){return new ya({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:a0(),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:ha,depthTest:!1,depthWrite:!1})}function a0(){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 uz(s){let e=new WeakMap,t=null;function i(o){if(o&&o.isTexture){const l=o.mapping,c=l===cy||l===hy,h=l===wh||l===Eh;if(c||h){let d=e.get(o);const u=d!==void 0?d.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==u)return t===null&&(t=new FC(s)),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 p=o.image;return c&&p&&p.height>0||h&&p&&n(p)?(t===null&&(t=new FC(s)),d=c?t.fromEquirectangular(o):t.fromCubemap(o),d.texture.pmremVersion=o.pmremVersion,e.set(o,d),o.addEventListener("dispose",r),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 r(o){const l=o.target;l.removeEventListener("dispose",r);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 pz(s){const e={};function t(i){if(e[i]!==void 0)return e[i];const n=s.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&&Wu("WebGLRenderer: "+i+" extension not supported."),n}}}function fz(s,e,t,i){const n={},r=new WeakMap;function a(d){const u=d.target;u.index!==null&&e.remove(u.index);for(const m in u.attributes)e.remove(u.attributes[m]);u.removeEventListener("dispose",a),delete n[u.id];const p=r.get(u);p&&(e.remove(p),r.delete(u)),i.releaseStatesOfGeometry(u),u.isInstancedBufferGeometry===!0&&delete u._maxInstanceCount,t.memory.geometries--}function o(d,u){return n[u.id]===!0||(u.addEventListener("dispose",a),n[u.id]=!0,t.memory.geometries++),u}function l(d){const u=d.attributes;for(const p in u)e.update(u[p],s.ARRAY_BUFFER)}function c(d){const u=[],p=d.index,m=d.attributes.position;let v=0;if(p!==null){const A=p.array;v=p.version;for(let b=0,y=A.length;b<y;b+=3){const x=A[b+0],_=A[b+1],M=A[b+2];u.push(x,_,_,M,M,x)}}else if(m!==void 0){const A=m.array;v=m.version;for(let b=0,y=A.length/3-1;b<y;b+=3){const x=b+0,_=b+1,M=b+2;u.push(x,_,_,M,M,x)}}else return;const g=new(iC(u)?xC:yC)(u,1);g.version=v;const f=r.get(d);f&&e.remove(f),r.set(d,g)}function h(d){const u=r.get(d);if(u){const p=d.index;p!==null&&u.version<p.version&&c(d)}else c(d);return r.get(d)}return{get:o,update:l,getWireframeAttribute:h}}function mz(s,e,t){let i;function n(u){i=u}let r,a;function o(u){r=u.type,a=u.bytesPerElement}function l(u,p){s.drawElements(i,p,r,u*a),t.update(p,i,1)}function c(u,p,m){m!==0&&(s.drawElementsInstanced(i,p,r,u*a,m),t.update(p,i,m))}function h(u,p,m){if(m===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,p,0,r,u,0,m);let v=0;for(let g=0;g<m;g++)v+=p[g];t.update(v,i,1)}function d(u,p,m,v){if(m===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let f=0;f<u.length;f++)c(u[f]/a,p[f],v[f]);else{g.multiDrawElementsInstancedWEBGL(i,p,0,r,u,0,v,0,m);let f=0;for(let A=0;A<m;A++)f+=p[A]*v[A];t.update(f,i,1)}}this.setMode=n,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=d}function gz(s){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(r,a,o){switch(t.calls++,a){case s.TRIANGLES:t.triangles+=o*(r/3);break;case s.LINES:t.lines+=o*(r/2);break;case s.LINE_STRIP:t.lines+=o*(r-1);break;case s.LINE_LOOP:t.lines+=o*r;break;case s.POINTS:t.points+=o*r;break;default:Ni("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 vz(s,e,t){const i=new WeakMap,n=new Ui;function r(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 u=i.get(o);if(u===void 0||u.count!==d){let p=function(){E.dispose(),i.delete(o),o.removeEventListener("dispose",p)};u!==void 0&&u.texture.dispose();const m=o.morphAttributes.position!==void 0,v=o.morphAttributes.normal!==void 0,g=o.morphAttributes.color!==void 0,f=o.morphAttributes.position||[],A=o.morphAttributes.normal||[],b=o.morphAttributes.color||[];let y=0;m===!0&&(y=1),v===!0&&(y=2),g===!0&&(y=3);let x=o.attributes.position.count*y,_=1;x>e.maxTextureSize&&(_=Math.ceil(x/e.maxTextureSize),x=e.maxTextureSize);const M=new Float32Array(x*_*4*d),E=new lC(M,x,_,d);E.type=pa,E.needsUpdate=!0;const w=y*4;for(let T=0;T<d;T++){const R=f[T],D=A[T],L=b[T],I=x*_*4*T;for(let O=0;O<R.count;O++){const N=O*w;m===!0&&(n.fromBufferAttribute(R,O),M[I+N+0]=n.x,M[I+N+1]=n.y,M[I+N+2]=n.z,M[I+N+3]=0),v===!0&&(n.fromBufferAttribute(D,O),M[I+N+4]=n.x,M[I+N+5]=n.y,M[I+N+6]=n.z,M[I+N+7]=0),g===!0&&(n.fromBufferAttribute(L,O),M[I+N+8]=n.x,M[I+N+9]=n.y,M[I+N+10]=n.z,M[I+N+11]=L.itemSize===4?n.w:1)}}u={count:d,texture:E,size:new si(x,_)},i.set(o,u),o.addEventListener("dispose",p)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(s,"morphTexture",a.morphTexture,t);else{let p=0;for(let v=0;v<c.length;v++)p+=c[v];const m=o.morphTargetsRelative?1:1-p;l.getUniforms().setValue(s,"morphTargetBaseInfluence",m),l.getUniforms().setValue(s,"morphTargetInfluences",c)}l.getUniforms().setValue(s,"morphTargetsTexture",u.texture,t),l.getUniforms().setValue(s,"morphTargetsTextureSize",u.size)}return{update:r}}function Az(s,e,t,i){let n=new WeakMap;function r(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,s.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,s.ARRAY_BUFFER),n.set(l,c))),l.isSkinnedMesh){const u=l.skeleton;n.get(u)!==c&&(u.update(),n.set(u,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:r,dispose:a}}const HC=new Nn,GC=new DC(1,1),VC=new lC,WC=new QN,QC=new IC,jC=[],XC=[],qC=new Float32Array(16),YC=new Float32Array(9),KC=new Float32Array(4);function Wh(s,e,t){const i=s[0];if(i<=0||i>0)return s;const n=e*t;let r=jC[n];if(r===void 0&&(r=new Float32Array(n),jC[n]=r),e!==0){i.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,s[a].toArray(r,o)}return r}function nn(s,e){if(s.length!==e.length)return!1;for(let t=0,i=s.length;t<i;t++)if(s[t]!==e[t])return!1;return!0}function sn(s,e){for(let t=0,i=e.length;t<i;t++)s[t]=e[t]}function o0(s,e){let t=XC[e];t===void 0&&(t=new Int32Array(e),XC[e]=t);for(let i=0;i!==e;++i)t[i]=s.allocateTextureUnit();return t}function bz(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function yz(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(nn(t,e))return;s.uniform2fv(this.addr,e),sn(t,e)}}function xz(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.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)&&(s.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(nn(t,e))return;s.uniform3fv(this.addr,e),sn(t,e)}}function _z(s,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)&&(s.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(nn(t,e))return;s.uniform4fv(this.addr,e),sn(t,e)}}function wz(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(nn(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),sn(t,e)}else{if(nn(t,i))return;KC.set(i),s.uniformMatrix2fv(this.addr,!1,KC),sn(t,i)}}function Ez(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(nn(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),sn(t,e)}else{if(nn(t,i))return;YC.set(i),s.uniformMatrix3fv(this.addr,!1,YC),sn(t,i)}}function Mz(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(nn(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),sn(t,e)}else{if(nn(t,i))return;qC.set(i),s.uniformMatrix4fv(this.addr,!1,qC),sn(t,i)}}function Sz(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function Cz(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(nn(t,e))return;s.uniform2iv(this.addr,e),sn(t,e)}}function Tz(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(nn(t,e))return;s.uniform3iv(this.addr,e),sn(t,e)}}function Iz(s,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)&&(s.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(nn(t,e))return;s.uniform4iv(this.addr,e),sn(t,e)}}function Pz(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function Dz(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(nn(t,e))return;s.uniform2uiv(this.addr,e),sn(t,e)}}function Rz(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(nn(t,e))return;s.uniform3uiv(this.addr,e),sn(t,e)}}function Bz(s,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)&&(s.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(nn(t,e))return;s.uniform4uiv(this.addr,e),sn(t,e)}}function Lz(s,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(s.uniform1i(this.addr,n),i[0]=n);let r;this.type===s.SAMPLER_2D_SHADOW?(GC.compareFunction=JS,r=GC):r=HC,t.setTexture2D(e||r,n)}function kz(s,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(s.uniform1i(this.addr,n),i[0]=n),t.setTexture3D(e||WC,n)}function Oz(s,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(s.uniform1i(this.addr,n),i[0]=n),t.setTextureCube(e||QC,n)}function Fz(s,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(s.uniform1i(this.addr,n),i[0]=n),t.setTexture2DArray(e||VC,n)}function Nz(s){switch(s){case 5126:return bz;case 35664:return yz;case 35665:return xz;case 35666:return _z;case 35674:return wz;case 35675:return Ez;case 35676:return Mz;case 5124:case 35670:return Sz;case 35667:case 35671:return Cz;case 35668:case 35672:return Tz;case 35669:case 35673:return Iz;case 5125:return Pz;case 36294:return Dz;case 36295:return Rz;case 36296:return Bz;case 35678:case 36198:case 36298:case 36306:case 35682:return Lz;case 35679:case 36299:case 36307:return kz;case 35680:case 36300:case 36308:case 36293:return Oz;case 36289:case 36303:case 36311:case 36292:return Fz}}function Uz(s,e){s.uniform1fv(this.addr,e)}function zz(s,e){const t=Wh(e,this.size,2);s.uniform2fv(this.addr,t)}function Hz(s,e){const t=Wh(e,this.size,3);s.uniform3fv(this.addr,t)}function Gz(s,e){const t=Wh(e,this.size,4);s.uniform4fv(this.addr,t)}function Vz(s,e){const t=Wh(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function Wz(s,e){const t=Wh(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function Qz(s,e){const t=Wh(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function jz(s,e){s.uniform1iv(this.addr,e)}function Xz(s,e){s.uniform2iv(this.addr,e)}function qz(s,e){s.uniform3iv(this.addr,e)}function Yz(s,e){s.uniform4iv(this.addr,e)}function Kz(s,e){s.uniform1uiv(this.addr,e)}function $z(s,e){s.uniform2uiv(this.addr,e)}function Zz(s,e){s.uniform3uiv(this.addr,e)}function Jz(s,e){s.uniform4uiv(this.addr,e)}function e7(s,e,t){const i=this.cache,n=e.length,r=o0(t,n);nn(i,r)||(s.uniform1iv(this.addr,r),sn(i,r));for(let a=0;a!==n;++a)t.setTexture2D(e[a]||HC,r[a])}function t7(s,e,t){const i=this.cache,n=e.length,r=o0(t,n);nn(i,r)||(s.uniform1iv(this.addr,r),sn(i,r));for(let a=0;a!==n;++a)t.setTexture3D(e[a]||WC,r[a])}function i7(s,e,t){const i=this.cache,n=e.length,r=o0(t,n);nn(i,r)||(s.uniform1iv(this.addr,r),sn(i,r));for(let a=0;a!==n;++a)t.setTextureCube(e[a]||QC,r[a])}function n7(s,e,t){const i=this.cache,n=e.length,r=o0(t,n);nn(i,r)||(s.uniform1iv(this.addr,r),sn(i,r));for(let a=0;a!==n;++a)t.setTexture2DArray(e[a]||VC,r[a])}function s7(s){switch(s){case 5126:return Uz;case 35664:return zz;case 35665:return Hz;case 35666:return Gz;case 35674:return Vz;case 35675:return Wz;case 35676:return Qz;case 5124:case 35670:return jz;case 35667:case 35671:return Xz;case 35668:case 35672:return qz;case 35669:case 35673:return Yz;case 5125:return Kz;case 36294:return $z;case 36295:return Zz;case 36296:return Jz;case 35678:case 36198:case 36298:case 36306:case 35682:return e7;case 35679:case 36299:case 36307:return t7;case 35680:case 36300:case 36308:case 36293:return i7;case 36289:case 36303:case 36311:case 36292:return n7}}class r7{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=Nz(t.type)}}class a7{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=s7(t.type)}}class o7{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const n=this.seq;for(let r=0,a=n.length;r!==a;++r){const o=n[r];o.setValue(e,t[o.id],i)}}}const Sx=/(\w+)(\])?(\[|\.)?/g;function $C(s,e){s.seq.push(e),s.map[e.id]=e}function l7(s,e,t){const i=s.name,n=i.length;for(Sx.lastIndex=0;;){const r=Sx.exec(i),a=Sx.lastIndex;let o=r[1];const l=r[2]==="]",c=r[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===n){$C(t,c===void 0?new r7(o,s,e):new a7(o,s,e));break}else{let h=t.map[o];h===void 0&&(h=new o7(o),$C(t,h)),t=h}}}class l0{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let n=0;n<i;++n){const r=e.getActiveUniform(t,n),a=e.getUniformLocation(t,r.name);l7(r,a,this)}}setValue(e,t,i,n){const r=this.map[t];r!==void 0&&r.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 r=0,a=t.length;r!==a;++r){const o=t[r],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,n)}}static seqWithValue(e,t){const i=[];for(let n=0,r=e.length;n!==r;++n){const a=e[n];a.id in t&&i.push(a)}return i}}function ZC(s,e,t){const i=s.createShader(e);return s.shaderSource(i,t),s.compileShader(i),i}const c7=37297;let h7=0;function d7(s,e){const t=s.split(`
|
||
`),i=[],n=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=n;a<r;a++){const o=a+1;i.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return i.join(`
|
||
`)}const JC=new Tt;function u7(s){jt._getMatrix(JC,jt.workingColorSpace,s);const e=`mat3( ${JC.elements.map(t=>t.toFixed(4))} )`;switch(jt.getTransfer(s)){case Og:return[e,"LinearTransferOETF"];case ni:return[e,"sRGBTransferOETF"];default:return Mt("WebGLProgram: Unsupported color space: ",s),[e,"LinearTransferOETF"]}}function e2(s,e,t){const i=s.getShaderParameter(e,s.COMPILE_STATUS),n=(s.getShaderInfoLog(e)||"").trim();if(i&&n==="")return"";const r=/ERROR: 0:(\d+)/.exec(n);if(r){const a=parseInt(r[1]);return t.toUpperCase()+`
|
||
|
||
`+n+`
|
||
|
||
`+d7(s.getShaderSource(e),a)}else return n}function p7(s,e){const t=u7(e);return[`vec4 ${s}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
||
`)}function f7(s,e){let t;switch(e){case AN:t="Linear";break;case bN:t="Reinhard";break;case yN:t="Cineon";break;case xN:t="ACESFilmic";break;case wN:t="AgX";break;case EN:t="Neutral";break;case _N:t="Custom";break;default:Mt("WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+s+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const c0=new Ne;function m7(){jt.getLuminanceCoefficients(c0);const s=c0.x.toFixed(4),e=c0.y.toFixed(4),t=c0.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${s}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
||
`)}function g7(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(tp).join(`
|
||
`)}function v7(s){const e=[];for(const t in s){const i=s[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
|
||
`)}function A7(s,e){const t={},i=s.getProgramParameter(e,s.ACTIVE_ATTRIBUTES);for(let n=0;n<i;n++){const r=s.getActiveAttrib(e,n),a=r.name;let o=1;r.type===s.FLOAT_MAT2&&(o=2),r.type===s.FLOAT_MAT3&&(o=3),r.type===s.FLOAT_MAT4&&(o=4),t[a]={type:r.type,location:s.getAttribLocation(e,a),locationSize:o}}return t}function tp(s){return s!==""}function t2(s,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return s.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 i2(s,e){return s.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const b7=/^[ \t]*#include +<([\w\d./]+)>/gm;function Cx(s){return s.replace(b7,x7)}const y7=new Map;function x7(s,e){let t=Dt[e];if(t===void 0){const i=y7.get(e);if(i!==void 0)t=Dt[i],Mt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return Cx(t)}const _7=/#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 n2(s){return s.replace(_7,w7)}function w7(s,e,t,i){let n="";for(let r=parseInt(e);r<parseInt(t);r++)n+=i.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return n}function s2(s){let e=`precision ${s.precision} float;
|
||
precision ${s.precision} int;
|
||
precision ${s.precision} sampler2D;
|
||
precision ${s.precision} samplerCube;
|
||
precision ${s.precision} sampler3D;
|
||
precision ${s.precision} sampler2DArray;
|
||
precision ${s.precision} sampler2DShadow;
|
||
precision ${s.precision} samplerCubeShadow;
|
||
precision ${s.precision} sampler2DArrayShadow;
|
||
precision ${s.precision} isampler2D;
|
||
precision ${s.precision} isampler3D;
|
||
precision ${s.precision} isamplerCube;
|
||
precision ${s.precision} isampler2DArray;
|
||
precision ${s.precision} usampler2D;
|
||
precision ${s.precision} usampler3D;
|
||
precision ${s.precision} usamplerCube;
|
||
precision ${s.precision} usampler2DArray;
|
||
`;return s.precision==="highp"?e+=`
|
||
#define HIGH_PRECISION`:s.precision==="mediump"?e+=`
|
||
#define MEDIUM_PRECISION`:s.precision==="lowp"&&(e+=`
|
||
#define LOW_PRECISION`),e}function E7(s){let e="SHADOWMAP_TYPE_BASIC";return s.shadowMapType===NS?e="SHADOWMAP_TYPE_PCF":s.shadowMapType===US?e="SHADOWMAP_TYPE_PCF_SOFT":s.shadowMapType===la&&(e="SHADOWMAP_TYPE_VSM"),e}function M7(s){let e="ENVMAP_TYPE_CUBE";if(s.envMap)switch(s.envMapMode){case wh:case Eh:e="ENVMAP_TYPE_CUBE";break;case Pg:e="ENVMAP_TYPE_CUBE_UV";break}return e}function S7(s){let e="ENVMAP_MODE_REFLECTION";return s.envMap&&s.envMapMode===Eh&&(e="ENVMAP_MODE_REFRACTION"),e}function C7(s){let e="ENVMAP_BLENDING_NONE";if(s.envMap)switch(s.combine){case VS:e="ENVMAP_BLENDING_MULTIPLY";break;case gN:e="ENVMAP_BLENDING_MIX";break;case vN:e="ENVMAP_BLENDING_ADD";break}return e}function T7(s){const e=s.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 I7(s,e,t,i){const n=s.getContext(),r=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=E7(t),c=M7(t),h=S7(t),d=C7(t),u=T7(t),p=g7(t),m=v7(r),v=n.createProgram();let g,f,A=t.glslVersion?"#version "+t.glslVersion+`
|
||
`:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(tp).join(`
|
||
`),g.length>0&&(g+=`
|
||
`),f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(tp).join(`
|
||
`),f.length>0&&(f+=`
|
||
`)):(g=[s2(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,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(tp).join(`
|
||
`),f=[s2(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,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:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.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!==go?"#define TONE_MAPPING":"",t.toneMapping!==go?Dt.tonemapping_pars_fragment:"",t.toneMapping!==go?f7("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Dt.colorspace_pars_fragment,p7("linearToOutputTexel",t.outputColorSpace),m7(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
||
`].filter(tp).join(`
|
||
`)),a=Cx(a),a=t2(a,t),a=i2(a,t),o=Cx(o),o=t2(o,t),o=i2(o,t),a=n2(a),o=n2(o),t.isRawShaderMaterial!==!0&&(A=`#version 300 es
|
||
`,g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
||
`)+`
|
||
`+g,f=["#define varying in",t.glslVersion===tC?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===tC?"":"#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=A+g+a,y=A+f+o,x=ZC(n,n.VERTEX_SHADER,b),_=ZC(n,n.FRAGMENT_SHADER,y);n.attachShader(v,x),n.attachShader(v,_),t.index0AttributeName!==void 0?n.bindAttribLocation(v,0,t.index0AttributeName):t.morphTargets===!0&&n.bindAttribLocation(v,0,"position"),n.linkProgram(v);function M(R){if(s.debug.checkShaderErrors){const D=n.getProgramInfoLog(v)||"",L=n.getShaderInfoLog(x)||"",I=n.getShaderInfoLog(_)||"",O=D.trim(),N=L.trim(),G=I.trim();let V=!0,H=!0;if(n.getProgramParameter(v,n.LINK_STATUS)===!1)if(V=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(n,v,x,_);else{const J=e2(n,x,"vertex"),W=e2(n,_,"fragment");Ni("THREE.WebGLProgram: Shader Error "+n.getError()+" - VALIDATE_STATUS "+n.getProgramParameter(v,n.VALIDATE_STATUS)+`
|
||
|
||
Material Name: `+R.name+`
|
||
Material Type: `+R.type+`
|
||
|
||
Program Info Log: `+O+`
|
||
`+J+`
|
||
`+W)}else O!==""?Mt("WebGLProgram: Program Info Log:",O):(N===""||G==="")&&(H=!1);H&&(R.diagnostics={runnable:V,programLog:O,vertexShader:{log:N,prefix:g},fragmentShader:{log:G,prefix:f}})}n.deleteShader(x),n.deleteShader(_),E=new l0(n,v),w=A7(n,v)}let E;this.getUniforms=function(){return E===void 0&&M(this),E};let w;this.getAttributes=function(){return w===void 0&&M(this),w};let T=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return T===!1&&(T=n.getProgramParameter(v,c7)),T},this.destroy=function(){i.releaseStatesOfProgram(this),n.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=h7++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=x,this.fragmentShader=_,this}let P7=0;class D7{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,n=this._getShaderStage(t),r=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return a.has(n)===!1&&(a.add(n),n.usedTimes++),a.has(r)===!1&&(a.add(r),r.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 R7(e),t.set(e,i)),i}}class R7{constructor(e){this.id=P7++,this.code=e,this.usedTimes=0}}function B7(s,e,t,i,n,r,a){const o=new dC,l=new D7,c=new Set,h=[],d=n.logarithmicDepthBuffer,u=n.vertexTextures;let p=n.precision;const m={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 v(w){return c.add(w),w===0?"uv":`uv${w}`}function g(w,T,R,D,L){const I=D.fog,O=L.geometry,N=w.isMeshStandardMaterial?D.environment:null,G=(w.isMeshStandardMaterial?t:e).get(w.envMap||N),V=G&&G.mapping===Pg?G.image.height:null,H=m[w.type];w.precision!==null&&(p=n.getMaxPrecision(w.precision),p!==w.precision&&Mt("WebGLProgram.getParameters:",w.precision,"not supported, using",p,"instead."));const J=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,W=J!==void 0?J.length:0;let X=0;O.morphAttributes.position!==void 0&&(X=1),O.morphAttributes.normal!==void 0&&(X=2),O.morphAttributes.color!==void 0&&(X=3);let me,Ee,Me,$;if(H){const ut=Or[H];me=ut.vertexShader,Ee=ut.fragmentShader}else me=w.vertexShader,Ee=w.fragmentShader,l.update(w),Me=l.getVertexShaderID(w),$=l.getFragmentShaderID(w);const se=s.getRenderTarget(),he=s.state.buffers.depth.getReversed(),Te=L.isInstancedMesh===!0,Le=L.isBatchedMesh===!0,Oe=!!w.map,tt=!!w.matcap,Ye=!!G,B=!!w.aoMap,re=!!w.lightMap,ee=!!w.bumpMap,Q=!!w.normalMap,k=!!w.displacementMap,ie=!!w.emissiveMap,fe=!!w.metalnessMap,xe=!!w.roughnessMap,te=w.anisotropy>0,C=w.clearcoat>0,S=w.dispersion>0,F=w.iridescence>0,q=w.sheen>0,K=w.transmission>0,Y=te&&!!w.anisotropyMap,ye=C&&!!w.clearcoatMap,pe=C&&!!w.clearcoatNormalMap,Ue=C&&!!w.clearcoatRoughnessMap,He=F&&!!w.iridescenceMap,oe=F&&!!w.iridescenceThicknessMap,we=q&&!!w.sheenColorMap,Ve=q&&!!w.sheenRoughnessMap,Fe=!!w.specularMap,Ie=!!w.specularColorMap,$e=!!w.specularIntensityMap,z=K&&!!w.transmissionMap,_e=K&&!!w.thicknessMap,ve=!!w.gradientMap,Be=!!w.alphaMap,ge=w.alphaTest>0,ne=!!w.alphaHash,ze=!!w.extensions;let je=go;w.toneMapped&&(se===null||se.isXRRenderTarget===!0)&&(je=s.toneMapping);const vt={shaderID:H,shaderType:w.type,shaderName:w.name,vertexShader:me,fragmentShader:Ee,defines:w.defines,customVertexShaderID:Me,customFragmentShaderID:$,isRawShaderMaterial:w.isRawShaderMaterial===!0,glslVersion:w.glslVersion,precision:p,batching:Le,batchingColor:Le&&L._colorsTexture!==null,instancing:Te,instancingColor:Te&&L.instanceColor!==null,instancingMorph:Te&&L.morphTexture!==null,supportsVertexTextures:u,outputColorSpace:se===null?s.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:Sh,alphaToCoverage:!!w.alphaToCoverage,map:Oe,matcap:tt,envMap:Ye,envMapMode:Ye&&G.mapping,envMapCubeUVHeight:V,aoMap:B,lightMap:re,bumpMap:ee,normalMap:Q,displacementMap:u&&k,emissiveMap:ie,normalMapObjectSpace:Q&&w.normalMapType===IN,normalMapTangentSpace:Q&&w.normalMapType===TN,metalnessMap:fe,roughnessMap:xe,anisotropy:te,anisotropyMap:Y,clearcoat:C,clearcoatMap:ye,clearcoatNormalMap:pe,clearcoatRoughnessMap:Ue,dispersion:S,iridescence:F,iridescenceMap:He,iridescenceThicknessMap:oe,sheen:q,sheenColorMap:we,sheenRoughnessMap:Ve,specularMap:Fe,specularColorMap:Ie,specularIntensityMap:$e,transmission:K,transmissionMap:z,thicknessMap:_e,gradientMap:ve,opaque:w.transparent===!1&&w.blending===xh&&w.alphaToCoverage===!1,alphaMap:Be,alphaTest:ge,alphaHash:ne,combine:w.combine,mapUv:Oe&&v(w.map.channel),aoMapUv:B&&v(w.aoMap.channel),lightMapUv:re&&v(w.lightMap.channel),bumpMapUv:ee&&v(w.bumpMap.channel),normalMapUv:Q&&v(w.normalMap.channel),displacementMapUv:k&&v(w.displacementMap.channel),emissiveMapUv:ie&&v(w.emissiveMap.channel),metalnessMapUv:fe&&v(w.metalnessMap.channel),roughnessMapUv:xe&&v(w.roughnessMap.channel),anisotropyMapUv:Y&&v(w.anisotropyMap.channel),clearcoatMapUv:ye&&v(w.clearcoatMap.channel),clearcoatNormalMapUv:pe&&v(w.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ue&&v(w.clearcoatRoughnessMap.channel),iridescenceMapUv:He&&v(w.iridescenceMap.channel),iridescenceThicknessMapUv:oe&&v(w.iridescenceThicknessMap.channel),sheenColorMapUv:we&&v(w.sheenColorMap.channel),sheenRoughnessMapUv:Ve&&v(w.sheenRoughnessMap.channel),specularMapUv:Fe&&v(w.specularMap.channel),specularColorMapUv:Ie&&v(w.specularColorMap.channel),specularIntensityMapUv:$e&&v(w.specularIntensityMap.channel),transmissionMapUv:z&&v(w.transmissionMap.channel),thicknessMapUv:_e&&v(w.thicknessMap.channel),alphaMapUv:Be&&v(w.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&(Q||te),vertexColors:w.vertexColors,vertexAlphas:w.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,pointsUvs:L.isPoints===!0&&!!O.attributes.uv&&(Oe||Be),fog:!!I,useFog:w.fog===!0,fogExp2:!!I&&I.isFogExp2,flatShading:w.flatShading===!0&&w.wireframe===!1,sizeAttenuation:w.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:he,skinning:L.isSkinnedMesh===!0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:W,morphTextureStride:X,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:w.dithering,shadowMapEnabled:s.shadowMap.enabled&&R.length>0,shadowMapType:s.shadowMap.type,toneMapping:je,decodeVideoTexture:Oe&&w.map.isVideoTexture===!0&&jt.getTransfer(w.map.colorSpace)===ni,decodeVideoTextureEmissive:ie&&w.emissiveMap.isVideoTexture===!0&&jt.getTransfer(w.emissiveMap.colorSpace)===ni,premultipliedAlpha:w.premultipliedAlpha,doubleSided:w.side===ca,flipSided:w.side===es,useDepthPacking:w.depthPacking>=0,depthPacking:w.depthPacking||0,index0AttributeName:w.index0AttributeName,extensionClipCullDistance:ze&&w.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ze&&w.extensions.multiDraw===!0||Le)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:w.customProgramCacheKey()};return vt.vertexUv1s=c.has(1),vt.vertexUv2s=c.has(2),vt.vertexUv3s=c.has(3),c.clear(),vt}function f(w){const T=[];if(w.shaderID?T.push(w.shaderID):(T.push(w.customVertexShaderID),T.push(w.customFragmentShaderID)),w.defines!==void 0)for(const R in w.defines)T.push(R),T.push(w.defines[R]);return w.isRawShaderMaterial===!1&&(A(T,w),b(T,w),T.push(s.outputColorSpace)),T.push(w.customProgramCacheKey),T.join()}function A(w,T){w.push(T.precision),w.push(T.outputColorSpace),w.push(T.envMapMode),w.push(T.envMapCubeUVHeight),w.push(T.mapUv),w.push(T.alphaMapUv),w.push(T.lightMapUv),w.push(T.aoMapUv),w.push(T.bumpMapUv),w.push(T.normalMapUv),w.push(T.displacementMapUv),w.push(T.emissiveMapUv),w.push(T.metalnessMapUv),w.push(T.roughnessMapUv),w.push(T.anisotropyMapUv),w.push(T.clearcoatMapUv),w.push(T.clearcoatNormalMapUv),w.push(T.clearcoatRoughnessMapUv),w.push(T.iridescenceMapUv),w.push(T.iridescenceThicknessMapUv),w.push(T.sheenColorMapUv),w.push(T.sheenRoughnessMapUv),w.push(T.specularMapUv),w.push(T.specularColorMapUv),w.push(T.specularIntensityMapUv),w.push(T.transmissionMapUv),w.push(T.thicknessMapUv),w.push(T.combine),w.push(T.fogExp2),w.push(T.sizeAttenuation),w.push(T.morphTargetsCount),w.push(T.morphAttributeCount),w.push(T.numDirLights),w.push(T.numPointLights),w.push(T.numSpotLights),w.push(T.numSpotLightMaps),w.push(T.numHemiLights),w.push(T.numRectAreaLights),w.push(T.numDirLightShadows),w.push(T.numPointLightShadows),w.push(T.numSpotLightShadows),w.push(T.numSpotLightShadowsWithMaps),w.push(T.numLightProbes),w.push(T.shadowMapType),w.push(T.toneMapping),w.push(T.numClippingPlanes),w.push(T.numClipIntersection),w.push(T.depthPacking)}function b(w,T){o.disableAll(),T.supportsVertexTextures&&o.enable(0),T.instancing&&o.enable(1),T.instancingColor&&o.enable(2),T.instancingMorph&&o.enable(3),T.matcap&&o.enable(4),T.envMap&&o.enable(5),T.normalMapObjectSpace&&o.enable(6),T.normalMapTangentSpace&&o.enable(7),T.clearcoat&&o.enable(8),T.iridescence&&o.enable(9),T.alphaTest&&o.enable(10),T.vertexColors&&o.enable(11),T.vertexAlphas&&o.enable(12),T.vertexUv1s&&o.enable(13),T.vertexUv2s&&o.enable(14),T.vertexUv3s&&o.enable(15),T.vertexTangents&&o.enable(16),T.anisotropy&&o.enable(17),T.alphaHash&&o.enable(18),T.batching&&o.enable(19),T.dispersion&&o.enable(20),T.batchingColor&&o.enable(21),T.gradientMap&&o.enable(22),w.push(o.mask),o.disableAll(),T.fog&&o.enable(0),T.useFog&&o.enable(1),T.flatShading&&o.enable(2),T.logarithmicDepthBuffer&&o.enable(3),T.reversedDepthBuffer&&o.enable(4),T.skinning&&o.enable(5),T.morphTargets&&o.enable(6),T.morphNormals&&o.enable(7),T.morphColors&&o.enable(8),T.premultipliedAlpha&&o.enable(9),T.shadowMapEnabled&&o.enable(10),T.doubleSided&&o.enable(11),T.flipSided&&o.enable(12),T.useDepthPacking&&o.enable(13),T.dithering&&o.enable(14),T.transmission&&o.enable(15),T.sheen&&o.enable(16),T.opaque&&o.enable(17),T.pointsUvs&&o.enable(18),T.decodeVideoTexture&&o.enable(19),T.decodeVideoTextureEmissive&&o.enable(20),T.alphaToCoverage&&o.enable(21),w.push(o.mask)}function y(w){const T=m[w.type];let R;if(T){const D=Or[T];R=rU.clone(D.uniforms)}else R=w.uniforms;return R}function x(w,T){let R;for(let D=0,L=h.length;D<L;D++){const I=h[D];if(I.cacheKey===T){R=I,++R.usedTimes;break}}return R===void 0&&(R=new I7(s,T,w,r),h.push(R)),R}function _(w){if(--w.usedTimes===0){const T=h.indexOf(w);h[T]=h[h.length-1],h.pop(),w.destroy()}}function M(w){l.remove(w)}function E(){l.dispose()}return{getParameters:g,getProgramCacheKey:f,getUniforms:y,acquireProgram:x,releaseProgram:_,releaseShaderCache:M,programs:h,dispose:E}}function L7(){let s=new WeakMap;function e(a){return s.has(a)}function t(a){let o=s.get(a);return o===void 0&&(o={},s.set(a,o)),o}function i(a){s.delete(a)}function n(a,o,l){s.get(a)[o]=l}function r(){s=new WeakMap}return{has:e,get:t,remove:i,update:n,dispose:r}}function k7(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.z!==e.z?s.z-e.z:s.id-e.id}function r2(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function a2(){const s=[];let e=0;const t=[],i=[],n=[];function r(){e=0,t.length=0,i.length=0,n.length=0}function a(d,u,p,m,v,g){let f=s[e];return f===void 0?(f={id:d.id,object:d,geometry:u,material:p,groupOrder:m,renderOrder:d.renderOrder,z:v,group:g},s[e]=f):(f.id=d.id,f.object=d,f.geometry=u,f.material=p,f.groupOrder=m,f.renderOrder=d.renderOrder,f.z=v,f.group=g),e++,f}function o(d,u,p,m,v,g){const f=a(d,u,p,m,v,g);p.transmission>0?i.push(f):p.transparent===!0?n.push(f):t.push(f)}function l(d,u,p,m,v,g){const f=a(d,u,p,m,v,g);p.transmission>0?i.unshift(f):p.transparent===!0?n.unshift(f):t.unshift(f)}function c(d,u){t.length>1&&t.sort(d||k7),i.length>1&&i.sort(u||r2),n.length>1&&n.sort(u||r2)}function h(){for(let d=e,u=s.length;d<u;d++){const p=s[d];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:i,transparent:n,init:r,push:o,unshift:l,finish:h,sort:c}}function O7(){let s=new WeakMap;function e(i,n){const r=s.get(i);let a;return r===void 0?(a=new a2,s.set(i,[a])):n>=r.length?(a=new a2,r.push(a)):a=r[n],a}function t(){s=new WeakMap}return{get:e,dispose:t}}function F7(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new Ne,color:new ri};break;case"SpotLight":t={position:new Ne,direction:new Ne,color:new ri,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new Ne,color:new ri,distance:0,decay:0};break;case"HemisphereLight":t={direction:new Ne,skyColor:new ri,groundColor:new ri};break;case"RectAreaLight":t={color:new ri,position:new Ne,halfWidth:new Ne,halfHeight:new Ne};break}return s[e.id]=t,t}}}function N7(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new si};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new si};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new si,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let U7=0;function z7(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function H7(s){const e=new F7,t=N7(),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 Ne);const n=new Ne,r=new tn,a=new tn;function o(c){let h=0,d=0,u=0;for(let w=0;w<9;w++)i.probe[w].set(0,0,0);let p=0,m=0,v=0,g=0,f=0,A=0,b=0,y=0,x=0,_=0,M=0;c.sort(z7);for(let w=0,T=c.length;w<T;w++){const R=c[w],D=R.color,L=R.intensity,I=R.distance,O=R.shadow&&R.shadow.map?R.shadow.map.texture:null;if(R.isAmbientLight)h+=D.r*L,d+=D.g*L,u+=D.b*L;else if(R.isLightProbe){for(let N=0;N<9;N++)i.probe[N].addScaledVector(R.sh.coefficients[N],L);M++}else if(R.isDirectionalLight){const N=e.get(R);if(N.color.copy(R.color).multiplyScalar(R.intensity),R.castShadow){const G=R.shadow,V=t.get(R);V.shadowIntensity=G.intensity,V.shadowBias=G.bias,V.shadowNormalBias=G.normalBias,V.shadowRadius=G.radius,V.shadowMapSize=G.mapSize,i.directionalShadow[p]=V,i.directionalShadowMap[p]=O,i.directionalShadowMatrix[p]=R.shadow.matrix,A++}i.directional[p]=N,p++}else if(R.isSpotLight){const N=e.get(R);N.position.setFromMatrixPosition(R.matrixWorld),N.color.copy(D).multiplyScalar(L),N.distance=I,N.coneCos=Math.cos(R.angle),N.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),N.decay=R.decay,i.spot[v]=N;const G=R.shadow;if(R.map&&(i.spotLightMap[x]=R.map,x++,G.updateMatrices(R),R.castShadow&&_++),i.spotLightMatrix[v]=G.matrix,R.castShadow){const V=t.get(R);V.shadowIntensity=G.intensity,V.shadowBias=G.bias,V.shadowNormalBias=G.normalBias,V.shadowRadius=G.radius,V.shadowMapSize=G.mapSize,i.spotShadow[v]=V,i.spotShadowMap[v]=O,y++}v++}else if(R.isRectAreaLight){const N=e.get(R);N.color.copy(D).multiplyScalar(L),N.halfWidth.set(R.width*.5,0,0),N.halfHeight.set(0,R.height*.5,0),i.rectArea[g]=N,g++}else if(R.isPointLight){const N=e.get(R);if(N.color.copy(R.color).multiplyScalar(R.intensity),N.distance=R.distance,N.decay=R.decay,R.castShadow){const G=R.shadow,V=t.get(R);V.shadowIntensity=G.intensity,V.shadowBias=G.bias,V.shadowNormalBias=G.normalBias,V.shadowRadius=G.radius,V.shadowMapSize=G.mapSize,V.shadowCameraNear=G.camera.near,V.shadowCameraFar=G.camera.far,i.pointShadow[m]=V,i.pointShadowMap[m]=O,i.pointShadowMatrix[m]=R.shadow.matrix,b++}i.point[m]=N,m++}else if(R.isHemisphereLight){const N=e.get(R);N.skyColor.copy(R.color).multiplyScalar(L),N.groundColor.copy(R.groundColor).multiplyScalar(L),i.hemi[f]=N,f++}}g>0&&(s.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=nt.LTC_FLOAT_1,i.rectAreaLTC2=nt.LTC_FLOAT_2):(i.rectAreaLTC1=nt.LTC_HALF_1,i.rectAreaLTC2=nt.LTC_HALF_2)),i.ambient[0]=h,i.ambient[1]=d,i.ambient[2]=u;const E=i.hash;(E.directionalLength!==p||E.pointLength!==m||E.spotLength!==v||E.rectAreaLength!==g||E.hemiLength!==f||E.numDirectionalShadows!==A||E.numPointShadows!==b||E.numSpotShadows!==y||E.numSpotMaps!==x||E.numLightProbes!==M)&&(i.directional.length=p,i.spot.length=v,i.rectArea.length=g,i.point.length=m,i.hemi.length=f,i.directionalShadow.length=A,i.directionalShadowMap.length=A,i.pointShadow.length=b,i.pointShadowMap.length=b,i.spotShadow.length=y,i.spotShadowMap.length=y,i.directionalShadowMatrix.length=A,i.pointShadowMatrix.length=b,i.spotLightMatrix.length=y+x-_,i.spotLightMap.length=x,i.numSpotLightShadowsWithMaps=_,i.numLightProbes=M,E.directionalLength=p,E.pointLength=m,E.spotLength=v,E.rectAreaLength=g,E.hemiLength=f,E.numDirectionalShadows=A,E.numPointShadows=b,E.numSpotShadows=y,E.numSpotMaps=x,E.numLightProbes=M,i.version=U7++)}function l(c,h){let d=0,u=0,p=0,m=0,v=0;const g=h.matrixWorldInverse;for(let f=0,A=c.length;f<A;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[p];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),p++}else if(b.isRectAreaLight){const y=i.rectArea[m];y.position.setFromMatrixPosition(b.matrixWorld),y.position.applyMatrix4(g),a.identity(),r.copy(b.matrixWorld),r.premultiply(g),a.extractRotation(r),y.halfWidth.set(b.width*.5,0,0),y.halfHeight.set(0,b.height*.5,0),y.halfWidth.applyMatrix4(a),y.halfHeight.applyMatrix4(a),m++}else if(b.isPointLight){const y=i.point[u];y.position.setFromMatrixPosition(b.matrixWorld),y.position.applyMatrix4(g),u++}else if(b.isHemisphereLight){const y=i.hemi[v];y.direction.setFromMatrixPosition(b.matrixWorld),y.direction.transformDirection(g),v++}}}return{setup:o,setupView:l,state:i}}function o2(s){const e=new H7(s),t=[],i=[];function n(h){c.camera=h,t.length=0,i.length=0}function r(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:r,pushShadow:a}}function G7(s){let e=new WeakMap;function t(n,r=0){const a=e.get(n);let o;return a===void 0?(o=new o2(s),e.set(n,[o])):r>=a.length?(o=new o2(s),a.push(o)):o=a[r],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const V7=`void main() {
|
||
gl_Position = vec4( position, 1.0 );
|
||
}`,W7=`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 Q7(s,e,t){let i=new PC;const n=new si,r=new si,a=new Ui,o=new mU({depthPacking:CN}),l=new gU,c={},h=t.maxTextureSize,d={[mo]:es,[es]:mo,[ca]:ca},u=new ya({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new si},radius:{value:4}},vertexShader:V7,fragmentShader:W7}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const m=new wo;m.setAttribute("position",new kr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Eo(m,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=NS;let f=this.type;this.render=function(_,M,E){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||_.length===0)return;const w=s.getRenderTarget(),T=s.getActiveCubeFace(),R=s.getActiveMipmapLevel(),D=s.state;D.setBlending(ha),D.buffers.depth.getReversed()===!0?D.buffers.color.setClear(0,0,0,0):D.buffers.color.setClear(1,1,1,1),D.buffers.depth.setTest(!0),D.setScissorTest(!1);const L=f!==la&&this.type===la,I=f===la&&this.type!==la;for(let O=0,N=_.length;O<N;O++){const G=_[O],V=G.shadow;if(V===void 0){Mt("WebGLShadowMap:",G,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;n.copy(V.mapSize);const H=V.getFrameExtents();if(n.multiply(H),r.copy(V.mapSize),(n.x>h||n.y>h)&&(n.x>h&&(r.x=Math.floor(h/H.x),n.x=r.x*H.x,V.mapSize.x=r.x),n.y>h&&(r.y=Math.floor(h/H.y),n.y=r.y*H.y,V.mapSize.y=r.y)),V.map===null||L===!0||I===!0){const W=this.type!==la?{minFilter:gs,magFilter:gs}:{};V.map!==null&&V.map.dispose(),V.map=new kl(n.x,n.y,W),V.map.texture.name=G.name+".shadowMap",V.camera.updateProjectionMatrix()}s.setRenderTarget(V.map),s.clear();const J=V.getViewportCount();for(let W=0;W<J;W++){const X=V.getViewport(W);a.set(r.x*X.x,r.y*X.y,r.x*X.z,r.y*X.w),D.viewport(a),V.updateMatrices(G,W),i=V.getFrustum(),y(M,E,V.camera,G,this.type)}V.isPointLightShadow!==!0&&this.type===la&&A(V,E),V.needsUpdate=!1}f=this.type,g.needsUpdate=!1,s.setRenderTarget(w,T,R)};function A(_,M){const E=e.update(v);u.defines.VSM_SAMPLES!==_.blurSamples&&(u.defines.VSM_SAMPLES=_.blurSamples,p.defines.VSM_SAMPLES=_.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),_.mapPass===null&&(_.mapPass=new kl(n.x,n.y)),u.uniforms.shadow_pass.value=_.map.texture,u.uniforms.resolution.value=_.mapSize,u.uniforms.radius.value=_.radius,s.setRenderTarget(_.mapPass),s.clear(),s.renderBufferDirect(M,null,E,u,v,null),p.uniforms.shadow_pass.value=_.mapPass.texture,p.uniforms.resolution.value=_.mapSize,p.uniforms.radius.value=_.radius,s.setRenderTarget(_.map),s.clear(),s.renderBufferDirect(M,null,E,p,v,null)}function b(_,M,E,w){let T=null;const R=E.isPointLight===!0?_.customDistanceMaterial:_.customDepthMaterial;if(R!==void 0)T=R;else if(T=E.isPointLight===!0?l:o,s.localClippingEnabled&&M.clipShadows===!0&&Array.isArray(M.clippingPlanes)&&M.clippingPlanes.length!==0||M.displacementMap&&M.displacementScale!==0||M.alphaMap&&M.alphaTest>0||M.map&&M.alphaTest>0||M.alphaToCoverage===!0){const D=T.uuid,L=M.uuid;let I=c[D];I===void 0&&(I={},c[D]=I);let O=I[L];O===void 0&&(O=T.clone(),I[L]=O,M.addEventListener("dispose",x)),T=O}if(T.visible=M.visible,T.wireframe=M.wireframe,w===la?T.side=M.shadowSide!==null?M.shadowSide:M.side:T.side=M.shadowSide!==null?M.shadowSide:d[M.side],T.alphaMap=M.alphaMap,T.alphaTest=M.alphaToCoverage===!0?.5:M.alphaTest,T.map=M.map,T.clipShadows=M.clipShadows,T.clippingPlanes=M.clippingPlanes,T.clipIntersection=M.clipIntersection,T.displacementMap=M.displacementMap,T.displacementScale=M.displacementScale,T.displacementBias=M.displacementBias,T.wireframeLinewidth=M.wireframeLinewidth,T.linewidth=M.linewidth,E.isPointLight===!0&&T.isMeshDistanceMaterial===!0){const D=s.properties.get(T);D.light=E}return T}function y(_,M,E,w,T){if(_.visible===!1)return;if(_.layers.test(M.layers)&&(_.isMesh||_.isLine||_.isPoints)&&(_.castShadow||_.receiveShadow&&T===la)&&(!_.frustumCulled||i.intersectsObject(_))){_.modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,_.matrixWorld);const D=e.update(_),L=_.material;if(Array.isArray(L)){const I=D.groups;for(let O=0,N=I.length;O<N;O++){const G=I[O],V=L[G.materialIndex];if(V&&V.visible){const H=b(_,V,w,T);_.onBeforeShadow(s,_,M,E,D,H,G),s.renderBufferDirect(E,null,D,H,_,G),_.onAfterShadow(s,_,M,E,D,H,G)}}}else if(L.visible){const I=b(_,L,w,T);_.onBeforeShadow(s,_,M,E,D,I,null),s.renderBufferDirect(E,null,D,I,_,null),_.onAfterShadow(s,_,M,E,D,I,null)}}const R=_.children;for(let D=0,L=R.length;D<L;D++)y(R[D],M,E,w,T)}function x(_){_.target.removeEventListener("dispose",x);for(const M in c){const E=c[M],w=_.target.uuid;w in E&&(E[w].dispose(),delete E[w])}}}const j7={[iy]:ny,[sy]:oy,[ry]:ly,[_h]:ay,[ny]:iy,[oy]:sy,[ly]:ry,[ay]:_h};function X7(s,e){function t(){let z=!1;const _e=new Ui;let ve=null;const Be=new Ui(0,0,0,0);return{setMask:function(ge){ve!==ge&&!z&&(s.colorMask(ge,ge,ge,ge),ve=ge)},setLocked:function(ge){z=ge},setClear:function(ge,ne,ze,je,vt){vt===!0&&(ge*=je,ne*=je,ze*=je),_e.set(ge,ne,ze,je),Be.equals(_e)===!1&&(s.clearColor(ge,ne,ze,je),Be.copy(_e))},reset:function(){z=!1,ve=null,Be.set(-1,0,0,0)}}}function i(){let z=!1,_e=!1,ve=null,Be=null,ge=null;return{setReversed:function(ne){if(_e!==ne){const ze=e.get("EXT_clip_control");ne?ze.clipControlEXT(ze.LOWER_LEFT_EXT,ze.ZERO_TO_ONE_EXT):ze.clipControlEXT(ze.LOWER_LEFT_EXT,ze.NEGATIVE_ONE_TO_ONE_EXT),_e=ne;const je=ge;ge=null,this.setClear(je)}},getReversed:function(){return _e},setTest:function(ne){ne?se(s.DEPTH_TEST):he(s.DEPTH_TEST)},setMask:function(ne){ve!==ne&&!z&&(s.depthMask(ne),ve=ne)},setFunc:function(ne){if(_e&&(ne=j7[ne]),Be!==ne){switch(ne){case iy:s.depthFunc(s.NEVER);break;case ny:s.depthFunc(s.ALWAYS);break;case sy:s.depthFunc(s.LESS);break;case _h:s.depthFunc(s.LEQUAL);break;case ry:s.depthFunc(s.EQUAL);break;case ay:s.depthFunc(s.GEQUAL);break;case oy:s.depthFunc(s.GREATER);break;case ly:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}Be=ne}},setLocked:function(ne){z=ne},setClear:function(ne){ge!==ne&&(_e&&(ne=1-ne),s.clearDepth(ne),ge=ne)},reset:function(){z=!1,ve=null,Be=null,ge=null,_e=!1}}}function n(){let z=!1,_e=null,ve=null,Be=null,ge=null,ne=null,ze=null,je=null,vt=null;return{setTest:function(ut){z||(ut?se(s.STENCIL_TEST):he(s.STENCIL_TEST))},setMask:function(ut){_e!==ut&&!z&&(s.stencilMask(ut),_e=ut)},setFunc:function(ut,Xi,Ht){(ve!==ut||Be!==Xi||ge!==Ht)&&(s.stencilFunc(ut,Xi,Ht),ve=ut,Be=Xi,ge=Ht)},setOp:function(ut,Xi,Ht){(ne!==ut||ze!==Xi||je!==Ht)&&(s.stencilOp(ut,Xi,Ht),ne=ut,ze=Xi,je=Ht)},setLocked:function(ut){z=ut},setClear:function(ut){vt!==ut&&(s.clearStencil(ut),vt=ut)},reset:function(){z=!1,_e=null,ve=null,Be=null,ge=null,ne=null,ze=null,je=null,vt=null}}}const r=new t,a=new i,o=new n,l=new WeakMap,c=new WeakMap;let h={},d={},u=new WeakMap,p=[],m=null,v=!1,g=null,f=null,A=null,b=null,y=null,x=null,_=null,M=new ri(0,0,0),E=0,w=!1,T=null,R=null,D=null,L=null,I=null;const O=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let N=!1,G=0;const V=s.getParameter(s.VERSION);V.indexOf("WebGL")!==-1?(G=parseFloat(/^WebGL (\d)/.exec(V)[1]),N=G>=1):V.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(V)[1]),N=G>=2);let H=null,J={};const W=s.getParameter(s.SCISSOR_BOX),X=s.getParameter(s.VIEWPORT),me=new Ui().fromArray(W),Ee=new Ui().fromArray(X);function Me(z,_e,ve,Be){const ge=new Uint8Array(4),ne=s.createTexture();s.bindTexture(z,ne),s.texParameteri(z,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(z,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let ze=0;ze<ve;ze++)z===s.TEXTURE_3D||z===s.TEXTURE_2D_ARRAY?s.texImage3D(_e,0,s.RGBA,1,1,Be,0,s.RGBA,s.UNSIGNED_BYTE,ge):s.texImage2D(_e+ze,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,ge);return ne}const $={};$[s.TEXTURE_2D]=Me(s.TEXTURE_2D,s.TEXTURE_2D,1),$[s.TEXTURE_CUBE_MAP]=Me(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),$[s.TEXTURE_2D_ARRAY]=Me(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),$[s.TEXTURE_3D]=Me(s.TEXTURE_3D,s.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),se(s.DEPTH_TEST),a.setFunc(_h),ee(!1),Q(FS),se(s.CULL_FACE),B(ha);function se(z){h[z]!==!0&&(s.enable(z),h[z]=!0)}function he(z){h[z]!==!1&&(s.disable(z),h[z]=!1)}function Te(z,_e){return d[z]!==_e?(s.bindFramebuffer(z,_e),d[z]=_e,z===s.DRAW_FRAMEBUFFER&&(d[s.FRAMEBUFFER]=_e),z===s.FRAMEBUFFER&&(d[s.DRAW_FRAMEBUFFER]=_e),!0):!1}function Le(z,_e){let ve=p,Be=!1;if(z){ve=u.get(_e),ve===void 0&&(ve=[],u.set(_e,ve));const ge=z.textures;if(ve.length!==ge.length||ve[0]!==s.COLOR_ATTACHMENT0){for(let ne=0,ze=ge.length;ne<ze;ne++)ve[ne]=s.COLOR_ATTACHMENT0+ne;ve.length=ge.length,Be=!0}}else ve[0]!==s.BACK&&(ve[0]=s.BACK,Be=!0);Be&&s.drawBuffers(ve)}function Oe(z){return m!==z?(s.useProgram(z),m=z,!0):!1}const tt={[Rl]:s.FUNC_ADD,[JF]:s.FUNC_SUBTRACT,[eN]:s.FUNC_REVERSE_SUBTRACT};tt[tN]=s.MIN,tt[iN]=s.MAX;const Ye={[nN]:s.ZERO,[sN]:s.ONE,[rN]:s.SRC_COLOR,[ey]:s.SRC_ALPHA,[dN]:s.SRC_ALPHA_SATURATE,[cN]:s.DST_COLOR,[oN]:s.DST_ALPHA,[aN]:s.ONE_MINUS_SRC_COLOR,[ty]:s.ONE_MINUS_SRC_ALPHA,[hN]:s.ONE_MINUS_DST_COLOR,[lN]:s.ONE_MINUS_DST_ALPHA,[uN]:s.CONSTANT_COLOR,[pN]:s.ONE_MINUS_CONSTANT_COLOR,[fN]:s.CONSTANT_ALPHA,[mN]:s.ONE_MINUS_CONSTANT_ALPHA};function B(z,_e,ve,Be,ge,ne,ze,je,vt,ut){if(z===ha){v===!0&&(he(s.BLEND),v=!1);return}if(v===!1&&(se(s.BLEND),v=!0),z!==ZF){if(z!==g||ut!==w){if((f!==Rl||y!==Rl)&&(s.blendEquation(s.FUNC_ADD),f=Rl,y=Rl),ut)switch(z){case xh:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case zS:s.blendFunc(s.ONE,s.ONE);break;case HS:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case GS:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:Ni("WebGLState: Invalid blending: ",z);break}else switch(z){case xh:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case zS:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case HS:Ni("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case GS:Ni("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ni("WebGLState: Invalid blending: ",z);break}A=null,b=null,x=null,_=null,M.set(0,0,0),E=0,g=z,w=ut}return}ge=ge||_e,ne=ne||ve,ze=ze||Be,(_e!==f||ge!==y)&&(s.blendEquationSeparate(tt[_e],tt[ge]),f=_e,y=ge),(ve!==A||Be!==b||ne!==x||ze!==_)&&(s.blendFuncSeparate(Ye[ve],Ye[Be],Ye[ne],Ye[ze]),A=ve,b=Be,x=ne,_=ze),(je.equals(M)===!1||vt!==E)&&(s.blendColor(je.r,je.g,je.b,vt),M.copy(je),E=vt),g=z,w=!1}function re(z,_e){z.side===ca?he(s.CULL_FACE):se(s.CULL_FACE);let ve=z.side===es;_e&&(ve=!ve),ee(ve),z.blending===xh&&z.transparent===!1?B(ha):B(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),r.setMask(z.colorWrite);const Be=z.stencilWrite;o.setTest(Be),Be&&(o.setMask(z.stencilWriteMask),o.setFunc(z.stencilFunc,z.stencilRef,z.stencilFuncMask),o.setOp(z.stencilFail,z.stencilZFail,z.stencilZPass)),ie(z.polygonOffset,z.polygonOffsetFactor,z.polygonOffsetUnits),z.alphaToCoverage===!0?se(s.SAMPLE_ALPHA_TO_COVERAGE):he(s.SAMPLE_ALPHA_TO_COVERAGE)}function ee(z){T!==z&&(z?s.frontFace(s.CW):s.frontFace(s.CCW),T=z)}function Q(z){z!==KF?(se(s.CULL_FACE),z!==R&&(z===FS?s.cullFace(s.BACK):z===$F?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):he(s.CULL_FACE),R=z}function k(z){z!==D&&(N&&s.lineWidth(z),D=z)}function ie(z,_e,ve){z?(se(s.POLYGON_OFFSET_FILL),(L!==_e||I!==ve)&&(s.polygonOffset(_e,ve),L=_e,I=ve)):he(s.POLYGON_OFFSET_FILL)}function fe(z){z?se(s.SCISSOR_TEST):he(s.SCISSOR_TEST)}function xe(z){z===void 0&&(z=s.TEXTURE0+O-1),H!==z&&(s.activeTexture(z),H=z)}function te(z,_e,ve){ve===void 0&&(H===null?ve=s.TEXTURE0+O-1:ve=H);let Be=J[ve];Be===void 0&&(Be={type:void 0,texture:void 0},J[ve]=Be),(Be.type!==z||Be.texture!==_e)&&(H!==ve&&(s.activeTexture(ve),H=ve),s.bindTexture(z,_e||$[z]),Be.type=z,Be.texture=_e)}function C(){const z=J[H];z!==void 0&&z.type!==void 0&&(s.bindTexture(z.type,null),z.type=void 0,z.texture=void 0)}function S(){try{s.compressedTexImage2D(...arguments)}catch(z){z("WebGLState:",z)}}function F(){try{s.compressedTexImage3D(...arguments)}catch(z){z("WebGLState:",z)}}function q(){try{s.texSubImage2D(...arguments)}catch(z){z("WebGLState:",z)}}function K(){try{s.texSubImage3D(...arguments)}catch(z){z("WebGLState:",z)}}function Y(){try{s.compressedTexSubImage2D(...arguments)}catch(z){z("WebGLState:",z)}}function ye(){try{s.compressedTexSubImage3D(...arguments)}catch(z){z("WebGLState:",z)}}function pe(){try{s.texStorage2D(...arguments)}catch(z){z("WebGLState:",z)}}function Ue(){try{s.texStorage3D(...arguments)}catch(z){z("WebGLState:",z)}}function He(){try{s.texImage2D(...arguments)}catch(z){z("WebGLState:",z)}}function oe(){try{s.texImage3D(...arguments)}catch(z){z("WebGLState:",z)}}function we(z){me.equals(z)===!1&&(s.scissor(z.x,z.y,z.z,z.w),me.copy(z))}function Ve(z){Ee.equals(z)===!1&&(s.viewport(z.x,z.y,z.z,z.w),Ee.copy(z))}function Fe(z,_e){let ve=c.get(_e);ve===void 0&&(ve=new WeakMap,c.set(_e,ve));let Be=ve.get(z);Be===void 0&&(Be=s.getUniformBlockIndex(_e,z.name),ve.set(z,Be))}function Ie(z,_e){const ve=c.get(_e).get(z);l.get(_e)!==ve&&(s.uniformBlockBinding(_e,ve,z.__bindingPointIndex),l.set(_e,ve))}function $e(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),a.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),h={},H=null,J={},d={},u=new WeakMap,p=[],m=null,v=!1,g=null,f=null,A=null,b=null,y=null,x=null,_=null,M=new ri(0,0,0),E=0,w=!1,T=null,R=null,D=null,L=null,I=null,me.set(0,0,s.canvas.width,s.canvas.height),Ee.set(0,0,s.canvas.width,s.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:se,disable:he,bindFramebuffer:Te,drawBuffers:Le,useProgram:Oe,setBlending:B,setMaterial:re,setFlipSided:ee,setCullFace:Q,setLineWidth:k,setPolygonOffset:ie,setScissorTest:fe,activeTexture:xe,bindTexture:te,unbindTexture:C,compressedTexImage2D:S,compressedTexImage3D:F,texImage2D:He,texImage3D:oe,updateUBOMapping:Fe,uniformBlockBinding:Ie,texStorage2D:pe,texStorage3D:Ue,texSubImage2D:q,texSubImage3D:K,compressedTexSubImage2D:Y,compressedTexSubImage3D:ye,scissor:we,viewport:Ve,reset:$e}}function q7(s,e,t,i,n,r,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 si,h=new WeakMap;let d;const u=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(C,S){return p?new OffscreenCanvas(C,S):Ng("canvas")}function v(C,S,F){let q=1;const K=te(C);if((K.width>F||K.height>F)&&(q=F/Math.max(K.width,K.height)),q<1)if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&C instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&C instanceof ImageBitmap||typeof VideoFrame<"u"&&C instanceof VideoFrame){const Y=Math.floor(q*K.width),ye=Math.floor(q*K.height);d===void 0&&(d=m(Y,ye));const pe=S?m(Y,ye):d;return pe.width=Y,pe.height=ye,pe.getContext("2d").drawImage(C,0,0,Y,ye),Mt("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+Y+"x"+ye+")."),pe}else return"data"in C&&Mt("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),C;return C}function g(C){return C.generateMipmaps}function f(C){s.generateMipmap(C)}function A(C){return C.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:C.isWebGL3DRenderTarget?s.TEXTURE_3D:C.isWebGLArrayRenderTarget||C.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function b(C,S,F,q,K=!1){if(C!==null){if(s[C]!==void 0)return s[C];Mt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+C+"'")}let Y=S;if(S===s.RED&&(F===s.FLOAT&&(Y=s.R32F),F===s.HALF_FLOAT&&(Y=s.R16F),F===s.UNSIGNED_BYTE&&(Y=s.R8)),S===s.RED_INTEGER&&(F===s.UNSIGNED_BYTE&&(Y=s.R8UI),F===s.UNSIGNED_SHORT&&(Y=s.R16UI),F===s.UNSIGNED_INT&&(Y=s.R32UI),F===s.BYTE&&(Y=s.R8I),F===s.SHORT&&(Y=s.R16I),F===s.INT&&(Y=s.R32I)),S===s.RG&&(F===s.FLOAT&&(Y=s.RG32F),F===s.HALF_FLOAT&&(Y=s.RG16F),F===s.UNSIGNED_BYTE&&(Y=s.RG8)),S===s.RG_INTEGER&&(F===s.UNSIGNED_BYTE&&(Y=s.RG8UI),F===s.UNSIGNED_SHORT&&(Y=s.RG16UI),F===s.UNSIGNED_INT&&(Y=s.RG32UI),F===s.BYTE&&(Y=s.RG8I),F===s.SHORT&&(Y=s.RG16I),F===s.INT&&(Y=s.RG32I)),S===s.RGB_INTEGER&&(F===s.UNSIGNED_BYTE&&(Y=s.RGB8UI),F===s.UNSIGNED_SHORT&&(Y=s.RGB16UI),F===s.UNSIGNED_INT&&(Y=s.RGB32UI),F===s.BYTE&&(Y=s.RGB8I),F===s.SHORT&&(Y=s.RGB16I),F===s.INT&&(Y=s.RGB32I)),S===s.RGBA_INTEGER&&(F===s.UNSIGNED_BYTE&&(Y=s.RGBA8UI),F===s.UNSIGNED_SHORT&&(Y=s.RGBA16UI),F===s.UNSIGNED_INT&&(Y=s.RGBA32UI),F===s.BYTE&&(Y=s.RGBA8I),F===s.SHORT&&(Y=s.RGBA16I),F===s.INT&&(Y=s.RGBA32I)),S===s.RGB&&(F===s.UNSIGNED_INT_5_9_9_9_REV&&(Y=s.RGB9_E5),F===s.UNSIGNED_INT_10F_11F_11F_REV&&(Y=s.R11F_G11F_B10F)),S===s.RGBA){const ye=K?Og:jt.getTransfer(q);F===s.FLOAT&&(Y=s.RGBA32F),F===s.HALF_FLOAT&&(Y=s.RGBA16F),F===s.UNSIGNED_BYTE&&(Y=ye===ni?s.SRGB8_ALPHA8:s.RGBA8),F===s.UNSIGNED_SHORT_4_4_4_4&&(Y=s.RGBA4),F===s.UNSIGNED_SHORT_5_5_5_1&&(Y=s.RGB5_A1)}return(Y===s.R16F||Y===s.R32F||Y===s.RG16F||Y===s.RG32F||Y===s.RGBA16F||Y===s.RGBA32F)&&e.get("EXT_color_buffer_float"),Y}function y(C,S){let F;return C?S===null||S===Ll||S===Hu?F=s.DEPTH24_STENCIL8:S===pa?F=s.DEPTH32F_STENCIL8:S===zu&&(F=s.DEPTH24_STENCIL8,Mt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):S===null||S===Ll||S===Hu?F=s.DEPTH_COMPONENT24:S===pa?F=s.DEPTH_COMPONENT32F:S===zu&&(F=s.DEPTH_COMPONENT16),F}function x(C,S){return g(C)===!0||C.isFramebufferTexture&&C.minFilter!==gs&&C.minFilter!==Ls?Math.log2(Math.max(S.width,S.height))+1:C.mipmaps!==void 0&&C.mipmaps.length>0?C.mipmaps.length:C.isCompressedTexture&&Array.isArray(C.image)?S.mipmaps.length:1}function _(C){const S=C.target;S.removeEventListener("dispose",_),E(S),S.isVideoTexture&&h.delete(S)}function M(C){const S=C.target;S.removeEventListener("dispose",M),T(S)}function E(C){const S=i.get(C);if(S.__webglInit===void 0)return;const F=C.source,q=u.get(F);if(q){const K=q[S.__cacheKey];K.usedTimes--,K.usedTimes===0&&w(C),Object.keys(q).length===0&&u.delete(F)}i.remove(C)}function w(C){const S=i.get(C);s.deleteTexture(S.__webglTexture);const F=C.source,q=u.get(F);delete q[S.__cacheKey],a.memory.textures--}function T(C){const S=i.get(C);if(C.depthTexture&&(C.depthTexture.dispose(),i.remove(C.depthTexture)),C.isWebGLCubeRenderTarget)for(let q=0;q<6;q++){if(Array.isArray(S.__webglFramebuffer[q]))for(let K=0;K<S.__webglFramebuffer[q].length;K++)s.deleteFramebuffer(S.__webglFramebuffer[q][K]);else s.deleteFramebuffer(S.__webglFramebuffer[q]);S.__webglDepthbuffer&&s.deleteRenderbuffer(S.__webglDepthbuffer[q])}else{if(Array.isArray(S.__webglFramebuffer))for(let q=0;q<S.__webglFramebuffer.length;q++)s.deleteFramebuffer(S.__webglFramebuffer[q]);else s.deleteFramebuffer(S.__webglFramebuffer);if(S.__webglDepthbuffer&&s.deleteRenderbuffer(S.__webglDepthbuffer),S.__webglMultisampledFramebuffer&&s.deleteFramebuffer(S.__webglMultisampledFramebuffer),S.__webglColorRenderbuffer)for(let q=0;q<S.__webglColorRenderbuffer.length;q++)S.__webglColorRenderbuffer[q]&&s.deleteRenderbuffer(S.__webglColorRenderbuffer[q]);S.__webglDepthRenderbuffer&&s.deleteRenderbuffer(S.__webglDepthRenderbuffer)}const F=C.textures;for(let q=0,K=F.length;q<K;q++){const Y=i.get(F[q]);Y.__webglTexture&&(s.deleteTexture(Y.__webglTexture),a.memory.textures--),i.remove(F[q])}i.remove(C)}let R=0;function D(){R=0}function L(){const C=R;return C>=n.maxTextures&&Mt("WebGLTextures: Trying to use "+C+" texture units while this GPU supports only "+n.maxTextures),R+=1,C}function I(C){const S=[];return S.push(C.wrapS),S.push(C.wrapT),S.push(C.wrapR||0),S.push(C.magFilter),S.push(C.minFilter),S.push(C.anisotropy),S.push(C.internalFormat),S.push(C.format),S.push(C.type),S.push(C.generateMipmaps),S.push(C.premultiplyAlpha),S.push(C.flipY),S.push(C.unpackAlignment),S.push(C.colorSpace),S.join()}function O(C,S){const F=i.get(C);if(C.isVideoTexture&&fe(C),C.isRenderTargetTexture===!1&&C.isExternalTexture!==!0&&C.version>0&&F.__version!==C.version){const q=C.image;if(q===null)Mt("WebGLRenderer: Texture marked for update but no image data found.");else if(q.complete===!1)Mt("WebGLRenderer: Texture marked for update but image is incomplete");else{$(F,C,S);return}}else C.isExternalTexture&&(F.__webglTexture=C.sourceTexture?C.sourceTexture:null);t.bindTexture(s.TEXTURE_2D,F.__webglTexture,s.TEXTURE0+S)}function N(C,S){const F=i.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&F.__version!==C.version){$(F,C,S);return}else C.isExternalTexture&&(F.__webglTexture=C.sourceTexture?C.sourceTexture:null);t.bindTexture(s.TEXTURE_2D_ARRAY,F.__webglTexture,s.TEXTURE0+S)}function G(C,S){const F=i.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&F.__version!==C.version){$(F,C,S);return}t.bindTexture(s.TEXTURE_3D,F.__webglTexture,s.TEXTURE0+S)}function V(C,S){const F=i.get(C);if(C.version>0&&F.__version!==C.version){se(F,C,S);return}t.bindTexture(s.TEXTURE_CUBE_MAP,F.__webglTexture,s.TEXTURE0+S)}const H={[dy]:s.REPEAT,[da]:s.CLAMP_TO_EDGE,[uy]:s.MIRRORED_REPEAT},J={[gs]:s.NEAREST,[MN]:s.NEAREST_MIPMAP_NEAREST,[Dg]:s.NEAREST_MIPMAP_LINEAR,[Ls]:s.LINEAR,[py]:s.LINEAR_MIPMAP_NEAREST,[Bl]:s.LINEAR_MIPMAP_LINEAR},W={[PN]:s.NEVER,[ON]:s.ALWAYS,[DN]:s.LESS,[JS]:s.LEQUAL,[RN]:s.EQUAL,[kN]:s.GEQUAL,[BN]:s.GREATER,[LN]:s.NOTEQUAL};function X(C,S){if(S.type===pa&&e.has("OES_texture_float_linear")===!1&&(S.magFilter===Ls||S.magFilter===py||S.magFilter===Dg||S.magFilter===Bl||S.minFilter===Ls||S.minFilter===py||S.minFilter===Dg||S.minFilter===Bl)&&Mt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(C,s.TEXTURE_WRAP_S,H[S.wrapS]),s.texParameteri(C,s.TEXTURE_WRAP_T,H[S.wrapT]),(C===s.TEXTURE_3D||C===s.TEXTURE_2D_ARRAY)&&s.texParameteri(C,s.TEXTURE_WRAP_R,H[S.wrapR]),s.texParameteri(C,s.TEXTURE_MAG_FILTER,J[S.magFilter]),s.texParameteri(C,s.TEXTURE_MIN_FILTER,J[S.minFilter]),S.compareFunction&&(s.texParameteri(C,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(C,s.TEXTURE_COMPARE_FUNC,W[S.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(S.magFilter===gs||S.minFilter!==Dg&&S.minFilter!==Bl||S.type===pa&&e.has("OES_texture_float_linear")===!1)return;if(S.anisotropy>1||i.get(S).__currentAnisotropy){const F=e.get("EXT_texture_filter_anisotropic");s.texParameterf(C,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,n.getMaxAnisotropy())),i.get(S).__currentAnisotropy=S.anisotropy}}}function me(C,S){let F=!1;C.__webglInit===void 0&&(C.__webglInit=!0,S.addEventListener("dispose",_));const q=S.source;let K=u.get(q);K===void 0&&(K={},u.set(q,K));const Y=I(S);if(Y!==C.__cacheKey){K[Y]===void 0&&(K[Y]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,F=!0),K[Y].usedTimes++;const ye=K[C.__cacheKey];ye!==void 0&&(K[C.__cacheKey].usedTimes--,ye.usedTimes===0&&w(S)),C.__cacheKey=Y,C.__webglTexture=K[Y].texture}return F}function Ee(C,S,F){return Math.floor(Math.floor(C/F)/S)}function Me(C,S,F,q){const K=C.updateRanges;if(K.length===0)t.texSubImage2D(s.TEXTURE_2D,0,0,0,S.width,S.height,F,q,S.data);else{K.sort((He,oe)=>He.start-oe.start);let Y=0;for(let He=1;He<K.length;He++){const oe=K[Y],we=K[He],Ve=oe.start+oe.count,Fe=Ee(we.start,S.width,4),Ie=Ee(oe.start,S.width,4);we.start<=Ve+1&&Fe===Ie&&Ee(we.start+we.count-1,S.width,4)===Fe?oe.count=Math.max(oe.count,we.start+we.count-oe.start):(++Y,K[Y]=we)}K.length=Y+1;const ye=s.getParameter(s.UNPACK_ROW_LENGTH),pe=s.getParameter(s.UNPACK_SKIP_PIXELS),Ue=s.getParameter(s.UNPACK_SKIP_ROWS);s.pixelStorei(s.UNPACK_ROW_LENGTH,S.width);for(let He=0,oe=K.length;He<oe;He++){const we=K[He],Ve=Math.floor(we.start/4),Fe=Math.ceil(we.count/4),Ie=Ve%S.width,$e=Math.floor(Ve/S.width),z=Fe;s.pixelStorei(s.UNPACK_SKIP_PIXELS,Ie),s.pixelStorei(s.UNPACK_SKIP_ROWS,$e),t.texSubImage2D(s.TEXTURE_2D,0,Ie,$e,z,1,F,q,S.data)}C.clearUpdateRanges(),s.pixelStorei(s.UNPACK_ROW_LENGTH,ye),s.pixelStorei(s.UNPACK_SKIP_PIXELS,pe),s.pixelStorei(s.UNPACK_SKIP_ROWS,Ue)}}function $(C,S,F){let q=s.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(q=s.TEXTURE_2D_ARRAY),S.isData3DTexture&&(q=s.TEXTURE_3D);const K=me(C,S),Y=S.source;t.bindTexture(q,C.__webglTexture,s.TEXTURE0+F);const ye=i.get(Y);if(Y.version!==ye.__version||K===!0){t.activeTexture(s.TEXTURE0+F);const pe=jt.getPrimaries(jt.workingColorSpace),Ue=S.colorSpace===vo?null:jt.getPrimaries(S.colorSpace),He=S.colorSpace===vo||pe===Ue?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,S.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,S.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,He);let oe=v(S.image,!1,n.maxTextureSize);oe=xe(S,oe);const we=r.convert(S.format,S.colorSpace),Ve=r.convert(S.type);let Fe=b(S.internalFormat,we,Ve,S.colorSpace,S.isVideoTexture);X(q,S);let Ie;const $e=S.mipmaps,z=S.isVideoTexture!==!0,_e=ye.__version===void 0||K===!0,ve=Y.dataReady,Be=x(S,oe);if(S.isDepthTexture)Fe=y(S.format===Vu,S.type),_e&&(z?t.texStorage2D(s.TEXTURE_2D,1,Fe,oe.width,oe.height):t.texImage2D(s.TEXTURE_2D,0,Fe,oe.width,oe.height,0,we,Ve,null));else if(S.isDataTexture)if($e.length>0){z&&_e&&t.texStorage2D(s.TEXTURE_2D,Be,Fe,$e[0].width,$e[0].height);for(let ge=0,ne=$e.length;ge<ne;ge++)Ie=$e[ge],z?ve&&t.texSubImage2D(s.TEXTURE_2D,ge,0,0,Ie.width,Ie.height,we,Ve,Ie.data):t.texImage2D(s.TEXTURE_2D,ge,Fe,Ie.width,Ie.height,0,we,Ve,Ie.data);S.generateMipmaps=!1}else z?(_e&&t.texStorage2D(s.TEXTURE_2D,Be,Fe,oe.width,oe.height),ve&&Me(S,oe,we,Ve)):t.texImage2D(s.TEXTURE_2D,0,Fe,oe.width,oe.height,0,we,Ve,oe.data);else if(S.isCompressedTexture)if(S.isCompressedArrayTexture){z&&_e&&t.texStorage3D(s.TEXTURE_2D_ARRAY,Be,Fe,$e[0].width,$e[0].height,oe.depth);for(let ge=0,ne=$e.length;ge<ne;ge++)if(Ie=$e[ge],S.format!==nr)if(we!==null)if(z){if(ve)if(S.layerUpdates.size>0){const ze=BC(Ie.width,Ie.height,S.format,S.type);for(const je of S.layerUpdates){const vt=Ie.data.subarray(je*ze/Ie.data.BYTES_PER_ELEMENT,(je+1)*ze/Ie.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,ge,0,0,je,Ie.width,Ie.height,1,we,vt)}S.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,ge,0,0,0,Ie.width,Ie.height,oe.depth,we,Ie.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,ge,Fe,Ie.width,Ie.height,oe.depth,0,Ie.data,0,0);else Mt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else z?ve&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,ge,0,0,0,Ie.width,Ie.height,oe.depth,we,Ve,Ie.data):t.texImage3D(s.TEXTURE_2D_ARRAY,ge,Fe,Ie.width,Ie.height,oe.depth,0,we,Ve,Ie.data)}else{z&&_e&&t.texStorage2D(s.TEXTURE_2D,Be,Fe,$e[0].width,$e[0].height);for(let ge=0,ne=$e.length;ge<ne;ge++)Ie=$e[ge],S.format!==nr?we!==null?z?ve&&t.compressedTexSubImage2D(s.TEXTURE_2D,ge,0,0,Ie.width,Ie.height,we,Ie.data):t.compressedTexImage2D(s.TEXTURE_2D,ge,Fe,Ie.width,Ie.height,0,Ie.data):Mt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):z?ve&&t.texSubImage2D(s.TEXTURE_2D,ge,0,0,Ie.width,Ie.height,we,Ve,Ie.data):t.texImage2D(s.TEXTURE_2D,ge,Fe,Ie.width,Ie.height,0,we,Ve,Ie.data)}else if(S.isDataArrayTexture)if(z){if(_e&&t.texStorage3D(s.TEXTURE_2D_ARRAY,Be,Fe,oe.width,oe.height,oe.depth),ve)if(S.layerUpdates.size>0){const ge=BC(oe.width,oe.height,S.format,S.type);for(const ne of S.layerUpdates){const ze=oe.data.subarray(ne*ge/oe.data.BYTES_PER_ELEMENT,(ne+1)*ge/oe.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,ne,oe.width,oe.height,1,we,Ve,ze)}S.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,oe.width,oe.height,oe.depth,we,Ve,oe.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,Fe,oe.width,oe.height,oe.depth,0,we,Ve,oe.data);else if(S.isData3DTexture)z?(_e&&t.texStorage3D(s.TEXTURE_3D,Be,Fe,oe.width,oe.height,oe.depth),ve&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,oe.width,oe.height,oe.depth,we,Ve,oe.data)):t.texImage3D(s.TEXTURE_3D,0,Fe,oe.width,oe.height,oe.depth,0,we,Ve,oe.data);else if(S.isFramebufferTexture){if(_e)if(z)t.texStorage2D(s.TEXTURE_2D,Be,Fe,oe.width,oe.height);else{let ge=oe.width,ne=oe.height;for(let ze=0;ze<Be;ze++)t.texImage2D(s.TEXTURE_2D,ze,Fe,ge,ne,0,we,Ve,null),ge>>=1,ne>>=1}}else if($e.length>0){if(z&&_e){const ge=te($e[0]);t.texStorage2D(s.TEXTURE_2D,Be,Fe,ge.width,ge.height)}for(let ge=0,ne=$e.length;ge<ne;ge++)Ie=$e[ge],z?ve&&t.texSubImage2D(s.TEXTURE_2D,ge,0,0,we,Ve,Ie):t.texImage2D(s.TEXTURE_2D,ge,Fe,we,Ve,Ie);S.generateMipmaps=!1}else if(z){if(_e){const ge=te(oe);t.texStorage2D(s.TEXTURE_2D,Be,Fe,ge.width,ge.height)}ve&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,we,Ve,oe)}else t.texImage2D(s.TEXTURE_2D,0,Fe,we,Ve,oe);g(S)&&f(q),ye.__version=Y.version,S.onUpdate&&S.onUpdate(S)}C.__version=S.version}function se(C,S,F){if(S.image.length!==6)return;const q=me(C,S),K=S.source;t.bindTexture(s.TEXTURE_CUBE_MAP,C.__webglTexture,s.TEXTURE0+F);const Y=i.get(K);if(K.version!==Y.__version||q===!0){t.activeTexture(s.TEXTURE0+F);const ye=jt.getPrimaries(jt.workingColorSpace),pe=S.colorSpace===vo?null:jt.getPrimaries(S.colorSpace),Ue=S.colorSpace===vo||ye===pe?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,S.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,S.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ue);const He=S.isCompressedTexture||S.image[0].isCompressedTexture,oe=S.image[0]&&S.image[0].isDataTexture,we=[];for(let ne=0;ne<6;ne++)!He&&!oe?we[ne]=v(S.image[ne],!0,n.maxCubemapSize):we[ne]=oe?S.image[ne].image:S.image[ne],we[ne]=xe(S,we[ne]);const Ve=we[0],Fe=r.convert(S.format,S.colorSpace),Ie=r.convert(S.type),$e=b(S.internalFormat,Fe,Ie,S.colorSpace),z=S.isVideoTexture!==!0,_e=Y.__version===void 0||q===!0,ve=K.dataReady;let Be=x(S,Ve);X(s.TEXTURE_CUBE_MAP,S);let ge;if(He){z&&_e&&t.texStorage2D(s.TEXTURE_CUBE_MAP,Be,$e,Ve.width,Ve.height);for(let ne=0;ne<6;ne++){ge=we[ne].mipmaps;for(let ze=0;ze<ge.length;ze++){const je=ge[ze];S.format!==nr?Fe!==null?z?ve&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ze,0,0,je.width,je.height,Fe,je.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ze,$e,je.width,je.height,0,je.data):Mt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):z?ve&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ze,0,0,je.width,je.height,Fe,Ie,je.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ze,$e,je.width,je.height,0,Fe,Ie,je.data)}}}else{if(ge=S.mipmaps,z&&_e){ge.length>0&&Be++;const ne=te(we[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,Be,$e,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(oe){z?ve&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,we[ne].width,we[ne].height,Fe,Ie,we[ne].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,$e,we[ne].width,we[ne].height,0,Fe,Ie,we[ne].data);for(let ze=0;ze<ge.length;ze++){const je=ge[ze].image[ne].image;z?ve&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ze+1,0,0,je.width,je.height,Fe,Ie,je.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ze+1,$e,je.width,je.height,0,Fe,Ie,je.data)}}else{z?ve&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Fe,Ie,we[ne]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,$e,Fe,Ie,we[ne]);for(let ze=0;ze<ge.length;ze++){const je=ge[ze];z?ve&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ze+1,0,0,Fe,Ie,je.image[ne]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ne,ze+1,$e,Fe,Ie,je.image[ne])}}}g(S)&&f(s.TEXTURE_CUBE_MAP),Y.__version=K.version,S.onUpdate&&S.onUpdate(S)}C.__version=S.version}function he(C,S,F,q,K,Y){const ye=r.convert(F.format,F.colorSpace),pe=r.convert(F.type),Ue=b(F.internalFormat,ye,pe,F.colorSpace),He=i.get(S),oe=i.get(F);if(oe.__renderTarget=S,!He.__hasExternalTextures){const we=Math.max(1,S.width>>Y),Ve=Math.max(1,S.height>>Y);K===s.TEXTURE_3D||K===s.TEXTURE_2D_ARRAY?t.texImage3D(K,Y,Ue,we,Ve,S.depth,0,ye,pe,null):t.texImage2D(K,Y,Ue,we,Ve,0,ye,pe,null)}t.bindFramebuffer(s.FRAMEBUFFER,C),ie(S)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,q,K,oe.__webglTexture,0,k(S)):(K===s.TEXTURE_2D||K>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,q,K,oe.__webglTexture,Y),t.bindFramebuffer(s.FRAMEBUFFER,null)}function Te(C,S,F){if(s.bindRenderbuffer(s.RENDERBUFFER,C),S.depthBuffer){const q=S.depthTexture,K=q&&q.isDepthTexture?q.type:null,Y=y(S.stencilBuffer,K),ye=S.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,pe=k(S);ie(S)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,pe,Y,S.width,S.height):F?s.renderbufferStorageMultisample(s.RENDERBUFFER,pe,Y,S.width,S.height):s.renderbufferStorage(s.RENDERBUFFER,Y,S.width,S.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,ye,s.RENDERBUFFER,C)}else{const q=S.textures;for(let K=0;K<q.length;K++){const Y=q[K],ye=r.convert(Y.format,Y.colorSpace),pe=r.convert(Y.type),Ue=b(Y.internalFormat,ye,pe,Y.colorSpace),He=k(S);F&&ie(S)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,He,Ue,S.width,S.height):ie(S)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,He,Ue,S.width,S.height):s.renderbufferStorage(s.RENDERBUFFER,Ue,S.width,S.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function Le(C,S){if(S&&S.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(s.FRAMEBUFFER,C),!(S.depthTexture&&S.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const F=i.get(S.depthTexture);F.__renderTarget=S,(!F.__webglTexture||S.depthTexture.image.width!==S.width||S.depthTexture.image.height!==S.height)&&(S.depthTexture.image.width=S.width,S.depthTexture.image.height=S.height,S.depthTexture.needsUpdate=!0),O(S.depthTexture,0);const q=F.__webglTexture,K=k(S);if(S.depthTexture.format===Gu)ie(S)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,q,0,K):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,q,0);else if(S.depthTexture.format===Vu)ie(S)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,q,0,K):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,q,0);else throw new Error("Unknown depthTexture format")}function Oe(C){const S=i.get(C),F=C.isWebGLCubeRenderTarget===!0;if(S.__boundDepthTexture!==C.depthTexture){const q=C.depthTexture;if(S.__depthDisposeCallback&&S.__depthDisposeCallback(),q){const K=()=>{delete S.__boundDepthTexture,delete S.__depthDisposeCallback,q.removeEventListener("dispose",K)};q.addEventListener("dispose",K),S.__depthDisposeCallback=K}S.__boundDepthTexture=q}if(C.depthTexture&&!S.__autoAllocateDepthBuffer){if(F)throw new Error("target.depthTexture not supported in Cube render targets");const q=C.texture.mipmaps;q&&q.length>0?Le(S.__webglFramebuffer[0],C):Le(S.__webglFramebuffer,C)}else if(F){S.__webglDepthbuffer=[];for(let q=0;q<6;q++)if(t.bindFramebuffer(s.FRAMEBUFFER,S.__webglFramebuffer[q]),S.__webglDepthbuffer[q]===void 0)S.__webglDepthbuffer[q]=s.createRenderbuffer(),Te(S.__webglDepthbuffer[q],C,!1);else{const K=C.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Y=S.__webglDepthbuffer[q];s.bindRenderbuffer(s.RENDERBUFFER,Y),s.framebufferRenderbuffer(s.FRAMEBUFFER,K,s.RENDERBUFFER,Y)}}else{const q=C.texture.mipmaps;if(q&&q.length>0?t.bindFramebuffer(s.FRAMEBUFFER,S.__webglFramebuffer[0]):t.bindFramebuffer(s.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer===void 0)S.__webglDepthbuffer=s.createRenderbuffer(),Te(S.__webglDepthbuffer,C,!1);else{const K=C.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Y=S.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,Y),s.framebufferRenderbuffer(s.FRAMEBUFFER,K,s.RENDERBUFFER,Y)}}t.bindFramebuffer(s.FRAMEBUFFER,null)}function tt(C,S,F){const q=i.get(C);S!==void 0&&he(q.__webglFramebuffer,C,C.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),F!==void 0&&Oe(C)}function Ye(C){const S=C.texture,F=i.get(C),q=i.get(S);C.addEventListener("dispose",M);const K=C.textures,Y=C.isWebGLCubeRenderTarget===!0,ye=K.length>1;if(ye||(q.__webglTexture===void 0&&(q.__webglTexture=s.createTexture()),q.__version=S.version,a.memory.textures++),Y){F.__webglFramebuffer=[];for(let pe=0;pe<6;pe++)if(S.mipmaps&&S.mipmaps.length>0){F.__webglFramebuffer[pe]=[];for(let Ue=0;Ue<S.mipmaps.length;Ue++)F.__webglFramebuffer[pe][Ue]=s.createFramebuffer()}else F.__webglFramebuffer[pe]=s.createFramebuffer()}else{if(S.mipmaps&&S.mipmaps.length>0){F.__webglFramebuffer=[];for(let pe=0;pe<S.mipmaps.length;pe++)F.__webglFramebuffer[pe]=s.createFramebuffer()}else F.__webglFramebuffer=s.createFramebuffer();if(ye)for(let pe=0,Ue=K.length;pe<Ue;pe++){const He=i.get(K[pe]);He.__webglTexture===void 0&&(He.__webglTexture=s.createTexture(),a.memory.textures++)}if(C.samples>0&&ie(C)===!1){F.__webglMultisampledFramebuffer=s.createFramebuffer(),F.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let pe=0;pe<K.length;pe++){const Ue=K[pe];F.__webglColorRenderbuffer[pe]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,F.__webglColorRenderbuffer[pe]);const He=r.convert(Ue.format,Ue.colorSpace),oe=r.convert(Ue.type),we=b(Ue.internalFormat,He,oe,Ue.colorSpace,C.isXRRenderTarget===!0),Ve=k(C);s.renderbufferStorageMultisample(s.RENDERBUFFER,Ve,we,C.width,C.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+pe,s.RENDERBUFFER,F.__webglColorRenderbuffer[pe])}s.bindRenderbuffer(s.RENDERBUFFER,null),C.depthBuffer&&(F.__webglDepthRenderbuffer=s.createRenderbuffer(),Te(F.__webglDepthRenderbuffer,C,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(Y){t.bindTexture(s.TEXTURE_CUBE_MAP,q.__webglTexture),X(s.TEXTURE_CUBE_MAP,S);for(let pe=0;pe<6;pe++)if(S.mipmaps&&S.mipmaps.length>0)for(let Ue=0;Ue<S.mipmaps.length;Ue++)he(F.__webglFramebuffer[pe][Ue],C,S,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+pe,Ue);else he(F.__webglFramebuffer[pe],C,S,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0);g(S)&&f(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ye){for(let pe=0,Ue=K.length;pe<Ue;pe++){const He=K[pe],oe=i.get(He);let we=s.TEXTURE_2D;(C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)&&(we=C.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(we,oe.__webglTexture),X(we,He),he(F.__webglFramebuffer,C,He,s.COLOR_ATTACHMENT0+pe,we,0),g(He)&&f(we)}t.unbindTexture()}else{let pe=s.TEXTURE_2D;if((C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)&&(pe=C.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(pe,q.__webglTexture),X(pe,S),S.mipmaps&&S.mipmaps.length>0)for(let Ue=0;Ue<S.mipmaps.length;Ue++)he(F.__webglFramebuffer[Ue],C,S,s.COLOR_ATTACHMENT0,pe,Ue);else he(F.__webglFramebuffer,C,S,s.COLOR_ATTACHMENT0,pe,0);g(S)&&f(pe),t.unbindTexture()}C.depthBuffer&&Oe(C)}function B(C){const S=C.textures;for(let F=0,q=S.length;F<q;F++){const K=S[F];if(g(K)){const Y=A(C),ye=i.get(K).__webglTexture;t.bindTexture(Y,ye),f(Y),t.unbindTexture()}}}const re=[],ee=[];function Q(C){if(C.samples>0){if(ie(C)===!1){const S=C.textures,F=C.width,q=C.height;let K=s.COLOR_BUFFER_BIT;const Y=C.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,ye=i.get(C),pe=S.length>1;if(pe)for(let He=0;He<S.length;He++)t.bindFramebuffer(s.FRAMEBUFFER,ye.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+He,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,ye.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+He,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,ye.__webglMultisampledFramebuffer);const Ue=C.texture.mipmaps;Ue&&Ue.length>0?t.bindFramebuffer(s.DRAW_FRAMEBUFFER,ye.__webglFramebuffer[0]):t.bindFramebuffer(s.DRAW_FRAMEBUFFER,ye.__webglFramebuffer);for(let He=0;He<S.length;He++){if(C.resolveDepthBuffer&&(C.depthBuffer&&(K|=s.DEPTH_BUFFER_BIT),C.stencilBuffer&&C.resolveStencilBuffer&&(K|=s.STENCIL_BUFFER_BIT)),pe){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,ye.__webglColorRenderbuffer[He]);const oe=i.get(S[He]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,oe,0)}s.blitFramebuffer(0,0,F,q,0,0,F,q,K,s.NEAREST),l===!0&&(re.length=0,ee.length=0,re.push(s.COLOR_ATTACHMENT0+He),C.depthBuffer&&C.resolveDepthBuffer===!1&&(re.push(Y),ee.push(Y),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,ee)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,re))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),pe)for(let He=0;He<S.length;He++){t.bindFramebuffer(s.FRAMEBUFFER,ye.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+He,s.RENDERBUFFER,ye.__webglColorRenderbuffer[He]);const oe=i.get(S[He]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,ye.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+He,s.TEXTURE_2D,oe,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,ye.__webglMultisampledFramebuffer)}else if(C.depthBuffer&&C.resolveDepthBuffer===!1&&l){const S=C.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[S])}}}function k(C){return Math.min(n.maxSamples,C.samples)}function ie(C){const S=i.get(C);return C.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function fe(C){const S=a.render.frame;h.get(C)!==S&&(h.set(C,S),C.update())}function xe(C,S){const F=C.colorSpace,q=C.format,K=C.type;return C.isCompressedTexture===!0||C.isVideoTexture===!0||F!==Sh&&F!==vo&&(jt.getTransfer(F)===ni?(q!==nr||K!==ua)&&Mt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ni("WebGLTextures: Unsupported texture color space:",F)),S}function te(C){return typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement?(c.width=C.naturalWidth||C.width,c.height=C.naturalHeight||C.height):typeof VideoFrame<"u"&&C instanceof VideoFrame?(c.width=C.displayWidth,c.height=C.displayHeight):(c.width=C.width,c.height=C.height),c}this.allocateTextureUnit=L,this.resetTextureUnits=D,this.setTexture2D=O,this.setTexture2DArray=N,this.setTexture3D=G,this.setTextureCube=V,this.rebindTextures=tt,this.setupRenderTarget=Ye,this.updateRenderTargetMipmap=B,this.updateMultisampleRenderTarget=Q,this.setupDepthRenderbuffer=Oe,this.setupFrameBufferTexture=he,this.useMultisampledRTT=ie}function Y7(s,e){function t(i,n=vo){let r;const a=jt.getTransfer(n);if(i===ua)return s.UNSIGNED_BYTE;if(i===my)return s.UNSIGNED_SHORT_4_4_4_4;if(i===gy)return s.UNSIGNED_SHORT_5_5_5_1;if(i===XS)return s.UNSIGNED_INT_5_9_9_9_REV;if(i===qS)return s.UNSIGNED_INT_10F_11F_11F_REV;if(i===QS)return s.BYTE;if(i===jS)return s.SHORT;if(i===zu)return s.UNSIGNED_SHORT;if(i===fy)return s.INT;if(i===Ll)return s.UNSIGNED_INT;if(i===pa)return s.FLOAT;if(i===Mh)return s.HALF_FLOAT;if(i===YS)return s.ALPHA;if(i===KS)return s.RGB;if(i===nr)return s.RGBA;if(i===Gu)return s.DEPTH_COMPONENT;if(i===Vu)return s.DEPTH_STENCIL;if(i===$S)return s.RED;if(i===vy)return s.RED_INTEGER;if(i===Ay)return s.RG;if(i===by)return s.RG_INTEGER;if(i===yy)return s.RGBA_INTEGER;if(i===Rg||i===Bg||i===Lg||i===kg)if(a===ni)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===Rg)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Bg)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Lg)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===kg)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===Rg)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Bg)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Lg)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===kg)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===xy||i===_y||i===wy||i===Ey)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===xy)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===_y)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===wy)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Ey)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===My||i===Sy||i===Cy)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===My||i===Sy)return a===ni?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Cy)return a===ni?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===Ty||i===Iy||i===Py||i===Dy||i===Ry||i===By||i===Ly||i===ky||i===Oy||i===Fy||i===Ny||i===Uy||i===zy||i===Hy)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===Ty)return a===ni?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Iy)return a===ni?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Py)return a===ni?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Dy)return a===ni?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Ry)return a===ni?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===By)return a===ni?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Ly)return a===ni?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ky)return a===ni?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Oy)return a===ni?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Fy)return a===ni?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Ny)return a===ni?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Uy)return a===ni?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===zy)return a===ni?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Hy)return a===ni?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Gy||i===Vy||i===Wy)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===Gy)return a===ni?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Vy)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Wy)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Qy||i===jy||i===Xy||i===qy)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===Qy)return r.COMPRESSED_RED_RGTC1_EXT;if(i===jy)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Xy)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===qy)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Hu?s.UNSIGNED_INT_24_8:s[i]!==void 0?s[i]:null}return{convert:t}}const K7=`
|
||
void main() {
|
||
|
||
gl_Position = vec4( position, 1.0 );
|
||
|
||
}`,$7=`
|
||
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 Z7{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new RC(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 ya({vertexShader:K7,fragmentShader:$7,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Eo(new s0(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class J7 extends Th{constructor(e,t){super();const i=this;let n=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,d=null,u=null,p=null,m=null;const v=typeof XRWebGLBinding<"u",g=new Z7,f={},A=t.getContextAttributes();let b=null,y=null;const x=[],_=[],M=new si;let E=null;const w=new lr;w.viewport=new Ui;const T=new lr;T.viewport=new Ui;const R=[w,T],D=new AU;let L=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let se=x[$];return se===void 0&&(se=new yx,x[$]=se),se.getTargetRaySpace()},this.getControllerGrip=function($){let se=x[$];return se===void 0&&(se=new yx,x[$]=se),se.getGripSpace()},this.getHand=function($){let se=x[$];return se===void 0&&(se=new yx,x[$]=se),se.getHandSpace()};function O($){const se=_.indexOf($.inputSource);if(se===-1)return;const he=x[se];he!==void 0&&(he.update($.inputSource,$.frame,c||a),he.dispatchEvent({type:$.type,data:$.inputSource}))}function N(){n.removeEventListener("select",O),n.removeEventListener("selectstart",O),n.removeEventListener("selectend",O),n.removeEventListener("squeeze",O),n.removeEventListener("squeezestart",O),n.removeEventListener("squeezeend",O),n.removeEventListener("end",N),n.removeEventListener("inputsourceschange",G);for(let $=0;$<x.length;$++){const se=_[$];se!==null&&(_[$]=null,x[$].disconnect(se))}L=null,I=null,g.reset();for(const $ in f)delete f[$];e.setRenderTarget(b),p=null,u=null,d=null,n=null,y=null,Me.stop(),i.isPresenting=!1,e.setPixelRatio(E),e.setSize(M.width,M.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function($){r=$,i.isPresenting===!0&&Mt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function($){o=$,i.isPresenting===!0&&Mt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function($){c=$},this.getBaseLayer=function(){return u!==null?u:p},this.getBinding=function(){return d===null&&v&&(d=new XRWebGLBinding(n,t)),d},this.getFrame=function(){return m},this.getSession=function(){return n},this.setSession=async function($){if(n=$,n!==null){if(b=e.getRenderTarget(),n.addEventListener("select",O),n.addEventListener("selectstart",O),n.addEventListener("selectend",O),n.addEventListener("squeeze",O),n.addEventListener("squeezestart",O),n.addEventListener("squeezeend",O),n.addEventListener("end",N),n.addEventListener("inputsourceschange",G),A.xrCompatible!==!0&&await t.makeXRCompatible(),E=e.getPixelRatio(),e.getSize(M),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let se=null,he=null,Te=null;A.depth&&(Te=A.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=A.stencil?Vu:Gu,he=A.stencil?Hu:Ll);const Le={colorFormat:t.RGBA8,depthFormat:Te,scaleFactor:r};d=this.getBinding(),u=d.createProjectionLayer(Le),n.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),y=new kl(u.textureWidth,u.textureHeight,{format:nr,type:ua,depthTexture:new DC(u.textureWidth,u.textureHeight,he,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:A.stencil,colorSpace:e.outputColorSpace,samples:A.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{const se={antialias:A.antialias,alpha:!0,depth:A.depth,stencil:A.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(n,t,se),n.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),y=new kl(p.framebufferWidth,p.framebufferHeight,{format:nr,type:ua,colorSpace:e.outputColorSpace,stencilBuffer:A.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await n.requestReferenceSpace(o),Me.setContext(n),Me.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function G($){for(let se=0;se<$.removed.length;se++){const he=$.removed[se],Te=_.indexOf(he);Te>=0&&(_[Te]=null,x[Te].disconnect(he))}for(let se=0;se<$.added.length;se++){const he=$.added[se];let Te=_.indexOf(he);if(Te===-1){for(let Oe=0;Oe<x.length;Oe++)if(Oe>=_.length){_.push(he),Te=Oe;break}else if(_[Oe]===null){_[Oe]=he,Te=Oe;break}if(Te===-1)break}const Le=x[Te];Le&&Le.connect(he)}}const V=new Ne,H=new Ne;function J($,se,he){V.setFromMatrixPosition(se.matrixWorld),H.setFromMatrixPosition(he.matrixWorld);const Te=V.distanceTo(H),Le=se.projectionMatrix.elements,Oe=he.projectionMatrix.elements,tt=Le[14]/(Le[10]-1),Ye=Le[14]/(Le[10]+1),B=(Le[9]+1)/Le[5],re=(Le[9]-1)/Le[5],ee=(Le[8]-1)/Le[0],Q=(Oe[8]+1)/Oe[0],k=tt*ee,ie=tt*Q,fe=Te/(-ee+Q),xe=fe*-ee;if(se.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(xe),$.translateZ(fe),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert(),Le[10]===-1)$.projectionMatrix.copy(se.projectionMatrix),$.projectionMatrixInverse.copy(se.projectionMatrixInverse);else{const te=tt+fe,C=Ye+fe,S=k-xe,F=ie+(Te-xe),q=B*Ye/C*te,K=re*Ye/C*te;$.projectionMatrix.makePerspective(S,F,q,K,te,C),$.projectionMatrixInverse.copy($.projectionMatrix).invert()}}function W($,se){se===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(se.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(n===null)return;let se=$.near,he=$.far;g.texture!==null&&(g.depthNear>0&&(se=g.depthNear),g.depthFar>0&&(he=g.depthFar)),D.near=T.near=w.near=se,D.far=T.far=w.far=he,(L!==D.near||I!==D.far)&&(n.updateRenderState({depthNear:D.near,depthFar:D.far}),L=D.near,I=D.far),D.layers.mask=$.layers.mask|6,w.layers.mask=D.layers.mask&3,T.layers.mask=D.layers.mask&5;const Te=$.parent,Le=D.cameras;W(D,Te);for(let Oe=0;Oe<Le.length;Oe++)W(Le[Oe],Te);Le.length===2?J(D,w,T):D.projectionMatrix.copy(w.projectionMatrix),X($,D,Te)};function X($,se,he){he===null?$.matrix.copy(se.matrixWorld):($.matrix.copy(he.matrixWorld),$.matrix.invert(),$.matrix.multiply(se.matrixWorld)),$.matrix.decompose($.position,$.quaternion,$.scale),$.updateMatrixWorld(!0),$.projectionMatrix.copy(se.projectionMatrix),$.projectionMatrixInverse.copy(se.projectionMatrixInverse),$.isPerspectiveCamera&&($.fov=Ky*2*Math.atan(1/$.projectionMatrix.elements[5]),$.zoom=1)}this.getCamera=function(){return D},this.getFoveation=function(){if(!(u===null&&p===null))return l},this.setFoveation=function($){l=$,u!==null&&(u.fixedFoveation=$),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=$)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(D)},this.getCameraTexture=function($){return f[$]};let me=null;function Ee($,se){if(h=se.getViewerPose(c||a),m=se,h!==null){const he=h.views;p!==null&&(e.setRenderTargetFramebuffer(y,p.framebuffer),e.setRenderTarget(y));let Te=!1;he.length!==D.cameras.length&&(D.cameras.length=0,Te=!0);for(let Oe=0;Oe<he.length;Oe++){const tt=he[Oe];let Ye=null;if(p!==null)Ye=p.getViewport(tt);else{const re=d.getViewSubImage(u,tt);Ye=re.viewport,Oe===0&&(e.setRenderTargetTextures(y,re.colorTexture,re.depthStencilTexture),e.setRenderTarget(y))}let B=R[Oe];B===void 0&&(B=new lr,B.layers.enable(Oe),B.viewport=new Ui,R[Oe]=B),B.matrix.fromArray(tt.transform.matrix),B.matrix.decompose(B.position,B.quaternion,B.scale),B.projectionMatrix.fromArray(tt.projectionMatrix),B.projectionMatrixInverse.copy(B.projectionMatrix).invert(),B.viewport.set(Ye.x,Ye.y,Ye.width,Ye.height),Oe===0&&(D.matrix.copy(B.matrix),D.matrix.decompose(D.position,D.quaternion,D.scale)),Te===!0&&D.cameras.push(B)}const Le=n.enabledFeatures;if(Le&&Le.includes("depth-sensing")&&n.depthUsage=="gpu-optimized"&&v){d=i.getBinding();const Oe=d.getDepthInformation(he[0]);Oe&&Oe.isValid&&Oe.texture&&g.init(Oe,n.renderState)}if(Le&&Le.includes("camera-access")&&v){e.state.unbindTexture(),d=i.getBinding();for(let Oe=0;Oe<he.length;Oe++){const tt=he[Oe].camera;if(tt){let Ye=f[tt];Ye||(Ye=new RC,f[tt]=Ye);const B=d.getCameraImage(tt);Ye.sourceTexture=B}}}}for(let he=0;he<x.length;he++){const Te=_[he],Le=x[he];Te!==null&&Le!==void 0&&Le.update(Te,se,c||a)}me&&me($,se),se.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:se}),m=null}const Me=new LC;Me.setAnimationLoop(Ee),this.setAnimationLoop=function($){me=$},this.dispose=function(){}}}const Ql=new Nl,eH=new tn;function tH(s,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,MC(s)),f.isFog?(g.fogNear.value=f.near,g.fogFar.value=f.far):f.isFogExp2&&(g.fogDensity.value=f.density)}function n(g,f,A,b,y){f.isMeshBasicMaterial||f.isMeshLambertMaterial?r(g,f):f.isMeshToonMaterial?(r(g,f),d(g,f)):f.isMeshPhongMaterial?(r(g,f),h(g,f)):f.isMeshStandardMaterial?(r(g,f),u(g,f),f.isMeshPhysicalMaterial&&p(g,f,y)):f.isMeshMatcapMaterial?(r(g,f),m(g,f)):f.isMeshDepthMaterial?r(g,f):f.isMeshDistanceMaterial?(r(g,f),v(g,f)):f.isMeshNormalMaterial?r(g,f):f.isLineBasicMaterial?(a(g,f),f.isLineDashedMaterial&&o(g,f)):f.isPointsMaterial?l(g,f,A,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 r(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===es&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,t(f.normalMap,g.normalMapTransform),g.normalScale.value.copy(f.normalScale),f.side===es&&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 A=e.get(f),b=A.envMap,y=A.envMapRotation;b&&(g.envMap.value=b,Ql.copy(y),Ql.x*=-1,Ql.y*=-1,Ql.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(Ql.y*=-1,Ql.z*=-1),g.envMapRotation.value.setFromMatrix4(eH.makeRotationFromEuler(Ql)),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,A,b){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.size.value=f.size*A,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 u(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 p(g,f,A){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===es&&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=A.texture,g.transmissionSamplerSize.value.set(A.width,A.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 m(g,f){f.matcap&&(g.matcap.value=f.matcap)}function v(g,f){const A=e.get(f).light;g.referencePosition.value.setFromMatrixPosition(A.matrixWorld),g.nearDistance.value=A.shadow.camera.near,g.farDistance.value=A.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function iH(s,e,t,i){let n={},r={},a=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function l(A,b){const y=b.program;i.uniformBlockBinding(A,y)}function c(A,b){let y=n[A.id];y===void 0&&(m(A),y=h(A),n[A.id]=y,A.addEventListener("dispose",g));const x=b.program;i.updateUBOMapping(A,x);const _=e.render.frame;r[A.id]!==_&&(u(A),r[A.id]=_)}function h(A){const b=d();A.__bindingPointIndex=b;const y=s.createBuffer(),x=A.__size,_=A.usage;return s.bindBuffer(s.UNIFORM_BUFFER,y),s.bufferData(s.UNIFORM_BUFFER,x,_),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,b,y),y}function d(){for(let A=0;A<o;A++)if(a.indexOf(A)===-1)return a.push(A),A;return Ni("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(A){const b=n[A.id],y=A.uniforms,x=A.__cache;s.bindBuffer(s.UNIFORM_BUFFER,b);for(let _=0,M=y.length;_<M;_++){const E=Array.isArray(y[_])?y[_]:[y[_]];for(let w=0,T=E.length;w<T;w++){const R=E[w];if(p(R,_,w,x)===!0){const D=R.__offset,L=Array.isArray(R.value)?R.value:[R.value];let I=0;for(let O=0;O<L.length;O++){const N=L[O],G=v(N);typeof N=="number"||typeof N=="boolean"?(R.__data[0]=N,s.bufferSubData(s.UNIFORM_BUFFER,D+I,R.__data)):N.isMatrix3?(R.__data[0]=N.elements[0],R.__data[1]=N.elements[1],R.__data[2]=N.elements[2],R.__data[3]=0,R.__data[4]=N.elements[3],R.__data[5]=N.elements[4],R.__data[6]=N.elements[5],R.__data[7]=0,R.__data[8]=N.elements[6],R.__data[9]=N.elements[7],R.__data[10]=N.elements[8],R.__data[11]=0):(N.toArray(R.__data,I),I+=G.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,D,R.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function p(A,b,y,x){const _=A.value,M=b+"_"+y;if(x[M]===void 0)return typeof _=="number"||typeof _=="boolean"?x[M]=_:x[M]=_.clone(),!0;{const E=x[M];if(typeof _=="number"||typeof _=="boolean"){if(E!==_)return x[M]=_,!0}else if(E.equals(_)===!1)return E.copy(_),!0}return!1}function m(A){const b=A.uniforms;let y=0;const x=16;for(let M=0,E=b.length;M<E;M++){const w=Array.isArray(b[M])?b[M]:[b[M]];for(let T=0,R=w.length;T<R;T++){const D=w[T],L=Array.isArray(D.value)?D.value:[D.value];for(let I=0,O=L.length;I<O;I++){const N=L[I],G=v(N),V=y%x,H=V%G.boundary,J=V+H;y+=H,J!==0&&x-J<G.storage&&(y+=x-J),D.__data=new Float32Array(G.storage/Float32Array.BYTES_PER_ELEMENT),D.__offset=y,y+=G.storage}}}const _=y%x;return _>0&&(y+=x-_),A.__size=y,A.__cache={},this}function v(A){const b={boundary:0,storage:0};return typeof A=="number"||typeof A=="boolean"?(b.boundary=4,b.storage=4):A.isVector2?(b.boundary=8,b.storage=8):A.isVector3||A.isColor?(b.boundary=16,b.storage=12):A.isVector4?(b.boundary=16,b.storage=16):A.isMatrix3?(b.boundary=48,b.storage=48):A.isMatrix4?(b.boundary=64,b.storage=64):A.isTexture?Mt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Mt("WebGLRenderer: Unsupported uniform value type.",A),b}function g(A){const b=A.target;b.removeEventListener("dispose",g);const y=a.indexOf(b.__bindingPointIndex);a.splice(y,1),s.deleteBuffer(n[b.id]),delete n[b.id],delete r[b.id]}function f(){for(const A in n)s.deleteBuffer(n[A]);a=[],n={},r={}}return{bind:l,update:c,dispose:f}}const nH=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 xa=null;function sH(){return xa===null&&(xa=new dU(nH,32,32,Ay,Mh),xa.minFilter=Ls,xa.magFilter=Ls,xa.wrapS=da,xa.wrapT=da,xa.generateMipmaps=!1,xa.needsUpdate=!0),xa}class rH{constructor(e={}){const{canvas:t=FN(),context:i=null,depth:n=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1}=e;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=a;const m=new Set([yy,by,vy]),v=new Set([ua,Ll,zu,Hu,my,gy]),g=new Uint32Array(4),f=new Int32Array(4);let A=null,b=null;const y=[],x=[];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=go,this.toneMappingExposure=1,this.transmissionResolutionScale=.25,this.interactionCullingEnabled=!1,this.interactionActive=!1,this.interactionRenderScene=null,this.interactionFrameBudgetMs=10,this.interactionSkipShadows=!1;const _=this;let M=!1;this._outputColorSpace=vs;let E=0,w=0,T=null,R=-1,D=null;const L=new Ui,I=new Ui;let O=null;const N=new ri(0);let G=0,V=t.width,H=t.height,J=1,W=null,X=null;const me=new Ui(0,0,V,H),Ee=new Ui(0,0,V,H);let Me=!1;const $=new PC;let se=!1,he=!1;const Te=new tn,Le=new Ne,Oe=new Ui,tt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ye=!1,B=null;const re=[];function ee(U){re.push(B);const Z=Number.isFinite(_.interactionFrameBudgetMs)?_.interactionFrameBudgetMs:0,le=_.interactionRenderScene===null||U===_.interactionRenderScene;_.interactionCullingEnabled===!0&&_.interactionActive===!0&&le===!0&&Z>0?B={startTime:performance.now(),budgetMs:Z,aborted:!1}:B=null}function Q(U){const Z=Number.isFinite(_.interactionFrameBudgetMs)?_.interactionFrameBudgetMs:0,le=_.interactionRenderScene===null||U===_.interactionRenderScene;return _.interactionCullingEnabled===!0&&_.interactionActive===!0&&le===!0&&Z>0}function k(){B=re.pop()??null}function ie(){return B===null?!1:B.aborted===!0?!0:performance.now()-B.startTime<B.budgetMs?!1:(B.aborted=!0,!0)}function fe(U){if(U&&U.name==="highlightModel")return!0;if(U&&U.isSplit===!0&&Array.isArray(U.material)&&U.material.length>1){const Z=U.geometry&&Array.isArray(U.geometry.groups)?U.geometry.groups:null;if(Z!==null)for(let le=0,ce=Z.length;le<ce;le++){const ae=Z[le];if(ae&&ae.visible!==!1&&ae.materialIndex===1)return!0}}return!1}function xe(U,Z,le){return U&&U.name==="highlightModel"?!0:U&&U.isSplit===!0&&Array.isArray(U.material)&&U.material.length>1?Z&&Z.visible!==!1&&Z.materialIndex===1&&U.material[1]===le:!1}function te(){return T===null?J:1}let C=i;function S(U,Z){return t.getContext(U,Z)}try{const U={alpha:!0,depth:n,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Jb}`),t.addEventListener("webglcontextlost",pf,!1),t.addEventListener("webglcontextrestored",Sd,!1),t.addEventListener("webglcontextcreationerror",nA,!1),C===null){const Z="webgl2";if(C=S(Z,U),C===null)throw S(Z)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(U){throw U("WebGLRenderer: "+U.message),U}let F,q,K,Y,ye,pe,Ue,He,oe,we,Ve,Fe,Ie,$e,z,_e,ve,Be,ge,ne,ze,je,vt,ut;function Xi(){F=new pz(C),F.init(),je=new Y7(C,F),q=new sz(C,F,e,je),K=new X7(C,F),q.reversedDepthBuffer&&u&&K.buffers.depth.setReversed(!0),Y=new gz(C),ye=new L7,pe=new q7(C,F,K,ye,q,je,Y),Ue=new az(_),He=new uz(_),oe=new yU(C),vt=new iz(C,oe),we=new fz(C,oe,Y,vt),Ve=new Az(C,we,oe,Y),ge=new vz(C,q,pe),_e=new rz(ye),Fe=new B7(_,Ue,He,F,q,vt,_e),Ie=new tH(_,ye),$e=new O7,z=new G7(F),Be=new tz(_,Ue,He,K,Ve,p,l),ve=new Q7(_,Ve,q),ut=new iH(C,Y,q,K),ne=new nz(C,F,Y),ze=new mz(C,F,Y),Y.programs=Fe.programs,_.capabilities=q,_.extensions=F,_.properties=ye,_.renderLists=$e,_.shadowMap=ve,_.state=K,_.info=Y}Xi();const Ht=new J7(_,C);this.xr=Ht,this.getContext=function(){return C},this.getContextAttributes=function(){return C.getContextAttributes()},this.forceContextLoss=function(){const U=F.get("WEBGL_lose_context");U&&U.loseContext()},this.forceContextRestore=function(){const U=F.get("WEBGL_lose_context");U&&U.restoreContext()},this.getPixelRatio=function(){return J},this.setPixelRatio=function(U){U!==void 0&&(J=U,this.setSize(V,H,!1))},this.getSize=function(U){return U.set(V,H)},this.setSize=function(U,Z,le=!0){if(Ht.isPresenting){Mt("WebGLRenderer: Can't change size while VR device is presenting.");return}V=U,H=Z,t.width=Math.floor(U*J),t.height=Math.floor(Z*J),le===!0&&(t.style.width=U+"px",t.style.height=Z+"px"),this.setViewport(0,0,U,Z)},this.getDrawingBufferSize=function(U){return U.set(V*J,H*J).floor()},this.setDrawingBufferSize=function(U,Z,le){V=U,H=Z,J=le,t.width=Math.floor(U*le),t.height=Math.floor(Z*le),this.setViewport(0,0,U,Z)},this.getCurrentViewport=function(U){return U.copy(L)},this.getViewport=function(U){return U.copy(me)},this.setViewport=function(U,Z,le,ce){U.isVector4?me.set(U.x,U.y,U.z,U.w):me.set(U,Z,le,ce),K.viewport(L.copy(me).multiplyScalar(J).round())},this.getScissor=function(U){return U.copy(Ee)},this.setScissor=function(U,Z,le,ce){U.isVector4?Ee.set(U.x,U.y,U.z,U.w):Ee.set(U,Z,le,ce),K.scissor(I.copy(Ee).multiplyScalar(J).round())},this.getScissorTest=function(){return Me},this.setScissorTest=function(U){K.setScissorTest(Me=U)},this.setOpaqueSort=function(U){W=U},this.setTransparentSort=function(U){X=U},this.getClearColor=function(U){return U.copy(Be.getClearColor())},this.setClearColor=function(){Be.setClearColor(...arguments)},this.getClearAlpha=function(){return Be.getClearAlpha()},this.setClearAlpha=function(){Be.setClearAlpha(...arguments)},this.clear=function(U=!0,Z=!0,le=!0){let ce=0;if(U){let ae=!1;if(T!==null){const Ge=T.texture.format;ae=m.has(Ge)}if(ae){const Ge=T.texture.type,ke=v.has(Ge),Qe=Be.getClearColor(),Ze=Be.getClearAlpha(),at=Qe.r,rt=Qe.g,ht=Qe.b;ke?(g[0]=at,g[1]=rt,g[2]=ht,g[3]=Ze,C.clearBufferuiv(C.COLOR,0,g)):(f[0]=at,f[1]=rt,f[2]=ht,f[3]=Ze,C.clearBufferiv(C.COLOR,0,f))}else ce|=C.COLOR_BUFFER_BIT}Z&&(ce|=C.DEPTH_BUFFER_BIT),le&&(ce|=C.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),C.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",pf,!1),t.removeEventListener("webglcontextrestored",Sd,!1),t.removeEventListener("webglcontextcreationerror",nA,!1),Be.dispose(),$e.dispose(),z.dispose(),ye.dispose(),Ue.dispose(),He.dispose(),Ve.dispose(),vt.dispose(),ut.dispose(),Fe.dispose(),Ht.dispose(),Ht.removeEventListener("sessionstart",Sc),Ht.removeEventListener("sessionend",mf),js.stop()};function pf(U){U.preventDefault(),sC("WebGLRenderer: Context Lost."),M=!0}function Sd(){sC("WebGLRenderer: Context Restored."),M=!1;const U=Y.autoReset,Z=ve.enabled,le=ve.autoUpdate,ce=ve.needsUpdate,ae=ve.type;Xi(),Y.autoReset=U,ve.enabled=Z,ve.autoUpdate=le,ve.needsUpdate=ce,ve.type=ae}function nA(U){Ni("WebGLRenderer: A WebGL context could not be created. Reason: ",U.statusMessage)}function ff(U){const Z=U.target;Z.removeEventListener("dispose",ff),sA(Z)}function sA(U){Ga(U),ye.remove(U)}function Ga(U){const Z=ye.get(U).programs;Z!==void 0&&(Z.forEach(function(le){Fe.releaseProgram(le)}),U.isShaderMaterial&&Fe.releaseShaderCache(U))}this.renderBufferDirect=function(U,Z,le,ce,ae,Ge){Z===null&&(Z=tt);const ke=ae.isMesh&&ae.matrixWorld.determinant()<0,Qe=j(U,Z,le,ce,ae);K.setMaterial(ce,ke);let Ze=le.index,at=1;if(ce.wireframe===!0){if(Ze=we.getWireframeAttribute(le),Ze===void 0)return;at=2}const rt=le.drawRange,ht=le.attributes.position;let Xe=rt.start*at,Rt=(rt.start+rt.count)*at;Ge!==null&&(Xe=Math.max(Xe,Ge.start*at),Rt=Math.min(Rt,(Ge.start+Ge.count)*at)),Ze!==null?(Xe=Math.max(Xe,0),Rt=Math.min(Rt,Ze.count)):ht!=null&&(Xe=Math.max(Xe,0),Rt=Math.min(Rt,ht.count));const mt=Rt-Xe;if(mt<0||mt===1/0)return;vt.setup(ae,ce,Qe,le,Ze);let Vt,Nt=ne;if(Ze!==null&&(Vt=oe.get(Ze),Nt=ze,Nt.setIndex(Vt)),ae.isMesh)ce.wireframe===!0?(K.setLineWidth(ce.wireframeLinewidth*te()),Nt.setMode(C.LINES)):Nt.setMode(C.TRIANGLES);else if(ae.isLine){let lt=ce.linewidth;lt===void 0&&(lt=1),K.setLineWidth(lt*te()),ae.isLineSegments?Nt.setMode(C.LINES):ae.isLineLoop?Nt.setMode(C.LINE_LOOP):Nt.setMode(C.LINE_STRIP)}else ae.isPoints?Nt.setMode(C.POINTS):ae.isSprite&&Nt.setMode(C.TRIANGLES);if(ae.isBatchedMesh)if(ae._multiDrawInstances!==null)Wu("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Nt.renderMultiDrawInstances(ae._multiDrawStarts,ae._multiDrawCounts,ae._multiDrawCount,ae._multiDrawInstances);else if(F.get("WEBGL_multi_draw"))Nt.renderMultiDraw(ae._multiDrawStarts,ae._multiDrawCounts,ae._multiDrawCount);else{const lt=ae._multiDrawStarts,Mi=ae._multiDrawCounts,Ut=ae._multiDrawCount,ti=Ze?oe.get(Ze).bytesPerElement:1,Xn=ye.get(ce).currentProgram.getUniforms();for(let Xt=0;Xt<Ut;Xt++)Xn.setValue(C,"_gl_DrawID",Xt),Nt.render(lt[Xt]/ti,Mi[Xt])}else if(ae.isInstancedMesh)Nt.renderInstances(Xe,mt,ae.count);else if(le.isInstancedBufferGeometry){const lt=le._maxInstanceCount!==void 0?le._maxInstanceCount:1/0,Mi=Math.min(le.instanceCount,lt);Nt.renderInstances(Xe,mt,Mi)}else Nt.render(Xe,mt)};function Cd(U,Z,le){U.transparent===!0&&U.side===ca&&U.forceSinglePass===!1?(U.side=es,U.needsUpdate=!0,Pd(U,Z,le),U.side=mo,U.needsUpdate=!0,Pd(U,Z,le),U.side=ca):Pd(U,Z,le)}this.compile=function(U,Z,le=null){le===null&&(le=U),b=z.get(le),b.init(Z),x.push(b),le.traverseVisible(function(ae){ae.isLight&&ae.layers.test(Z.layers)&&(b.pushLight(ae),ae.castShadow&&b.pushShadow(ae))}),U!==le&&U.traverseVisible(function(ae){ae.isLight&&ae.layers.test(Z.layers)&&(b.pushLight(ae),ae.castShadow&&b.pushShadow(ae))}),b.setupLights();const ce=new Set;return U.traverse(function(ae){if(!(ae.isMesh||ae.isPoints||ae.isLine||ae.isSprite))return;const Ge=ae.material;if(Ge)if(Array.isArray(Ge))for(let ke=0;ke<Ge.length;ke++){const Qe=Ge[ke];Cd(Qe,le,ae),ce.add(Qe)}else Cd(Ge,le,ae),ce.add(Ge)}),b=x.pop(),ce},this.compileAsync=function(U,Z,le=null){const ce=this.compile(U,Z,le);return new Promise(ae=>{function Ge(){if(ce.forEach(function(ke){ye.get(ke).currentProgram.isReady()&&ce.delete(ke)}),ce.size===0){ae(U);return}setTimeout(Ge,10)}F.get("KHR_parallel_shader_compile")!==null?Ge():setTimeout(Ge,10)})};let Td=null;function rA(U){Td&&Td(U)}function Sc(){js.stop()}function mf(){js.start()}const js=new LC;js.setAnimationLoop(rA),typeof self<"u"&&js.setContext(self),this.setAnimationLoop=function(U){Td=U,Ht.setAnimationLoop(U),U===null?js.stop():js.start()},Ht.addEventListener("sessionstart",Sc),Ht.addEventListener("sessionend",mf),this.render=function(U,Z){if(Z!==void 0&&Z.isCamera!==!0){Ni("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(M!==!0){U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),Z.parent===null&&Z.matrixWorldAutoUpdate===!0&&Z.updateMatrixWorld(),Ht.enabled===!0&&Ht.isPresenting===!0&&(Ht.cameraAutoUpdate===!0&&Ht.updateCamera(Z),Z=Ht.getCamera()),U.isScene===!0&&U.onBeforeRender(_,U,Z,T),b=z.get(U,x.length),b.init(Z),x.push(b),Te.multiplyMatrices(Z.projectionMatrix,Z.matrixWorldInverse),$.setFromProjectionMatrix(Te,Lr,Z.reversedDepth),he=this.localClippingEnabled,se=_e.init(this.clippingPlanes,he),A=$e.get(U,y.length),A.init(),y.push(A),ee(U);try{if(Ht.enabled===!0&&Ht.isPresenting===!0){const Ge=_.xr.getDepthSensingMesh();Ge!==null&&Cc(Ge,Z,-1/0,_.sortObjects)}Cc(U,Z,0,_.sortObjects),A.finish(),_.sortObjects===!0&&A.sort(W,X),Ye=Ht.enabled===!1||Ht.isPresenting===!1||Ht.hasDepthSensing()===!1,Ye&&Be.addToRenderList(A,U),this.info.render.frame++,se===!0&&_e.beginShadows();const le=b.state.shadowsArray;(_.interactionSkipShadows!==!0||Q(U)===!1)&&ve.render(le,U,Z),se===!0&&_e.endShadows(),this.info.autoReset===!0&&this.info.reset();const ce=A.opaque,ae=A.transmissive;if(b.setupLights(),Z.isArrayCamera){const Ge=Z.cameras;if(ae.length>0)for(let ke=0,Qe=Ge.length;ke<Qe;ke++){const Ze=Ge[ke];aA(ce,ae,U,Ze)}Ye&&Be.render(U);for(let ke=0,Qe=Ge.length;ke<Qe;ke++){const Ze=Ge[ke];gf(A,U,Ze,Ze.viewport)}}else ae.length>0&&aA(ce,ae,U,Z),Ye&&Be.render(U),gf(A,U,Z)}finally{k()}T!==null&&w===0&&(pe.updateMultisampleRenderTarget(T),pe.updateRenderTargetMipmap(T)),U.isScene===!0&&U.onAfterRender(_,U,Z),vt.resetDefaultState(),R=-1,D=null,x.pop(),x.length>0?(b=x[x.length-1],se===!0&&_e.setGlobalState(_.clippingPlanes,b.state.camera)):b=null,y.pop(),y.length>0?A=y[y.length-1]:A=null}};function Cc(U,Z,le,ce){if(U.visible===!1)return;const ae=ie();if(ae===!0&&fe(U)===!1){const ke=U.children;for(let Qe=0,Ze=ke.length;Qe<Ze;Qe++)Cc(ke[Qe],Z,le,ce);return}if(U.layers.test(Z.layers)){if(U.isGroup)le=U.renderOrder;else if(U.isLOD)U.autoUpdate===!0&&U.update(Z);else if(U.isLight)b.pushLight(U),U.castShadow&&b.pushShadow(U);else if(U.isSprite){if(!U.frustumCulled||$.intersectsSprite(U)){ce&&Oe.setFromMatrixPosition(U.matrixWorld).applyMatrix4(Te);const ke=Ve.update(U),Qe=U.material;Qe.visible&&A.push(U,ke,Qe,le,Oe.z,null)}}else if((U.isMesh||U.isLine||U.isPoints)&&(!U.frustumCulled||$.intersectsObject(U))){const ke=Ve.update(U),Qe=U.material;if(ce&&(U.boundingSphere!==void 0?(U.boundingSphere===null&&U.computeBoundingSphere(),Oe.copy(U.boundingSphere.center)):(ke.boundingSphere===null&&ke.computeBoundingSphere(),Oe.copy(ke.boundingSphere.center)),Oe.applyMatrix4(U.matrixWorld).applyMatrix4(Te)),Array.isArray(Qe)){const Ze=ke.groups;for(let at=0,rt=Ze.length;at<rt;at++){const ht=Ze[at],Xe=Qe[ht.materialIndex];ae===!0&&xe(U,ht,Xe)===!1||Xe&&Xe.visible&&A.push(U,ke,Xe,le,Oe.z,ht)}}else Qe.visible&&(ae===!1||xe(U,null,Qe)===!0)&&A.push(U,ke,Qe,le,Oe.z,null)}}const Ge=U.children;for(let ke=0,Qe=Ge.length;ke<Qe;ke++)Cc(Ge[ke],Z,le,ce)}function gf(U,Z,le,ce){const{opaque:ae,transmissive:Ge,transparent:ke}=U;b.setupLightsView(le),se===!0&&_e.setGlobalState(_.clippingPlanes,le),ce&&K.viewport(L.copy(ce)),ae.length>0&&Id(ae,Z,le),Ge.length>0&&Id(Ge,Z,le),ke.length>0&&Id(ke,Z,le),K.buffers.depth.setTest(!0),K.buffers.depth.setMask(!0),K.buffers.color.setMask(!0),K.setPolygonOffset(!1)}function aA(U,Z,le,ce){if((le.isScene===!0?le.overrideMaterial:null)!==null)return;b.state.transmissionRenderTarget[ce.id]===void 0&&(b.state.transmissionRenderTarget[ce.id]=new kl(1,1,{generateMipmaps:!0,type:F.has("EXT_color_buffer_half_float")||F.has("EXT_color_buffer_float")?Mh:ua,minFilter:Bl,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:jt.workingColorSpace}));const ae=b.state.transmissionRenderTarget[ce.id],Ge=ce.viewport||L;ae.setSize(Ge.z*_.transmissionResolutionScale,Ge.w*_.transmissionResolutionScale);const ke=_.getRenderTarget(),Qe=_.getActiveCubeFace(),Ze=_.getActiveMipmapLevel();_.setRenderTarget(ae),_.getClearColor(N),G=_.getClearAlpha(),G<1&&_.setClearColor(16777215,.5),_.clear(),Ye&&Be.render(le);const at=_.toneMapping;_.toneMapping=go;const rt=ce.viewport;if(ce.viewport!==void 0&&(ce.viewport=void 0),b.setupLightsView(ce),se===!0&&_e.setGlobalState(_.clippingPlanes,ce),Id(U,le,ce),pe.updateMultisampleRenderTarget(ae),pe.updateRenderTargetMipmap(ae),F.has("WEBGL_multisampled_render_to_texture")===!1){let ht=!1;for(let Xe=0,Rt=Z.length;Xe<Rt;Xe++){const mt=Z[Xe],{object:Vt,geometry:Nt,material:lt,group:Mi}=mt;if(lt.side===ca&&Vt.layers.test(ce.layers)){const Ut=lt.side;lt.side=es,lt.needsUpdate=!0,oA(Vt,le,ce,Nt,lt,Mi),lt.side=Ut,lt.needsUpdate=!0,ht=!0}}ht===!0&&(pe.updateMultisampleRenderTarget(ae),pe.updateRenderTargetMipmap(ae))}_.setRenderTarget(ke,Qe,Ze),_.setClearColor(N,G),rt!==void 0&&(ce.viewport=rt),_.toneMapping=at}function Id(U,Z,le){const ce=Z.isScene===!0?Z.overrideMaterial:null;for(let ae=0,Ge=U.length;ae<Ge;ae++){const ke=U[ae];if(ie()===!0&&xe(ke.object,ke.group,ke.material)===!1)continue;const{object:Qe,geometry:Ze,group:at}=ke;let rt=ke.material;rt.allowOverride===!0&&ce!==null&&(rt=ce),Qe.layers.test(le.layers)&&oA(Qe,Z,le,Ze,rt,at)}}function oA(U,Z,le,ce,ae,Ge){U.onBeforeRender(_,Z,le,ce,ae,Ge),U.modelViewMatrix.multiplyMatrices(le.matrixWorldInverse,U.matrixWorld),U.normalMatrix.getNormalMatrix(U.modelViewMatrix),ae.onBeforeRender(_,Z,le,ce,U,Ge),ae.transparent===!0&&ae.side===ca&&ae.forceSinglePass===!1?(ae.side=es,ae.needsUpdate=!0,_.renderBufferDirect(le,Z,ce,ae,U,Ge),ae.side=mo,ae.needsUpdate=!0,_.renderBufferDirect(le,Z,ce,ae,U,Ge),ae.side=ca):_.renderBufferDirect(le,Z,ce,ae,U,Ge),U.onAfterRender(_,Z,le,ce,ae,Ge)}function Pd(U,Z,le){Z.isScene!==!0&&(Z=tt);const ce=ye.get(U),ae=b?.state.lights,Ge=b?.state.shadowsArray,ke=ae.state.version,Qe=Fe.getParameters(U,ae.state,Ge,Z,le),Ze=Fe.getProgramCacheKey(Qe);let at=ce.programs;ce.environment=U.isMeshStandardMaterial?Z.environment:null,ce.fog=Z.fog,ce.envMap=(U.isMeshStandardMaterial?He:Ue).get(U.envMap||ce.environment),ce.envMapRotation=ce.environment!==null&&U.envMap===null?Z.environmentRotation:U.envMapRotation,at===void 0&&(U.addEventListener("dispose",ff),at=new Map,ce.programs=at);let rt=at.get(Ze);if(rt!==void 0){if(ce.currentProgram===rt&&ce.lightsStateVersion===ke)return cA(U,Qe),rt}else Qe.uniforms=Fe.getUniforms(U),U.onBeforeCompile(Qe,_),rt=Fe.acquireProgram(Qe,Ze),at.set(Ze,rt),ce.uniforms=Qe.uniforms;const ht=ce.uniforms;return(!U.isShaderMaterial&&!U.isRawShaderMaterial||U.clipping===!0)&&(ht.clippingPlanes=_e.uniform),cA(U,Qe),ce.needsLights=Re(U),ce.lightsStateVersion=ke,ce.needsLights&&(ht.ambientLightColor.value=ae.state.ambient,ht.lightProbe.value=ae.state.probe,ht.directionalLights.value=ae.state.directional,ht.directionalLightShadows.value=ae.state.directionalShadow,ht.spotLights.value=ae.state.spot,ht.spotLightShadows.value=ae.state.spotShadow,ht.rectAreaLights.value=ae.state.rectArea,ht.ltc_1.value=ae.state.rectAreaLTC1,ht.ltc_2.value=ae.state.rectAreaLTC2,ht.pointLights.value=ae.state.point,ht.pointLightShadows.value=ae.state.pointShadow,ht.hemisphereLights.value=ae.state.hemi,ht.directionalShadowMap.value=ae.state.directionalShadowMap,ht.directionalShadowMatrix.value=ae.state.directionalShadowMatrix,ht.spotShadowMap.value=ae.state.spotShadowMap,ht.spotLightMatrix.value=ae.state.spotLightMatrix,ht.spotLightMap.value=ae.state.spotLightMap,ht.pointShadowMap.value=ae.state.pointShadowMap,ht.pointShadowMatrix.value=ae.state.pointShadowMatrix),ce.currentProgram=rt,ce.uniformsList=null,rt}function lA(U){if(U.uniformsList===null){const Z=U.currentProgram.getUniforms();U.uniformsList=l0.seqWithValue(Z.seq,U.uniforms)}return U.uniformsList}function cA(U,Z){const le=ye.get(U);le.outputColorSpace=Z.outputColorSpace,le.batching=Z.batching,le.batchingColor=Z.batchingColor,le.instancing=Z.instancing,le.instancingColor=Z.instancingColor,le.instancingMorph=Z.instancingMorph,le.skinning=Z.skinning,le.morphTargets=Z.morphTargets,le.morphNormals=Z.morphNormals,le.morphColors=Z.morphColors,le.morphTargetsCount=Z.morphTargetsCount,le.numClippingPlanes=Z.numClippingPlanes,le.numIntersection=Z.numClipIntersection,le.vertexAlphas=Z.vertexAlphas,le.vertexTangents=Z.vertexTangents,le.toneMapping=Z.toneMapping}function j(U,Z,le,ce,ae){Z.isScene!==!0&&(Z=tt),pe.resetTextureUnits();const Ge=Z.fog,ke=ce.isMeshStandardMaterial?Z.environment:null,Qe=T===null?_.outputColorSpace:T.isXRRenderTarget===!0?T.texture.colorSpace:Sh,Ze=(ce.isMeshStandardMaterial?He:Ue).get(ce.envMap||ke),at=ce.vertexColors===!0&&!!le.attributes.color&&le.attributes.color.itemSize===4,rt=!!le.attributes.tangent&&(!!ce.normalMap||ce.anisotropy>0),ht=!!le.morphAttributes.position,Xe=!!le.morphAttributes.normal,Rt=!!le.morphAttributes.color;let mt=go;ce.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(mt=_.toneMapping);const Vt=le.morphAttributes.position||le.morphAttributes.normal||le.morphAttributes.color,Nt=Vt!==void 0?Vt.length:0,lt=ye.get(ce),Mi=b?.state.lights;if(se===!0&&(he===!0||U!==D)){const yn=U===D&&ce.id===R;_e.setState(ce,U,yn)}let Ut=!1;ce.version===lt.__version?(lt.needsLights&<.lightsStateVersion!==Mi.state.version||lt.outputColorSpace!==Qe||ae.isBatchedMesh&<.batching===!1||!ae.isBatchedMesh&<.batching===!0||ae.isBatchedMesh&<.batchingColor===!0&&ae.colorTexture===null||ae.isBatchedMesh&<.batchingColor===!1&&ae.colorTexture!==null||ae.isInstancedMesh&<.instancing===!1||!ae.isInstancedMesh&<.instancing===!0||ae.isSkinnedMesh&<.skinning===!1||!ae.isSkinnedMesh&<.skinning===!0||ae.isInstancedMesh&<.instancingColor===!0&&ae.instanceColor===null||ae.isInstancedMesh&<.instancingColor===!1&&ae.instanceColor!==null||ae.isInstancedMesh&<.instancingMorph===!0&&ae.morphTexture===null||ae.isInstancedMesh&<.instancingMorph===!1&&ae.morphTexture!==null||lt.envMap!==Ze||ce.fog===!0&<.fog!==Ge||lt.numClippingPlanes!==void 0&&(lt.numClippingPlanes!==_e.numPlanes||lt.numIntersection!==_e.numIntersection)||lt.vertexAlphas!==at||lt.vertexTangents!==rt||lt.morphTargets!==ht||lt.morphNormals!==Xe||lt.morphColors!==Rt||lt.toneMapping!==mt||lt.morphTargetsCount!==Nt)&&(Ut=!0):(Ut=!0,lt.__version=ce.version);let ti=lt.currentProgram;Ut===!0&&(ti=Pd(ce,Z,ae));let Xn=!1,Xt=!1,os=!1;const Zt=ti.getUniforms(),bn=lt.uniforms;if(K.useProgram(ti.program)&&(Xn=!0,Xt=!0,os=!0),ce.id!==R&&(R=ce.id,Xt=!0),Xn||D!==U){K.buffers.depth.getReversed()&&U.reversedDepth!==!0&&(U._reversedDepth=!0,U.updateProjectionMatrix()),Zt.setValue(C,"projectionMatrix",U.projectionMatrix),Zt.setValue(C,"viewMatrix",U.matrixWorldInverse);const yn=Zt.map.cameraPosition;yn!==void 0&&yn.setValue(C,Le.setFromMatrixPosition(U.matrixWorld)),q.logarithmicDepthBuffer&&Zt.setValue(C,"logDepthBufFC",2/(Math.log(U.far+1)/Math.LN2)),(ce.isMeshPhongMaterial||ce.isMeshToonMaterial||ce.isMeshLambertMaterial||ce.isMeshBasicMaterial||ce.isMeshStandardMaterial||ce.isShaderMaterial)&&Zt.setValue(C,"isOrthographic",U.isOrthographicCamera===!0),D!==U&&(D=U,Xt=!0,os=!0)}if(ae.isSkinnedMesh){Zt.setOptional(C,ae,"bindMatrix"),Zt.setOptional(C,ae,"bindMatrixInverse");const yn=ae.skeleton;yn&&(yn.boneTexture===null&&yn.computeBoneTexture(),Zt.setValue(C,"boneTexture",yn.boneTexture,pe))}ae.isBatchedMesh&&(Zt.setOptional(C,ae,"batchingTexture"),Zt.setValue(C,"batchingTexture",ae._matricesTexture,pe),Zt.setOptional(C,ae,"batchingIdTexture"),Zt.setValue(C,"batchingIdTexture",ae._indirectTexture,pe),Zt.setOptional(C,ae,"batchingColorTexture"),ae._colorsTexture!==null&&Zt.setValue(C,"batchingColorTexture",ae._colorsTexture,pe));const Xs=le.morphAttributes;if((Xs.position!==void 0||Xs.normal!==void 0||Xs.color!==void 0)&&ge.update(ae,le,ti),(Xt||lt.receiveShadow!==ae.receiveShadow)&&(lt.receiveShadow=ae.receiveShadow,Zt.setValue(C,"receiveShadow",ae.receiveShadow)),ce.isMeshGouraudMaterial&&ce.envMap!==null&&(bn.envMap.value=Ze,bn.flipEnvMap.value=Ze.isCubeTexture&&Ze.isRenderTargetTexture===!1?-1:1),ce.isMeshStandardMaterial&&ce.envMap===null&&Z.environment!==null&&(bn.envMapIntensity.value=Z.environmentIntensity),bn.dfgLUT!==void 0&&(bn.dfgLUT.value=sH()),Xt&&(Zt.setValue(C,"toneMappingExposure",_.toneMappingExposure),lt.needsLights&&Ae(bn,os),Ge&&ce.fog===!0&&Ie.refreshFogUniforms(bn,Ge),Ie.refreshMaterialUniforms(bn,ce,J,H,b.state.transmissionRenderTarget[U.id]),l0.upload(C,lA(lt),bn,pe)),ce.isShaderMaterial&&ce.uniformsNeedUpdate===!0&&(l0.upload(C,lA(lt),bn,pe),ce.uniformsNeedUpdate=!1),ce.isSpriteMaterial&&Zt.setValue(C,"center",ae.center),Zt.setValue(C,"modelViewMatrix",ae.modelViewMatrix),Zt.setValue(C,"normalMatrix",ae.normalMatrix),Zt.setValue(C,"modelMatrix",ae.matrixWorld),ce.isShaderMaterial||ce.isRawShaderMaterial){const yn=ce.uniformsGroups;for(let xr=0,dw=yn.length;xr<dw;xr++){const Tc=yn[xr];ut.update(Tc,ti),ut.bind(Tc,ti)}}return ti}function Ae(U,Z){U.ambientLightColor.needsUpdate=Z,U.lightProbe.needsUpdate=Z,U.directionalLights.needsUpdate=Z,U.directionalLightShadows.needsUpdate=Z,U.pointLights.needsUpdate=Z,U.pointLightShadows.needsUpdate=Z,U.spotLights.needsUpdate=Z,U.spotLightShadows.needsUpdate=Z,U.rectAreaLights.needsUpdate=Z,U.hemisphereLights.needsUpdate=Z}function Re(U){return U.isMeshLambertMaterial||U.isMeshToonMaterial||U.isMeshPhongMaterial||U.isMeshStandardMaterial||U.isShadowMaterial||U.isShaderMaterial&&U.lights===!0}this.getActiveCubeFace=function(){return E},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(U,Z,le){const ce=ye.get(U);ce.__autoAllocateDepthBuffer=U.resolveDepthBuffer===!1,ce.__autoAllocateDepthBuffer===!1&&(ce.__useRenderToTexture=!1),ye.get(U.texture).__webglTexture=Z,ye.get(U.depthTexture).__webglTexture=ce.__autoAllocateDepthBuffer?void 0:le,ce.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(U,Z){const le=ye.get(U);le.__webglFramebuffer=Z,le.__useDefaultFramebuffer=Z===void 0};const Ce=C.createFramebuffer();this.setRenderTarget=function(U,Z=0,le=0){T=U,E=Z,w=le;let ce=!0,ae=null,Ge=!1,ke=!1;if(U){const Qe=ye.get(U);if(Qe.__useDefaultFramebuffer!==void 0)K.bindFramebuffer(C.FRAMEBUFFER,null),ce=!1;else if(Qe.__webglFramebuffer===void 0)pe.setupRenderTarget(U);else if(Qe.__hasExternalTextures)pe.rebindTextures(U,ye.get(U.texture).__webglTexture,ye.get(U.depthTexture).__webglTexture);else if(U.depthBuffer){const rt=U.depthTexture;if(Qe.__boundDepthTexture!==rt){if(rt!==null&&ye.has(rt)&&(U.width!==rt.image.width||U.height!==rt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");pe.setupDepthRenderbuffer(U)}}const Ze=U.texture;(Ze.isData3DTexture||Ze.isDataArrayTexture||Ze.isCompressedArrayTexture)&&(ke=!0);const at=ye.get(U).__webglFramebuffer;U.isWebGLCubeRenderTarget?(Array.isArray(at[Z])?ae=at[Z][le]:ae=at[Z],Ge=!0):U.samples>0&&pe.useMultisampledRTT(U)===!1?ae=ye.get(U).__webglMultisampledFramebuffer:Array.isArray(at)?ae=at[le]:ae=at,L.copy(U.viewport),I.copy(U.scissor),O=U.scissorTest}else L.copy(me).multiplyScalar(J).floor(),I.copy(Ee).multiplyScalar(J).floor(),O=Me;if(le!==0&&(ae=Ce),K.bindFramebuffer(C.FRAMEBUFFER,ae)&&ce&&K.drawBuffers(U,ae),K.viewport(L),K.scissor(I),K.setScissorTest(O),Ge){const Qe=ye.get(U.texture);C.framebufferTexture2D(C.FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Qe.__webglTexture,le)}else if(ke){const Qe=Z;for(let Ze=0;Ze<U.textures.length;Ze++){const at=ye.get(U.textures[Ze]);C.framebufferTextureLayer(C.FRAMEBUFFER,C.COLOR_ATTACHMENT0+Ze,at.__webglTexture,le,Qe)}}else if(U!==null&&le!==0){const Qe=ye.get(U.texture);C.framebufferTexture2D(C.FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_2D,Qe.__webglTexture,le)}R=-1},this.readRenderTargetPixels=function(U,Z,le,ce,ae,Ge,ke,Qe=0){if(!(U&&U.isWebGLRenderTarget)){Ni("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ze=ye.get(U).__webglFramebuffer;if(U.isWebGLCubeRenderTarget&&ke!==void 0&&(Ze=Ze[ke]),Ze){K.bindFramebuffer(C.FRAMEBUFFER,Ze);try{const at=U.textures[Qe],rt=at.format,ht=at.type;if(!q.textureFormatReadable(rt)){Ni("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!q.textureTypeReadable(ht)){Ni("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Z>=0&&Z<=U.width-ce&&le>=0&&le<=U.height-ae&&(U.textures.length>1&&C.readBuffer(C.COLOR_ATTACHMENT0+Qe),C.readPixels(Z,le,ce,ae,je.convert(rt),je.convert(ht),Ge))}finally{const at=T!==null?ye.get(T).__webglFramebuffer:null;K.bindFramebuffer(C.FRAMEBUFFER,at)}}},this.readRenderTargetPixelsAsync=async function(U,Z,le,ce,ae,Ge,ke,Qe=0){if(!(U&&U.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ze=ye.get(U).__webglFramebuffer;if(U.isWebGLCubeRenderTarget&&ke!==void 0&&(Ze=Ze[ke]),Ze)if(Z>=0&&Z<=U.width-ce&&le>=0&&le<=U.height-ae){K.bindFramebuffer(C.FRAMEBUFFER,Ze);const at=U.textures[Qe],rt=at.format,ht=at.type;if(!q.textureFormatReadable(rt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!q.textureTypeReadable(ht))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Xe=C.createBuffer();C.bindBuffer(C.PIXEL_PACK_BUFFER,Xe),C.bufferData(C.PIXEL_PACK_BUFFER,Ge.byteLength,C.STREAM_READ),U.textures.length>1&&C.readBuffer(C.COLOR_ATTACHMENT0+Qe),C.readPixels(Z,le,ce,ae,je.convert(rt),je.convert(ht),0);const Rt=T!==null?ye.get(T).__webglFramebuffer:null;K.bindFramebuffer(C.FRAMEBUFFER,Rt);const mt=C.fenceSync(C.SYNC_GPU_COMMANDS_COMPLETE,0);return C.flush(),await NN(C,mt,4),C.bindBuffer(C.PIXEL_PACK_BUFFER,Xe),C.getBufferSubData(C.PIXEL_PACK_BUFFER,0,Ge),C.deleteBuffer(Xe),C.deleteSync(mt),Ge}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(U,Z=null,le=0){const ce=Math.pow(2,-le),ae=Math.floor(U.image.width*ce),Ge=Math.floor(U.image.height*ce),ke=Z!==null?Z.x:0,Qe=Z!==null?Z.y:0;pe.setTexture2D(U,0),C.copyTexSubImage2D(C.TEXTURE_2D,le,0,0,ke,Qe,ae,Ge),K.unbindTexture()};const Se=C.createFramebuffer(),st=C.createFramebuffer();this.copyTextureToTexture=function(U,Z,le=null,ce=null,ae=0,Ge=null){Ge===null&&(ae!==0?(Wu("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Ge=ae,ae=0):Ge=0);let ke,Qe,Ze,at,rt,ht,Xe,Rt,mt;const Vt=U.isCompressedTexture?U.mipmaps[Ge]:U.image;if(le!==null)ke=le.max.x-le.min.x,Qe=le.max.y-le.min.y,Ze=le.isBox3?le.max.z-le.min.z:1,at=le.min.x,rt=le.min.y,ht=le.isBox3?le.min.z:0;else{const Xs=Math.pow(2,-ae);ke=Math.floor(Vt.width*Xs),Qe=Math.floor(Vt.height*Xs),U.isDataArrayTexture?Ze=Vt.depth:U.isData3DTexture?Ze=Math.floor(Vt.depth*Xs):Ze=1,at=0,rt=0,ht=0}ce!==null?(Xe=ce.x,Rt=ce.y,mt=ce.z):(Xe=0,Rt=0,mt=0);const Nt=je.convert(Z.format),lt=je.convert(Z.type);let Mi;Z.isData3DTexture?(pe.setTexture3D(Z,0),Mi=C.TEXTURE_3D):Z.isDataArrayTexture||Z.isCompressedArrayTexture?(pe.setTexture2DArray(Z,0),Mi=C.TEXTURE_2D_ARRAY):(pe.setTexture2D(Z,0),Mi=C.TEXTURE_2D),C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL,Z.flipY),C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Z.premultiplyAlpha),C.pixelStorei(C.UNPACK_ALIGNMENT,Z.unpackAlignment);const Ut=C.getParameter(C.UNPACK_ROW_LENGTH),ti=C.getParameter(C.UNPACK_IMAGE_HEIGHT),Xn=C.getParameter(C.UNPACK_SKIP_PIXELS),Xt=C.getParameter(C.UNPACK_SKIP_ROWS),os=C.getParameter(C.UNPACK_SKIP_IMAGES);C.pixelStorei(C.UNPACK_ROW_LENGTH,Vt.width),C.pixelStorei(C.UNPACK_IMAGE_HEIGHT,Vt.height),C.pixelStorei(C.UNPACK_SKIP_PIXELS,at),C.pixelStorei(C.UNPACK_SKIP_ROWS,rt),C.pixelStorei(C.UNPACK_SKIP_IMAGES,ht);const Zt=U.isDataArrayTexture||U.isData3DTexture,bn=Z.isDataArrayTexture||Z.isData3DTexture;if(U.isDepthTexture){const Xs=ye.get(U),yn=ye.get(Z),xr=ye.get(Xs.__renderTarget),dw=ye.get(yn.__renderTarget);K.bindFramebuffer(C.READ_FRAMEBUFFER,xr.__webglFramebuffer),K.bindFramebuffer(C.DRAW_FRAMEBUFFER,dw.__webglFramebuffer);for(let Tc=0;Tc<Ze;Tc++)Zt&&(C.framebufferTextureLayer(C.READ_FRAMEBUFFER,C.COLOR_ATTACHMENT0,ye.get(U).__webglTexture,ae,ht+Tc),C.framebufferTextureLayer(C.DRAW_FRAMEBUFFER,C.COLOR_ATTACHMENT0,ye.get(Z).__webglTexture,Ge,mt+Tc)),C.blitFramebuffer(at,rt,ke,Qe,Xe,Rt,ke,Qe,C.DEPTH_BUFFER_BIT,C.NEAREST);K.bindFramebuffer(C.READ_FRAMEBUFFER,null),K.bindFramebuffer(C.DRAW_FRAMEBUFFER,null)}else if(ae!==0||U.isRenderTargetTexture||ye.has(U)){const Xs=ye.get(U),yn=ye.get(Z);K.bindFramebuffer(C.READ_FRAMEBUFFER,Se),K.bindFramebuffer(C.DRAW_FRAMEBUFFER,st);for(let xr=0;xr<Ze;xr++)Zt?C.framebufferTextureLayer(C.READ_FRAMEBUFFER,C.COLOR_ATTACHMENT0,Xs.__webglTexture,ae,ht+xr):C.framebufferTexture2D(C.READ_FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_2D,Xs.__webglTexture,ae),bn?C.framebufferTextureLayer(C.DRAW_FRAMEBUFFER,C.COLOR_ATTACHMENT0,yn.__webglTexture,Ge,mt+xr):C.framebufferTexture2D(C.DRAW_FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_2D,yn.__webglTexture,Ge),ae!==0?C.blitFramebuffer(at,rt,ke,Qe,Xe,Rt,ke,Qe,C.COLOR_BUFFER_BIT,C.NEAREST):bn?C.copyTexSubImage3D(Mi,Ge,Xe,Rt,mt+xr,at,rt,ke,Qe):C.copyTexSubImage2D(Mi,Ge,Xe,Rt,at,rt,ke,Qe);K.bindFramebuffer(C.READ_FRAMEBUFFER,null),K.bindFramebuffer(C.DRAW_FRAMEBUFFER,null)}else bn?U.isDataTexture||U.isData3DTexture?C.texSubImage3D(Mi,Ge,Xe,Rt,mt,ke,Qe,Ze,Nt,lt,Vt.data):Z.isCompressedArrayTexture?C.compressedTexSubImage3D(Mi,Ge,Xe,Rt,mt,ke,Qe,Ze,Nt,Vt.data):C.texSubImage3D(Mi,Ge,Xe,Rt,mt,ke,Qe,Ze,Nt,lt,Vt):U.isDataTexture?C.texSubImage2D(C.TEXTURE_2D,Ge,Xe,Rt,ke,Qe,Nt,lt,Vt.data):U.isCompressedTexture?C.compressedTexSubImage2D(C.TEXTURE_2D,Ge,Xe,Rt,Vt.width,Vt.height,Nt,Vt.data):C.texSubImage2D(C.TEXTURE_2D,Ge,Xe,Rt,ke,Qe,Nt,lt,Vt);C.pixelStorei(C.UNPACK_ROW_LENGTH,Ut),C.pixelStorei(C.UNPACK_IMAGE_HEIGHT,ti),C.pixelStorei(C.UNPACK_SKIP_PIXELS,Xn),C.pixelStorei(C.UNPACK_SKIP_ROWS,Xt),C.pixelStorei(C.UNPACK_SKIP_IMAGES,os),Ge===0&&Z.generateMipmaps&&C.generateMipmap(Mi),K.unbindTexture()},this.initRenderTarget=function(U){ye.get(U).__webglFramebuffer===void 0&&pe.setupRenderTarget(U)},this.initTexture=function(U){U.isCubeTexture?pe.setTextureCube(U,0):U.isData3DTexture?pe.setTexture3D(U,0):U.isDataArrayTexture||U.isCompressedArrayTexture?pe.setTexture2DArray(U,0):pe.setTexture2D(U,0),K.unbindTexture()},this.resetState=function(){E=0,w=0,T=null,K.reset(),vt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Lr}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=jt._getDrawingBufferColorSpace(e),t.unpackColorSpace=jt._getUnpackColorSpace()}}const l2=.9;class aH{engine;renderer;constructor(e){this.engine=e,this.renderer=null}createRenderer(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize();return this.renderer=new rH({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=US,this.renderer.localClippingEnabled=!0,this.renderer.outputColorSpace=vs,this.renderer.toneMappingExposure=l2,this.engine.container.appendChild(this.renderer.domElement),this.renderer}disposeRenderer(){this.renderer?.dispose()}}const c2={type:"change"},Tx={type:"start"},h2={type:"end"},h0=new Cr,d2=new $t,oH=Math.cos(70*Bt.DEG2RAD),Wi=new P,lH=new P,cH=new P,hH=new P(0,1,0),dH=new P(1,0,0),uH=new P(0,0,1),is=.25*Math.PI,ai={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},d0=1e-6;let pH=class extends wg{constructor(s,e,t=null){super(e,t),this.engine=s,this.state=ai.NONE,this.target=new P,this.cursor=new P,this.origin=new P(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=Bt.degToRad(5),this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.perspectiveWheelZoomBoost=5,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:ls.ROTATE,MIDDLE:ls.DOLLY,RIGHT:ls.PAN},this.touches={ONE:cs.ROTATE,TWO:cs.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new P,this._lastQuaternion=new Lt,this._lastTargetPosition=new P,this._quat=new Lt().setFromUnitVectors(e.up,new P(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new gh,this._sphericalDelta=new gh,this._scale=1,this._panOffset=new P,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 P,this._mouse=new be,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=mH.bind(this),this._onPointerDown=fH.bind(this),this._onPointerUp=gH.bind(this),this._onContextMenu=wH.bind(this),this._onMouseWheel=bH.bind(this),this._onKeyDown=yH.bind(this),this._onTouchStart=xH.bind(this),this._onTouchMove=_H.bind(this),this._onMouseDown=vH.bind(this),this._onMouseMove=AH.bind(this),this._interceptControlDown=EH.bind(this),this._interceptControlUp=MH.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(s){super.connect(s),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(s){s.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=s}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(c2),this.update(),this.state=ai.NONE}update(s=null){this.engine&&this.engine.interactionManager&&this.engine.interactionManager.origin&&this.origin.copy(this.engine.interactionManager.origin);const e=this.object.position;Wi.copy(e).sub(this.target),Wi.applyQuaternion(this._quat),this._spherical.setFromVector3(Wi),this.autoRotate&&this.state===ai.NONE&&this._rotateLeft(this._getAutoRotationAngle(s)),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+=is:t>Math.PI&&(t-=is),i<-Math.PI?i+=is:i>Math.PI&&(i-=is),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 r=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),n=r!=this._spherical.radius}if(Wi.setFromSpherical(this._spherical),Wi.applyQuaternion(this._quatInverse),this.engine&&this.engine.deviceType==="PC"){const r=new P;if(r.copy(this.origin).sub(this.target),r.lengthSq()>1e-4&&(this._sphericalDelta.theta!==0||this._sphericalDelta.phi!==0)){const a=this.enableDamping?this.dampingFactor*3:1,o=hH,l=lH;this.object.getWorldDirection(l);const c=Math.abs(l.y)>.999?dH:o,h=cH;h.crossVectors(l,c),h.lengthSq()<d0&&h.crossVectors(l,uH),h.normalize();const d=new P().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 u=new P().copy(this.target).sub(this.origin);u.applyAxisAngle(o,Math.PI*this._sphericalDelta.theta*a),u.applyAxisAngle(h,Math.PI*this._sphericalDelta.phi*a),this.target.copy(this.origin).add(u)}else e.copy(this.target).add(Wi);this.object.lookAt(this.target)}else e.copy(this.target).add(Wi),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 r=null;if(this.object.isPerspectiveCamera){const a=Wi.length();r=this._clampDistance(a*this._scale);const o=a-r;this.object.position.addScaledVector(this._dollyDirection,o),this.object.updateMatrixWorld(),n=!!o}else if(this.object.isOrthographicCamera){const a=new P(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 P(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(a),this.object.updateMatrixWorld(),r=Wi.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;r!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(r).add(this.object.position):(h0.origin.copy(this.object.position),h0.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(h0.direction))<oH?this.object.lookAt(this.target):(d2.setFromNormalAndCoplanarPoint(this.object.up,this.target),h0.intersectPlane(d2,this.target))))}else if(this.object.isOrthographicCamera){const r=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),r!==this.object.zoom&&(this.object.updateProjectionMatrix(),n=!0)}return this._scale=1,this._performCursorZoom=!1,n||this._lastPosition.distanceToSquared(this.object.position)>d0||8*(1-this._lastQuaternion.dot(this.object.quaternion))>d0||this._lastTargetPosition.distanceToSquared(this.target)>d0?(this.dispatchEvent(c2),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(s){return s!==null?is/60*this.autoRotateSpeed*s:is/60/60*this.autoRotateSpeed}_getZoomScale(s){const e=Math.abs(s*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(s){this._sphericalDelta.theta-=s}_rotateUp(s){this._sphericalDelta.phi-=s}_panLeft(s,e){Wi.setFromMatrixColumn(e,0),Wi.multiplyScalar(-s),this._panOffset.add(Wi)}_panUp(s,e){this.screenSpacePanning===!0?Wi.setFromMatrixColumn(e,1):(Wi.setFromMatrixColumn(e,0),Wi.crossVectors(this.object.up,Wi)),Wi.multiplyScalar(s),this._panOffset.add(Wi)}_pan(s,e){const t=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Wi.copy(i).sub(this.target);let n=Wi.length();n*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*s*n/t.clientHeight,this.object.matrix),this._panUp(2*e*n/t.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(s*(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(s){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=s:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(s){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=s:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(s,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const t=this.domElement.getBoundingClientRect(),i=s-t.left,n=e-t.top,r=t.width,a=t.height;this._mouse.x=i/r*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(s){return Math.max(this.minDistance,Math.min(this.maxDistance,s))}_handleMouseDownRotate(s){this._rotateStart.set(s.clientX,s.clientY)}_handleMouseDownDolly(s){this._updateZoomParameters(s.clientX,s.clientX),this._dollyStart.set(s.clientX,s.clientY)}_handleMouseDownPan(s){this._panStart.set(s.clientX,s.clientY)}_handleMouseMoveRotate(s){this._rotateEnd.set(s.clientX,s.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(is*this._rotateDelta.x/e.clientHeight),this._rotateUp(is*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(s){this._dollyEnd.set(s.clientX,s.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(s){this._panEnd.set(s.clientX,s.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(s){this._updateZoomParameters(s.clientX,s.clientY),s.deltaY<0?this._dollyIn(this._getZoomScale(s.deltaY)):s.deltaY>0&&this._dollyOut(this._getZoomScale(s.deltaY)),this.update()}_handleKeyDown(s){let e=!1;switch(s.code){case this.keys.UP:s.ctrlKey||s.metaKey||s.shiftKey?this.enableRotate&&this._rotateUp(is*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:s.ctrlKey||s.metaKey||s.shiftKey?this.enableRotate&&this._rotateUp(-is*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:s.ctrlKey||s.metaKey||s.shiftKey?this.enableRotate&&this._rotateLeft(is*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:s.ctrlKey||s.metaKey||s.shiftKey?this.enableRotate&&this._rotateLeft(-is*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(s.preventDefault(),this.update())}_handleTouchStartRotate(s){if(this._pointers.length===1)this._rotateStart.set(s.pageX,s.pageY);else{const e=this._getSecondPointerPosition(s),t=.5*(s.pageX+e.x),i=.5*(s.pageY+e.y);this._rotateStart.set(t,i)}}_handleTouchStartPan(s){if(this._pointers.length===1)this._panStart.set(s.pageX,s.pageY);else{const e=this._getSecondPointerPosition(s),t=.5*(s.pageX+e.x),i=.5*(s.pageY+e.y);this._panStart.set(t,i)}}_handleTouchStartDolly(s){const e=this._getSecondPointerPosition(s),t=s.pageX-e.x,i=s.pageY-e.y,n=Math.sqrt(t*t+i*i);this._dollyStart.set(0,n)}_handleTouchStartDollyPan(s){this.enableZoom&&this._handleTouchStartDolly(s),this.enablePan&&this._handleTouchStartPan(s)}_handleTouchStartDollyRotate(s){this.enableZoom&&this._handleTouchStartDolly(s),this.enableRotate&&this._handleTouchStartRotate(s)}_handleTouchMoveRotate(s){if(this._pointers.length==1)this._rotateEnd.set(s.pageX,s.pageY);else{const t=this._getSecondPointerPosition(s),i=.5*(s.pageX+t.x),n=.5*(s.pageY+t.y);this._rotateEnd.set(i,n)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(is*this._rotateDelta.x/e.clientHeight),this._rotateUp(is*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(s){if(this._pointers.length===1)this._panEnd.set(s.pageX,s.pageY);else{const e=this._getSecondPointerPosition(s),t=.5*(s.pageX+e.x),i=.5*(s.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(s){const e=this._getSecondPointerPosition(s),t=s.pageX-e.x,i=s.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 r=(s.pageX+e.x)*.5,a=(s.pageY+e.y)*.5;this._updateZoomParameters(r,a)}_handleTouchMoveDollyPan(s){this.enableZoom&&this._handleTouchMoveDolly(s),this.enablePan&&this._handleTouchMovePan(s)}_handleTouchMoveDollyRotate(s){this.enableZoom&&this._handleTouchMoveDolly(s),this.enableRotate&&this._handleTouchMoveRotate(s)}_addPointer(s){this._pointers.push(s.pointerId)}_removePointer(s){delete this._pointerPositions[s.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==s.pointerId){this._pointers.splice(e,1);return}}_isTrackingPointer(s){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==s.pointerId)return!0;return!1}_trackPointer(s){let e=this._pointerPositions[s.pointerId];e===void 0&&(e=new be,this._pointerPositions[s.pointerId]=e),e.set(s.pageX,s.pageY)}_getSecondPointerPosition(s){const e=s.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(s){const e=s.deltaMode,t={clientX:s.clientX,clientY:s.clientY,deltaY:s.deltaY};switch(e){case 1:t.deltaY*=16;break;case 2:t.deltaY*=100;break}return s.ctrlKey&&!this._controlActive&&(t.deltaY*=10),t}};function fH(s){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(s)&&(this._addPointer(s),s.pointerType==="touch"?this._onTouchStart(s):this._onMouseDown(s)))}function mH(s){this.enabled!==!1&&(s.pointerType==="touch"?this._onTouchMove(s):this._onMouseMove(s))}function gH(s){switch(this._removePointer(s),this._pointers.length){case 0:this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(h2),this.state=ai.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 vH(s){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(s.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 ls.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(s),this.state=ai.DOLLY;break;case ls.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=ai.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=ai.ROTATE}break;case ls.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=ai.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=ai.PAN}break;default:this.state=ai.NONE}this.state!==ai.NONE&&this.dispatchEvent(Tx)}function AH(s){switch(this.state){case ai.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(s);break;case ai.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(s);break;case ai.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(s);break}}function bH(s){this.enabled===!1||this.enableZoom===!1||this.state!==ai.NONE||(s.preventDefault(),this.dispatchEvent(Tx),this._handleMouseWheel(this._customWheelEvent(s)),this.dispatchEvent(h2))}function yH(s){this.enabled!==!1&&this._handleKeyDown(s)}function xH(s){switch(this._trackPointer(s),this._pointers.length){case 1:switch(this.touches.ONE){case cs.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(s),this.state=ai.TOUCH_ROTATE;break;case cs.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(s),this.state=ai.TOUCH_PAN;break;default:this.state=ai.NONE}break;case 2:switch(this.touches.TWO){case cs.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(s),this.state=ai.TOUCH_DOLLY_PAN;break;case cs.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(s),this.state=ai.TOUCH_DOLLY_ROTATE;break;default:this.state=ai.NONE}break;default:this.state=ai.NONE}this.state!==ai.NONE&&this.dispatchEvent(Tx)}function _H(s){switch(this._trackPointer(s),this.state){case ai.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(s),this.update();break;case ai.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(s),this.update();break;case ai.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(s),this.update();break;case ai.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(s),this.update();break;default:this.state=ai.NONE}}function wH(s){this.enabled!==!1&&s.preventDefault()}function EH(s){s.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function MH(s){s.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class u2{constructor(e,t,i,n){this._Engine=e,this.camera=t,this.domElement=i,this._isEnabled=!1,this._rayOriginOffset=new P(0,-1,0),this._camerLocalDirection=new P,this._tmpVector=new P,this._rayCaster=new fs,this._fallingTime=0,this._isMouseInElement=!1,this._euler=new Yi(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=.003,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.shiftDown=!1,this.gravityTestCount=5,this.catchTestCount=10,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){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 r=this.GetEngine();r.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 r=this.GetEngine();r.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:if(this.applyGravity){this.keydown=!1,this._camerLocalDirection.y=0;break}this.keydown=!0,this._camerLocalDirection.y=1;break;case 69:if(this.applyGravity){this.keydown=!1,this._camerLocalDirection.y=0;break}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;case 16:this.shiftDown=!0;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;case 16:this.shiftDown=!1;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.applyGravity&&(this.keydown=!1,this._camerLocalDirection.y=0),this.keydown||this.gravityTest(),this.collisionTest()}gravityTest(){if(!(this._camerLocalDirection.y==0&&this._camerLocalDirection.z==0&&this._camerLocalDirection.x==0))if(this.applyGravity){let e=!0;this._fallingTime+=.01,this._tmpVector.set(0,-1,0);const t=this.hitTest();if(t==null)return;if(t){const i=t.point.add(new P(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.applyGravity&&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*(this.shiftDown?2:1))}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*(this.shiftDown?2:1))}collisionTestY(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector=new P(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.shiftDown?2:1));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={},r=t.handelBehaved.handle_catch(this._rayCaster,n);if(r==null)return null;let a=r.object.name,o=r.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("门")||c.infos[0].name.includes("門")||c.infos[0].name.includes("door")))return null}return r}}const Ix="__isModelUrlGroup";function p2(s){return s.__modelGroupMap instanceof Map||(s.__modelGroupMap=new Map),s.__modelGroupMap}function f2(s){return s.__modelObjectIndexMap instanceof Map||(s.__modelObjectIndexMap=new Map),s.__modelObjectIndexMap}function Px(s,e){s.url=e,s.name=e,s.userData=s.userData??{},s.userData[Ix]=!0}function Dx(s,e){return s instanceof Si?e==null?s.userData?.[Ix]===!0:s.userData?.[Ix]===!0&&s.url===e:!1}function m2(s,e){return s?.models?.find?.(t=>t?.url===e)}function u0(s,e){const t=p2(s),i=t.get(e);if(i&&i.parent!=null)return i;const n=m2(s,e);if(n?.group instanceof Si&&n.group.parent!=null)return Px(n.group,e),t.set(e,n.group),n.group;const r=s?.scene?.children?.find?.(a=>a instanceof Si?Dx(a,e)?!0:a.name===e&&a.url===e:!1);return r!=null?(Px(r,e),t.set(e,r),n!=null&&(n.group=r),r):null}function ip(s,e){const t=u0(s,e);if(t!=null)return t;const i=new Si;Px(i,e),s.scene.add(i),p2(s).set(e,i);const n=m2(s,e);return n!=null&&(n.group=i),i}function SH(s){const e=[],t=new Set;return(Array.isArray(s?.models)?s.models:[]).forEach(i=>{if(i?.url==null)return;const n=u0(s,i.url);n==null||t.has(n.uuid)||(t.add(n.uuid),e.push(n))}),s?.scene?.children?.forEach?.(i=>{!Dx(i)||t.has(i.uuid)||(t.add(i.uuid),e.push(i))}),e}function Qh(s,e){const t=[],i=new Set;return SH(s).forEach(n=>{n.traverse(r=>{r===n||i.has(r.uuid)||e(r)&&(i.add(r.uuid),t.push(r))})}),s?.scene?.children?.forEach?.(n=>{if(n.name=="highlightModel")i.add(n.uuid),t.push(n);else{if(i.has(n.uuid)||Dx(n)||n.url==null)return;e(n)&&(i.add(n.uuid),t.push(n))}}),t}function Rx(s){return Qh(s,e=>e instanceof We&&!(e instanceof hi))}function g2(s){return Qh(s,e=>e instanceof hi)}function CH(s){if(typeof s.__modelObjectIndexSeed=="number")return;let e=-1;s?.scene?.traverse?.(t=>{typeof t?.index=="number"&&Number.isFinite(t.index)&&(e=Math.max(e,t.index))}),s.__modelObjectIndexSeed=e+1}function TH(s){CH(s);const e=s.__modelObjectIndexSeed;return s.__modelObjectIndexSeed+=1,e}function Bx(s,e,t){const i=typeof t=="number"?t:TH(s);return e.index=i,f2(s).set(i,e),i}function Lx(s,e){if(!Number.isFinite(e))return;const t=f2(s),i=t.get(e);if(i&&i.parent!=null)return i;i&&i.parent==null&&t.delete(e);const n=Qh(s,r=>r.index===e)[0];return n!=null?(t.set(e,n),n):s?.scene?.children?.find?.(r=>r?.index===e)}function kx(s){const e={self:null,options:null,mouseDownTime:0,mouseDownPosition:null,lastClickTime:0};e.handle_catch=function(v,g){return m(v,g,!0)},e.init=function(v,g){e.self!=null&&e.self.disActive!=null&&e.self.type!=v.type&&e.self.disActive(),e.self=v,g==null&&(g={showCatch:!1}),e.options=g,e.isClickSimpleModel=!0},e.render=function(){e.self&&e.self.render!=null&&e.self.render()},e.active=function(){s.renderer.domElement.addEventListener("mousedown",o),s.renderer.domElement.addEventListener("mouseup",c),s.renderer.domElement.addEventListener("mousemove",l),s.renderer.domElement.addEventListener("touchstart",d,{passive:!1}),s.renderer.domElement.addEventListener("touchend",p,{passive:!1}),s.renderer.domElement.addEventListener("touchmove",u,{passive:!1}),window.addEventListener("keydown",t),window.addEventListener("keyup",i)},e.disActive=function(){s.renderer.domElement.removeEventListener("mousedown",o),s.renderer.domElement.removeEventListener("mouseup",c),s.renderer.domElement.removeEventListener("mousemove",l),s.renderer.domElement.removeEventListener("touchstart",d),s.renderer.domElement.removeEventListener("touchend",p),s.renderer.domElement.removeEventListener("touchmove",u),window.removeEventListener("keydown",t),window.removeEventListener("keyup",i)};function t(v){(v.keyCode===8||v.keyCode===46)&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),v.keyCode===27&&e.self&&e.self.handelKeyEscDown!=null&&e.self.handelKeyEscDown(),v.keyCode===13&&e.self&&e.self.handelKeyEnterDown!=null&&e.self.handelKeyEnterDown(),v.keyCode===32&&e.self&&e.self.handelKeySpaceDown!=null&&e.self.handelKeySpaceDown(),v.key==="Control"&&e.self&&e.self.handelKeyCtrlDown!=null&&e.self.handelKeyCtrlDown(),v.key==="Delete"&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),v.key==="Shift"&&e.self&&e.self.handelKeyShiftDown!=null&&e.self.handelKeyShiftDown(),v.key==="Meta"&&e.self&&e.self.handelKeyMetaDown!=null&&e.self.handelKeyMetaDown()}function i(v){v.key==="Alt"&&e.self&&e.self.handelKeyAltUp!=null&&e.self.handelKeyAltUp(),v.key==="Tab"&&e.self&&e.self.handelKeyTabUp!=null&&e.self.handelKeyTabUp(),v.key==="Control"&&e.self&&e.self.handelKeyCtrlUp!=null&&e.self.handelKeyCtrlUp(),v.key==="Shift"&&e.self&&e.self.handelKeyShiftUp!=null&&e.self.handelKeyShiftUp(),v.key==="Meta"&&e.self&&e.self.handelKeyMetaUp!=null&&e.self.handelKeyMetaUp(),v.key==="Command"&&e.self&&e.self.handelKeyCommandUp!=null&&e.self.handelKeyCommandUp(),v.key==="Windows"&&e.self&&e.self.handelKeyWindowsUp!=null&&e.self.handelKeyWindowsUp()}function n(v){const g=new be,f=s.renderer.domElement.clientWidth,A=s.renderer.domElement.clientHeight;return g.x=v.offsetX/f*2-1,g.y=-(v.offsetY/A)*2+1,g}function r(v){const g=new fs,f=n(v);return g.setFromCamera(f,s.camera),g}function a(v,g=!1,f=!1,A=!0){const b=r(v);if(v.raycaster=b,g){const y=m(b,v,f,A);v.catch=y}}function o(v){e.mouseDownTime=Date.now(),e.mouseDownPosition=new P(v.offsetX,v.offsetY,0),e.self&&e.self.handleMouseDown!=null&&v.button==0&&(a(v,!0,!0),v.catch!=null&&(s.engineStatus.highlightModels==null||s.engineStatus.highlightModels.length==0)&&s.controlModule.orbitControls.origin.set(v.catch.point.x,v.catch.point.y,v.catch.point.z),e.self.handleMouseDown(v))}function l(v){e.self&&e.self.handleMouseMove!=null&&(s.engineStatus.isFree&&a(v,!0,!0,e.isClickSimpleModel),e.self.handleMouseMove(v))}function c(v){const g=Date.now(),f=g-e.mouseDownTime,A=new P(v.offsetX,v.offsetY,0);e.self&&e.self.handleMouseUp!=null&&v.button==0&&(a(v,!1,!1,!1),e.self.handleMouseUp(v));const b=A.distanceTo(e.mouseDownPosition);(f<100||b==0)&&e.self&&e.self.handleMouseClick!=null&&(a(v,!0,!0,!1),g-e.lastClickTime<200?e.self.handleMouseDoubleClick!=null&&v.button==0&&e.self.handleMouseDoubleClick(v):e.self.handleMouseClick!=null&&v.button==0?e.self.handleMouseClick(v):e.self.handleRightMouseClick!=null&&v.button==2&&e.self.handleRightMouseClick(v),e.lastClickTime=Date.now())}function h(v){const g=v.touches[0]||v.changedTouches[0];if(!g)return null;const f=s.renderer.domElement.getBoundingClientRect(),A=g.clientX-f.left,b=g.clientY-f.top;return{offsetX:A,offsetY:b,button:0,clientX:g.clientX,clientY:g.clientY,preventDefault:()=>v.preventDefault(),stopPropagation:()=>v.stopPropagation(),originalEvent:v}}function d(v){if(v.preventDefault(),v.touches.length!==1)return;const g=h(v);g&&o(g)}function u(v){if(v.preventDefault(),v.touches.length!==1)return;const g=h(v);g&&l(g)}function p(v){v.preventDefault();const g=h(v);g&&c(g)}function m(v,g,f=!1,A=!0){if(!s.engineStatus.isFree&&f==!1){s.hoverHighLight.clearHighlight();return}s.catchSvg.innerHTML="";let b=s.octreeBox.rayInterationModel(v,f,A);b=s.clipping?.filterIntersectionsByClipping(b)??b;let y=g2(s);A&&(y=y.filter(V=>V.count<500));let x=v.intersectObjects(y,!1);if(x=s.clipping?.filterIntersectionsByClipping(x)??x,x.length>0&&(b.length==0||x[0].distance<b[0].distance)){let V=x[0].object;if(V.ids!=null&&V.ids.length!=0){let H=V.ids[x[0].instanceId],J={object:{url:V.url,id:H,name:H,isInstance:!0},face:x[0].face,distance:x[0].distance,point:x[0].point,instanceId:x[0].instanceId,matrix:V.matrixs[x[0].instanceId]};b.splice(0,0,J)}}if(b.length===0)return;let _=b[0].object.url,M=b[0].object.name,E=s.modelEdge.getModelEdge(_,M);E||(E=[0,0,[]]);let w=[];E[2].forEach(V=>{V[0]!=null&&V[1]!=null&&w.push({X:V[0].X*.5+V[1].X*.5,Y:V[0].Y*.5+V[1].Y*.5,Z:V[0].Z*.5+V[1].Z*.5})});let T=[...E[2].map(V=>V[0]),...w],R="face",D=[],L=[],I=10;if(T.forEach(V=>{if(V!=null){let H=new P(V.X,V.Z,-V.Y);if(s.clipping&&!s.clipping.isPointInClippingRange(H))return;let J=new Kt(s.camera,s.renderer,s.scene).worldToScreen(H),W=Math.sqrt(Math.pow(J.x-g.offsetX,2)+Math.pow(J.y-g.offsetY,2));W<I&&(I=W,D.push({point:H,distance:W,pointxy:J}))}}),D.length>0?(D.sort((V,H)=>V.distance-H.distance),R="point"):(E[2].forEach(V=>{if(V[0]!=null&&V[1]!=null){let H=new P(V[0].X,V[0].Z,-V[0].Y),J=new P(V[1].X,V[1].Z,-V[1].Y),W=new Kt(s.camera,s.renderer,s.scene).worldToScreen(H),X=new Kt(s.camera,s.renderer,s.scene).worldToScreen(J),me=O(new be(g.offsetX,g.offsetY),W,X);if(me<I){let Ee=N(new be(g.offsetX,g.offsetY),W,X),Me=G(Ee,H,J);if(s.clipping&&!s.clipping.isPointInClippingRange(Me))return;L.push({distance:me,point:Me,pointxy:new Kt(s.camera,s.renderer,s.scene).worldToScreen(Me),start:W,end:X})}}}),L.length>0&&(L.sort((V,H)=>V.distance-H.distance),R="line")),R=="point"&&e.options.showCatch){const V=new Kt(s.camera,s.renderer,s.scene).worldToScreen(D[0].point);s.catchSvg.innerHTML="";const H=V.x+s.reactBoundingClientRect.left,J=V.y+s.reactBoundingClientRect.top;console.log(H,J);const W=document.createElementNS("http://www.w3.org/2000/svg","polygon");W.setAttribute("class","catchPoint"),W.setAttribute("points",`${H},${J-8} ${H-7},${J+4} ${H+7},${J+4}`),W.setAttribute("stroke","rgb(8, 223, 215)"),W.setAttribute("fill","transparent"),s.catchSvg.appendChild(W),b[0].point=D[0].point}else if(R=="line"&&e.options.showCatch){const V=new Kt(s.camera,s.renderer,s.scene).worldToScreen(L[0].point),H=L[0].start,J=L[0].end;s.catchSvg.innerHTML="";const W=document.createElementNS("http://www.w3.org/2000/svg","line");W.setAttribute("class","catchLine"),W.setAttribute("x1",(H.x+s.reactBoundingClientRect.left).toString()),W.setAttribute("y1",(H.y+s.reactBoundingClientRect.top).toString()),W.setAttribute("x2",(J.x+s.reactBoundingClientRect.left).toString()),W.setAttribute("y2",(J.y+s.reactBoundingClientRect.top).toString()),W.setAttribute("stroke","rgb(8, 223, 215)"),W.setAttribute("stroke-width","2"),s.catchSvg.appendChild(W);const X=V.x+s.reactBoundingClientRect.left,me=V.y+s.reactBoundingClientRect.top,Ee=document.createElementNS("http://www.w3.org/2000/svg","polygon");Ee.setAttribute("class","catchPoint"),Ee.setAttribute("points",`${X},${me-8} ${X-7},${me+4} ${X+7},${me+4}`),Ee.setAttribute("stroke","rgb(8, 223, 215)"),Ee.setAttribute("fill","transparent"),s.catchSvg.appendChild(Ee),b[0].point=L[0].point}else if(R=="face"&&e.options.showCatch){let V=b[0].point.clone(),H=b[0].normal||(b[0].face?b[0].face.normal:null);const J=(H?H.clone():new P(0,0,1)).normalize(),W=Math.abs(J.y)<.9?new P(0,1,0):new P(1,0,0),X=new P().crossVectors(J,W).normalize(),me=new P().crossVectors(J,X).normalize(),Ee=20,Me=new Kt(s.camera,s.renderer,s.scene),$=Me.worldToScreen(V),se=Me.worldToScreen(new P().copy(V).add(X)),he=Math.sqrt((se.x-$.x)**2+(se.y-$.y)**2),Te=he>0?Ee/he:.2,Le=[new P().copy(X).add(me).multiplyScalar(Te),new P().copy(X).sub(me).multiplyScalar(Te),new P().copy(X).multiplyScalar(-1).sub(me).multiplyScalar(Te),new P().copy(X).multiplyScalar(-1).add(me).multiplyScalar(Te)].map(tt=>new P().copy(V).add(tt)).map(tt=>new Kt(s.camera,s.renderer,s.scene).worldToScreen(tt));s.catchSvg.innerHTML="";const Oe=document.createElementNS("http://www.w3.org/2000/svg","polygon");Oe.setAttribute("class","catchFace"),Oe.setAttribute("points",Le.map(tt=>`${tt.x+s.reactBoundingClientRect.left},${tt.y+s.reactBoundingClientRect.top}`).join(" ")),Oe.setAttribute("fill","rgba(1, 238, 255, 0.2)"),Oe.setAttribute("stroke","rgb(0, 255, 247)"),Oe.setAttribute("stroke-width","1"),s.catchSvg.appendChild(Oe)}return b[0];function O(V,H,J){const W=new be().subVectors(J,H),X=W.lengthSq();if(X<1e-10)return V.distanceTo(H);const me=new be().subVectors(V,H),Ee=Bt.clamp(me.dot(W)/X,0,1),Me=new be().copy(W).multiplyScalar(Ee).add(H);return V.distanceTo(Me)}function N(V,H,J){const W=new be().subVectors(J,H),X=W.lengthSq();if(X<1e-10)return 0;const me=new be().subVectors(V,H);return Bt.clamp(me.dot(W)/X,0,1)}function G(V,H,J){const W=Bt.clamp(V,0,1);return new P().lerpVectors(H,J,W)}}return e}class IH{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=kx(this.engine),this.handelBehaved.init(this,null),this.handelBehaved.active()}init(){this.orbitControls=new pH(this.engine,this.engine.camera,this.engine.renderer.domElement),this.orbitControls.showOriginIcon=!0,this.firstPersonControls=new u2(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 u2(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 Kt(this.engine.camera,this.engine.renderer,this.engine.scene)}switchDefaultMode(){if(this.firstPersonControls){this.firstPersonControls.enabled=!1;const e=this.engine.camera,t=new P;e.getWorldDirection(t),this.orbitControls.target.copy(e.position).add(t.multiplyScalar(10)),this.orbitControls.update()}this.orbitControls.enabled=!0,this.engine.worldToScreen=new Kt(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 jl={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 Xl{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 PH=new Zi(-1,1,1,-1,0,1);class DH extends dt{constructor(){super(),this.setAttribute("position",new it([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new it([0,2,0,0,2,0],2))}}const RH=new DH;class p0{constructor(e){this._mesh=new We(RH,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,PH)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class f0 extends Xl{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof mi?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Mn.clone(e.uniforms),this.material=new mi({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 p0(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 v2 extends Xl{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(),r=e.state;r.buffers.color.setMask(!1),r.buffers.depth.setMask(!1),r.buffers.color.setLocked(!0),r.buffers.depth.setLocked(!0);let a,o;this.inverse?(a=0,o=1):(a=1,o=0),r.buffers.stencil.setTest(!0),r.buffers.stencil.setOp(n.REPLACE,n.REPLACE,n.REPLACE),r.buffers.stencil.setFunc(n.ALWAYS,a,4294967295),r.buffers.stencil.setClear(o),r.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),r.buffers.color.setLocked(!1),r.buffers.depth.setLocked(!1),r.buffers.color.setMask(!0),r.buffers.depth.setMask(!0),r.buffers.stencil.setLocked(!1),r.buffers.stencil.setFunc(n.EQUAL,1,4294967295),r.buffers.stencil.setOp(n.KEEP,n.KEEP,n.KEEP),r.buffers.stencil.setLocked(!0)}}class BH extends Xl{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class LH{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 ki(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:li}),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 f0(jl),this.copyPass.material.blending=vi,this.timer=new Bb}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,r=this.passes.length;n<r;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()}v2!==void 0&&(a instanceof v2?i=!0:a instanceof BH&&(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 r=0;r<this.passes.length;r++)this.passes[r].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 kH extends Xl{constructor(e,t,i=null,n=null,r=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=i,this.clearColor=n,this.clearAlpha=r,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.isRenderPass=!0,this._oldClearColor=new qe}render(e,t,i){const n=e.autoClear;e.autoClear=!1;let r,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&&(r=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(r),this.overrideMaterial!==null&&(this.scene.overrideMaterial=a),e.autoClear=n}}const m0={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 P(-1,-1,-1)},sceneBoxMax:{value:new P(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;
|
||
}`},g0={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 );
|
||
|
||
}`},Ox={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 OH(s=5){const e=Math.floor(s)%2===0?Math.floor(s)+1:Math.floor(s),t=FH(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 P(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 r=new On(n,e,e);return r.wrapS=ln,r.wrapT=ln,r.needsUpdate=!0,r}function FH(s){const e=Math.floor(s)%2===0?Math.floor(s)+1:Math.floor(s),t=e*e,i=Array(t).fill(0);let n=Math.floor(e/2),r=e-1;for(let a=1;a<=t;){if(n===-1&&r===e?(r=e-2,n=0):(r===e&&(r=0),n<0&&(n=e-1)),i[n*e+r]!==0){r-=2,n++;continue}else i[n*e+r]=a++;r++,n--}return i}const v0={defines:{SAMPLES:16,SAMPLE_VECTORS:A2(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 A2(s,e,t){const i=NH(s,e,t);let n="vec3[SAMPLES](";for(let r=0;r<s;r++){const a=i[r];n+=`vec3(${a.x}, ${a.y}, ${a.z})${r<s-1?",":")"}`}return n}function NH(s,e,t){const i=[];for(let n=0;n<s;n++){const r=2*Math.PI*e*n/s,a=Math.pow(n/(s-1),t);i.push(new P(Math.cos(r),Math.sin(r),a))}return i}class b2{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,r;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,u=l-d,p=c-d,m=e-u,v=t-p;let g,f;m>v?(g=1,f=0):(g=0,f=1);const A=m-g+h,b=v-f+h,y=m-1+2*h,x=v-1+2*h,_=l&255,M=c&255,E=this.perm[_+this.perm[M]]%12,w=this.perm[_+g+this.perm[M+f]]%12,T=this.perm[_+1+this.perm[M+1]]%12;let R=.5-m*m-v*v;R<0?i=0:(R*=R,i=R*R*this._dot(this.grad3[E],m,v));let D=.5-A*A-b*b;D<0?n=0:(D*=D,n=D*D*this._dot(this.grad3[w],A,b));let L=.5-y*y-x*x;return L<0?r=0:(L*=L,r=L*L*this._dot(this.grad3[T],y,x)),70*(i+n+r)}noise3d(e,t,i){let n,r,a,o;const l=(e+t+i)*.3333333333333333,c=Math.floor(e+l),h=Math.floor(t+l),d=Math.floor(i+l),u=1/6,p=(c+h+d)*u,m=c-p,v=h-p,g=d-p,f=e-m,A=t-v,b=i-g;let y,x,_,M,E,w;f>=A?A>=b?(y=1,x=0,_=0,M=1,E=1,w=0):f>=b?(y=1,x=0,_=0,M=1,E=0,w=1):(y=0,x=0,_=1,M=1,E=0,w=1):A<b?(y=0,x=0,_=1,M=0,E=1,w=1):f<b?(y=0,x=1,_=0,M=0,E=1,w=1):(y=0,x=1,_=0,M=1,E=1,w=0);const T=f-y+u,R=A-x+u,D=b-_+u,L=f-M+2*u,I=A-E+2*u,O=b-w+2*u,N=f-1+3*u,G=A-1+3*u,V=b-1+3*u,H=c&255,J=h&255,W=d&255,X=this.perm[H+this.perm[J+this.perm[W]]]%12,me=this.perm[H+y+this.perm[J+x+this.perm[W+_]]]%12,Ee=this.perm[H+M+this.perm[J+E+this.perm[W+w]]]%12,Me=this.perm[H+1+this.perm[J+1+this.perm[W+1]]]%12;let $=.6-f*f-A*A-b*b;$<0?n=0:($*=$,n=$*$*this._dot3(this.grad3[X],f,A,b));let se=.6-T*T-R*R-D*D;se<0?r=0:(se*=se,r=se*se*this._dot3(this.grad3[me],T,R,D));let he=.6-L*L-I*I-O*O;he<0?a=0:(he*=he,a=he*he*this._dot3(this.grad3[Ee],L,I,O));let Te=.6-N*N-G*G-V*V;return Te<0?o=0:(Te*=Te,o=Te*Te*this._dot3(this.grad3[Me],N,G,V)),32*(n+r+a+o)}noise4d(e,t,i,n){const r=this.grad4,a=this.simplex,o=this.perm,l=(Math.sqrt(5)-1)/4,c=(5-Math.sqrt(5))/20;let h,d,u,p,m;const v=(e+t+i+n)*l,g=Math.floor(e+v),f=Math.floor(t+v),A=Math.floor(i+v),b=Math.floor(n+v),y=(g+f+A+b)*c,x=g-y,_=f-y,M=A-y,E=b-y,w=e-x,T=t-_,R=i-M,D=n-E,L=w>T?32:0,I=w>R?16:0,O=T>R?8:0,N=w>D?4:0,G=T>D?2:0,V=R>D?1:0,H=L+I+O+N+G+V,J=a[H][0]>=3?1:0,W=a[H][1]>=3?1:0,X=a[H][2]>=3?1:0,me=a[H][3]>=3?1:0,Ee=a[H][0]>=2?1:0,Me=a[H][1]>=2?1:0,$=a[H][2]>=2?1:0,se=a[H][3]>=2?1:0,he=a[H][0]>=1?1:0,Te=a[H][1]>=1?1:0,Le=a[H][2]>=1?1:0,Oe=a[H][3]>=1?1:0,tt=w-J+c,Ye=T-W+c,B=R-X+c,re=D-me+c,ee=w-Ee+2*c,Q=T-Me+2*c,k=R-$+2*c,ie=D-se+2*c,fe=w-he+3*c,xe=T-Te+3*c,te=R-Le+3*c,C=D-Oe+3*c,S=w-1+4*c,F=T-1+4*c,q=R-1+4*c,K=D-1+4*c,Y=g&255,ye=f&255,pe=A&255,Ue=b&255,He=o[Y+o[ye+o[pe+o[Ue]]]]%32,oe=o[Y+J+o[ye+W+o[pe+X+o[Ue+me]]]]%32,we=o[Y+Ee+o[ye+Me+o[pe+$+o[Ue+se]]]]%32,Ve=o[Y+he+o[ye+Te+o[pe+Le+o[Ue+Oe]]]]%32,Fe=o[Y+1+o[ye+1+o[pe+1+o[Ue+1]]]]%32;let Ie=.6-w*w-T*T-R*R-D*D;Ie<0?h=0:(Ie*=Ie,h=Ie*Ie*this._dot4(r[He],w,T,R,D));let $e=.6-tt*tt-Ye*Ye-B*B-re*re;$e<0?d=0:($e*=$e,d=$e*$e*this._dot4(r[oe],tt,Ye,B,re));let z=.6-ee*ee-Q*Q-k*k-ie*ie;z<0?u=0:(z*=z,u=z*z*this._dot4(r[we],ee,Q,k,ie));let _e=.6-fe*fe-xe*xe-te*te-C*C;_e<0?p=0:(_e*=_e,p=_e*_e*this._dot4(r[Ve],fe,xe,te,C));let ve=.6-S*S-F*F-q*q-K*K;return ve<0?m=0:(ve*=ve,m=ve*ve*this._dot4(r[Fe],S,F,q,K)),27*(h+d+u+p+m)}_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,r){return e[0]*t+e[1]*i+e[2]*n+e[3]*r}}class cr extends Xl{constructor(e,t,i=512,n=512,r,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=OH(),this.pdNoiseTexture=this._generateNoise(),this.gtaoRenderTarget=new ki(this.width,this.height,{type:li}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new mi({defines:Object.assign({},m0.defines),uniforms:Mn.clone(m0.uniforms),vertexShader:m0.vertexShader,fragmentShader:m0.fragmentShader,blending:vi,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 dg,this.normalMaterial.blending=vi,this.pdMaterial=new mi({defines:Object.assign({},v0.defines),uniforms:Mn.clone(v0.uniforms),vertexShader:v0.vertexShader,fragmentShader:v0.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 mi({defines:Object.assign({},g0.defines),uniforms:Mn.clone(g0.uniforms),vertexShader:g0.vertexShader,fragmentShader:g0.fragmentShader,blending:vi}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new mi({uniforms:Mn.clone(jl.uniforms),vertexShader:jl.vertexShader,fragmentShader:jl.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:Ld,blendDst:Va,blendEquation:Kn,blendSrcAlpha:Bd,blendDstAlpha:Va,blendEquationAlpha:Kn}),this.blendMaterial=new mi({uniforms:Mn.clone(Ox.uniforms),vertexShader:Ox.vertexShader,fragmentShader:Ox.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:yf,blendSrc:Ld,blendDst:Va,blendEquation:Kn,blendSrcAlpha:Bd,blendDstAlpha:Va,blendEquationAlpha:Kn}),this._fsQuad=new p0(null),this._originalClearColor=new qe,this.setGBuffer(r?r.depthTexture:void 0,r?r.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 so,this.depthTexture.format=Mr,this.depthTexture.type=Qa,this.normalRenderTarget=new ki(this.width,this.height,{minFilter:Jt,magFilter:Jt,type:li,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=A2(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 cr.OUTPUT.Off:break;case cr.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=i.texture,this.copyMaterial.blending=vi,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case cr.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=vi,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case cr.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=vi,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case cr.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 cr.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=vi,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case cr.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=i.texture,this.copyMaterial.blending=vi,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,r){e.getClearColor(this._originalClearColor);const a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(i),e.autoClear=!1,n!=null&&(e.setClearColor(n),e.setClearAlpha(r||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,r){e.getClearColor(this._originalClearColor);const a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(i),e.autoClear=!1,n=t.clearColor||n,r=t.clearAlpha||r,n!=null&&(e.setClearColor(n),e.setClearAlpha(r||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 b2,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 r=new On(n,e,e,_i,bt);return r.wrapS=ln,r.wrapT=ln,r.needsUpdate=!0,r}}cr.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};const A0={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 );
|
||
|
||
}
|
||
|
||
}`},b0={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 );
|
||
|
||
}`},y0={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 _a extends Xl{constructor(e,t,i=512,n=512,r=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(r),this._generateRandomKernelRotations();const a=new so;a.format=Mr,a.type=Qa,this.normalRenderTarget=new ki(this.width,this.height,{minFilter:Jt,magFilter:Jt,type:li,depthTexture:a}),this.ssaoRenderTarget=new ki(this.width,this.height,{type:li}),this.blurRenderTarget=this.ssaoRenderTarget.clone(),this.ssaoMaterial=new mi({defines:Object.assign({},A0.defines),uniforms:Mn.clone(A0.uniforms),vertexShader:A0.vertexShader,fragmentShader:A0.fragmentShader,blending:vi}),this.ssaoMaterial.defines.KERNEL_SIZE=r,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 dg,this.normalMaterial.blending=vi,this.blurMaterial=new mi({defines:Object.assign({},y0.defines),uniforms:Mn.clone(y0.uniforms),vertexShader:y0.vertexShader,fragmentShader:y0.fragmentShader}),this.blurMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.depthRenderMaterial=new mi({defines:Object.assign({},b0.defines),uniforms:Mn.clone(b0.uniforms),vertexShader:b0.vertexShader,fragmentShader:b0.fragmentShader,blending:vi}),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 mi({uniforms:Mn.clone(jl.uniforms),vertexShader:jl.vertexShader,fragmentShader:jl.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:Ld,blendDst:Va,blendEquation:Kn,blendSrcAlpha:Bd,blendDstAlpha:Va,blendEquationAlpha:Kn}),this._fsQuad=new p0(null),this._originalClearColor=new qe}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 _a.OUTPUT.SSAO:this.copyMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.copyMaterial.blending=vi,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:i);break;case _a.OUTPUT.Blur:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=vi,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:i);break;case _a.OUTPUT.Depth:this._renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:i);break;case _a.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=vi,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:i);break;case _a.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=yf,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,r){e.getClearColor(this._originalClearColor);const a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(i),e.autoClear=!1,n!=null&&(e.setClearColor(n),e.setClearAlpha(r||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,r){e.getClearColor(this._originalClearColor);const a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(i),e.autoClear=!1,n=t.clearColor||n,r=t.clearAlpha||r,n!=null&&(e.setClearColor(n),e.setClearAlpha(r||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 P;n.x=Math.random()*2-1,n.y=Math.random()*2-1,n.z=Math.random(),n.normalize();let r=i/e;r=Bt.lerp(.1,1,r*r),n.multiplyScalar(r),t.push(n)}}_generateRandomKernelRotations(){const e=new b2,t=16,i=new Float32Array(t);for(let n=0;n<t;n++){const r=Math.random()*2-1,a=Math.random()*2-1,o=0;i[n]=e.noise3d(r,a,o)}this.noiseTexture=new On(i,4,4,Sr,xi),this.noiseTexture.wrapS=ln,this.noiseTexture.wrapT=ln,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}}_a.OUTPUT={Default:0,SSAO:1,Blur:2,Depth:3,Normal:4};const x0={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 UH extends Xl{constructor(){super(),this.isOutputPass=!0,this.uniforms=Mn.clone(x0.uniforms),this.material=new hg({name:x0.name,uniforms:this.uniforms,vertexShader:x0.vertexShader,fragmentShader:x0.fragmentShader}),this._fsQuad=new p0(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={},It.getTransfer(this._outputColorSpace)===Yt&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===Pf?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===Df?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===Rf?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===Yr?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===Lf?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===kf?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===Bf&&(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 zH={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 );
|
||
|
||
}`},HH={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;
|
||
}
|
||
`},y2=.5,x2=1.05,_2=1.05;class GH{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 r=this.engine.deviceModule.getContainerSize();e=e??r.width,t=t??r.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(r=>r instanceof f0&&r.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,r=this.engine.renderer,a=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1,o=new ki(e,t,{minFilter:wt,magFilter:wt,format:_i,samples:4});this.composer=new LH(r,o),this.composer.setPixelRatio(a),this.composer.setSize(e,t);const l=new kH(i,n);this.composer.addPass(l),this.gtaoPass=new cr(i,n,e,t),this.gtaoPass.output=cr.OUTPUT.Default,this.gtaoPass.blendIntensity=y2,this.gtaoPass.enabled=!1,this.gtaoPass.updateGtaoMaterial&&this.gtaoPass.updateGtaoMaterial({enabled:!0,radius:.5,thickness:.5,distanceExponent:1,distanceFallOff:1,scale:5,samples:10,resolutionScale:.45,useTemporalFiltering:!1,screenSpaceRadius:!1}),this.applyClippingToAmbientOcclusionPass(this.gtaoPass),this.composer.addPass(this.gtaoPass),this.ssaoPass=new _a(i,n,e,t),this.ssaoPass.kernelRadius=8,this.ssaoPass.minDistance=.005,this.ssaoPass.maxDistance=.1,this.ssaoPass.output=_a.OUTPUT.Default,this.ssaoPass.enabled=!1,this.applyClippingToAmbientOcclusionPass(this.ssaoPass),this.composer.addPass(this.ssaoPass),this.saturationPass=new f0(HH),this.saturationPass.uniforms.saturation.value=x2,this.saturationPass.uniforms.contrast.value=_2,this.saturationPass.enabled=!1,this.composer.addPass(this.saturationPass),this.outputPass=new UH,this.outputPass.enabled=!0,this.composer.addPass(this.outputPass),this.fxaaPass=new f0(zH),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 _0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function w2(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function w0(s){throw new Error('Could not dynamically require "'+s+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var E2={exports:{}},M2;function VH(){return M2||(M2=1,(function(s,e){(function(t){s.exports=t()})(function(){return(function t(i,n,r){function a(c,h){if(!n[c]){if(!i[c]){var d=typeof w0=="function"&&w0;if(!h&&d)return d(c,!0);if(o)return o(c,!0);var u=new Error("Cannot find module '"+c+"'");throw u.code="MODULE_NOT_FOUND",u}var p=n[c]={exports:{}};i[c][0].call(p.exports,function(m){var v=i[c][1][m];return a(v||m)},p,p.exports,t,i,n,r)}return n[c].exports}for(var o=typeof w0=="function"&&w0,l=0;l<r.length;l++)a(r[l]);return a})({1:[function(t,i,n){var r=t("./utils"),a=t("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.encode=function(l){for(var c,h,d,u,p,m,v,g=[],f=0,A=l.length,b=A,y=r.getTypeOf(l)!=="string";f<l.length;)b=A-f,d=y?(c=l[f++],h=f<A?l[f++]:0,f<A?l[f++]:0):(c=l.charCodeAt(f++),h=f<A?l.charCodeAt(f++):0,f<A?l.charCodeAt(f++):0),u=c>>2,p=(3&c)<<4|h>>4,m=1<b?(15&h)<<2|d>>6:64,v=2<b?63&d:64,g.push(o.charAt(u)+o.charAt(p)+o.charAt(m)+o.charAt(v));return g.join("")},n.decode=function(l){var c,h,d,u,p,m,v=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 A,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(A=a.uint8array?new Uint8Array(0|b):new Array(0|b);v<l.length;)c=o.indexOf(l.charAt(v++))<<2|(u=o.indexOf(l.charAt(v++)))>>4,h=(15&u)<<4|(p=o.indexOf(l.charAt(v++)))>>2,d=(3&p)<<6|(m=o.indexOf(l.charAt(v++))),A[g++]=c,p!==64&&(A[g++]=h),m!==64&&(A[g++]=d);return A}},{"./support":30,"./utils":32}],2:[function(t,i,n){var r=t("./external"),a=t("./stream/DataWorker"),o=t("./stream/Crc32Probe"),l=t("./stream/DataLengthProbe");function c(h,d,u,p,m){this.compressedSize=h,this.uncompressedSize=d,this.crc32=u,this.compression=p,this.compressedContent=m}c.prototype={getContentWorker:function(){var h=new a(r.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(r.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,u){return h.pipe(new o).pipe(new l("uncompressedSize")).pipe(d.compressWorker(u)).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 r=t("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},n.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,i,n){var r=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?r.getTypeOf(o)!=="string"?(function(c,h,d,u){var p=a,m=u+d;c^=-1;for(var v=u;v<m;v++)c=c>>>8^p[255&(c^h[v])];return-1^c})(0|l,o,o.length,0):(function(c,h,d,u){var p=a,m=u+d;c^=-1;for(var v=u;v<m;v++)c=c>>>8^p[255&(c^h.charCodeAt(v))];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 r=null;r=typeof Promise<"u"?Promise:t("lie"),i.exports={Promise:r}},{lie:37}],7:[function(t,i,n){var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=t("pako"),o=t("./utils"),l=t("./stream/GenericWorker"),c=r?"uint8array":"array";function h(d,u){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=u,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(u){d.push({data:u,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 r(p,m){var v,g="";for(v=0;v<m;v++)g+=String.fromCharCode(255&p),p>>>=8;return g}function a(p,m,v,g,f,A){var b,y,x=p.file,_=p.compression,M=A!==c.utf8encode,E=o.transformTo("string",A(x.name)),w=o.transformTo("string",c.utf8encode(x.name)),T=x.comment,R=o.transformTo("string",A(T)),D=o.transformTo("string",c.utf8encode(T)),L=w.length!==x.name.length,I=D.length!==T.length,O="",N="",G="",V=x.dir,H=x.date,J={crc32:0,compressedSize:0,uncompressedSize:0};m&&!v||(J.crc32=p.crc32,J.compressedSize=p.compressedSize,J.uncompressedSize=p.uncompressedSize);var W=0;m&&(W|=8),M||!L&&!I||(W|=2048);var X=0,me=0;V&&(X|=16),f==="UNIX"?(me=798,X|=(function(Me,$){var se=Me;return Me||(se=$?16893:33204),(65535&se)<<16})(x.unixPermissions,V)):(me=20,X|=(function(Me){return 63&(Me||0)})(x.dosPermissions)),b=H.getUTCHours(),b<<=6,b|=H.getUTCMinutes(),b<<=5,b|=H.getUTCSeconds()/2,y=H.getUTCFullYear()-1980,y<<=4,y|=H.getUTCMonth()+1,y<<=5,y|=H.getUTCDate(),L&&(N=r(1,1)+r(h(E),4)+w,O+="up"+r(N.length,2)+N),I&&(G=r(1,1)+r(h(R),4)+D,O+="uc"+r(G.length,2)+G);var Ee="";return Ee+=`
|
||
\0`,Ee+=r(W,2),Ee+=_.magic,Ee+=r(b,2),Ee+=r(y,2),Ee+=r(J.crc32,4),Ee+=r(J.compressedSize,4),Ee+=r(J.uncompressedSize,4),Ee+=r(E.length,2),Ee+=r(O.length,2),{fileRecord:d.LOCAL_FILE_HEADER+Ee+E+O,dirRecord:d.CENTRAL_FILE_HEADER+r(me,2)+Ee+r(R.length,2)+"\0\0\0\0"+r(X,4)+r(g,4)+E+O+R}}var o=t("../utils"),l=t("../stream/GenericWorker"),c=t("../utf8"),h=t("../crc32"),d=t("../signature");function u(p,m,v,g){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=m,this.zipPlatform=v,this.encodeFileName=g,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(u,l),u.prototype.push=function(p){var m=p.meta.percent||0,v=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,l.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:v?(m+100*(v-g-1))/v:100}}))},u.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var m=this.streamFiles&&!p.file.dir;if(m){var v=a(p,m,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:v.fileRecord,meta:{percent:0}})}else this.accumulate=!0},u.prototype.closedSource=function(p){this.accumulate=!1;var m=this.streamFiles&&!p.file.dir,v=a(p,m,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(v.dirRecord),m)this.push({data:(function(g){return d.DATA_DESCRIPTOR+r(g.crc32,4)+r(g.compressedSize,4)+r(g.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:v.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},u.prototype.flush=function(){for(var p=this.bytesWritten,m=0;m<this.dirRecords.length;m++)this.push({data:this.dirRecords[m],meta:{percent:100}});var v=this.bytesWritten-p,g=(function(f,A,b,y,x){var _=o.transformTo("string",x(y));return d.CENTRAL_DIRECTORY_END+"\0\0\0\0"+r(f,2)+r(f,2)+r(A,4)+r(b,4)+r(_.length,2)+_})(this.dirRecords.length,v,p,this.zipComment,this.encodeFileName);this.push({data:g,meta:{percent:100}})},u.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},u.prototype.registerPrevious=function(p){this._sources.push(p);var m=this;return p.on("data",function(v){m.processChunk(v)}),p.on("end",function(){m.closedSource(m.previous.streamInfo),m._sources.length?m.prepareNextSource():m.end()}),p.on("error",function(v){m.error(v)}),this},u.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))},u.prototype.error=function(p){var m=this._sources;if(!l.prototype.error.call(this,p))return!1;for(var v=0;v<m.length;v++)try{m[v].error(p)}catch{}return!0},u.prototype.lock=function(){l.prototype.lock.call(this);for(var p=this._sources,m=0;m<p.length;m++)p[m].lock()},i.exports=u},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,i,n){var r=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(u,p){d++;var m=(function(A,b){var y=A||b,x=r[y];if(!x)throw new Error(y+" is not a valid compression method !");return x})(p.options.compression,l.compression),v=p.options.compressionOptions||l.compressionOptions||{},g=p.dir,f=p.date;p._compressWorker(m,v).withStreamInfo("file",{name:u,dir:g,date:f,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(h)}),h.entriesCount=d}catch(u){h.error(u)}return h}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(t,i,n){function r(){if(!(this instanceof r))return new r;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 r;for(var o in this)typeof this[o]!="function"&&(a[o]=this[o]);return a}}(r.prototype=t("./object")).loadAsync=t("./load"),r.support=t("./support"),r.defaults=t("./defaults"),r.version="3.10.1",r.loadAsync=function(a,o){return new r().loadAsync(a,o)},r.external=t("./external"),i.exports=r},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(t,i,n){var r=t("./utils"),a=t("./external"),o=t("./utf8"),l=t("./zipEntries"),c=t("./stream/Crc32Probe"),h=t("./nodejsUtils");function d(u){return new a.Promise(function(p,m){var v=u.decompressed.getContentWorker().pipe(new c);v.on("error",function(g){m(g)}).on("end",function(){v.streamInfo.crc32!==u.decompressed.crc32?m(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}i.exports=function(u,p){var m=this;return p=r.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),h.isNode&&h.isStream(u)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):r.prepareContent("the loaded zip file",u,!0,p.optimizedBinaryString,p.base64).then(function(v){var g=new l(p);return g.load(v),g}).then(function(v){var g=[a.Promise.resolve(v)],f=v.files;if(p.checkCRC32)for(var A=0;A<f.length;A++)g.push(d(f[A]));return a.Promise.all(g)}).then(function(v){for(var g=v.shift(),f=g.files,A=0;A<f.length;A++){var b=f[A],y=b.fileNameStr,x=r.resolve(b.fileNameStr);m.file(x,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:p.createFolders}),b.dir||(m.file(x).unsafeOriginalName=y)}return g.zipComment.length&&(m.comment=g.zipComment),m})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,i,n){var r=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)}r.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 r=t("readable-stream").Readable;function a(o,l,c){r.call(this,l),this._helper=o;var h=this;o.on("data",function(d,u){h.push(d)||h._helper.pause(),c&&c(u)}).on("error",function(d){h.emit("error",d)}).on("end",function(){h.push(null)})}t("../utils").inherits(a,r),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(r,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(r,a);if(typeof r=="number")throw new Error('The "data" argument must not be a number');return new Buffer(r,a)},allocBuffer:function(r){if(Buffer.alloc)return Buffer.alloc(r);var a=new Buffer(r);return a.fill(0),a},isBuffer:function(r){return Buffer.isBuffer(r)},isStream:function(r){return r&&typeof r.on=="function"&&typeof r.pause=="function"&&typeof r.resume=="function"}}},{}],15:[function(t,i,n){function r(x,_,M){var E,w=o.getTypeOf(_),T=o.extend(M||{},h);T.date=T.date||new Date,T.compression!==null&&(T.compression=T.compression.toUpperCase()),typeof T.unixPermissions=="string"&&(T.unixPermissions=parseInt(T.unixPermissions,8)),T.unixPermissions&&16384&T.unixPermissions&&(T.dir=!0),T.dosPermissions&&16&T.dosPermissions&&(T.dir=!0),T.dir&&(x=f(x)),T.createFolders&&(E=g(x))&&A.call(this,E,!0);var R=w==="string"&&T.binary===!1&&T.base64===!1;M&&M.binary!==void 0||(T.binary=!R),(_ instanceof d&&_.uncompressedSize===0||T.dir||!_||_.length===0)&&(T.base64=!1,T.binary=!0,_="",T.compression="STORE",w="string");var D=null;D=_ instanceof d||_ instanceof l?_:m.isNode&&m.isStream(_)?new v(x,_):o.prepareContent(x,_,T.binary,T.optimizedBinaryString,T.base64);var L=new u(x,D,T);this.files[x]=L}var a=t("./utf8"),o=t("./utils"),l=t("./stream/GenericWorker"),c=t("./stream/StreamHelper"),h=t("./defaults"),d=t("./compressedObject"),u=t("./zipObject"),p=t("./generate"),m=t("./nodejsUtils"),v=t("./nodejs/NodejsStreamInputAdapter"),g=function(x){x.slice(-1)==="/"&&(x=x.substring(0,x.length-1));var _=x.lastIndexOf("/");return 0<_?x.substring(0,_):""},f=function(x){return x.slice(-1)!=="/"&&(x+="/"),x},A=function(x,_){return _=_!==void 0?_:h.createFolders,x=f(x),this.files[x]||r.call(this,x,null,{dir:!0,createFolders:_}),this.files[x]};function b(x){return Object.prototype.toString.call(x)==="[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(x){var _,M,E;for(_ in this.files)E=this.files[_],(M=_.slice(this.root.length,_.length))&&_.slice(0,this.root.length)===this.root&&x(M,E)},filter:function(x){var _=[];return this.forEach(function(M,E){x(M,E)&&_.push(E)}),_},file:function(x,_,M){if(arguments.length!==1)return x=this.root+x,r.call(this,x,_,M),this;if(b(x)){var E=x;return this.filter(function(T,R){return!R.dir&&E.test(T)})}var w=this.files[this.root+x];return w&&!w.dir?w:null},folder:function(x){if(!x)return this;if(b(x))return this.filter(function(w,T){return T.dir&&x.test(w)});var _=this.root+x,M=A.call(this,_),E=this.clone();return E.root=M.name,E},remove:function(x){x=this.root+x;var _=this.files[x];if(_||(x.slice(-1)!=="/"&&(x+="/"),_=this.files[x]),_&&!_.dir)delete this.files[x];else for(var M=this.filter(function(w,T){return T.name.slice(0,x.length)===x}),E=0;E<M.length;E++)delete this.files[M[E].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(x){var _,M={};try{if((M=o.extend(x||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=M.type.toLowerCase(),M.compression=M.compression.toUpperCase(),M.type==="binarystring"&&(M.type="string"),!M.type)throw new Error("No output type specified.");o.checkSupport(M.type),M.platform!=="darwin"&&M.platform!=="freebsd"&&M.platform!=="linux"&&M.platform!=="sunos"||(M.platform="UNIX"),M.platform==="win32"&&(M.platform="DOS");var E=M.comment||this.comment||"";_=p.generateWorker(this,M,E)}catch(w){(_=new l("error")).error(w)}return new c(_,M.type||"string",M.mimeType)},generateAsync:function(x,_){return this.generateInternalStream(x).accumulate(_)},generateNodeStream:function(x,_){return(x=x||{}).type||(x.type="nodebuffer"),this.generateInternalStream(x).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 r=t("./DataReader");function a(o){r.call(this,o);for(var l=0;l<this.data.length;l++)o[l]=255&o[l]}t("../utils").inherits(a,r),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),u=this.length-4;0<=u;--u)if(this.data[u]===l&&this.data[u+1]===c&&this.data[u+2]===h&&this.data[u+3]===d)return u-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),u=this.readData(4);return l===u[0]&&c===u[1]&&h===u[2]&&d===u[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 r=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 r.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 r=t("./Uint8ArrayReader");function a(o){r.call(this,o)}t("../utils").inherits(a,r),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 r=t("./DataReader");function a(o){r.call(this,o)}t("../utils").inherits(a,r),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 r=t("./ArrayReader");function a(o){r.call(this,o)}t("../utils").inherits(a,r),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 r=t("../utils"),a=t("../support"),o=t("./ArrayReader"),l=t("./StringReader"),c=t("./NodeBufferReader"),h=t("./Uint8ArrayReader");i.exports=function(d){var u=r.getTypeOf(d);return r.checkSupport(u),u!=="string"||a.uint8array?u==="nodebuffer"?new c(d):a.uint8array?new h(r.transformTo("uint8array",d)):new o(r.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 r=t("./GenericWorker"),a=t("../utils");function o(l){r.call(this,"ConvertWorker to "+l),this.destType=l}a.inherits(o,r),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 r=t("./GenericWorker"),a=t("../crc32");function o(){r.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(o,r),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 r=t("../utils"),a=t("./GenericWorker");function o(l){a.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}r.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 r=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=r.getTypeOf(h),c.isPaused||c._tickAndRepeat()},function(h){c.error(h)})}r.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,r.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.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 r(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}r.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=r},{}],29:[function(t,i,n){var r=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 u(m,v){return new h.Promise(function(g,f){var A=[],b=m._internalType,y=m._outputType,x=m._mimeType;m.on("data",function(_,M){A.push(_),v&&v(M)}).on("error",function(_){A=[],f(_)}).on("end",function(){try{var _=(function(M,E,w){switch(M){case"blob":return r.newBlob(r.transformTo("arraybuffer",E),w);case"base64":return l.encode(E);default:return r.transformTo(M,E)}})(y,(function(M,E){var w,T=0,R=null,D=0;for(w=0;w<E.length;w++)D+=E[w].length;switch(M){case"string":return E.join("");case"array":return Array.prototype.concat.apply([],E);case"uint8array":for(R=new Uint8Array(D),w=0;w<E.length;w++)R.set(E[w],T),T+=E[w].length;return R;case"nodebuffer":return Buffer.concat(E);default:throw new Error("concat : unsupported type '"+M+"'")}})(b,A),x);g(_)}catch(M){f(M)}A=[]}).resume()})}function p(m,v,g){var f=v;switch(v){case"blob":case"arraybuffer":f="uint8array";break;case"base64":f="string"}try{this._internalType=f,this._outputType=v,this._mimeType=g,r.checkSupport(f),this._worker=m.pipe(new a(f)),m.lock()}catch(A){this._worker=new o("error"),this._worker.error(A)}}p.prototype={accumulate:function(m){return u(this,m)},on:function(m,v){var g=this;return m==="data"?this._worker.on(m,function(f){v.call(g,f.data,f.meta)}):this._worker.on(m,function(){r.delay(v,arguments,g)}),this},resume:function(){return r.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(m){if(r.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new d(this,{objectMode:this._outputType!=="nodebuffer"},m)}},i.exports=p},{"../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 r=new ArrayBuffer(0);try{n.blob=new Blob([r],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(r),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 r=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 u(){l.call(this,"utf-8 encode")}n.utf8encode=function(p){return a.nodebuffer?o.newBufferFrom(p,"utf-8"):(function(m){var v,g,f,A,b,y=m.length,x=0;for(A=0;A<y;A++)(64512&(g=m.charCodeAt(A)))==55296&&A+1<y&&(64512&(f=m.charCodeAt(A+1)))==56320&&(g=65536+(g-55296<<10)+(f-56320),A++),x+=g<128?1:g<2048?2:g<65536?3:4;for(v=a.uint8array?new Uint8Array(x):new Array(x),A=b=0;b<x;A++)(64512&(g=m.charCodeAt(A)))==55296&&A+1<y&&(64512&(f=m.charCodeAt(A+1)))==56320&&(g=65536+(g-55296<<10)+(f-56320),A++),g<128?v[b++]=g:(g<2048?v[b++]=192|g>>>6:(g<65536?v[b++]=224|g>>>12:(v[b++]=240|g>>>18,v[b++]=128|g>>>12&63),v[b++]=128|g>>>6&63),v[b++]=128|63&g);return v})(p)},n.utf8decode=function(p){return a.nodebuffer?r.transformTo("nodebuffer",p).toString("utf-8"):(function(m){var v,g,f,A,b=m.length,y=new Array(2*b);for(v=g=0;v<b;)if((f=m[v++])<128)y[g++]=f;else if(4<(A=c[f]))y[g++]=65533,v+=A-1;else{for(f&=A===2?31:A===3?15:7;1<A&&v<b;)f=f<<6|63&m[v++],A--;1<A?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),r.applyFromCharCode(y)})(p=r.transformTo(a.uint8array?"uint8array":"array",p))},r.inherits(d,l),d.prototype.processChunk=function(p){var m=r.transformTo(a.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var v=m;(m=new Uint8Array(v.length+this.leftOver.length)).set(this.leftOver,0),m.set(v,this.leftOver.length)}else m=this.leftOver.concat(m);this.leftOver=null}var g=(function(A,b){var y;for((b=b||A.length)>A.length&&(b=A.length),y=b-1;0<=y&&(192&A[y])==128;)y--;return y<0||y===0?b:y+c[A[y]]>b?y:b})(m),f=m;g!==m.length&&(a.uint8array?(f=m.subarray(0,g),this.leftOver=m.subarray(g,m.length)):(f=m.slice(0,g),this.leftOver=m.slice(g,m.length))),this.push({data:n.utf8decode(f),meta:p.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=d,r.inherits(u,l),u.prototype.processChunk=function(p){this.push({data:n.utf8encode(p.data),meta:p.meta})},n.Utf8EncodeWorker=u},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,i,n){var r=t("./support"),a=t("./base64"),o=t("./nodejsUtils"),l=t("./external");function c(v){return v}function h(v,g){for(var f=0;f<v.length;++f)g[f]=255&v.charCodeAt(f);return g}t("setimmediate"),n.newBlob=function(v,g){n.checkSupport("blob");try{return new Blob([v],{type:g})}catch{try{var f=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return f.append(v),f.getBlob(g)}catch{throw new Error("Bug : can't construct the Blob.")}}};var d={stringifyByChunk:function(v,g,f){var A=[],b=0,y=v.length;if(y<=f)return String.fromCharCode.apply(null,v);for(;b<y;)g==="array"||g==="nodebuffer"?A.push(String.fromCharCode.apply(null,v.slice(b,Math.min(b+f,y)))):A.push(String.fromCharCode.apply(null,v.subarray(b,Math.min(b+f,y)))),b+=f;return A.join("")},stringifyByChar:function(v){for(var g="",f=0;f<v.length;f++)g+=String.fromCharCode(v[f]);return g},applyCanBeUsed:{uint8array:(function(){try{return r.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return r.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}})()}};function u(v){var g=65536,f=n.getTypeOf(v),A=!0;if(f==="uint8array"?A=d.applyCanBeUsed.uint8array:f==="nodebuffer"&&(A=d.applyCanBeUsed.nodebuffer),A)for(;1<g;)try{return d.stringifyByChunk(v,f,g)}catch{g=Math.floor(g/2)}return d.stringifyByChar(v)}function p(v,g){for(var f=0;f<v.length;f++)g[f]=v[f];return g}n.applyFromCharCode=u;var m={};m.string={string:c,array:function(v){return h(v,new Array(v.length))},arraybuffer:function(v){return m.string.uint8array(v).buffer},uint8array:function(v){return h(v,new Uint8Array(v.length))},nodebuffer:function(v){return h(v,o.allocBuffer(v.length))}},m.array={string:u,array:c,arraybuffer:function(v){return new Uint8Array(v).buffer},uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return o.newBufferFrom(v)}},m.arraybuffer={string:function(v){return u(new Uint8Array(v))},array:function(v){return p(new Uint8Array(v),new Array(v.byteLength))},arraybuffer:c,uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return o.newBufferFrom(new Uint8Array(v))}},m.uint8array={string:u,array:function(v){return p(v,new Array(v.length))},arraybuffer:function(v){return v.buffer},uint8array:c,nodebuffer:function(v){return o.newBufferFrom(v)}},m.nodebuffer={string:u,array:function(v){return p(v,new Array(v.length))},arraybuffer:function(v){return m.nodebuffer.uint8array(v).buffer},uint8array:function(v){return p(v,new Uint8Array(v.length))},nodebuffer:c},n.transformTo=function(v,g){if(g=g||"",!v)return g;n.checkSupport(v);var f=n.getTypeOf(g);return m[f][v](g)},n.resolve=function(v){for(var g=v.split("/"),f=[],A=0;A<g.length;A++){var b=g[A];b==="."||b===""&&A!==0&&A!==g.length-1||(b===".."?f.pop():f.push(b))}return f.join("/")},n.getTypeOf=function(v){return typeof v=="string"?"string":Object.prototype.toString.call(v)==="[object Array]"?"array":r.nodebuffer&&o.isBuffer(v)?"nodebuffer":r.uint8array&&v instanceof Uint8Array?"uint8array":r.arraybuffer&&v instanceof ArrayBuffer?"arraybuffer":void 0},n.checkSupport=function(v){if(!r[v.toLowerCase()])throw new Error(v+" is not supported by this platform")},n.MAX_VALUE_16BITS=65535,n.MAX_VALUE_32BITS=-1,n.pretty=function(v){var g,f,A="";for(f=0;f<(v||"").length;f++)A+="\\x"+((g=v.charCodeAt(f))<16?"0":"")+g.toString(16).toUpperCase();return A},n.delay=function(v,g,f){setImmediate(function(){v.apply(f||null,g||[])})},n.inherits=function(v,g){function f(){}f.prototype=g.prototype,v.prototype=new f},n.extend=function(){var v,g,f={};for(v=0;v<arguments.length;v++)for(g in arguments[v])Object.prototype.hasOwnProperty.call(arguments[v],g)&&f[g]===void 0&&(f[g]=arguments[v][g]);return f},n.prepareContent=function(v,g,f,A,b){return l.Promise.resolve(g).then(function(y){return r.blob&&(y instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(y))!==-1)&&typeof FileReader<"u"?new l.Promise(function(x,_){var M=new FileReader;M.onload=function(E){x(E.target.result)},M.onerror=function(E){_(E.target.error)},M.readAsArrayBuffer(y)}):y}).then(function(y){var x=n.getTypeOf(y);return x?(x==="arraybuffer"?y=n.transformTo("uint8array",y):x==="string"&&(b?y=a.decode(y):f&&A!==!0&&(y=(function(_){return h(_,r.uint8array?new Uint8Array(_.length):new Array(_.length))})(y))),y):l.Promise.reject(new Error("Can't read the data of '"+v+"'. 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 r=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 u=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(u)+", expected "+a.pretty(d)+")")}},isSignature:function(d,u){var p=this.reader.index;this.reader.setIndex(d);var m=this.reader.readString(4)===u;return this.reader.setIndex(p),m},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),u=c.uint8array?"uint8array":"array",p=a.transformTo(u,d);this.zipComment=this.loadOptions.decodeFileName(p)},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,u,p,m=this.zip64EndOfCentralSize-44;0<m;)d=this.reader.readInt(2),u=this.reader.readInt(4),p=this.reader.readData(u),this.zip64ExtensibleData[d]={id:d,length:u,value:p}},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,u;for(d=0;d<this.files.length;d++)u=this.files[d],this.reader.setIndex(u.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),u.readLocalPart(this.reader),u.handleUTF8(),u.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 u=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 p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var m=u-p;if(0<m)this.isSignature(u,o.CENTRAL_FILE_HEADER)||(this.reader.zero=m);else if(m<0)throw new Error("Corrupted zip: missing "+Math.abs(m)+" bytes.")},prepareReader:function(d){this.reader=r(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 r=t("./reader/readerFor"),a=t("./utils"),o=t("./compressedObject"),l=t("./crc32"),c=t("./utf8"),h=t("./compressions"),d=t("./support");function u(p,m){this.options=p,this.loadOptions=m}u.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var m,v;if(p.skip(22),this.fileNameLength=p.readInt(2),v=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(v),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((m=(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,m,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var m=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(m),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=r(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var m,v,g,f=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<f;)m=p.readInt(2),v=p.readInt(2),g=p.readData(v),this.extraFields[m]={id:m,length:v,value:g};p.setIndex(f)},handleUTF8:function(){var p=d.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var m=this.findExtraFieldUnicodePath();if(m!==null)this.fileNameStr=m;else{var v=a.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(v)}var g=this.findExtraFieldUnicodeComment();if(g!==null)this.fileCommentStr=g;else{var f=a.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(f)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var m=r(p.value);return m.readInt(1)!==1||l(this.fileName)!==m.readInt(4)?null:c.utf8decode(m.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var m=r(p.value);return m.readInt(1)!==1||l(this.fileComment)!==m.readInt(4)?null:c.utf8decode(m.readData(p.length-5))}return null}},i.exports=u},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(t,i,n){function r(m,v,g){this.name=m,this.dir=g.dir,this.date=g.date,this.comment=g.comment,this.unixPermissions=g.unixPermissions,this.dosPermissions=g.dosPermissions,this._data=v,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");r.prototype={internalStream:function(m){var v=null,g="string";try{if(!m)throw new Error("No output type specified.");var f=(g=m.toLowerCase())==="string"||g==="text";g!=="binarystring"&&g!=="text"||(g="string"),v=this._decompressWorker();var A=!this._dataBinary;A&&!f&&(v=v.pipe(new l.Utf8EncodeWorker)),!A&&f&&(v=v.pipe(new l.Utf8DecodeWorker))}catch(b){(v=new h("error")).error(b)}return new a(v,g,"")},async:function(m,v){return this.internalStream(m).accumulate(v)},nodeStream:function(m,v){return this.internalStream(m||"nodebuffer").toNodejsStream(v)},_compressWorker:function(m,v){if(this._data instanceof c&&this._data.compression.magic===m.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(g,m,v)},_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"],u=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<d.length;p++)r.prototype[d[p]]=u;i.exports=r},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,i,n){(function(r){var a,o,l=r.MutationObserver||r.WebKitMutationObserver;if(l){var c=0,h=new l(m),d=r.document.createTextNode("");h.observe(d,{characterData:!0}),a=function(){d.data=c=++c%2}}else if(r.setImmediate||r.MessageChannel===void 0)a="document"in r&&"onreadystatechange"in r.document.createElement("script")?function(){var v=r.document.createElement("script");v.onreadystatechange=function(){m(),v.onreadystatechange=null,v.parentNode.removeChild(v),v=null},r.document.documentElement.appendChild(v)}:function(){setTimeout(m,0)};else{var u=new r.MessageChannel;u.port1.onmessage=m,a=function(){u.port2.postMessage(0)}}var p=[];function m(){var v,g;o=!0;for(var f=p.length;f;){for(g=p,p=[],v=-1;++v<f;)g[v]();f=p.length}o=!1}i.exports=function(v){p.push(v)!==1||o||a()}}).call(this,typeof _0<"u"?_0:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(t,i,n){var r=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&&v(this,f)}function u(f,A,b){this.promise=f,typeof A=="function"&&(this.onFulfilled=A,this.callFulfilled=this.otherCallFulfilled),typeof b=="function"&&(this.onRejected=b,this.callRejected=this.otherCallRejected)}function p(f,A,b){r(function(){var y;try{y=A(b)}catch(x){return o.reject(f,x)}y===f?o.reject(f,new TypeError("Cannot resolve promise with itself")):o.resolve(f,y)})}function m(f){var A=f&&f.then;if(f&&(typeof f=="object"||typeof f=="function")&&typeof A=="function")return function(){A.apply(f,arguments)}}function v(f,A){var b=!1;function y(M){b||(b=!0,o.reject(f,M))}function x(M){b||(b=!0,o.resolve(f,M))}var _=g(function(){A(x,y)});_.status==="error"&&y(_.value)}function g(f,A){var b={};try{b.value=f(A),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 A=this.constructor;return this.then(function(b){return A.resolve(f()).then(function(){return b})},function(b){return A.resolve(f()).then(function(){throw b})})},d.prototype.catch=function(f){return this.then(null,f)},d.prototype.then=function(f,A){if(typeof f!="function"&&this.state===c||typeof A!="function"&&this.state===l)return this;var b=new this.constructor(a);return this.state!==h?p(b,this.state===c?f:A,this.outcome):this.queue.push(new u(b,f,A)),b},u.prototype.callFulfilled=function(f){o.resolve(this.promise,f)},u.prototype.otherCallFulfilled=function(f){p(this.promise,this.onFulfilled,f)},u.prototype.callRejected=function(f){o.reject(this.promise,f)},u.prototype.otherCallRejected=function(f){p(this.promise,this.onRejected,f)},o.resolve=function(f,A){var b=g(m,A);if(b.status==="error")return o.reject(f,b.value);var y=b.value;if(y)v(f,y);else{f.state=c,f.outcome=A;for(var x=-1,_=f.queue.length;++x<_;)f.queue[x].callFulfilled(A)}return f},o.reject=function(f,A){f.state=l,f.outcome=A;for(var b=-1,y=f.queue.length;++b<y;)f.queue[b].callRejected(A);return f},d.resolve=function(f){return f instanceof this?f:o.resolve(new this(a),f)},d.reject=function(f){var A=new this(a);return o.reject(A,f)},d.all=function(f){var A=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 x=new Array(b),_=0,M=-1,E=new this(a);++M<b;)w(f[M],M);return E;function w(T,R){A.resolve(T).then(function(D){x[R]=D,++_!==b||y||(y=!0,o.resolve(E,x))},function(D){y||(y=!0,o.reject(E,D))})}},d.race=function(f){var A=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 x=-1,_=new this(a);++x<b;)M=f[x],A.resolve(M).then(function(E){y||(y=!0,o.resolve(_,E))},function(E){y||(y=!0,o.reject(_,E))});var M;return _}},{immediate:36}],38:[function(t,i,n){var r={};(0,t("./lib/utils/common").assign)(r,t("./lib/deflate"),t("./lib/inflate"),t("./lib/zlib/constants")),i.exports=r},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(t,i,n){var r=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,u=-1,p=0,m=8;function v(f){if(!(this instanceof v))return new v(f);this.options=a.assign({level:u,method:m,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},f||{});var A=this.options;A.raw&&0<A.windowBits?A.windowBits=-A.windowBits:A.gzip&&0<A.windowBits&&A.windowBits<16&&(A.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var b=r.deflateInit2(this.strm,A.level,A.method,A.windowBits,A.memLevel,A.strategy);if(b!==d)throw new Error(l[b]);if(A.header&&r.deflateSetHeader(this.strm,A.header),A.dictionary){var y;if(y=typeof A.dictionary=="string"?o.string2buf(A.dictionary):h.call(A.dictionary)==="[object ArrayBuffer]"?new Uint8Array(A.dictionary):A.dictionary,(b=r.deflateSetDictionary(this.strm,y))!==d)throw new Error(l[b]);this._dict_set=!0}}function g(f,A){var b=new v(A);if(b.push(f,!0),b.err)throw b.msg||l[b.err];return b.result}v.prototype.push=function(f,A){var b,y,x=this.strm,_=this.options.chunkSize;if(this.ended)return!1;y=A===~~A?A:A===!0?4:0,typeof f=="string"?x.input=o.string2buf(f):h.call(f)==="[object ArrayBuffer]"?x.input=new Uint8Array(f):x.input=f,x.next_in=0,x.avail_in=x.input.length;do{if(x.avail_out===0&&(x.output=new a.Buf8(_),x.next_out=0,x.avail_out=_),(b=r.deflate(x,y))!==1&&b!==d)return this.onEnd(b),!(this.ended=!0);x.avail_out!==0&&(x.avail_in!==0||y!==4&&y!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(a.shrinkBuf(x.output,x.next_out))):this.onData(a.shrinkBuf(x.output,x.next_out)))}while((0<x.avail_in||x.avail_out===0)&&b!==1);return y===4?(b=r.deflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===d):y!==2||(this.onEnd(d),!(x.avail_out=0))},v.prototype.onData=function(f){this.chunks.push(f)},v.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=v,n.deflate=g,n.deflateRaw=function(f,A){return(A=A||{}).raw=!0,g(f,A)},n.gzip=function(f,A){return(A=A||{}).gzip=!0,g(f,A)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(t,i,n){var r=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"),u=Object.prototype.toString;function p(v){if(!(this instanceof p))return new p(v);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},v||{});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)||v&&v.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=r.inflateInit2(this.strm,g.windowBits);if(f!==l.Z_OK)throw new Error(c[f]);this.header=new d,r.inflateGetHeader(this.strm,this.header)}function m(v,g){var f=new p(g);if(f.push(v,!0),f.err)throw f.msg||c[f.err];return f.result}p.prototype.push=function(v,g){var f,A,b,y,x,_,M=this.strm,E=this.options.chunkSize,w=this.options.dictionary,T=!1;if(this.ended)return!1;A=g===~~g?g:g===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof v=="string"?M.input=o.binstring2buf(v):u.call(v)==="[object ArrayBuffer]"?M.input=new Uint8Array(v):M.input=v,M.next_in=0,M.avail_in=M.input.length;do{if(M.avail_out===0&&(M.output=new a.Buf8(E),M.next_out=0,M.avail_out=E),(f=r.inflate(M,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&w&&(_=typeof w=="string"?o.string2buf(w):u.call(w)==="[object ArrayBuffer]"?new Uint8Array(w):w,f=r.inflateSetDictionary(this.strm,_)),f===l.Z_BUF_ERROR&&T===!0&&(f=l.Z_OK,T=!1),f!==l.Z_STREAM_END&&f!==l.Z_OK)return this.onEnd(f),!(this.ended=!0);M.next_out&&(M.avail_out!==0&&f!==l.Z_STREAM_END&&(M.avail_in!==0||A!==l.Z_FINISH&&A!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(b=o.utf8border(M.output,M.next_out),y=M.next_out-b,x=o.buf2string(M.output,b),M.next_out=y,M.avail_out=E-y,y&&a.arraySet(M.output,M.output,b,y,0),this.onData(x)):this.onData(a.shrinkBuf(M.output,M.next_out)))),M.avail_in===0&&M.avail_out===0&&(T=!0)}while((0<M.avail_in||M.avail_out===0)&&f!==l.Z_STREAM_END);return f===l.Z_STREAM_END&&(A=l.Z_FINISH),A===l.Z_FINISH?(f=r.inflateEnd(this.strm),this.onEnd(f),this.ended=!0,f===l.Z_OK):A!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(M.avail_out=0))},p.prototype.onData=function(v){this.chunks.push(v)},p.prototype.onEnd=function(v){v===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},n.Inflate=p,n.inflate=m,n.inflateRaw=function(v,g){return(g=g||{}).raw=!0,m(v,g)},n.ungzip=m},{"./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 r=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,u){if(c.subarray&&l.subarray)l.set(c.subarray(h,h+d),u);else for(var p=0;p<d;p++)l[u+p]=c[h+p]},flattenChunks:function(l){var c,h,d,u,p,m;for(c=d=0,h=l.length;c<h;c++)d+=l[c].length;for(m=new Uint8Array(d),c=u=0,h=l.length;c<h;c++)p=l[c],m.set(p,u),u+=p.length;return m}},o={arraySet:function(l,c,h,d,u){for(var p=0;p<d;p++)l[u+p]=c[h+p]},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(r)},{}],42:[function(t,i,n){var r=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 r.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,u){if(u<65537&&(d.subarray&&o||!d.subarray&&a))return String.fromCharCode.apply(null,r.shrinkBuf(d,u));for(var p="",m=0;m<u;m++)p+=String.fromCharCode(d[m]);return p}l[254]=l[254]=1,n.string2buf=function(d){var u,p,m,v,g,f=d.length,A=0;for(v=0;v<f;v++)(64512&(p=d.charCodeAt(v)))==55296&&v+1<f&&(64512&(m=d.charCodeAt(v+1)))==56320&&(p=65536+(p-55296<<10)+(m-56320),v++),A+=p<128?1:p<2048?2:p<65536?3:4;for(u=new r.Buf8(A),v=g=0;g<A;v++)(64512&(p=d.charCodeAt(v)))==55296&&v+1<f&&(64512&(m=d.charCodeAt(v+1)))==56320&&(p=65536+(p-55296<<10)+(m-56320),v++),p<128?u[g++]=p:(p<2048?u[g++]=192|p>>>6:(p<65536?u[g++]=224|p>>>12:(u[g++]=240|p>>>18,u[g++]=128|p>>>12&63),u[g++]=128|p>>>6&63),u[g++]=128|63&p);return u},n.buf2binstring=function(d){return h(d,d.length)},n.binstring2buf=function(d){for(var u=new r.Buf8(d.length),p=0,m=u.length;p<m;p++)u[p]=d.charCodeAt(p);return u},n.buf2string=function(d,u){var p,m,v,g,f=u||d.length,A=new Array(2*f);for(p=m=0;p<f;)if((v=d[p++])<128)A[m++]=v;else if(4<(g=l[v]))A[m++]=65533,p+=g-1;else{for(v&=g===2?31:g===3?15:7;1<g&&p<f;)v=v<<6|63&d[p++],g--;1<g?A[m++]=65533:v<65536?A[m++]=v:(v-=65536,A[m++]=55296|v>>10&1023,A[m++]=56320|1023&v)}return h(A,m)},n.utf8border=function(d,u){var p;for((u=u||d.length)>d.length&&(u=d.length),p=u-1;0<=p&&(192&d[p])==128;)p--;return p<0||p===0?u:p+l[d[p]]>u?p:u}},{"./common":41}],43:[function(t,i,n){i.exports=function(r,a,o,l){for(var c=65535&r|0,h=r>>>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 r=(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=r,d=c+l;a^=-1;for(var u=c;u<d;u++)a=a>>>8^h[255&(a^o[u])];return-1^a}},{}],46:[function(t,i,n){var r,a=t("../utils/common"),o=t("./trees"),l=t("./adler32"),c=t("./crc32"),h=t("./messages"),d=0,u=4,p=0,m=-2,v=-1,g=4,f=2,A=8,b=9,y=286,x=30,_=19,M=2*y+1,E=15,w=3,T=258,R=T+w+1,D=42,L=113,I=1,O=2,N=3,G=4;function V(B,re){return B.msg=h[re],re}function H(B){return(B<<1)-(4<B?9:0)}function J(B){for(var re=B.length;0<=--re;)B[re]=0}function W(B){var re=B.state,ee=re.pending;ee>B.avail_out&&(ee=B.avail_out),ee!==0&&(a.arraySet(B.output,re.pending_buf,re.pending_out,ee,B.next_out),B.next_out+=ee,re.pending_out+=ee,B.total_out+=ee,B.avail_out-=ee,re.pending-=ee,re.pending===0&&(re.pending_out=0))}function X(B,re){o._tr_flush_block(B,0<=B.block_start?B.block_start:-1,B.strstart-B.block_start,re),B.block_start=B.strstart,W(B.strm)}function me(B,re){B.pending_buf[B.pending++]=re}function Ee(B,re){B.pending_buf[B.pending++]=re>>>8&255,B.pending_buf[B.pending++]=255&re}function Me(B,re){var ee,Q,k=B.max_chain_length,ie=B.strstart,fe=B.prev_length,xe=B.nice_match,te=B.strstart>B.w_size-R?B.strstart-(B.w_size-R):0,C=B.window,S=B.w_mask,F=B.prev,q=B.strstart+T,K=C[ie+fe-1],Y=C[ie+fe];B.prev_length>=B.good_match&&(k>>=2),xe>B.lookahead&&(xe=B.lookahead);do if(C[(ee=re)+fe]===Y&&C[ee+fe-1]===K&&C[ee]===C[ie]&&C[++ee]===C[ie+1]){ie+=2,ee++;do;while(C[++ie]===C[++ee]&&C[++ie]===C[++ee]&&C[++ie]===C[++ee]&&C[++ie]===C[++ee]&&C[++ie]===C[++ee]&&C[++ie]===C[++ee]&&C[++ie]===C[++ee]&&C[++ie]===C[++ee]&&ie<q);if(Q=T-(q-ie),ie=q-T,fe<Q){if(B.match_start=re,xe<=(fe=Q))break;K=C[ie+fe-1],Y=C[ie+fe]}}while((re=F[re&S])>te&&--k!=0);return fe<=B.lookahead?fe:B.lookahead}function $(B){var re,ee,Q,k,ie,fe,xe,te,C,S,F=B.w_size;do{if(k=B.window_size-B.lookahead-B.strstart,B.strstart>=F+(F-R)){for(a.arraySet(B.window,B.window,F,F,0),B.match_start-=F,B.strstart-=F,B.block_start-=F,re=ee=B.hash_size;Q=B.head[--re],B.head[re]=F<=Q?Q-F:0,--ee;);for(re=ee=F;Q=B.prev[--re],B.prev[re]=F<=Q?Q-F:0,--ee;);k+=F}if(B.strm.avail_in===0)break;if(fe=B.strm,xe=B.window,te=B.strstart+B.lookahead,C=k,S=void 0,S=fe.avail_in,C<S&&(S=C),ee=S===0?0:(fe.avail_in-=S,a.arraySet(xe,fe.input,fe.next_in,S,te),fe.state.wrap===1?fe.adler=l(fe.adler,xe,S,te):fe.state.wrap===2&&(fe.adler=c(fe.adler,xe,S,te)),fe.next_in+=S,fe.total_in+=S,S),B.lookahead+=ee,B.lookahead+B.insert>=w)for(ie=B.strstart-B.insert,B.ins_h=B.window[ie],B.ins_h=(B.ins_h<<B.hash_shift^B.window[ie+1])&B.hash_mask;B.insert&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[ie+w-1])&B.hash_mask,B.prev[ie&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=ie,ie++,B.insert--,!(B.lookahead+B.insert<w)););}while(B.lookahead<R&&B.strm.avail_in!==0)}function se(B,re){for(var ee,Q;;){if(B.lookahead<R){if($(B),B.lookahead<R&&re===d)return I;if(B.lookahead===0)break}if(ee=0,B.lookahead>=w&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+w-1])&B.hash_mask,ee=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),ee!==0&&B.strstart-ee<=B.w_size-R&&(B.match_length=Me(B,ee)),B.match_length>=w)if(Q=o._tr_tally(B,B.strstart-B.match_start,B.match_length-w),B.lookahead-=B.match_length,B.match_length<=B.max_lazy_match&&B.lookahead>=w){for(B.match_length--;B.strstart++,B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+w-1])&B.hash_mask,ee=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart,--B.match_length!=0;);B.strstart++}else B.strstart+=B.match_length,B.match_length=0,B.ins_h=B.window[B.strstart],B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+1])&B.hash_mask;else Q=o._tr_tally(B,0,B.window[B.strstart]),B.lookahead--,B.strstart++;if(Q&&(X(B,!1),B.strm.avail_out===0))return I}return B.insert=B.strstart<w-1?B.strstart:w-1,re===u?(X(B,!0),B.strm.avail_out===0?N:G):B.last_lit&&(X(B,!1),B.strm.avail_out===0)?I:O}function he(B,re){for(var ee,Q,k;;){if(B.lookahead<R){if($(B),B.lookahead<R&&re===d)return I;if(B.lookahead===0)break}if(ee=0,B.lookahead>=w&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+w-1])&B.hash_mask,ee=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),B.prev_length=B.match_length,B.prev_match=B.match_start,B.match_length=w-1,ee!==0&&B.prev_length<B.max_lazy_match&&B.strstart-ee<=B.w_size-R&&(B.match_length=Me(B,ee),B.match_length<=5&&(B.strategy===1||B.match_length===w&&4096<B.strstart-B.match_start)&&(B.match_length=w-1)),B.prev_length>=w&&B.match_length<=B.prev_length){for(k=B.strstart+B.lookahead-w,Q=o._tr_tally(B,B.strstart-1-B.prev_match,B.prev_length-w),B.lookahead-=B.prev_length-1,B.prev_length-=2;++B.strstart<=k&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+w-1])&B.hash_mask,ee=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),--B.prev_length!=0;);if(B.match_available=0,B.match_length=w-1,B.strstart++,Q&&(X(B,!1),B.strm.avail_out===0))return I}else if(B.match_available){if((Q=o._tr_tally(B,0,B.window[B.strstart-1]))&&X(B,!1),B.strstart++,B.lookahead--,B.strm.avail_out===0)return I}else B.match_available=1,B.strstart++,B.lookahead--}return B.match_available&&(Q=o._tr_tally(B,0,B.window[B.strstart-1]),B.match_available=0),B.insert=B.strstart<w-1?B.strstart:w-1,re===u?(X(B,!0),B.strm.avail_out===0?N:G):B.last_lit&&(X(B,!1),B.strm.avail_out===0)?I:O}function Te(B,re,ee,Q,k){this.good_length=B,this.max_lazy=re,this.nice_length=ee,this.max_chain=Q,this.func=k}function Le(){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=A,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*M),this.dyn_dtree=new a.Buf16(2*(2*x+1)),this.bl_tree=new a.Buf16(2*(2*_+1)),J(this.dyn_ltree),J(this.dyn_dtree),J(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(E+1),this.heap=new a.Buf16(2*y+1),J(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*y+1),J(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 Oe(B){var re;return B&&B.state?(B.total_in=B.total_out=0,B.data_type=f,(re=B.state).pending=0,re.pending_out=0,re.wrap<0&&(re.wrap=-re.wrap),re.status=re.wrap?D:L,B.adler=re.wrap===2?0:1,re.last_flush=d,o._tr_init(re),p):V(B,m)}function tt(B){var re=Oe(B);return re===p&&(function(ee){ee.window_size=2*ee.w_size,J(ee.head),ee.max_lazy_match=r[ee.level].max_lazy,ee.good_match=r[ee.level].good_length,ee.nice_match=r[ee.level].nice_length,ee.max_chain_length=r[ee.level].max_chain,ee.strstart=0,ee.block_start=0,ee.lookahead=0,ee.insert=0,ee.match_length=ee.prev_length=w-1,ee.match_available=0,ee.ins_h=0})(B.state),re}function Ye(B,re,ee,Q,k,ie){if(!B)return m;var fe=1;if(re===v&&(re=6),Q<0?(fe=0,Q=-Q):15<Q&&(fe=2,Q-=16),k<1||b<k||ee!==A||Q<8||15<Q||re<0||9<re||ie<0||g<ie)return V(B,m);Q===8&&(Q=9);var xe=new Le;return(B.state=xe).strm=B,xe.wrap=fe,xe.gzhead=null,xe.w_bits=Q,xe.w_size=1<<xe.w_bits,xe.w_mask=xe.w_size-1,xe.hash_bits=k+7,xe.hash_size=1<<xe.hash_bits,xe.hash_mask=xe.hash_size-1,xe.hash_shift=~~((xe.hash_bits+w-1)/w),xe.window=new a.Buf8(2*xe.w_size),xe.head=new a.Buf16(xe.hash_size),xe.prev=new a.Buf16(xe.w_size),xe.lit_bufsize=1<<k+6,xe.pending_buf_size=4*xe.lit_bufsize,xe.pending_buf=new a.Buf8(xe.pending_buf_size),xe.d_buf=1*xe.lit_bufsize,xe.l_buf=3*xe.lit_bufsize,xe.level=re,xe.strategy=ie,xe.method=ee,tt(B)}r=[new Te(0,0,0,0,function(B,re){var ee=65535;for(ee>B.pending_buf_size-5&&(ee=B.pending_buf_size-5);;){if(B.lookahead<=1){if($(B),B.lookahead===0&&re===d)return I;if(B.lookahead===0)break}B.strstart+=B.lookahead,B.lookahead=0;var Q=B.block_start+ee;if((B.strstart===0||B.strstart>=Q)&&(B.lookahead=B.strstart-Q,B.strstart=Q,X(B,!1),B.strm.avail_out===0)||B.strstart-B.block_start>=B.w_size-R&&(X(B,!1),B.strm.avail_out===0))return I}return B.insert=0,re===u?(X(B,!0),B.strm.avail_out===0?N:G):(B.strstart>B.block_start&&(X(B,!1),B.strm.avail_out),I)}),new Te(4,4,8,4,se),new Te(4,5,16,8,se),new Te(4,6,32,32,se),new Te(4,4,16,16,he),new Te(8,16,32,32,he),new Te(8,16,128,128,he),new Te(8,32,128,256,he),new Te(32,128,258,1024,he),new Te(32,258,258,4096,he)],n.deflateInit=function(B,re){return Ye(B,re,A,15,8,0)},n.deflateInit2=Ye,n.deflateReset=tt,n.deflateResetKeep=Oe,n.deflateSetHeader=function(B,re){return B&&B.state?B.state.wrap!==2?m:(B.state.gzhead=re,p):m},n.deflate=function(B,re){var ee,Q,k,ie;if(!B||!B.state||5<re||re<0)return B?V(B,m):m;if(Q=B.state,!B.output||!B.input&&B.avail_in!==0||Q.status===666&&re!==u)return V(B,B.avail_out===0?-5:m);if(Q.strm=B,ee=Q.last_flush,Q.last_flush=re,Q.status===D)if(Q.wrap===2)B.adler=0,me(Q,31),me(Q,139),me(Q,8),Q.gzhead?(me(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)),me(Q,255&Q.gzhead.time),me(Q,Q.gzhead.time>>8&255),me(Q,Q.gzhead.time>>16&255),me(Q,Q.gzhead.time>>24&255),me(Q,Q.level===9?2:2<=Q.strategy||Q.level<2?4:0),me(Q,255&Q.gzhead.os),Q.gzhead.extra&&Q.gzhead.extra.length&&(me(Q,255&Q.gzhead.extra.length),me(Q,Q.gzhead.extra.length>>8&255)),Q.gzhead.hcrc&&(B.adler=c(B.adler,Q.pending_buf,Q.pending,0)),Q.gzindex=0,Q.status=69):(me(Q,0),me(Q,0),me(Q,0),me(Q,0),me(Q,0),me(Q,Q.level===9?2:2<=Q.strategy||Q.level<2?4:0),me(Q,3),Q.status=L);else{var fe=A+(Q.w_bits-8<<4)<<8;fe|=(2<=Q.strategy||Q.level<2?0:Q.level<6?1:Q.level===6?2:3)<<6,Q.strstart!==0&&(fe|=32),fe+=31-fe%31,Q.status=L,Ee(Q,fe),Q.strstart!==0&&(Ee(Q,B.adler>>>16),Ee(Q,65535&B.adler)),B.adler=1}if(Q.status===69)if(Q.gzhead.extra){for(k=Q.pending;Q.gzindex<(65535&Q.gzhead.extra.length)&&(Q.pending!==Q.pending_buf_size||(Q.gzhead.hcrc&&Q.pending>k&&(B.adler=c(B.adler,Q.pending_buf,Q.pending-k,k)),W(B),k=Q.pending,Q.pending!==Q.pending_buf_size));)me(Q,255&Q.gzhead.extra[Q.gzindex]),Q.gzindex++;Q.gzhead.hcrc&&Q.pending>k&&(B.adler=c(B.adler,Q.pending_buf,Q.pending-k,k)),Q.gzindex===Q.gzhead.extra.length&&(Q.gzindex=0,Q.status=73)}else Q.status=73;if(Q.status===73)if(Q.gzhead.name){k=Q.pending;do{if(Q.pending===Q.pending_buf_size&&(Q.gzhead.hcrc&&Q.pending>k&&(B.adler=c(B.adler,Q.pending_buf,Q.pending-k,k)),W(B),k=Q.pending,Q.pending===Q.pending_buf_size)){ie=1;break}ie=Q.gzindex<Q.gzhead.name.length?255&Q.gzhead.name.charCodeAt(Q.gzindex++):0,me(Q,ie)}while(ie!==0);Q.gzhead.hcrc&&Q.pending>k&&(B.adler=c(B.adler,Q.pending_buf,Q.pending-k,k)),ie===0&&(Q.gzindex=0,Q.status=91)}else Q.status=91;if(Q.status===91)if(Q.gzhead.comment){k=Q.pending;do{if(Q.pending===Q.pending_buf_size&&(Q.gzhead.hcrc&&Q.pending>k&&(B.adler=c(B.adler,Q.pending_buf,Q.pending-k,k)),W(B),k=Q.pending,Q.pending===Q.pending_buf_size)){ie=1;break}ie=Q.gzindex<Q.gzhead.comment.length?255&Q.gzhead.comment.charCodeAt(Q.gzindex++):0,me(Q,ie)}while(ie!==0);Q.gzhead.hcrc&&Q.pending>k&&(B.adler=c(B.adler,Q.pending_buf,Q.pending-k,k)),ie===0&&(Q.status=103)}else Q.status=103;if(Q.status===103&&(Q.gzhead.hcrc?(Q.pending+2>Q.pending_buf_size&&W(B),Q.pending+2<=Q.pending_buf_size&&(me(Q,255&B.adler),me(Q,B.adler>>8&255),B.adler=0,Q.status=L)):Q.status=L),Q.pending!==0){if(W(B),B.avail_out===0)return Q.last_flush=-1,p}else if(B.avail_in===0&&H(re)<=H(ee)&&re!==u)return V(B,-5);if(Q.status===666&&B.avail_in!==0)return V(B,-5);if(B.avail_in!==0||Q.lookahead!==0||re!==d&&Q.status!==666){var xe=Q.strategy===2?(function(te,C){for(var S;;){if(te.lookahead===0&&($(te),te.lookahead===0)){if(C===d)return I;break}if(te.match_length=0,S=o._tr_tally(te,0,te.window[te.strstart]),te.lookahead--,te.strstart++,S&&(X(te,!1),te.strm.avail_out===0))return I}return te.insert=0,C===u?(X(te,!0),te.strm.avail_out===0?N:G):te.last_lit&&(X(te,!1),te.strm.avail_out===0)?I:O})(Q,re):Q.strategy===3?(function(te,C){for(var S,F,q,K,Y=te.window;;){if(te.lookahead<=T){if($(te),te.lookahead<=T&&C===d)return I;if(te.lookahead===0)break}if(te.match_length=0,te.lookahead>=w&&0<te.strstart&&(F=Y[q=te.strstart-1])===Y[++q]&&F===Y[++q]&&F===Y[++q]){K=te.strstart+T;do;while(F===Y[++q]&&F===Y[++q]&&F===Y[++q]&&F===Y[++q]&&F===Y[++q]&&F===Y[++q]&&F===Y[++q]&&F===Y[++q]&&q<K);te.match_length=T-(K-q),te.match_length>te.lookahead&&(te.match_length=te.lookahead)}if(te.match_length>=w?(S=o._tr_tally(te,1,te.match_length-w),te.lookahead-=te.match_length,te.strstart+=te.match_length,te.match_length=0):(S=o._tr_tally(te,0,te.window[te.strstart]),te.lookahead--,te.strstart++),S&&(X(te,!1),te.strm.avail_out===0))return I}return te.insert=0,C===u?(X(te,!0),te.strm.avail_out===0?N:G):te.last_lit&&(X(te,!1),te.strm.avail_out===0)?I:O})(Q,re):r[Q.level].func(Q,re);if(xe!==N&&xe!==G||(Q.status=666),xe===I||xe===N)return B.avail_out===0&&(Q.last_flush=-1),p;if(xe===O&&(re===1?o._tr_align(Q):re!==5&&(o._tr_stored_block(Q,0,0,!1),re===3&&(J(Q.head),Q.lookahead===0&&(Q.strstart=0,Q.block_start=0,Q.insert=0))),W(B),B.avail_out===0))return Q.last_flush=-1,p}return re!==u?p:Q.wrap<=0?1:(Q.wrap===2?(me(Q,255&B.adler),me(Q,B.adler>>8&255),me(Q,B.adler>>16&255),me(Q,B.adler>>24&255),me(Q,255&B.total_in),me(Q,B.total_in>>8&255),me(Q,B.total_in>>16&255),me(Q,B.total_in>>24&255)):(Ee(Q,B.adler>>>16),Ee(Q,65535&B.adler)),W(B),0<Q.wrap&&(Q.wrap=-Q.wrap),Q.pending!==0?p:1)},n.deflateEnd=function(B){var re;return B&&B.state?(re=B.state.status)!==D&&re!==69&&re!==73&&re!==91&&re!==103&&re!==L&&re!==666?V(B,m):(B.state=null,re===L?V(B,-3):p):m},n.deflateSetDictionary=function(B,re){var ee,Q,k,ie,fe,xe,te,C,S=re.length;if(!B||!B.state||(ie=(ee=B.state).wrap)===2||ie===1&&ee.status!==D||ee.lookahead)return m;for(ie===1&&(B.adler=l(B.adler,re,S,0)),ee.wrap=0,S>=ee.w_size&&(ie===0&&(J(ee.head),ee.strstart=0,ee.block_start=0,ee.insert=0),C=new a.Buf8(ee.w_size),a.arraySet(C,re,S-ee.w_size,ee.w_size,0),re=C,S=ee.w_size),fe=B.avail_in,xe=B.next_in,te=B.input,B.avail_in=S,B.next_in=0,B.input=re,$(ee);ee.lookahead>=w;){for(Q=ee.strstart,k=ee.lookahead-(w-1);ee.ins_h=(ee.ins_h<<ee.hash_shift^ee.window[Q+w-1])&ee.hash_mask,ee.prev[Q&ee.w_mask]=ee.head[ee.ins_h],ee.head[ee.ins_h]=Q,Q++,--k;);ee.strstart=Q,ee.lookahead=w-1,$(ee)}return ee.strstart+=ee.lookahead,ee.block_start=ee.strstart,ee.insert=ee.lookahead,ee.lookahead=0,ee.match_length=ee.prev_length=w-1,ee.match_available=0,B.next_in=xe,B.input=te,B.avail_in=fe,ee.wrap=ie,p},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(r,a){var o,l,c,h,d,u,p,m,v,g,f,A,b,y,x,_,M,E,w,T,R,D,L,I,O;o=r.state,l=r.next_in,I=r.input,c=l+(r.avail_in-5),h=r.next_out,O=r.output,d=h-(a-r.avail_out),u=h+(r.avail_out-257),p=o.dmax,m=o.wsize,v=o.whave,g=o.wnext,f=o.window,A=o.hold,b=o.bits,y=o.lencode,x=o.distcode,_=(1<<o.lenbits)-1,M=(1<<o.distbits)-1;e:do{b<15&&(A+=I[l++]<<b,b+=8,A+=I[l++]<<b,b+=8),E=y[A&_];t:for(;;){if(A>>>=w=E>>>24,b-=w,(w=E>>>16&255)===0)O[h++]=65535&E;else{if(!(16&w)){if((64&w)==0){E=y[(65535&E)+(A&(1<<w)-1)];continue t}if(32&w){o.mode=12;break e}r.msg="invalid literal/length code",o.mode=30;break e}T=65535&E,(w&=15)&&(b<w&&(A+=I[l++]<<b,b+=8),T+=A&(1<<w)-1,A>>>=w,b-=w),b<15&&(A+=I[l++]<<b,b+=8,A+=I[l++]<<b,b+=8),E=x[A&M];i:for(;;){if(A>>>=w=E>>>24,b-=w,!(16&(w=E>>>16&255))){if((64&w)==0){E=x[(65535&E)+(A&(1<<w)-1)];continue i}r.msg="invalid distance code",o.mode=30;break e}if(R=65535&E,b<(w&=15)&&(A+=I[l++]<<b,(b+=8)<w&&(A+=I[l++]<<b,b+=8)),p<(R+=A&(1<<w)-1)){r.msg="invalid distance too far back",o.mode=30;break e}if(A>>>=w,b-=w,(w=h-d)<R){if(v<(w=R-w)&&o.sane){r.msg="invalid distance too far back",o.mode=30;break e}if(L=f,(D=0)===g){if(D+=m-w,w<T){for(T-=w;O[h++]=f[D++],--w;);D=h-R,L=O}}else if(g<w){if(D+=m+g-w,(w-=g)<T){for(T-=w;O[h++]=f[D++],--w;);if(D=0,g<T){for(T-=w=g;O[h++]=f[D++],--w;);D=h-R,L=O}}}else if(D+=g-w,w<T){for(T-=w;O[h++]=f[D++],--w;);D=h-R,L=O}for(;2<T;)O[h++]=L[D++],O[h++]=L[D++],O[h++]=L[D++],T-=3;T&&(O[h++]=L[D++],1<T&&(O[h++]=L[D++]))}else{for(D=h-R;O[h++]=O[D++],O[h++]=O[D++],O[h++]=O[D++],2<(T-=3););T&&(O[h++]=O[D++],1<T&&(O[h++]=O[D++]))}break}}break}}while(l<c&&h<u);l-=T=b>>3,A&=(1<<(b-=T<<3))-1,r.next_in=l,r.next_out=h,r.avail_in=l<c?c-l+5:5-(l-c),r.avail_out=h<u?u-h+257:257-(h-u),o.hold=A,o.bits=b}},{}],49:[function(t,i,n){var r=t("../utils/common"),a=t("./adler32"),o=t("./crc32"),l=t("./inffast"),c=t("./inftrees"),h=1,d=2,u=0,p=-2,m=1,v=852,g=592;function f(D){return(D>>>24&255)+(D>>>8&65280)+((65280&D)<<8)+((255&D)<<24)}function A(){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 r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function b(D){var L;return D&&D.state?(L=D.state,D.total_in=D.total_out=L.total=0,D.msg="",L.wrap&&(D.adler=1&L.wrap),L.mode=m,L.last=0,L.havedict=0,L.dmax=32768,L.head=null,L.hold=0,L.bits=0,L.lencode=L.lendyn=new r.Buf32(v),L.distcode=L.distdyn=new r.Buf32(g),L.sane=1,L.back=-1,u):p}function y(D){var L;return D&&D.state?((L=D.state).wsize=0,L.whave=0,L.wnext=0,b(D)):p}function x(D,L){var I,O;return D&&D.state?(O=D.state,L<0?(I=0,L=-L):(I=1+(L>>4),L<48&&(L&=15)),L&&(L<8||15<L)?p:(O.window!==null&&O.wbits!==L&&(O.window=null),O.wrap=I,O.wbits=L,y(D))):p}function _(D,L){var I,O;return D?(O=new A,(D.state=O).window=null,(I=x(D,L))!==u&&(D.state=null),I):p}var M,E,w=!0;function T(D){if(w){var L;for(M=new r.Buf32(512),E=new r.Buf32(32),L=0;L<144;)D.lens[L++]=8;for(;L<256;)D.lens[L++]=9;for(;L<280;)D.lens[L++]=7;for(;L<288;)D.lens[L++]=8;for(c(h,D.lens,0,288,M,0,D.work,{bits:9}),L=0;L<32;)D.lens[L++]=5;c(d,D.lens,0,32,E,0,D.work,{bits:5}),w=!1}D.lencode=M,D.lenbits=9,D.distcode=E,D.distbits=5}function R(D,L,I,O){var N,G=D.state;return G.window===null&&(G.wsize=1<<G.wbits,G.wnext=0,G.whave=0,G.window=new r.Buf8(G.wsize)),O>=G.wsize?(r.arraySet(G.window,L,I-G.wsize,G.wsize,0),G.wnext=0,G.whave=G.wsize):(O<(N=G.wsize-G.wnext)&&(N=O),r.arraySet(G.window,L,I-O,N,G.wnext),(O-=N)?(r.arraySet(G.window,L,I-O,O,0),G.wnext=O,G.whave=G.wsize):(G.wnext+=N,G.wnext===G.wsize&&(G.wnext=0),G.whave<G.wsize&&(G.whave+=N))),0}n.inflateReset=y,n.inflateReset2=x,n.inflateResetKeep=b,n.inflateInit=function(D){return _(D,15)},n.inflateInit2=_,n.inflate=function(D,L){var I,O,N,G,V,H,J,W,X,me,Ee,Me,$,se,he,Te,Le,Oe,tt,Ye,B,re,ee,Q,k=0,ie=new r.Buf8(4),fe=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!D||!D.state||!D.output||!D.input&&D.avail_in!==0)return p;(I=D.state).mode===12&&(I.mode=13),V=D.next_out,N=D.output,J=D.avail_out,G=D.next_in,O=D.input,H=D.avail_in,W=I.hold,X=I.bits,me=H,Ee=J,re=u;e:for(;;)switch(I.mode){case m:if(I.wrap===0){I.mode=13;break}for(;X<16;){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}if(2&I.wrap&&W===35615){ie[I.check=0]=255&W,ie[1]=W>>>8&255,I.check=o(I.check,ie,2,0),X=W=0,I.mode=2;break}if(I.flags=0,I.head&&(I.head.done=!1),!(1&I.wrap)||(((255&W)<<8)+(W>>8))%31){D.msg="incorrect header check",I.mode=30;break}if((15&W)!=8){D.msg="unknown compression method",I.mode=30;break}if(X-=4,B=8+(15&(W>>>=4)),I.wbits===0)I.wbits=B;else if(B>I.wbits){D.msg="invalid window size",I.mode=30;break}I.dmax=1<<B,D.adler=I.check=1,I.mode=512&W?10:12,X=W=0;break;case 2:for(;X<16;){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}if(I.flags=W,(255&I.flags)!=8){D.msg="unknown compression method",I.mode=30;break}if(57344&I.flags){D.msg="unknown header flags set",I.mode=30;break}I.head&&(I.head.text=W>>8&1),512&I.flags&&(ie[0]=255&W,ie[1]=W>>>8&255,I.check=o(I.check,ie,2,0)),X=W=0,I.mode=3;case 3:for(;X<32;){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}I.head&&(I.head.time=W),512&I.flags&&(ie[0]=255&W,ie[1]=W>>>8&255,ie[2]=W>>>16&255,ie[3]=W>>>24&255,I.check=o(I.check,ie,4,0)),X=W=0,I.mode=4;case 4:for(;X<16;){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}I.head&&(I.head.xflags=255&W,I.head.os=W>>8),512&I.flags&&(ie[0]=255&W,ie[1]=W>>>8&255,I.check=o(I.check,ie,2,0)),X=W=0,I.mode=5;case 5:if(1024&I.flags){for(;X<16;){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}I.length=W,I.head&&(I.head.extra_len=W),512&I.flags&&(ie[0]=255&W,ie[1]=W>>>8&255,I.check=o(I.check,ie,2,0)),X=W=0}else I.head&&(I.head.extra=null);I.mode=6;case 6:if(1024&I.flags&&(H<(Me=I.length)&&(Me=H),Me&&(I.head&&(B=I.head.extra_len-I.length,I.head.extra||(I.head.extra=new Array(I.head.extra_len)),r.arraySet(I.head.extra,O,G,Me,B)),512&I.flags&&(I.check=o(I.check,O,Me,G)),H-=Me,G+=Me,I.length-=Me),I.length))break e;I.length=0,I.mode=7;case 7:if(2048&I.flags){if(H===0)break e;for(Me=0;B=O[G+Me++],I.head&&B&&I.length<65536&&(I.head.name+=String.fromCharCode(B)),B&&Me<H;);if(512&I.flags&&(I.check=o(I.check,O,Me,G)),H-=Me,G+=Me,B)break e}else I.head&&(I.head.name=null);I.length=0,I.mode=8;case 8:if(4096&I.flags){if(H===0)break e;for(Me=0;B=O[G+Me++],I.head&&B&&I.length<65536&&(I.head.comment+=String.fromCharCode(B)),B&&Me<H;);if(512&I.flags&&(I.check=o(I.check,O,Me,G)),H-=Me,G+=Me,B)break e}else I.head&&(I.head.comment=null);I.mode=9;case 9:if(512&I.flags){for(;X<16;){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}if(W!==(65535&I.check)){D.msg="header crc mismatch",I.mode=30;break}X=W=0}I.head&&(I.head.hcrc=I.flags>>9&1,I.head.done=!0),D.adler=I.check=0,I.mode=12;break;case 10:for(;X<32;){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}D.adler=I.check=f(W),X=W=0,I.mode=11;case 11:if(I.havedict===0)return D.next_out=V,D.avail_out=J,D.next_in=G,D.avail_in=H,I.hold=W,I.bits=X,2;D.adler=I.check=1,I.mode=12;case 12:if(L===5||L===6)break e;case 13:if(I.last){W>>>=7&X,X-=7&X,I.mode=27;break}for(;X<3;){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}switch(I.last=1&W,X-=1,3&(W>>>=1)){case 0:I.mode=14;break;case 1:if(T(I),I.mode=20,L!==6)break;W>>>=2,X-=2;break e;case 2:I.mode=17;break;case 3:D.msg="invalid block type",I.mode=30}W>>>=2,X-=2;break;case 14:for(W>>>=7&X,X-=7&X;X<32;){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}if((65535&W)!=(W>>>16^65535)){D.msg="invalid stored block lengths",I.mode=30;break}if(I.length=65535&W,X=W=0,I.mode=15,L===6)break e;case 15:I.mode=16;case 16:if(Me=I.length){if(H<Me&&(Me=H),J<Me&&(Me=J),Me===0)break e;r.arraySet(N,O,G,Me,V),H-=Me,G+=Me,J-=Me,V+=Me,I.length-=Me;break}I.mode=12;break;case 17:for(;X<14;){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}if(I.nlen=257+(31&W),W>>>=5,X-=5,I.ndist=1+(31&W),W>>>=5,X-=5,I.ncode=4+(15&W),W>>>=4,X-=4,286<I.nlen||30<I.ndist){D.msg="too many length or distance symbols",I.mode=30;break}I.have=0,I.mode=18;case 18:for(;I.have<I.ncode;){for(;X<3;){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}I.lens[fe[I.have++]]=7&W,W>>>=3,X-=3}for(;I.have<19;)I.lens[fe[I.have++]]=0;if(I.lencode=I.lendyn,I.lenbits=7,ee={bits:I.lenbits},re=c(0,I.lens,0,19,I.lencode,0,I.work,ee),I.lenbits=ee.bits,re){D.msg="invalid code lengths set",I.mode=30;break}I.have=0,I.mode=19;case 19:for(;I.have<I.nlen+I.ndist;){for(;Te=(k=I.lencode[W&(1<<I.lenbits)-1])>>>16&255,Le=65535&k,!((he=k>>>24)<=X);){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}if(Le<16)W>>>=he,X-=he,I.lens[I.have++]=Le;else{if(Le===16){for(Q=he+2;X<Q;){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}if(W>>>=he,X-=he,I.have===0){D.msg="invalid bit length repeat",I.mode=30;break}B=I.lens[I.have-1],Me=3+(3&W),W>>>=2,X-=2}else if(Le===17){for(Q=he+3;X<Q;){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}X-=he,B=0,Me=3+(7&(W>>>=he)),W>>>=3,X-=3}else{for(Q=he+7;X<Q;){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}X-=he,B=0,Me=11+(127&(W>>>=he)),W>>>=7,X-=7}if(I.have+Me>I.nlen+I.ndist){D.msg="invalid bit length repeat",I.mode=30;break}for(;Me--;)I.lens[I.have++]=B}}if(I.mode===30)break;if(I.lens[256]===0){D.msg="invalid code -- missing end-of-block",I.mode=30;break}if(I.lenbits=9,ee={bits:I.lenbits},re=c(h,I.lens,0,I.nlen,I.lencode,0,I.work,ee),I.lenbits=ee.bits,re){D.msg="invalid literal/lengths set",I.mode=30;break}if(I.distbits=6,I.distcode=I.distdyn,ee={bits:I.distbits},re=c(d,I.lens,I.nlen,I.ndist,I.distcode,0,I.work,ee),I.distbits=ee.bits,re){D.msg="invalid distances set",I.mode=30;break}if(I.mode=20,L===6)break e;case 20:I.mode=21;case 21:if(6<=H&&258<=J){D.next_out=V,D.avail_out=J,D.next_in=G,D.avail_in=H,I.hold=W,I.bits=X,l(D,Ee),V=D.next_out,N=D.output,J=D.avail_out,G=D.next_in,O=D.input,H=D.avail_in,W=I.hold,X=I.bits,I.mode===12&&(I.back=-1);break}for(I.back=0;Te=(k=I.lencode[W&(1<<I.lenbits)-1])>>>16&255,Le=65535&k,!((he=k>>>24)<=X);){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}if(Te&&(240&Te)==0){for(Oe=he,tt=Te,Ye=Le;Te=(k=I.lencode[Ye+((W&(1<<Oe+tt)-1)>>Oe)])>>>16&255,Le=65535&k,!(Oe+(he=k>>>24)<=X);){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}W>>>=Oe,X-=Oe,I.back+=Oe}if(W>>>=he,X-=he,I.back+=he,I.length=Le,Te===0){I.mode=26;break}if(32&Te){I.back=-1,I.mode=12;break}if(64&Te){D.msg="invalid literal/length code",I.mode=30;break}I.extra=15&Te,I.mode=22;case 22:if(I.extra){for(Q=I.extra;X<Q;){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}I.length+=W&(1<<I.extra)-1,W>>>=I.extra,X-=I.extra,I.back+=I.extra}I.was=I.length,I.mode=23;case 23:for(;Te=(k=I.distcode[W&(1<<I.distbits)-1])>>>16&255,Le=65535&k,!((he=k>>>24)<=X);){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}if((240&Te)==0){for(Oe=he,tt=Te,Ye=Le;Te=(k=I.distcode[Ye+((W&(1<<Oe+tt)-1)>>Oe)])>>>16&255,Le=65535&k,!(Oe+(he=k>>>24)<=X);){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}W>>>=Oe,X-=Oe,I.back+=Oe}if(W>>>=he,X-=he,I.back+=he,64&Te){D.msg="invalid distance code",I.mode=30;break}I.offset=Le,I.extra=15&Te,I.mode=24;case 24:if(I.extra){for(Q=I.extra;X<Q;){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}I.offset+=W&(1<<I.extra)-1,W>>>=I.extra,X-=I.extra,I.back+=I.extra}if(I.offset>I.dmax){D.msg="invalid distance too far back",I.mode=30;break}I.mode=25;case 25:if(J===0)break e;if(Me=Ee-J,I.offset>Me){if((Me=I.offset-Me)>I.whave&&I.sane){D.msg="invalid distance too far back",I.mode=30;break}$=Me>I.wnext?(Me-=I.wnext,I.wsize-Me):I.wnext-Me,Me>I.length&&(Me=I.length),se=I.window}else se=N,$=V-I.offset,Me=I.length;for(J<Me&&(Me=J),J-=Me,I.length-=Me;N[V++]=se[$++],--Me;);I.length===0&&(I.mode=21);break;case 26:if(J===0)break e;N[V++]=I.length,J--,I.mode=21;break;case 27:if(I.wrap){for(;X<32;){if(H===0)break e;H--,W|=O[G++]<<X,X+=8}if(Ee-=J,D.total_out+=Ee,I.total+=Ee,Ee&&(D.adler=I.check=I.flags?o(I.check,N,Ee,V-Ee):a(I.check,N,Ee,V-Ee)),Ee=J,(I.flags?W:f(W))!==I.check){D.msg="incorrect data check",I.mode=30;break}X=W=0}I.mode=28;case 28:if(I.wrap&&I.flags){for(;X<32;){if(H===0)break e;H--,W+=O[G++]<<X,X+=8}if(W!==(4294967295&I.total)){D.msg="incorrect length check",I.mode=30;break}X=W=0}I.mode=29;case 29:re=1;break e;case 30:re=-3;break e;case 31:return-4;default:return p}return D.next_out=V,D.avail_out=J,D.next_in=G,D.avail_in=H,I.hold=W,I.bits=X,(I.wsize||Ee!==D.avail_out&&I.mode<30&&(I.mode<27||L!==4))&&R(D,D.output,D.next_out,Ee-D.avail_out)?(I.mode=31,-4):(me-=D.avail_in,Ee-=D.avail_out,D.total_in+=me,D.total_out+=Ee,I.total+=Ee,I.wrap&&Ee&&(D.adler=I.check=I.flags?o(I.check,N,Ee,D.next_out-Ee):a(I.check,N,Ee,D.next_out-Ee)),D.data_type=I.bits+(I.last?64:0)+(I.mode===12?128:0)+(I.mode===20||I.mode===15?256:0),(me==0&&Ee===0||L===4)&&re===u&&(re=-5),re)},n.inflateEnd=function(D){if(!D||!D.state)return p;var L=D.state;return L.window&&(L.window=null),D.state=null,u},n.inflateGetHeader=function(D,L){var I;return D&&D.state?(2&(I=D.state).wrap)==0?p:((I.head=L).done=!1,u):p},n.inflateSetDictionary=function(D,L){var I,O=L.length;return D&&D.state?(I=D.state).wrap!==0&&I.mode!==11?p:I.mode===11&&a(1,L,O,0)!==I.check?-3:R(D,L,O,O)?(I.mode=31,-4):(I.havedict=1,u):p},n.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(t,i,n){var r=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,u,p,m,v,g,f){var A,b,y,x,_,M,E,w,T,R=f.bits,D=0,L=0,I=0,O=0,N=0,G=0,V=0,H=0,J=0,W=0,X=null,me=0,Ee=new r.Buf16(16),Me=new r.Buf16(16),$=null,se=0;for(D=0;D<=15;D++)Ee[D]=0;for(L=0;L<p;L++)Ee[d[u+L]]++;for(N=R,O=15;1<=O&&Ee[O]===0;O--);if(O<N&&(N=O),O===0)return m[v++]=20971520,m[v++]=20971520,f.bits=1,0;for(I=1;I<O&&Ee[I]===0;I++);for(N<I&&(N=I),D=H=1;D<=15;D++)if(H<<=1,(H-=Ee[D])<0)return-1;if(0<H&&(h===0||O!==1))return-1;for(Me[1]=0,D=1;D<15;D++)Me[D+1]=Me[D]+Ee[D];for(L=0;L<p;L++)d[u+L]!==0&&(g[Me[d[u+L]]++]=L);if(M=h===0?(X=$=g,19):h===1?(X=a,me-=257,$=o,se-=257,256):(X=l,$=c,-1),D=I,_=v,V=L=W=0,y=-1,x=(J=1<<(G=N))-1,h===1&&852<J||h===2&&592<J)return 1;for(;;){for(E=D-V,T=g[L]<M?(w=0,g[L]):g[L]>M?(w=$[se+g[L]],X[me+g[L]]):(w=96,0),A=1<<D-V,I=b=1<<G;m[_+(W>>V)+(b-=A)]=E<<24|w<<16|T|0,b!==0;);for(A=1<<D-1;W&A;)A>>=1;if(A!==0?(W&=A-1,W+=A):W=0,L++,--Ee[D]==0){if(D===O)break;D=d[u+g[L]]}if(N<D&&(W&x)!==y){for(V===0&&(V=N),_+=I,H=1<<(G=D-V);G+V<O&&!((H-=Ee[G+V])<=0);)G++,H<<=1;if(J+=1<<G,h===1&&852<J||h===2&&592<J)return 1;m[y=W&x]=N<<24|G<<16|_-v|0}}return W!==0&&(m[_+W]=D-V<<24|64<<16|0),f.bits=N,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 r=t("../utils/common"),a=0,o=1;function l(k){for(var ie=k.length;0<=--ie;)k[ie]=0}var c=0,h=29,d=256,u=d+1+h,p=30,m=19,v=2*u+1,g=15,f=16,A=7,b=256,y=16,x=17,_=18,M=[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],E=[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],w=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],T=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],R=new Array(2*(u+2));l(R);var D=new Array(2*p);l(D);var L=new Array(512);l(L);var I=new Array(256);l(I);var O=new Array(h);l(O);var N,G,V,H=new Array(p);function J(k,ie,fe,xe,te){this.static_tree=k,this.extra_bits=ie,this.extra_base=fe,this.elems=xe,this.max_length=te,this.has_stree=k&&k.length}function W(k,ie){this.dyn_tree=k,this.max_code=0,this.stat_desc=ie}function X(k){return k<256?L[k]:L[256+(k>>>7)]}function me(k,ie){k.pending_buf[k.pending++]=255&ie,k.pending_buf[k.pending++]=ie>>>8&255}function Ee(k,ie,fe){k.bi_valid>f-fe?(k.bi_buf|=ie<<k.bi_valid&65535,me(k,k.bi_buf),k.bi_buf=ie>>f-k.bi_valid,k.bi_valid+=fe-f):(k.bi_buf|=ie<<k.bi_valid&65535,k.bi_valid+=fe)}function Me(k,ie,fe){Ee(k,fe[2*ie],fe[2*ie+1])}function $(k,ie){for(var fe=0;fe|=1&k,k>>>=1,fe<<=1,0<--ie;);return fe>>>1}function se(k,ie,fe){var xe,te,C=new Array(g+1),S=0;for(xe=1;xe<=g;xe++)C[xe]=S=S+fe[xe-1]<<1;for(te=0;te<=ie;te++){var F=k[2*te+1];F!==0&&(k[2*te]=$(C[F]++,F))}}function he(k){var ie;for(ie=0;ie<u;ie++)k.dyn_ltree[2*ie]=0;for(ie=0;ie<p;ie++)k.dyn_dtree[2*ie]=0;for(ie=0;ie<m;ie++)k.bl_tree[2*ie]=0;k.dyn_ltree[2*b]=1,k.opt_len=k.static_len=0,k.last_lit=k.matches=0}function Te(k){8<k.bi_valid?me(k,k.bi_buf):0<k.bi_valid&&(k.pending_buf[k.pending++]=k.bi_buf),k.bi_buf=0,k.bi_valid=0}function Le(k,ie,fe,xe){var te=2*ie,C=2*fe;return k[te]<k[C]||k[te]===k[C]&&xe[ie]<=xe[fe]}function Oe(k,ie,fe){for(var xe=k.heap[fe],te=fe<<1;te<=k.heap_len&&(te<k.heap_len&&Le(ie,k.heap[te+1],k.heap[te],k.depth)&&te++,!Le(ie,xe,k.heap[te],k.depth));)k.heap[fe]=k.heap[te],fe=te,te<<=1;k.heap[fe]=xe}function tt(k,ie,fe){var xe,te,C,S,F=0;if(k.last_lit!==0)for(;xe=k.pending_buf[k.d_buf+2*F]<<8|k.pending_buf[k.d_buf+2*F+1],te=k.pending_buf[k.l_buf+F],F++,xe===0?Me(k,te,ie):(Me(k,(C=I[te])+d+1,ie),(S=M[C])!==0&&Ee(k,te-=O[C],S),Me(k,C=X(--xe),fe),(S=E[C])!==0&&Ee(k,xe-=H[C],S)),F<k.last_lit;);Me(k,b,ie)}function Ye(k,ie){var fe,xe,te,C=ie.dyn_tree,S=ie.stat_desc.static_tree,F=ie.stat_desc.has_stree,q=ie.stat_desc.elems,K=-1;for(k.heap_len=0,k.heap_max=v,fe=0;fe<q;fe++)C[2*fe]!==0?(k.heap[++k.heap_len]=K=fe,k.depth[fe]=0):C[2*fe+1]=0;for(;k.heap_len<2;)C[2*(te=k.heap[++k.heap_len]=K<2?++K:0)]=1,k.depth[te]=0,k.opt_len--,F&&(k.static_len-=S[2*te+1]);for(ie.max_code=K,fe=k.heap_len>>1;1<=fe;fe--)Oe(k,C,fe);for(te=q;fe=k.heap[1],k.heap[1]=k.heap[k.heap_len--],Oe(k,C,1),xe=k.heap[1],k.heap[--k.heap_max]=fe,k.heap[--k.heap_max]=xe,C[2*te]=C[2*fe]+C[2*xe],k.depth[te]=(k.depth[fe]>=k.depth[xe]?k.depth[fe]:k.depth[xe])+1,C[2*fe+1]=C[2*xe+1]=te,k.heap[1]=te++,Oe(k,C,1),2<=k.heap_len;);k.heap[--k.heap_max]=k.heap[1],(function(Y,ye){var pe,Ue,He,oe,we,Ve,Fe=ye.dyn_tree,Ie=ye.max_code,$e=ye.stat_desc.static_tree,z=ye.stat_desc.has_stree,_e=ye.stat_desc.extra_bits,ve=ye.stat_desc.extra_base,Be=ye.stat_desc.max_length,ge=0;for(oe=0;oe<=g;oe++)Y.bl_count[oe]=0;for(Fe[2*Y.heap[Y.heap_max]+1]=0,pe=Y.heap_max+1;pe<v;pe++)Be<(oe=Fe[2*Fe[2*(Ue=Y.heap[pe])+1]+1]+1)&&(oe=Be,ge++),Fe[2*Ue+1]=oe,Ie<Ue||(Y.bl_count[oe]++,we=0,ve<=Ue&&(we=_e[Ue-ve]),Ve=Fe[2*Ue],Y.opt_len+=Ve*(oe+we),z&&(Y.static_len+=Ve*($e[2*Ue+1]+we)));if(ge!==0){do{for(oe=Be-1;Y.bl_count[oe]===0;)oe--;Y.bl_count[oe]--,Y.bl_count[oe+1]+=2,Y.bl_count[Be]--,ge-=2}while(0<ge);for(oe=Be;oe!==0;oe--)for(Ue=Y.bl_count[oe];Ue!==0;)Ie<(He=Y.heap[--pe])||(Fe[2*He+1]!==oe&&(Y.opt_len+=(oe-Fe[2*He+1])*Fe[2*He],Fe[2*He+1]=oe),Ue--)}})(k,ie),se(C,K,k.bl_count)}function B(k,ie,fe){var xe,te,C=-1,S=ie[1],F=0,q=7,K=4;for(S===0&&(q=138,K=3),ie[2*(fe+1)+1]=65535,xe=0;xe<=fe;xe++)te=S,S=ie[2*(xe+1)+1],++F<q&&te===S||(F<K?k.bl_tree[2*te]+=F:te!==0?(te!==C&&k.bl_tree[2*te]++,k.bl_tree[2*y]++):F<=10?k.bl_tree[2*x]++:k.bl_tree[2*_]++,C=te,K=(F=0)===S?(q=138,3):te===S?(q=6,3):(q=7,4))}function re(k,ie,fe){var xe,te,C=-1,S=ie[1],F=0,q=7,K=4;for(S===0&&(q=138,K=3),xe=0;xe<=fe;xe++)if(te=S,S=ie[2*(xe+1)+1],!(++F<q&&te===S)){if(F<K)for(;Me(k,te,k.bl_tree),--F!=0;);else te!==0?(te!==C&&(Me(k,te,k.bl_tree),F--),Me(k,y,k.bl_tree),Ee(k,F-3,2)):F<=10?(Me(k,x,k.bl_tree),Ee(k,F-3,3)):(Me(k,_,k.bl_tree),Ee(k,F-11,7));C=te,K=(F=0)===S?(q=138,3):te===S?(q=6,3):(q=7,4)}}l(H);var ee=!1;function Q(k,ie,fe,xe){Ee(k,(c<<1)+(xe?1:0),3),(function(te,C,S,F){Te(te),me(te,S),me(te,~S),r.arraySet(te.pending_buf,te.window,C,S,te.pending),te.pending+=S})(k,ie,fe)}n._tr_init=function(k){ee||((function(){var ie,fe,xe,te,C,S=new Array(g+1);for(te=xe=0;te<h-1;te++)for(O[te]=xe,ie=0;ie<1<<M[te];ie++)I[xe++]=te;for(I[xe-1]=te,te=C=0;te<16;te++)for(H[te]=C,ie=0;ie<1<<E[te];ie++)L[C++]=te;for(C>>=7;te<p;te++)for(H[te]=C<<7,ie=0;ie<1<<E[te]-7;ie++)L[256+C++]=te;for(fe=0;fe<=g;fe++)S[fe]=0;for(ie=0;ie<=143;)R[2*ie+1]=8,ie++,S[8]++;for(;ie<=255;)R[2*ie+1]=9,ie++,S[9]++;for(;ie<=279;)R[2*ie+1]=7,ie++,S[7]++;for(;ie<=287;)R[2*ie+1]=8,ie++,S[8]++;for(se(R,u+1,S),ie=0;ie<p;ie++)D[2*ie+1]=5,D[2*ie]=$(ie,5);N=new J(R,M,d+1,u,g),G=new J(D,E,0,p,g),V=new J(new Array(0),w,0,m,A)})(),ee=!0),k.l_desc=new W(k.dyn_ltree,N),k.d_desc=new W(k.dyn_dtree,G),k.bl_desc=new W(k.bl_tree,V),k.bi_buf=0,k.bi_valid=0,he(k)},n._tr_stored_block=Q,n._tr_flush_block=function(k,ie,fe,xe){var te,C,S=0;0<k.level?(k.strm.data_type===2&&(k.strm.data_type=(function(F){var q,K=4093624447;for(q=0;q<=31;q++,K>>>=1)if(1&K&&F.dyn_ltree[2*q]!==0)return a;if(F.dyn_ltree[18]!==0||F.dyn_ltree[20]!==0||F.dyn_ltree[26]!==0)return o;for(q=32;q<d;q++)if(F.dyn_ltree[2*q]!==0)return o;return a})(k)),Ye(k,k.l_desc),Ye(k,k.d_desc),S=(function(F){var q;for(B(F,F.dyn_ltree,F.l_desc.max_code),B(F,F.dyn_dtree,F.d_desc.max_code),Ye(F,F.bl_desc),q=m-1;3<=q&&F.bl_tree[2*T[q]+1]===0;q--);return F.opt_len+=3*(q+1)+5+5+4,q})(k),te=k.opt_len+3+7>>>3,(C=k.static_len+3+7>>>3)<=te&&(te=C)):te=C=fe+5,fe+4<=te&&ie!==-1?Q(k,ie,fe,xe):k.strategy===4||C===te?(Ee(k,2+(xe?1:0),3),tt(k,R,D)):(Ee(k,4+(xe?1:0),3),(function(F,q,K,Y){var ye;for(Ee(F,q-257,5),Ee(F,K-1,5),Ee(F,Y-4,4),ye=0;ye<Y;ye++)Ee(F,F.bl_tree[2*T[ye]+1],3);re(F,F.dyn_ltree,q-1),re(F,F.dyn_dtree,K-1)})(k,k.l_desc.max_code+1,k.d_desc.max_code+1,S+1),tt(k,k.dyn_ltree,k.dyn_dtree)),he(k),xe&&Te(k)},n._tr_tally=function(k,ie,fe){return k.pending_buf[k.d_buf+2*k.last_lit]=ie>>>8&255,k.pending_buf[k.d_buf+2*k.last_lit+1]=255&ie,k.pending_buf[k.l_buf+k.last_lit]=255&fe,k.last_lit++,ie===0?k.dyn_ltree[2*fe]++:(k.matches++,ie--,k.dyn_ltree[2*(I[fe]+d+1)]++,k.dyn_dtree[2*X(ie)]++),k.last_lit===k.lit_bufsize-1},n._tr_align=function(k){Ee(k,2,3),Me(k,b,R),(function(ie){ie.bi_valid===16?(me(ie,ie.bi_buf),ie.bi_buf=0,ie.bi_valid=0):8<=ie.bi_valid&&(ie.pending_buf[ie.pending++]=255&ie.bi_buf,ie.bi_buf>>=8,ie.bi_valid-=8)})(k)}},{"../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(r){(function(a,o){if(!a.setImmediate){var l,c,h,d,u=1,p={},m=!1,v=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(){A(y)})}:(function(){if(a.postMessage&&!a.importScripts){var y=!0,x=a.onmessage;return a.onmessage=function(){y=!1},a.postMessage("","*"),a.onmessage=x,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){A(y.data)},function(y){h.port2.postMessage(y)}):v&&"onreadystatechange"in v.createElement("script")?(c=v.documentElement,function(y){var x=v.createElement("script");x.onreadystatechange=function(){A(y),x.onreadystatechange=null,c.removeChild(x),x=null},c.appendChild(x)}):function(y){setTimeout(A,0,y)},g.setImmediate=function(y){typeof y!="function"&&(y=new Function(""+y));for(var x=new Array(arguments.length-1),_=0;_<x.length;_++)x[_]=arguments[_+1];var M={callback:y,args:x};return p[u]=M,l(u),u++},g.clearImmediate=f}function f(y){delete p[y]}function A(y){if(m)setTimeout(A,0,y);else{var x=p[y];if(x){m=!0;try{(function(_){var M=_.callback,E=_.args;switch(E.length){case 0:M();break;case 1:M(E[0]);break;case 2:M(E[0],E[1]);break;case 3:M(E[0],E[1],E[2]);break;default:M.apply(o,E)}})(x)}finally{f(y),m=!1}}}}function b(y){y.source===a&&typeof y.data=="string"&&y.data.indexOf(d)===0&&A(+y.data.slice(d.length))}})(typeof self>"u"?r===void 0?this:r:self)}).call(this,typeof _0<"u"?_0:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(E2)),E2.exports}var WH=VH();const S2=w2(WH);function C2(s,e){return function(){return s.apply(e,arguments)}}const{toString:QH}=Object.prototype,{getPrototypeOf:Fx}=Object,{iterator:E0,toStringTag:T2}=Symbol,M0=(s=>e=>{const t=QH.call(e);return s[t]||(s[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),hr=s=>(s=s.toLowerCase(),e=>M0(e)===s),S0=s=>e=>typeof e===s,{isArray:jh}=Array,Xh=S0("undefined");function np(s){return s!==null&&!Xh(s)&&s.constructor!==null&&!Xh(s.constructor)&&ns(s.constructor.isBuffer)&&s.constructor.isBuffer(s)}const I2=hr("ArrayBuffer");function jH(s){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(s):e=s&&s.buffer&&I2(s.buffer),e}const XH=S0("string"),ns=S0("function"),P2=S0("number"),sp=s=>s!==null&&typeof s=="object",qH=s=>s===!0||s===!1,C0=s=>{if(M0(s)!=="object")return!1;const e=Fx(s);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(T2 in s)&&!(E0 in s)},YH=s=>{if(!sp(s)||np(s))return!1;try{return Object.keys(s).length===0&&Object.getPrototypeOf(s)===Object.prototype}catch{return!1}},KH=hr("Date"),$H=hr("File"),ZH=hr("Blob"),JH=hr("FileList"),eG=s=>sp(s)&&ns(s.pipe),tG=s=>{let e;return s&&(typeof FormData=="function"&&s instanceof FormData||ns(s.append)&&((e=M0(s))==="formdata"||e==="object"&&ns(s.toString)&&s.toString()==="[object FormData]"))},iG=hr("URLSearchParams"),[nG,sG,rG,aG]=["ReadableStream","Request","Response","Headers"].map(hr),oG=s=>s.trim?s.trim():s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function rp(s,e,{allOwnKeys:t=!1}={}){if(s===null||typeof s>"u")return;let i,n;if(typeof s!="object"&&(s=[s]),jh(s))for(i=0,n=s.length;i<n;i++)e.call(null,s[i],i,s);else{if(np(s))return;const r=t?Object.getOwnPropertyNames(s):Object.keys(s),a=r.length;let o;for(i=0;i<a;i++)o=r[i],e.call(null,s[o],o,s)}}function D2(s,e){if(np(s))return null;e=e.toLowerCase();const t=Object.keys(s);let i=t.length,n;for(;i-- >0;)if(n=t[i],e===n.toLowerCase())return n;return null}const ql=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,R2=s=>!Xh(s)&&s!==ql;function Nx(){const{caseless:s,skipUndefined:e}=R2(this)&&this||{},t={},i=(n,r)=>{const a=s&&D2(t,r)||r;C0(t[a])&&C0(n)?t[a]=Nx(t[a],n):C0(n)?t[a]=Nx({},n):jh(n)?t[a]=n.slice():(!e||!Xh(n))&&(t[a]=n)};for(let n=0,r=arguments.length;n<r;n++)arguments[n]&&rp(arguments[n],i);return t}const lG=(s,e,t,{allOwnKeys:i}={})=>(rp(e,(n,r)=>{t&&ns(n)?s[r]=C2(n,t):s[r]=n},{allOwnKeys:i}),s),cG=s=>(s.charCodeAt(0)===65279&&(s=s.slice(1)),s),hG=(s,e,t,i)=>{s.prototype=Object.create(e.prototype,i),s.prototype.constructor=s,Object.defineProperty(s,"super",{value:e.prototype}),t&&Object.assign(s.prototype,t)},dG=(s,e,t,i)=>{let n,r,a;const o={};if(e=e||{},s==null)return e;do{for(n=Object.getOwnPropertyNames(s),r=n.length;r-- >0;)a=n[r],(!i||i(a,s,e))&&!o[a]&&(e[a]=s[a],o[a]=!0);s=t!==!1&&Fx(s)}while(s&&(!t||t(s,e))&&s!==Object.prototype);return e},uG=(s,e,t)=>{s=String(s),(t===void 0||t>s.length)&&(t=s.length),t-=e.length;const i=s.indexOf(e,t);return i!==-1&&i===t},pG=s=>{if(!s)return null;if(jh(s))return s;let e=s.length;if(!P2(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=s[e];return t},fG=(s=>e=>s&&e instanceof s)(typeof Uint8Array<"u"&&Fx(Uint8Array)),mG=(s,e)=>{const t=(s&&s[E0]).call(s);let i;for(;(i=t.next())&&!i.done;){const n=i.value;e.call(s,n[0],n[1])}},gG=(s,e)=>{let t;const i=[];for(;(t=s.exec(e))!==null;)i.push(t);return i},vG=hr("HTMLFormElement"),AG=s=>s.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,i){return t.toUpperCase()+i}),B2=(({hasOwnProperty:s})=>(e,t)=>s.call(e,t))(Object.prototype),bG=hr("RegExp"),L2=(s,e)=>{const t=Object.getOwnPropertyDescriptors(s),i={};rp(t,(n,r)=>{let a;(a=e(n,r,s))!==!1&&(i[r]=a||n)}),Object.defineProperties(s,i)},yG=s=>{L2(s,(e,t)=>{if(ns(s)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const i=s[t];if(ns(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+"'")})}})},xG=(s,e)=>{const t={},i=n=>{n.forEach(r=>{t[r]=!0})};return jh(s)?i(s):i(String(s).split(e)),t},_G=()=>{},wG=(s,e)=>s!=null&&Number.isFinite(s=+s)?s:e;function EG(s){return!!(s&&ns(s.append)&&s[T2]==="FormData"&&s[E0])}const MG=s=>{const e=new Array(10),t=(i,n)=>{if(sp(i)){if(e.indexOf(i)>=0)return;if(np(i))return i;if(!("toJSON"in i)){e[n]=i;const r=jh(i)?[]:{};return rp(i,(a,o)=>{const l=t(a,n+1);!Xh(l)&&(r[o]=l)}),e[n]=void 0,r}}return i};return t(s,0)},SG=hr("AsyncFunction"),CG=s=>s&&(sp(s)||ns(s))&&ns(s.then)&&ns(s.catch),k2=((s,e)=>s?setImmediate:e?((t,i)=>(ql.addEventListener("message",({source:n,data:r})=>{n===ql&&r===t&&i.length&&i.shift()()},!1),n=>{i.push(n),ql.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",ns(ql.postMessage)),TG=typeof queueMicrotask<"u"?queueMicrotask.bind(ql):typeof process<"u"&&process.nextTick||k2,IG=s=>s!=null&&ns(s[E0]),Pe={isArray:jh,isArrayBuffer:I2,isBuffer:np,isFormData:tG,isArrayBufferView:jH,isString:XH,isNumber:P2,isBoolean:qH,isObject:sp,isPlainObject:C0,isEmptyObject:YH,isReadableStream:nG,isRequest:sG,isResponse:rG,isHeaders:aG,isUndefined:Xh,isDate:KH,isFile:$H,isBlob:ZH,isRegExp:bG,isFunction:ns,isStream:eG,isURLSearchParams:iG,isTypedArray:fG,isFileList:JH,forEach:rp,merge:Nx,extend:lG,trim:oG,stripBOM:cG,inherits:hG,toFlatObject:dG,kindOf:M0,kindOfTest:hr,endsWith:uG,toArray:pG,forEachEntry:mG,matchAll:gG,isHTMLForm:vG,hasOwnProperty:B2,hasOwnProp:B2,reduceDescriptors:L2,freezeMethods:yG,toObjectSet:xG,toCamelCase:AG,noop:_G,toFiniteNumber:wG,findKey:D2,global:ql,isContextDefined:R2,isSpecCompliantForm:EG,toJSONObject:MG,isAsyncFn:SG,isThenable:CG,setImmediate:k2,asap:TG,isIterable:IG};function St(s,e,t,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=s,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)}Pe.inherits(St,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:Pe.toJSONObject(this.config),code:this.code,status:this.status}}});const O2=St.prototype,F2={};["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(s=>{F2[s]={value:s}}),Object.defineProperties(St,F2),Object.defineProperty(O2,"isAxiosError",{value:!0}),St.from=(s,e,t,i,n,r)=>{const a=Object.create(O2);Pe.toFlatObject(s,a,function(c){return c!==Error.prototype},c=>c!=="isAxiosError");const o=s&&s.message?s.message:"Error",l=e==null&&s?s.code:e;return St.call(a,o,l,t,i,n),s&&a.cause==null&&Object.defineProperty(a,"cause",{value:s,configurable:!0}),a.name=s&&s.name||"Error",r&&Object.assign(a,r),a};const PG=null;function Ux(s){return Pe.isPlainObject(s)||Pe.isArray(s)}function N2(s){return Pe.endsWith(s,"[]")?s.slice(0,-2):s}function U2(s,e,t){return s?s.concat(e).map(function(i,n){return i=N2(i),!t&&n?"["+i+"]":i}).join(t?".":""):e}function DG(s){return Pe.isArray(s)&&!s.some(Ux)}const RG=Pe.toFlatObject(Pe,{},null,function(s){return/^is[A-Z]/.test(s)});function T0(s,e,t){if(!Pe.isObject(s))throw new TypeError("target must be an object");e=e||new FormData,t=Pe.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(p,m){return!Pe.isUndefined(m[p])});const i=t.metaTokens,n=t.visitor||c,r=t.dots,a=t.indexes,o=(t.Blob||typeof Blob<"u"&&Blob)&&Pe.isSpecCompliantForm(e);if(!Pe.isFunction(n))throw new TypeError("visitor must be a function");function l(p){if(p===null)return"";if(Pe.isDate(p))return p.toISOString();if(Pe.isBoolean(p))return p.toString();if(!o&&Pe.isBlob(p))throw new St("Blob is not supported. Use a Buffer instead.");return Pe.isArrayBuffer(p)||Pe.isTypedArray(p)?o&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function c(p,m,v){let g=p;if(p&&!v&&typeof p=="object"){if(Pe.endsWith(m,"{}"))m=i?m:m.slice(0,-2),p=JSON.stringify(p);else if(Pe.isArray(p)&&DG(p)||(Pe.isFileList(p)||Pe.endsWith(m,"[]"))&&(g=Pe.toArray(p)))return m=N2(m),g.forEach(function(f,A){!(Pe.isUndefined(f)||f===null)&&e.append(a===!0?U2([m],A,r):a===null?m:m+"[]",l(f))}),!1}return Ux(p)?!0:(e.append(U2(v,m,r),l(p)),!1)}const h=[],d=Object.assign(RG,{defaultVisitor:c,convertValue:l,isVisitable:Ux});function u(p,m){if(!Pe.isUndefined(p)){if(h.indexOf(p)!==-1)throw Error("Circular reference detected in "+m.join("."));h.push(p),Pe.forEach(p,function(v,g){(!(Pe.isUndefined(v)||v===null)&&n.call(e,v,Pe.isString(g)?g.trim():g,m,d))===!0&&u(v,m?m.concat(g):[g])}),h.pop()}}if(!Pe.isObject(s))throw new TypeError("data must be an object");return u(s),e}function z2(s){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(s).replace(/[!'()~]|%20|%00/g,function(t){return e[t]})}function zx(s,e){this._pairs=[],s&&T0(s,this,e)}const H2=zx.prototype;H2.append=function(s,e){this._pairs.push([s,e])},H2.toString=function(s){const e=s?function(t){return s.call(this,t,z2)}:z2;return this._pairs.map(function(t){return e(t[0])+"="+e(t[1])},"").join("&")};function BG(s){return encodeURIComponent(s).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function G2(s,e,t){if(!e)return s;const i=t&&t.encode||BG;Pe.isFunction(t)&&(t={serialize:t});const n=t&&t.serialize;let r;if(n?r=n(e,t):r=Pe.isURLSearchParams(e)?e.toString():new zx(e,t).toString(i),r){const a=s.indexOf("#");a!==-1&&(s=s.slice(0,a)),s+=(s.indexOf("?")===-1?"?":"&")+r}return s}class V2{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){Pe.forEach(this.handlers,function(t){t!==null&&e(t)})}}const W2={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},LG=typeof URLSearchParams<"u"?URLSearchParams:zx,kG=typeof FormData<"u"?FormData:null,OG=typeof Blob<"u"?Blob:null,FG={isBrowser:!0,classes:{URLSearchParams:LG,FormData:kG,Blob:OG},protocols:["http","https","file","blob","url","data"]},Hx=typeof window<"u"&&typeof document<"u",Gx=typeof navigator=="object"&&navigator||void 0,NG=Hx&&(!Gx||["ReactNative","NativeScript","NS"].indexOf(Gx.product)<0),UG=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",zG=Hx&&window.location.href||"http://localhost",HG=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Hx,hasStandardBrowserEnv:NG,hasStandardBrowserWebWorkerEnv:UG,navigator:Gx,origin:zG},Symbol.toStringTag,{value:"Module"})),Tn={...HG,...FG};function GG(s,e){return T0(s,new Tn.classes.URLSearchParams,{visitor:function(t,i,n,r){return Tn.isNode&&Pe.isBuffer(t)?(this.append(i,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...e})}function VG(s){return Pe.matchAll(/\w+|\[(\w*)]/g,s).map(e=>e[0]==="[]"?"":e[1]||e[0])}function WG(s){const e={},t=Object.keys(s);let i;const n=t.length;let r;for(i=0;i<n;i++)r=t[i],e[r]=s[r];return e}function Q2(s){function e(t,i,n,r){let a=t[r++];if(a==="__proto__")return!0;const o=Number.isFinite(+a),l=r>=t.length;return a=!a&&Pe.isArray(n)?n.length:a,l?(Pe.hasOwnProp(n,a)?n[a]=[n[a],i]:n[a]=i,!o):((!n[a]||!Pe.isObject(n[a]))&&(n[a]=[]),e(t,i,n[a],r)&&Pe.isArray(n[a])&&(n[a]=WG(n[a])),!o)}if(Pe.isFormData(s)&&Pe.isFunction(s.entries)){const t={};return Pe.forEachEntry(s,(i,n)=>{e(VG(i),n,t,0)}),t}return null}function QG(s,e,t){if(Pe.isString(s))try{return(e||JSON.parse)(s),Pe.trim(s)}catch(i){if(i.name!=="SyntaxError")throw i}return(t||JSON.stringify)(s)}const ap={transitional:W2,adapter:["xhr","http","fetch"],transformRequest:[function(s,e){const t=e.getContentType()||"",i=t.indexOf("application/json")>-1,n=Pe.isObject(s);if(n&&Pe.isHTMLForm(s)&&(s=new FormData(s)),Pe.isFormData(s))return i?JSON.stringify(Q2(s)):s;if(Pe.isArrayBuffer(s)||Pe.isBuffer(s)||Pe.isStream(s)||Pe.isFile(s)||Pe.isBlob(s)||Pe.isReadableStream(s))return s;if(Pe.isArrayBufferView(s))return s.buffer;if(Pe.isURLSearchParams(s))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),s.toString();let r;if(n){if(t.indexOf("application/x-www-form-urlencoded")>-1)return GG(s,this.formSerializer).toString();if((r=Pe.isFileList(s))||t.indexOf("multipart/form-data")>-1){const a=this.env&&this.env.FormData;return T0(r?{"files[]":s}:s,a&&new a,this.formSerializer)}}return n||i?(e.setContentType("application/json",!1),QG(s)):s}],transformResponse:[function(s){const e=this.transitional||ap.transitional,t=e&&e.forcedJSONParsing,i=this.responseType==="json";if(Pe.isResponse(s)||Pe.isReadableStream(s))return s;if(s&&Pe.isString(s)&&(t&&!this.responseType||i)){const n=!(e&&e.silentJSONParsing)&&i;try{return JSON.parse(s,this.parseReviver)}catch(r){if(n)throw r.name==="SyntaxError"?St.from(r,St.ERR_BAD_RESPONSE,this,null,this.response):r}}return s}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Tn.classes.FormData,Blob:Tn.classes.Blob},validateStatus:function(s){return s>=200&&s<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Pe.forEach(["delete","get","head","post","put","patch"],s=>{ap.headers[s]={}});const jG=Pe.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"]),XG=s=>{const e={};let t,i,n;return s&&s.split(`
|
||
`).forEach(function(r){n=r.indexOf(":"),t=r.substring(0,n).trim().toLowerCase(),i=r.substring(n+1).trim(),!(!t||e[t]&&jG[t])&&(t==="set-cookie"?e[t]?e[t].push(i):e[t]=[i]:e[t]=e[t]?e[t]+", "+i:i)}),e},j2=Symbol("internals");function op(s){return s&&String(s).trim().toLowerCase()}function I0(s){return s===!1||s==null?s:Pe.isArray(s)?s.map(I0):String(s)}function qG(s){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;for(;i=t.exec(s);)e[i[1]]=i[2];return e}const YG=s=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(s.trim());function Vx(s,e,t,i,n){if(Pe.isFunction(i))return i.call(this,e,t);if(n&&(e=t),!!Pe.isString(e)){if(Pe.isString(i))return e.indexOf(i)!==-1;if(Pe.isRegExp(i))return i.test(e)}}function KG(s){return s.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,i)=>t.toUpperCase()+i)}function $G(s,e){const t=Pe.toCamelCase(" "+e);["get","set","has"].forEach(i=>{Object.defineProperty(s,i+t,{value:function(n,r,a){return this[i].call(this,e,n,r,a)},configurable:!0})})}let ss=class{constructor(s){s&&this.set(s)}set(s,e,t){const i=this;function n(a,o,l){const c=op(o);if(!c)throw new Error("header name must be a non-empty string");const h=Pe.findKey(i,c);(!h||i[h]===void 0||l===!0||l===void 0&&i[h]!==!1)&&(i[h||o]=I0(a))}const r=(a,o)=>Pe.forEach(a,(l,c)=>n(l,c,o));if(Pe.isPlainObject(s)||s instanceof this.constructor)r(s,e);else if(Pe.isString(s)&&(s=s.trim())&&!YG(s))r(XG(s),e);else if(Pe.isObject(s)&&Pe.isIterable(s)){let a={},o,l;for(const c of s){if(!Pe.isArray(c))throw TypeError("Object iterator must return a key-value pair");a[l=c[0]]=(o=a[l])?Pe.isArray(o)?[...o,c[1]]:[o,c[1]]:c[1]}r(a,e)}else s!=null&&n(e,s,t);return this}get(s,e){if(s=op(s),s){const t=Pe.findKey(this,s);if(t){const i=this[t];if(!e)return i;if(e===!0)return qG(i);if(Pe.isFunction(e))return e.call(this,i,t);if(Pe.isRegExp(e))return e.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(s,e){if(s=op(s),s){const t=Pe.findKey(this,s);return!!(t&&this[t]!==void 0&&(!e||Vx(this,this[t],t,e)))}return!1}delete(s,e){const t=this;let i=!1;function n(r){if(r=op(r),r){const a=Pe.findKey(t,r);a&&(!e||Vx(t,t[a],a,e))&&(delete t[a],i=!0)}}return Pe.isArray(s)?s.forEach(n):n(s),i}clear(s){const e=Object.keys(this);let t=e.length,i=!1;for(;t--;){const n=e[t];(!s||Vx(this,this[n],n,s,!0))&&(delete this[n],i=!0)}return i}normalize(s){const e=this,t={};return Pe.forEach(this,(i,n)=>{const r=Pe.findKey(t,n);if(r){e[r]=I0(i),delete e[n];return}const a=s?KG(n):String(n).trim();a!==n&&delete e[n],e[a]=I0(i),t[a]=!0}),this}concat(...s){return this.constructor.concat(this,...s)}toJSON(s){const e=Object.create(null);return Pe.forEach(this,(t,i)=>{t!=null&&t!==!1&&(e[i]=s&&Pe.isArray(t)?t.join(", "):t)}),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([s,e])=>s+": "+e).join(`
|
||
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(s){return s instanceof this?s:new this(s)}static concat(s,...e){const t=new this(s);return e.forEach(i=>t.set(i)),t}static accessor(s){const e=(this[j2]=this[j2]={accessors:{}}).accessors,t=this.prototype;function i(n){const r=op(n);e[r]||($G(t,n),e[r]=!0)}return Pe.isArray(s)?s.forEach(i):i(s),this}};ss.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Pe.reduceDescriptors(ss.prototype,({value:s},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>s,set(i){this[t]=i}}}),Pe.freezeMethods(ss);function Wx(s,e){const t=this||ap,i=e||t,n=ss.from(i.headers);let r=i.data;return Pe.forEach(s,function(a){r=a.call(t,r,n.normalize(),e?e.status:void 0)}),n.normalize(),r}function X2(s){return!!(s&&s.__CANCEL__)}function qh(s,e,t){St.call(this,s??"canceled",St.ERR_CANCELED,e,t),this.name="CanceledError"}Pe.inherits(qh,St,{__CANCEL__:!0});function q2(s,e,t){const i=t.config.validateStatus;!t.status||!i||i(t.status)?s(t):e(new St("Request failed with status code "+t.status,[St.ERR_BAD_REQUEST,St.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function ZG(s){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(s);return e&&e[1]||""}function JG(s,e){s=s||10;const t=new Array(s),i=new Array(s);let n=0,r=0,a;return e=e!==void 0?e:1e3,function(o){const l=Date.now(),c=i[r];a||(a=l),t[n]=o,i[n]=l;let h=r,d=0;for(;h!==n;)d+=t[h++],h=h%s;if(n=(n+1)%s,n===r&&(r=(r+1)%s),l-a<e)return;const u=c&&l-c;return u?Math.round(d*1e3/u):void 0}}function eV(s,e){let t=0,i=1e3/e,n,r;const a=(o,l=Date.now())=>{t=l,n=null,r&&(clearTimeout(r),r=null),s(...o)};return[(...o)=>{const l=Date.now(),c=l-t;c>=i?a(o,l):(n=o,r||(r=setTimeout(()=>{r=null,a(n)},i-c)))},()=>n&&a(n)]}const P0=(s,e,t=3)=>{let i=0;const n=JG(50,250);return eV(r=>{const a=r.loaded,o=r.lengthComputable?r.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:r,lengthComputable:o!=null,[e?"download":"upload"]:!0};s(d)},t)},Y2=(s,e)=>{const t=s!=null;return[i=>e[0]({lengthComputable:t,total:s,loaded:i}),e[1]]},K2=s=>(...e)=>Pe.asap(()=>s(...e)),tV=Tn.hasStandardBrowserEnv?((s,e)=>t=>(t=new URL(t,Tn.origin),s.protocol===t.protocol&&s.host===t.host&&(e||s.port===t.port)))(new URL(Tn.origin),Tn.navigator&&/(msie|trident)/i.test(Tn.navigator.userAgent)):()=>!0,iV=Tn.hasStandardBrowserEnv?{write(s,e,t,i,n,r,a){if(typeof document>"u")return;const o=[`${s}=${encodeURIComponent(e)}`];Pe.isNumber(t)&&o.push(`expires=${new Date(t).toUTCString()}`),Pe.isString(i)&&o.push(`path=${i}`),Pe.isString(n)&&o.push(`domain=${n}`),r===!0&&o.push("secure"),Pe.isString(a)&&o.push(`SameSite=${a}`),document.cookie=o.join("; ")},read(s){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+s+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(s){this.write(s,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function nV(s){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(s)}function sV(s,e){return e?s.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):s}function $2(s,e,t){let i=!nV(e);return s&&(i||t==!1)?sV(s,e):e}const Z2=s=>s instanceof ss?{...s}:s;function Yl(s,e){e=e||{};const t={};function i(c,h,d,u){return Pe.isPlainObject(c)&&Pe.isPlainObject(h)?Pe.merge.call({caseless:u},c,h):Pe.isPlainObject(h)?Pe.merge({},h):Pe.isArray(h)?h.slice():h}function n(c,h,d,u){if(Pe.isUndefined(h)){if(!Pe.isUndefined(c))return i(void 0,c,d,u)}else return i(c,h,d,u)}function r(c,h){if(!Pe.isUndefined(h))return i(void 0,h)}function a(c,h){if(Pe.isUndefined(h)){if(!Pe.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 s)return i(void 0,c)}const l={url:r,method:r,data:r,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(Z2(c),Z2(h),d,!0)};return Pe.forEach(Object.keys({...s,...e}),function(c){const h=l[c]||n,d=h(s[c],e[c],c);Pe.isUndefined(d)&&h!==o||(t[c]=d)}),t}const J2=s=>{const e=Yl({},s);let{data:t,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:r,headers:a,auth:o}=e;if(e.headers=a=ss.from(a),e.url=G2($2(e.baseURL,e.url,e.allowAbsoluteUrls),s.params,s.paramsSerializer),o&&a.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):""))),Pe.isFormData(t)){if(Tn.hasStandardBrowserEnv||Tn.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(Pe.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(Tn.hasStandardBrowserEnv&&(i&&Pe.isFunction(i)&&(i=i(e)),i||i!==!1&&tV(e.url))){const l=n&&r&&iV.read(r);l&&a.set(n,l)}return e},rV=typeof XMLHttpRequest<"u",aV=rV&&function(s){return new Promise(function(e,t){const i=J2(s);let n=i.data;const r=ss.from(i.headers).normalize();let{responseType:a,onUploadProgress:o,onDownloadProgress:l}=i,c,h,d,u,p;function m(){u&&u(),p&&p(),i.cancelToken&&i.cancelToken.unsubscribe(c),i.signal&&i.signal.removeEventListener("abort",c)}let v=new XMLHttpRequest;v.open(i.method.toUpperCase(),i.url,!0),v.timeout=i.timeout;function g(){if(!v)return;const A=ss.from("getAllResponseHeaders"in v&&v.getAllResponseHeaders()),b={data:!a||a==="text"||a==="json"?v.responseText:v.response,status:v.status,statusText:v.statusText,headers:A,config:s,request:v};q2(function(y){e(y),m()},function(y){t(y),m()},b),v=null}"onloadend"in v?v.onloadend=g:v.onreadystatechange=function(){!v||v.readyState!==4||v.status===0&&!(v.responseURL&&v.responseURL.indexOf("file:")===0)||setTimeout(g)},v.onabort=function(){v&&(t(new St("Request aborted",St.ECONNABORTED,s,v)),v=null)},v.onerror=function(A){const b=A&&A.message?A.message:"Network Error",y=new St(b,St.ERR_NETWORK,s,v);y.event=A||null,t(y),v=null},v.ontimeout=function(){let A=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const b=i.transitional||W2;i.timeoutErrorMessage&&(A=i.timeoutErrorMessage),t(new St(A,b.clarifyTimeoutError?St.ETIMEDOUT:St.ECONNABORTED,s,v)),v=null},n===void 0&&r.setContentType(null),"setRequestHeader"in v&&Pe.forEach(r.toJSON(),function(A,b){v.setRequestHeader(b,A)}),Pe.isUndefined(i.withCredentials)||(v.withCredentials=!!i.withCredentials),a&&a!=="json"&&(v.responseType=i.responseType),l&&([d,p]=P0(l,!0),v.addEventListener("progress",d)),o&&v.upload&&([h,u]=P0(o),v.upload.addEventListener("progress",h),v.upload.addEventListener("loadend",u)),(i.cancelToken||i.signal)&&(c=A=>{v&&(t(!A||A.type?new qh(null,s,v):A),v.abort(),v=null)},i.cancelToken&&i.cancelToken.subscribe(c),i.signal&&(i.signal.aborted?c():i.signal.addEventListener("abort",c)));const f=ZG(i.url);if(f&&Tn.protocols.indexOf(f)===-1){t(new St("Unsupported protocol "+f+":",St.ERR_BAD_REQUEST,s));return}v.send(n||null)})},oV=(s,e)=>{const{length:t}=s=s?s.filter(Boolean):[];if(e||t){let i=new AbortController,n;const r=function(c){if(!n){n=!0,o();const h=c instanceof Error?c:this.reason;i.abort(h instanceof St?h:new qh(h instanceof Error?h.message:h))}};let a=e&&setTimeout(()=>{a=null,r(new St(`timeout ${e} of ms exceeded`,St.ETIMEDOUT))},e);const o=()=>{s&&(a&&clearTimeout(a),a=null,s.forEach(c=>{c.unsubscribe?c.unsubscribe(r):c.removeEventListener("abort",r)}),s=null)};s.forEach(c=>c.addEventListener("abort",r));const{signal:l}=i;return l.unsubscribe=()=>Pe.asap(o),l}},lV=function*(s,e){let t=s.byteLength;if(t<e){yield s;return}let i=0,n;for(;i<t;)n=i+e,yield s.slice(i,n),i=n},cV=async function*(s,e){for await(const t of hV(s))yield*lV(t,e)},hV=async function*(s){if(s[Symbol.asyncIterator]){yield*s;return}const e=s.getReader();try{for(;;){const{done:t,value:i}=await e.read();if(t)break;yield i}}finally{await e.cancel()}},eT=(s,e,t,i)=>{const n=cV(s,e);let r=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 u=r+=d;t(u)}l.enqueue(new Uint8Array(h))}catch(c){throw o(c),c}},cancel(l){return o(l),n.return()}},{highWaterMark:2})},tT=64*1024,{isFunction:D0}=Pe,dV=(({Request:s,Response:e})=>({Request:s,Response:e}))(Pe.global),{ReadableStream:iT,TextEncoder:nT}=Pe.global,sT=(s,...e)=>{try{return!!s(...e)}catch{return!1}},uV=s=>{s=Pe.merge.call({skipUndefined:!0},dV,s);const{fetch:e,Request:t,Response:i}=s,n=e?D0(e):typeof fetch=="function",r=D0(t),a=D0(i);if(!n)return!1;const o=n&&D0(iT),l=n&&(typeof nT=="function"?(m=>v=>m.encode(v))(new nT):async m=>new Uint8Array(await new t(m).arrayBuffer())),c=r&&o&&sT(()=>{let m=!1;const v=new t(Tn.origin,{body:new iT,method:"POST",get duplex(){return m=!0,"half"}}).headers.has("Content-Type");return m&&!v}),h=a&&o&&sT(()=>Pe.isReadableStream(new i("").body)),d={stream:h&&(m=>m.body)};n&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!d[m]&&(d[m]=(v,g)=>{let f=v&&v[m];if(f)return f.call(v);throw new St(`Response type '${m}' is not supported`,St.ERR_NOT_SUPPORT,g)})});const u=async m=>{if(m==null)return 0;if(Pe.isBlob(m))return m.size;if(Pe.isSpecCompliantForm(m))return(await new t(Tn.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(Pe.isArrayBufferView(m)||Pe.isArrayBuffer(m))return m.byteLength;if(Pe.isURLSearchParams(m)&&(m=m+""),Pe.isString(m))return(await l(m)).byteLength},p=async(m,v)=>Pe.toFiniteNumber(m.getContentLength())??u(v);return async m=>{let{url:v,method:g,data:f,signal:A,cancelToken:b,timeout:y,onDownloadProgress:x,onUploadProgress:_,responseType:M,headers:E,withCredentials:w="same-origin",fetchOptions:T}=J2(m),R=e||fetch;M=M?(M+"").toLowerCase():"text";let D=oV([A,b&&b.toAbortSignal()],y),L=null;const I=D&&D.unsubscribe&&(()=>{D.unsubscribe()});let O;try{if(_&&c&&g!=="get"&&g!=="head"&&(O=await p(E,f))!==0){let W=new t(v,{method:"POST",body:f,duplex:"half"}),X;if(Pe.isFormData(f)&&(X=W.headers.get("content-type"))&&E.setContentType(X),W.body){const[me,Ee]=Y2(O,P0(K2(_)));f=eT(W.body,tT,me,Ee)}}Pe.isString(w)||(w=w?"include":"omit");const N=r&&"credentials"in t.prototype,G={...T,signal:D,method:g.toUpperCase(),headers:E.normalize().toJSON(),body:f,duplex:"half",credentials:N?w:void 0};L=r&&new t(v,G);let V=await(r?R(L,T):R(v,G));const H=h&&(M==="stream"||M==="response");if(h&&(x||H&&I)){const W={};["status","statusText","headers"].forEach(Me=>{W[Me]=V[Me]});const X=Pe.toFiniteNumber(V.headers.get("content-length")),[me,Ee]=x&&Y2(X,P0(K2(x),!0))||[];V=new i(eT(V.body,tT,me,()=>{Ee&&Ee(),I&&I()}),W)}M=M||"text";let J=await d[Pe.findKey(d,M)||"text"](V,m);return!H&&I&&I(),await new Promise((W,X)=>{q2(W,X,{data:J,headers:ss.from(V.headers),status:V.status,statusText:V.statusText,config:m,request:L})})}catch(N){throw I&&I(),N&&N.name==="TypeError"&&/Load failed|fetch/i.test(N.message)?Object.assign(new St("Network Error",St.ERR_NETWORK,m,L),{cause:N.cause||N}):St.from(N,N&&N.code,m,L)}}},pV=new Map,rT=s=>{let e=s&&s.env||{};const{fetch:t,Request:i,Response:n}=e,r=[i,n,t];let a=r.length,o=a,l,c,h=pV;for(;o--;)l=r[o],c=h.get(l),c===void 0&&h.set(l,c=o?new Map:uV(e)),h=c;return c};rT();const Qx={http:PG,xhr:aV,fetch:{get:rT}};Pe.forEach(Qx,(s,e)=>{if(s){try{Object.defineProperty(s,"name",{value:e})}catch{}Object.defineProperty(s,"adapterName",{value:e})}});const aT=s=>`- ${s}`,fV=s=>Pe.isFunction(s)||s===null||s===!1;function mV(s,e){s=Pe.isArray(s)?s:[s];const{length:t}=s;let i,n;const r={};for(let a=0;a<t;a++){i=s[a];let o;if(n=i,!fV(i)&&(n=Qx[(o=String(i)).toLowerCase()],n===void 0))throw new St(`Unknown adapter '${o}'`);if(n&&(Pe.isFunction(n)||(n=n.get(e))))break;r[o||"#"+a]=n}if(!n){const a=Object.entries(r).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(aT).join(`
|
||
`):" "+aT(a[0]):"as no adapter specified";throw new St("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return n}const oT={getAdapter:mV,adapters:Qx};function jx(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new qh(null,s)}function lT(s){return jx(s),s.headers=ss.from(s.headers),s.data=Wx.call(s,s.transformRequest),["post","put","patch"].indexOf(s.method)!==-1&&s.headers.setContentType("application/x-www-form-urlencoded",!1),oT.getAdapter(s.adapter||ap.adapter,s)(s).then(function(e){return jx(s),e.data=Wx.call(s,s.transformResponse,e),e.headers=ss.from(e.headers),e},function(e){return X2(e)||(jx(s),e&&e.response&&(e.response.data=Wx.call(s,s.transformResponse,e.response),e.response.headers=ss.from(e.response.headers))),Promise.reject(e)})}const cT="1.13.2",R0={};["object","boolean","number","function","string","symbol"].forEach((s,e)=>{R0[s]=function(t){return typeof t===s||"a"+(e<1?"n ":" ")+s}});const hT={};R0.transitional=function(s,e,t){function i(n,r){return"[Axios v"+cT+"] Transitional option '"+n+"'"+r+(t?". "+t:"")}return(n,r,a)=>{if(s===!1)throw new St(i(r," has been removed"+(e?" in "+e:"")),St.ERR_DEPRECATED);return e&&!hT[r]&&(hT[r]=!0,console.warn(i(r," has been deprecated since v"+e+" and will be removed in the near future"))),s?s(n,r,a):!0}},R0.spelling=function(s){return(e,t)=>(console.warn(`${t} is likely a misspelling of ${s}`),!0)};function gV(s,e,t){if(typeof s!="object")throw new St("options must be an object",St.ERR_BAD_OPTION_VALUE);const i=Object.keys(s);let n=i.length;for(;n-- >0;){const r=i[n],a=e[r];if(a){const o=s[r],l=o===void 0||a(o,r,s);if(l!==!0)throw new St("option "+r+" must be "+l,St.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new St("Unknown option "+r,St.ERR_BAD_OPTION)}}const B0={assertOptions:gV,validators:R0},Fr=B0.validators;let Kl=class{constructor(s){this.defaults=s||{},this.interceptors={request:new V2,response:new V2}}async request(s,e){try{return await this._request(s,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(s,e){typeof s=="string"?(e=e||{},e.url=s):e=s||{},e=Yl(this.defaults,e);const{transitional:t,paramsSerializer:i,headers:n}=e;t!==void 0&&B0.assertOptions(t,{silentJSONParsing:Fr.transitional(Fr.boolean),forcedJSONParsing:Fr.transitional(Fr.boolean),clarifyTimeoutError:Fr.transitional(Fr.boolean)},!1),i!=null&&(Pe.isFunction(i)?e.paramsSerializer={serialize:i}:B0.assertOptions(i,{encode:Fr.function,serialize:Fr.function},!0)),e.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?e.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:e.allowAbsoluteUrls=!0),B0.assertOptions(e,{baseUrl:Fr.spelling("baseURL"),withXsrfToken:Fr.spelling("withXSRFToken")},!0),e.method=(e.method||this.defaults.method||"get").toLowerCase();let r=n&&Pe.merge(n.common,n[e.method]);n&&Pe.forEach(["delete","get","head","post","put","patch","common"],p=>{delete n[p]}),e.headers=ss.concat(r,n);const a=[];let o=!0;this.interceptors.request.forEach(function(p){typeof p.runWhen=="function"&&p.runWhen(e)===!1||(o=o&&p.synchronous,a.unshift(p.fulfilled,p.rejected))});const l=[];this.interceptors.response.forEach(function(p){l.push(p.fulfilled,p.rejected)});let c,h=0,d;if(!o){const p=[lT.bind(this),void 0];for(p.unshift(...a),p.push(...l),d=p.length,c=Promise.resolve(e);h<d;)c=c.then(p[h++],p[h++]);return c}d=a.length;let u=e;for(;h<d;){const p=a[h++],m=a[h++];try{u=p(u)}catch(v){m.call(this,v);break}}try{c=lT.call(this,u)}catch(p){return Promise.reject(p)}for(h=0,d=l.length;h<d;)c=c.then(l[h++],l[h++]);return c}getUri(s){s=Yl(this.defaults,s);const e=$2(s.baseURL,s.url,s.allowAbsoluteUrls);return G2(e,s.params,s.paramsSerializer)}};Pe.forEach(["delete","get","head","options"],function(s){Kl.prototype[s]=function(e,t){return this.request(Yl(t||{},{method:s,url:e,data:(t||{}).data}))}}),Pe.forEach(["post","put","patch"],function(s){function e(t){return function(i,n,r){return this.request(Yl(r||{},{method:s,headers:t?{"Content-Type":"multipart/form-data"}:{},url:i,data:n}))}}Kl.prototype[s]=e(),Kl.prototype[s+"Form"]=e(!0)});let vV=class WR{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 r=i._listeners.length;for(;r-- >0;)i._listeners[r](n);i._listeners=null}),this.promise.then=n=>{let r;const a=new Promise(o=>{i.subscribe(o),r=o}).then(n);return a.cancel=function(){i.unsubscribe(r)},a},e(function(n,r,a){i.reason||(i.reason=new qh(n,r,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 WR(function(t){e=t}),cancel:e}}};function AV(s){return function(e){return s.apply(null,e)}}function bV(s){return Pe.isObject(s)&&s.isAxiosError===!0}const Xx={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(Xx).forEach(([s,e])=>{Xx[e]=s});function dT(s){const e=new Kl(s),t=C2(Kl.prototype.request,e);return Pe.extend(t,Kl.prototype,e,{allOwnKeys:!0}),Pe.extend(t,e,null,{allOwnKeys:!0}),t.create=function(i){return dT(Yl(s,i))},t}const Pi=dT(ap);Pi.Axios=Kl,Pi.CanceledError=qh,Pi.CancelToken=vV,Pi.isCancel=X2,Pi.VERSION=cT,Pi.toFormData=T0,Pi.AxiosError=St,Pi.Cancel=Pi.CanceledError,Pi.all=function(s){return Promise.all(s)},Pi.spread=AV,Pi.isAxiosError=bV,Pi.mergeConfig=Yl,Pi.AxiosHeaders=ss,Pi.formToJSON=s=>Q2(Pe.isHTMLForm(s)?new FormData(s):s),Pi.getAdapter=oT.getAdapter,Pi.HttpStatusCode=Xx,Pi.default=Pi;const{Axios:WJ,AxiosError:QJ,CanceledError:jJ,isCancel:XJ,CancelToken:qJ,VERSION:YJ,all:KJ,Cancel:$J,isAxiosError:ZJ,spread:JJ,toFormData:eee,AxiosHeaders:tee,HttpStatusCode:iee,formToJSON:nee,getAdapter:see,mergeConfig:ree}=Pi;class Yh{static MAGIC=new TextEncoder().encode("BIMGCM01");static isEncrypted(e){if(e.byteLength<8)return!1;const t=new Uint8Array(e);for(let i=0;i<8;i++)if(t[i]!==Yh.MAGIC[i])return!1;return!0}static async decryptPzEnc(e,t){const i=new Uint8Array(e),n=new TextEncoder().encode("BIMGCM01");for(let g=0;g<n.length;g++)if(i[g]!==n[g])throw new Error("magic 不匹配: 不是有效的 pzenc 文件");const r=i[8];if(r!==1)throw new Error(`不支持的 pzenc 版本: ${r}`);const a=i[9],o=i[10],l=11,c=i.slice(l,l+a),h=i.slice(l+a,l+a+o),d=i.slice(l+a+o),u=xV(d,h),p=yV(t);if(p.length!==32)throw new Error("AES-256 密钥必须是 32 字节");const m=await crypto.subtle.importKey("raw",p.buffer,{name:"AES-GCM"},!1,["decrypt"]),v=await crypto.subtle.decrypt({name:"AES-GCM",iv:c.buffer,additionalData:i.slice(0,l).buffer,tagLength:o*8},m,u.buffer);return new Uint8Array(v)}}function yV(s){const e=atob(s),t=new Uint8Array(e.length);for(let i=0;i<e.length;i++)t[i]=e.codePointAt(i);return t}function xV(s,e){const t=new Uint8Array(s.length+e.length);return t.set(s,0),t.set(e,s.length),t}function lp(s,e,t,i){Pi({method:"get",responseType:"arraybuffer",url:s}).then(async r=>{let a=r.data;i&&Yh.isEncrypted(r.data)&&(a=await Yh.decryptPzEnc(r.data,i)),S2.loadAsync(a).then(o=>{for(let l in o.files){const c=o.file(o.files[l].name);c&&c.async("blob").then(h=>{n(h,"utf-8",function(d,u){e(u)})}).catch(()=>{t()})}}).catch(()=>{t()})}).catch(()=>{t()});function n(r,a,o){var l=new FileReader,c=new Blob([r]);l.onload=function(h){o(null,h.target.result)},l.onerror=function(){o(null,null)},l.readAsText(c,a)}}const qx=new WeakMap;class _V extends dn{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 r=new gn(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,a=>{this.parse(a,t,n)},i,n)}parse(e,t,i=()=>{}){this.decodeDracoFile(e,t,null,null,ci,i).catch(i)}decodeDracoFile(e,t,i,n,r=qi,a=()=>{}){const o={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:r};return this.decodeGeometry(e,o).then(t).catch(a)}decodeGeometry(e,t){const i=JSON.stringify(t);if(qx.has(e)){const l=qx.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 r=this.workerNextTaskID++,a=e.byteLength,o=this._getWorker(r,a).then(l=>(n=l,new Promise((c,h)=>{n._callbacks[r]={resolve:c,reject:h},n.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return o.catch(()=>!0).then(()=>{n&&r&&this._releaseTask(n,r)}),qx.set(e,{key:i,promise:o}),o}_createGeometry(e){const t=new dt;e.index&&t.setIndex(new _t(e.index.array,1));for(let i=0;i<e.attributes.length;i++){const{name:n,array:r,itemSize:a,stride:o,vertexColorSpace:l}=e.attributes[i];let c;if(a===o)c=new _t(r,a);else{const h=new th(r,o);c=new ia(h,a,0)}n==="color"&&(this._assignVertexColorSpace(c,l),c.normalized=!(r instanceof Float32Array)),t.setAttribute(n,c)}return t}_assignVertexColorSpace(e,t){if(t!==ci)return;const i=new qe;for(let n=0,r=e.count;n<r;n++)i.fromBufferAttribute(e,n),It.colorSpaceToWorking(i,ci),e.setXYZ(n,i.r,i.g,i.b)}_loadLibrary(e,t){const i=new gn(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((n,r)=>{i.load(e,n,void 0,r)})}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 r=wV.toString(),a=["/* draco decoder */",n,"","/* worker */",r.substring(r.indexOf("{")+1,r.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(r){const a=r.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,r){return n._taskLoad>r._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 wV(){let s,e;onmessage=function(a){const o=a.data;switch(o.type){case"init":s=o.decoderConfig,e=new Promise(function(h){s.onModuleLoaded=function(d){h({draco:d})},DracoDecoderModule(s)});break;case"decode":const l=o.buffer,c=o.taskConfig;e.then(h=>{const d=h.draco,u=new d.Decoder;try{const p=t(d,u,new Int8Array(l),c),m=p.attributes.map(v=>v.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:o.id,error:p.message})}finally{d.destroy(u)}});break}};function t(a,o,l,c){const h=c.attributeIDs,d=c.attributeTypes;let u,p;const m=o.GetEncodedGeometryType(l);if(m===a.TRIANGULAR_MESH)u=new a.Mesh,p=o.DecodeArrayToMesh(l,l.byteLength,u);else if(m===a.POINT_CLOUD)u=new a.PointCloud,p=o.DecodeArrayToPointCloud(l,l.byteLength,u);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||u.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const v={index:null,attributes:[]};for(const g in h){const f=self[d[g]];let A,b;if(c.useUniqueIDs)b=h[g],A=o.GetAttributeByUniqueId(u,b);else{if(b=o.GetAttributeId(u,a[h[g]]),b===-1)continue;A=o.GetAttribute(u,b)}const y=n(a,o,u,g,f,A);g==="color"&&(y.vertexColorSpace=c.vertexColorSpace),v.attributes.push(y)}return m===a.TRIANGULAR_MESH&&(v.index=i(a,o,u)),a.destroy(u),v}function i(a,o,l){const c=l.num_faces()*3,h=c*4,d=a._malloc(h);o.GetTrianglesUInt32Array(l,h,d);const u=new Uint32Array(a.HEAPF32.buffer,d,c).slice();return a._free(d),{array:u,itemSize:1}}function n(a,o,l,c,h,d){const u=l.num_points(),p=d.num_components(),m=r(a,h),v=p*h.BYTES_PER_ELEMENT,g=Math.ceil(v/4)*4,f=g/h.BYTES_PER_ELEMENT,A=u*v,b=u*g,y=a._malloc(A);o.GetAttributeDataArrayForAllPoints(l,d,m,A,y);const x=new h(a.HEAPF32.buffer,y,A/h.BYTES_PER_ELEMENT);let _;if(v===g)_=x.slice();else{_=new h(b/h.BYTES_PER_ELEMENT);let M=0;for(let E=0,w=x.length;E<w;E++){for(let T=0;T<p;T++)_[M+T]=x[E*p+T];M+=f}}return a._free(y),{name:c,count:u,itemSize:p,array:_,stride:f}}function r(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 EV=(function(){var s="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(s),r,a=WebAssembly.instantiate(n,{}).then(function(f){r=f.instance,r.exports.__wasm_call_ctors()});function o(f){for(var A=new Uint8Array(f.length),b=0;b<f.length;++b){var y=f.charCodeAt(b);A[b]=y>96?y-97:y>64?y-39:y+4}for(var x=0,b=0;b<f.length;++b)A[x++]=A[b]<60?i[A[b]]:(A[b]-60)*64+A[++b];return A.buffer.slice(0,x)}function l(f,A,b,y,x,_,M){var E=f.exports.sbrk,w=y+3&-4,T=E(w*x),R=E(_.length),D=new Uint8Array(f.exports.memory.buffer);D.set(_,R);var L=A(T,y,x,R,_.length);if(L==0&&M&&M(T,w,x),b.set(D.subarray(T,T+y*x)),E(T-E(0)),L!=0)throw new Error("Malformed buffer data: "+L)}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=[],u=0;function p(f){var A={object:new Worker(f),pending:0,requests:{}};return A.object.onmessage=function(b){var y=b.data;A.pending-=y.count,A.requests[y.id][y.action](y.value),delete A.requests[y.id]},A}function m(f){for(var A="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([A],{type:"text/javascript"}),y=URL.createObjectURL(b),x=d.length;x<f;++x)d[x]=p(y);for(var x=f;x<d.length;++x)d[x].object.postMessage({});d.length=f,URL.revokeObjectURL(y)}function v(f,A,b,y,x){for(var _=d[0],M=1;M<d.length;++M)d[M].pending<_.pending&&(_=d[M]);return new Promise(function(E,w){var T=new Uint8Array(b),R=++u;_.pending+=f,_.requests[R]={resolve:E,reject:w},_.object.postMessage({id:R,count:f,size:A,source:T,mode:y,filter:x},[T.buffer])})}function g(f){var A=f.data;if(!A.id)return self.close();self.ready.then(function(b){try{var y=new Uint8Array(A.count*A.size);l(b,b.exports[A.mode],y,A.count,A.size,A.source,b.exports[A.filter]),self.postMessage({id:A.id,count:A.count,action:"resolve",value:y},[y.buffer])}catch(x){self.postMessage({id:A.id,count:A.count,action:"reject",value:x})}})}return{ready:a,supported:!0,useWorkers:function(f){m(f)},decodeVertexBuffer:function(f,A,b,y,x){l(r,r.exports.meshopt_decodeVertexBuffer,f,A,b,y,r.exports[c[x]])},decodeIndexBuffer:function(f,A,b,y){l(r,r.exports.meshopt_decodeIndexBuffer,f,A,b,y)},decodeIndexSequence:function(f,A,b,y){l(r,r.exports.meshopt_decodeIndexSequence,f,A,b,y)},decodeGltfBuffer:function(f,A,b,y,x,_){l(r,r.exports[h[x]],f,A,b,y,r.exports[c[_]])},decodeGltfBufferAsync:function(f,A,b,y,x){return d.length>0?v(f,A,b,h[y],c[x]):a.then(function(){var _=new Uint8Array(f*A);return l(r,r.exports[h[y]],_,f,A,b,r.exports[c[x]]),_})}}})();class MV{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:r,transfer:a}=this.queue.shift();this.workersResolve[e]=n,this.workers[e].postMessage(r,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 SV=0,uT=2,CV=1,pT=2,TV=0,IV=1,PV=10,DV=0,fT=9,mT=15,gT=16,vT=22,AT=37,bT=43,yT=76,xT=83,_T=97,wT=100,ET=103,MT=109,ST=122,CT=123,TT=131,IT=132,PT=133,DT=134,RT=137,BT=138,LT=139,kT=140,OT=141,FT=142,NT=145,UT=146,zT=148,HT=152,GT=153,VT=154,WT=155,QT=156,jT=157,XT=158,qT=165,YT=166,KT=1000054e3,$T=1000054001,ZT=1000054004,JT=1000054005,Yx=1000066e3,e3=1000066004;let cp=class{constructor(s,e,t,i){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(s.buffer,s.byteOffset+e,t),this._littleEndian=i,this._offset=0}_nextUint8(){const s=this._dataView.getUint8(this._offset);return this._offset+=1,s}_nextUint16(){const s=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,s}_nextUint32(){const s=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,s}_nextUint64(){const s=this._dataView.getUint32(this._offset,this._littleEndian)+4294967296*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,s}_nextInt32(){const s=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,s}_nextUint8Array(s){const e=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,s);return this._offset+=s,e}_skip(s){return this._offset+=s,this}_scan(s,e=0){const t=this._offset;let i=0;for(;this._dataView.getUint8(this._offset)!==e&&i<s;)i++,this._offset++;return i<s&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+t,i)}};const zn=[171,75,84,88,32,50,48,187,13,10,26,10];function t3(s){return new TextDecoder().decode(s)}function RV(s){const e=new Uint8Array(s.buffer,s.byteOffset,zn.length);if(e[0]!==zn[0]||e[1]!==zn[1]||e[2]!==zn[2]||e[3]!==zn[3]||e[4]!==zn[4]||e[5]!==zn[5]||e[6]!==zn[6]||e[7]!==zn[7]||e[8]!==zn[8]||e[9]!==zn[9]||e[10]!==zn[10]||e[11]!==zn[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 cp(s,zn.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 r=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,u=new cp(s,zn.length+i,d,!0);for(let W=0,X=Math.max(t.levelCount,1);W<X;W++)t.levels.push({levelData:new Uint8Array(s.buffer,s.byteOffset+u._nextUint64(),u._nextUint64()),uncompressedByteLength:u._nextUint64()});const p=new cp(s,r,a,!0);p._skip(4);const m=p._nextUint16(),v=p._nextUint16(),g=p._nextUint16(),f=p._nextUint16(),A={vendorId:m,descriptorType:v,versionNumber:g,colorModel:p._nextUint8(),colorPrimaries:p._nextUint8(),transferFunction:p._nextUint8(),flags:p._nextUint8(),texelBlockDimension:[p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8()],bytesPlane:[p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8()],samples:[]},b=(f/4-6)/4;for(let W=0;W<b;W++){const X={bitOffset:p._nextUint16(),bitLength:p._nextUint8(),channelType:p._nextUint8(),samplePosition:[p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};64&X.channelType?(X.sampleLower=p._nextInt32(),X.sampleUpper=p._nextInt32()):(X.sampleLower=p._nextUint32(),X.sampleUpper=p._nextUint32()),A.samples[W]=X}t.dataFormatDescriptor.length=0,t.dataFormatDescriptor.push(A);const y=new cp(s,o,l,!0);for(;y._offset<l;){const W=y._nextUint32(),X=y._scan(W),me=t3(X);if(t.keyValue[me]=y._nextUint8Array(W-X.byteLength-1),me.match(/^ktx/i)){const Ee=t3(t.keyValue[me]);t.keyValue[me]=Ee.substring(0,Ee.lastIndexOf("\0"))}y._skip(W%4?4-W%4:0)}if(h<=0)return t;const x=new cp(s,c,h,!0),_=x._nextUint16(),M=x._nextUint16(),E=x._nextUint32(),w=x._nextUint32(),T=x._nextUint32(),R=x._nextUint32(),D=[];for(let W=0,X=Math.max(t.levelCount,1);W<X;W++)D.push({imageFlags:x._nextUint32(),rgbSliceByteOffset:x._nextUint32(),rgbSliceByteLength:x._nextUint32(),alphaSliceByteOffset:x._nextUint32(),alphaSliceByteLength:x._nextUint32()});const L=c+x._offset,I=L+E,O=I+w,N=O+T,G=new Uint8Array(s.buffer,s.byteOffset+L,E),V=new Uint8Array(s.buffer,s.byteOffset+I,w),H=new Uint8Array(s.buffer,s.byteOffset+O,T),J=new Uint8Array(s.buffer,s.byteOffset+N,R);return t.globalData={endpointCount:_,selectorCount:M,imageDescs:D,endpointsData:G,selectorsData:V,tablesData:H,extendedData:J},t}let Kx,wa,$x;const Zx={env:{emscripten_notify_memory_growth:function(s){$x=new Uint8Array(wa.exports.memory.buffer)}}};let BV=class{init(){return Kx||(Kx=typeof fetch<"u"?fetch("data:application/wasm;base64,"+i3).then(s=>s.arrayBuffer()).then(s=>WebAssembly.instantiate(s,Zx)).then(this._init):WebAssembly.instantiate(Buffer.from(i3,"base64"),Zx).then(this._init),Kx)}_init(s){wa=s.instance,Zx.env.emscripten_notify_memory_growth(0)}decode(s,e=0){if(!wa)throw new Error("ZSTDDecoder: Await .init() before decoding.");const t=s.byteLength,i=wa.exports.malloc(t);$x.set(s,i),e=e||Number(wa.exports.ZSTD_findDecompressedSize(i,t));const n=wa.exports.malloc(e),r=wa.exports.ZSTD_decompress(n,e,i,t),a=$x.slice(n,n+r);return wa.exports.free(i),wa.exports.free(n),a}};const i3="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",LV="display-p3",kV="display-p3-linear";({...It.spaces[ci]});const Jx=new WeakMap;let e1=0,t1;class Fs extends dn{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new MV,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 gn(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),i=new gn(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(([r,a])=>{const o=Fs.BasisWorker.toString(),l=["/* constants */","let _EngineFormat = "+JSON.stringify(Fs.EngineFormat),"let _EngineType = "+JSON.stringify(Fs.EngineType),"let _TranscoderFormat = "+JSON.stringify(Fs.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(Fs.BasisFormat),"/* basis_transcoder.js */",r,"/* 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})}),e1>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),e1++}return this.transcoderPending}load(e,t,i,n){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const r=new gn(this.manager);r.setPath(this.path),r.setCrossOrigin(this.crossOrigin),r.setWithCredentials(this.withCredentials),r.setRequestHeader(this.requestHeader),r.setResponseType("arraybuffer"),r.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(Jx.has(e))return Jx.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:r,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 YE(r,l,c);else{const u=r[0].mipmaps;d=t.layerCount>1?new qE(u,a,o,t.layerCount,l,c):new lh(u,a,o,l,c)}return d.minFilter=r[0].mipmaps.length===1?wt:$n,d.magFilter=wt,d.generateMipmaps=!1,d.needsUpdate=!0,d.colorSpace=n3(t),d.premultiplyAlpha=!!(h&CV),d}async _createTexture(e,t={}){const i=RV(new Uint8Array(e)),n=i.vkFormat===Yx&&i.dataFormatDescriptor[0].colorModel===167;if(!(i.vkFormat===DV||n&&!this.workerConfig.astcHDRSupported))return FV(i);const r=t,a=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:r},[e])).then(o=>this._createTextureFrom(o.data,i));return Jx.set(e,{promise:a}),a}dispose(){this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),e1--}}Fs.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2},Fs.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},Fs.EngineFormat={RGBAFormat:_i,RGBA_ASTC_4x4_Format:qa,RGB_BPTC_UNSIGNED_Format:qd,RGBA_BPTC_Format:il,RGBA_ETC2_EAC_Format:Uc,RGBA_PVRTC_4BPPV1_Format:el,RGBA_S3TC_DXT5_Format:Xa,RGB_ETC1_Format:Vd,RGB_ETC2_Format:Nc,RGB_PVRTC_4BPPV1_Format:Gd,RGBA_S3TC_DXT1_Format:ja},Fs.EngineType={UnsignedByteType:bt,HalfFloatType:li,FloatType:xi},Fs.BasisWorker=function(){let s,e,t;const i=_EngineFormat,n=_EngineType,r=_TranscoderFormat,a=_BasisFormat;self.addEventListener("message",function(m){const v=m.data;switch(v.type){case"init":s=v.config,o(v.transcoderBinary);break;case"transcode":e.then(()=>{try{const{faces:g,buffers:f,width:A,height:b,hasAlpha:y,format:x,type:_,dfdFlags:M}=l(v.buffer);self.postMessage({type:"transcode",id:v.id,data:{faces:g,width:A,height:b,hasAlpha:y,format:x,type:_,dfdFlags:M}},f)}catch(g){console.error(g),self.postMessage({type:"error",id:v.id,error:g.message})}});break}});function o(m){e=new Promise(v=>{t={wasmBinary:m,onRuntimeInitialized:v},BASIS(t)}).then(()=>{t.initializeBasis(),t.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function l(m){const v=new t.KTX2File(new Uint8Array(m));function g(){v.close(),v.delete()}if(!v.isValid())throw g(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");let f;if(v.isUASTC())f=a.UASTC;else if(v.isETC1S())f=a.ETC1S;else if(v.isHDR())f=a.UASTC_HDR;else throw new Error("THREE.KTX2Loader: Unknown Basis encoding");const A=v.getWidth(),b=v.getHeight(),y=v.getLayers()||1,x=v.getLevels(),_=v.getFaces(),M=v.getHasAlpha(),E=v.getDFDFlags(),{transcoderFormat:w,engineFormat:T,engineType:R}=d(f,A,b,M);if(!A||!b||!x)throw g(),new Error("THREE.KTX2Loader: Invalid texture");if(!v.startTranscoding())throw g(),new Error("THREE.KTX2Loader: .startTranscoding failed");const D=[],L=[];for(let I=0;I<_;I++){const O=[];for(let N=0;N<x;N++){const G=[];let V,H;for(let W=0;W<y;W++){const X=v.getImageLevelInfo(N,W,I);I===0&&N===0&&W===0&&(X.origWidth%4!==0||X.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),x>1?(V=X.origWidth,H=X.origHeight):(V=X.width,H=X.height);let me=new Uint8Array(v.getImageTranscodedSizeInBytes(N,W,0,w));const Ee=v.transcodeImage(me,N,W,I,w,0,-1,-1);if(R===n.HalfFloatType&&(me=new Uint16Array(me.buffer,me.byteOffset,me.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!Ee)throw g(),new Error("THREE.KTX2Loader: .transcodeImage failed.");G.push(me)}const J=p(G);O.push({data:J,width:V,height:H}),L.push(J.buffer)}D.push({mipmaps:O,width:A,height:b,format:T,type:R})}return g(),{faces:D,buffers:L,width:A,height:b,hasAlpha:M,dfdFlags:E,format:T,type:R}}const c=[{if:"astcSupported",basisFormat:[a.UASTC],transcoderFormat:[r.ASTC_4x4,r.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:[r.BC7_M5,r.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:[r.BC1,r.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:[r.ETC1,r.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:[r.ETC1],engineFormat:[i.RGB_ETC1_Format],engineType:[n.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[r.PVRTC1_4_RGB,r.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:[r.BC6H],engineFormat:[i.RGB_BPTC_UNSIGNED_Format],engineType:[n.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[r.RGBA32,r.RGBA32],engineFormat:[i.RGBAFormat,i.RGBAFormat],engineType:[n.UnsignedByteType,n.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[a.UASTC_HDR],transcoderFormat:[r.RGBA_HALF],engineFormat:[i.RGBAFormat],engineType:[n.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],h={[a.ETC1S]:c.filter(m=>m.basisFormat.includes(a.ETC1S)).sort((m,v)=>m.priorityETC1S-v.priorityETC1S),[a.UASTC]:c.filter(m=>m.basisFormat.includes(a.UASTC)).sort((m,v)=>m.priorityUASTC-v.priorityUASTC),[a.UASTC_HDR]:c.filter(m=>m.basisFormat.includes(a.UASTC_HDR)).sort((m,v)=>m.priorityHDR-v.priorityHDR)};function d(m,v,g,f){const A=h[m];for(let b=0;b<A.length;b++){const y=A[b];if(y.if&&!s[y.if]||!y.basisFormat.includes(m)||f&&y.transcoderFormat.length<2||y.needsPowerOfTwo&&!(u(v)&&u(g)))continue;const x=y.transcoderFormat[f?1:0],_=y.engineFormat[f?1:0],M=y.engineType[0];return{transcoderFormat:x,engineFormat:_,engineType:M}}throw new Error("THREE.KTX2Loader: Failed to identify transcoding target.")}function u(m){return m<=2?!0:(m&m-1)===0&&m!==0}function p(m){if(m.length===1)return m[0];let v=0;for(let A=0;A<m.length;A++){const b=m[A];v+=b.byteLength}const g=new Uint8Array(v);let f=0;for(let A=0;A<m.length;A++){const b=m[A];g.set(b,f),f+=b.byteLength}return g}};const OV=new Set([_i,Oc,Is,Sr]),i1={[MT]:_i,[ET]:Is,[wT]:Sr,[_T]:_i,[xT]:Is,[yT]:Sr,[bT]:_i,[AT]:_i,[vT]:Is,[gT]:Is,[mT]:Sr,[fT]:Sr,[CT]:Oc,[ST]:Oc,[HT]:Uc,[zT]:Nc,[GT]:Wd,[VT]:Qd,[WT]:jd,[QT]:Xd,[Yx]:qa,[XT]:qa,[jT]:qa,[e3]:tl,[YT]:tl,[qT]:tl,[DT]:ja,[PT]:ja,[IT]:Jo,[TT]:Jo,[BT]:Xa,[RT]:Xa,[kT]:Kd,[LT]:Yd,[FT]:Zd,[OT]:$d,[UT]:il,[NT]:il,[JT]:el,[$T]:el,[ZT]:Fc,[KT]:Fc},Kh={[MT]:xi,[ET]:xi,[wT]:xi,[_T]:li,[xT]:li,[yT]:li,[bT]:bt,[AT]:bt,[vT]:bt,[gT]:bt,[mT]:bt,[fT]:bt,[CT]:Nd,[ST]:Ud,[HT]:bt,[zT]:bt,[GT]:bt,[VT]:bt,[WT]:bt,[QT]:bt,[Yx]:li,[XT]:bt,[jT]:bt,[e3]:li,[YT]:bt,[qT]:bt,[DT]:bt,[PT]:bt,[IT]:bt,[TT]:bt,[BT]:bt,[RT]:bt,[kT]:bt,[LT]:bt,[FT]:bt,[OT]:bt,[UT]:bt,[NT]:bt,[JT]:bt,[$T]:bt,[ZT]:bt,[KT]:bt};async function FV(s){const{vkFormat:e}=s;if(i1[e]===void 0)throw new Error("THREE.KTX2Loader: Unsupported vkFormat: "+e);Kh[e]===void 0&&console.warn('THREE.KTX2Loader: Missing ".type" for vkFormat: '+e);let t;s.supercompressionScheme===uT&&(t1||(t1=new Promise(async a=>{const o=new BV;await o.init(),a(o)})),t=await t1);const i=[];for(let a=0;a<s.levels.length;a++){const o=Math.max(1,s.pixelWidth>>a),l=Math.max(1,s.pixelHeight>>a),c=s.pixelDepth?Math.max(1,s.pixelDepth>>a):0,h=s.levels[a];let d;if(s.supercompressionScheme===SV)d=h.levelData;else if(s.supercompressionScheme===uT)d=t.decode(h.levelData,h.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let u;Kh[e]===xi?u=new Float32Array(d.buffer,d.byteOffset,d.byteLength/Float32Array.BYTES_PER_ELEMENT):Kh[e]===li?u=new Uint16Array(d.buffer,d.byteOffset,d.byteLength/Uint16Array.BYTES_PER_ELEMENT):Kh[e]===Nd||Kh[e]===Ud?u=new Uint32Array(d.buffer,d.byteOffset,d.byteLength/Uint32Array.BYTES_PER_ELEMENT):u=d,i.push({data:u,width:o,height:l,depth:c})}const n=s.levelCount===0||i.length>1;let r;if(OV.has(i1[e]))r=s.pixelDepth===0?new On(i[0].data,s.pixelWidth,s.pixelHeight):new au(i[0].data,s.pixelWidth,s.pixelHeight,s.pixelDepth),r.minFilter=n?Fd:Jt,r.magFilter=Jt,r.generateMipmaps=s.levelCount===0;else{if(s.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");r=new lh(i,s.pixelWidth,s.pixelHeight),r.minFilter=n?$n:wt,r.magFilter=wt}return r.mipmaps=i,r.type=Kh[e],r.format=i1[e],r.colorSpace=n3(s),r.needsUpdate=!0,Promise.resolve(r)}function n3(s){const e=s.dataFormatDescriptor[0];return e.colorPrimaries===IV?e.transferFunction===pT?ci:qi:e.colorPrimaries===PV?e.transferFunction===pT?LV:kV:(e.colorPrimaries===TV||console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${e.colorPrimaries}"`),qs)}function NV(s,e,t,i){const n=s.models.find(u=>u.url==t);if(n==null)return;const r=ip(s,t),a=e.circularMeps,o=e.rectMeps?.filter(u=>u.type==="风管"),l=e.rectMeps?.filter(u=>u.type==="桥架"),c=e.ellipseMeps,h=u=>(u.color=u.color.split(",").map(p=>parseInt(p)/255),u.color=new qe(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+0,y:u.startPoint.Z*.3048+0,z:-u.startPoint.Y*.3048+0},u.rotation={x:0,y:0,z:0},u),d=(u,p)=>{if(!Array.isArray(p)||p.length===0)return;const m=p.map(g=>h(g)),v=UV(u,r,m,t,s);v!=null&&m.forEach((g,f)=>{g.indexes=[[v,f,0,0]],n.nodesMap.set(Number(g.id),g)})};d("Circle",a),d("Rect",o),d("Ellipse",c),d("Bridge",l)}function UV(s,e,t,i,n){let r;const a={width:1,height:1,length:1,diameter:1,color:new qe,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(s){case"Rect":r=L0("Rect",a);break;case"Bridge":r=L0("Bridge",a);break;case"Circle":r=L0("Circle",a);break;case"Ellipse":r=L0("Ellipse",a);break}if(!r)return null;const o=new hi(r.geometry,r.material,t.length);o.url=i,e.add(o);const l=Bx(n,o),c=[],h=[];for(let u=0;u<t.length;u++){const p=t[u],m=new P(p.startPoint.X,0,-p.startPoint.Y),v=new P(p.endPoint.X,0,-p.endPoint.Y),g=new P(p.startPoint.X,p.startPoint.Z,-p.startPoint.Y),f=new P(p.endPoint.X,p.endPoint.Z,-p.endPoint.Y);let A=0,b=0,y=0;if(Math.abs(v.clone().sub(m.clone()).z)<.01&&Math.abs(v.clone().sub(m.clone()).x)<.01){if(A=(p.startPoint.Z>p.endPoint.Z?1:-1)*Math.PI*.5,p.base_x!=null){const G=new P(p.base_x.X,0,-p.base_x.Y);b=(G.clone().cross(new P(0,0,1)).y<=0?1:-1)*G.angleTo(new P(0,0,1))+Math.PI*.5}}else b=(v.clone().sub(m.clone()).cross(new P(0,0,1)).y>0?-1:1)*v.clone().sub(m.clone()).angleTo(new P(0,0,1)),A=(p.startPoint.Z>p.endPoint.Z?1:-1)*v.clone().sub(m.clone()).angleTo(f.clone().sub(g.clone()));const x=new Ke,_=new Yi(A,b,y,"YXZ"),M=x.clone().makeRotationFromEuler(_);let E,w;s==="Circle"?(E=p.diameter,w=p.diameter):(E=p.width,w=p.height);const T=x.clone().makeScale(E,w,p.length);x.multiplyMatrices(M,T),x.setPosition(p.position.x,p.position.y,p.position.z),o.setMatrixAt(u,x.clone()),o.setColorAt(u,p.color),o.geometry.computeBoundingBox();const R=o.geometry.boundingBox.min.clone().applyMatrix4(x.clone()),D=o.geometry.boundingBox.max.clone().applyMatrix4(x.clone()),L=new P(Math.min(R.x,D.x),Math.min(R.y,D.y),Math.min(R.z,D.z)),I=new P(Math.max(R.x,D.x),Math.max(R.y,D.y),Math.max(R.z,D.z)),O=L.clone().add(I.clone()).multiplyScalar(.5),N={name:p.name,min:L,max:I,center:O,dbid:u,materialName:r.material.name};s==="Circle"&&(N.minC={x:p.startPoint.X*.3048,y:p.startPoint.Z*.3048,z:-p.startPoint.Y*.3048},N.maxC={x:p.endPoint.X*.3048,y:p.endPoint.Z*.3048,z:-p.endPoint.Y*.3048}),o.ids||(o.ids=[]),o.matrixs||(o.matrixs=[]),o.matrixs.push(x.clone()),h.push(x.clone()),o.ids.push(Number(p.id)),c.push(N)}o.castShadow=!0,o.ElementInfos=c,o.name="rootModel",o.TypeName="InstancedMesh-Pipe",o.PipeType=s,o.MeshId=null,o.realMaterial=o.material.clone(),o.originalMaterial=o.material.clone(),o.matrixsClone=h,n?.sectionPlane&&(o.material.clippingPlanes=n.sectionPlane,o.originalMaterial.clippingPlanes=n.sectionPlane,o.realMaterial.clippingPlanes=n.sectionPlane);const d={geometry:o.geometry,matrix:o.matrix,position:o.position,rotation:o.rotation};return o.meshs=d,o.instanceMatrix&&o.instanceMatrix.array&&(o.cloneInstanceMatrix=Array.from(o.instanceMatrix.array)),o.instanceMatrix.needsUpdate=!0,l}function L0(s,e){const t=new sa;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,s){case"Rect":t.moveTo(-e.width/2,-e.height/2),t.lineTo(-e.width/2,e.height/2),t.lineTo(e.width/2,e.height/2),t.lineTo(e.width/2,-e.height/2),t.lineTo(-e.width/2,-e.height/2);break;case"Ellipse":t.moveTo(-e.width/2,-e.height/2),t.lineTo(-e.width/2,e.height/2),t.lineTo(e.width/2,e.height/2),t.lineTo(e.width/2,-e.height/2),t.lineTo(-e.width/2,-e.height/2);break;case"Bridge":t.moveTo(-e.width/2,-e.height/2),t.lineTo(-e.width/2,e.height/2),t.lineTo(-e.width/2+.01,e.height/2),t.lineTo(-e.width/2+.01,-e.height/2+.01),t.lineTo(e.width/2-.01,-e.height/2+.01),t.lineTo(e.width/2-.01,e.height/2),t.lineTo(e.width/2,e.height/2),t.lineTo(e.width/2,-e.height/2),t.lineTo(-e.width/2,-e.height/2);break;case"Circle":t.moveTo(0,0),t.absarc(0,0,e.diameter*.5,0,Math.PI*2,!1);break}const i={depth:e.length*.3048,bevelEnabled:!1};return n(t,i,e.color,e.position,e.rotation);function n(r,a,o,l,c){const h=new hh(r,a),d=new oo({color:o,side:qt}),u=new We(h,d);return u.position.set(l.x,l.y,l.z),u.rotation._order="YXZ",u.rotation.set(c.x,c.y,c.z),u}}function Ea(s,e=!1){const t=s[0].index!==null,i=new Set(Object.keys(s[0].attributes)),n=new Set(Object.keys(s[0].morphAttributes)),r={},a={},o=s[0].morphTargetsRelative,l=new dt;let c=0;for(let h=0;h<s.length;++h){const d=s[h];let u=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 p in d.attributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;r[p]===void 0&&(r[p]=[]),r[p].push(d.attributes[p]),u++}if(u!==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 p in d.morphAttributes){if(!n.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;a[p]===void 0&&(a[p]=[]),a[p].push(d.morphAttributes[p])}if(e){let p;if(t)p=d.index.count;else if(d.attributes.position!==void 0)p=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,p,h),c+=p}}if(t){let h=0;const d=[];for(let u=0;u<s.length;++u){const p=s[u].index;for(let m=0;m<p.count;++m)d.push(p.getX(m)+h);h+=s[u].attributes.position.count}l.setIndex(d)}for(const h in r){const d=s3(r[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 u=0;u<d;++u){const p=[];for(let v=0;v<a[h].length;++v)p.push(a[h][v][u]);const m=s3(p);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(m)}}return l}function s3(s){let e,t,i,n=-1,r=0;for(let c=0;c<s.length;++c){const h=s[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;r+=h.count*t}const a=new e(r),o=new _t(a,t,i);let l=0;for(let c=0;c<s.length;++c){const h=s[c];if(h.isInterleavedBufferAttribute){const d=l/t;for(let u=0,p=h.count;u<p;u++)for(let m=0;m<t;m++){const v=h.getComponent(u,m);o.setComponent(u+d,m,v)}}else a.set(h.array,l);l+=h.count*t}return n!==void 0&&(o.gpuType=n),o}function r3(s,e){if(e===Yw)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===sm||e===_A){let t=s.getIndex();if(t===null){const a=[],o=s.getAttribute("position");if(o!==void 0){for(let l=0;l<o.count;l++)a.push(l);s.setIndex(a),t=s.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),s}const i=t.count-2,n=[];if(e===sm)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 r=s.clone();return r.setIndex(n),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),s}function zV(s){const e=new Map,t=new Map,i=s.clone();return a3(s,i,function(n,r){e.set(r,n),t.set(n,r)}),i.traverse(function(n){if(!n.isSkinnedMesh)return;const r=n,a=e.get(n),o=a.skeleton.bones;r.skeleton=a.skeleton.clone(),r.bindMatrix.copy(a.bindMatrix),r.skeleton.bones=o.map(function(l){return t.get(l)}),r.bind(r.skeleton,r.bindMatrix)}),i}function a3(s,e,t){t(s,e);for(let i=0;i<s.children.length;i++)a3(s.children[i],e.children[i],t)}class HV extends dn{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new jV(t)}),this.register(function(t){return new XV(t)}),this.register(function(t){return new iW(t)}),this.register(function(t){return new nW(t)}),this.register(function(t){return new sW(t)}),this.register(function(t){return new YV(t)}),this.register(function(t){return new KV(t)}),this.register(function(t){return new $V(t)}),this.register(function(t){return new ZV(t)}),this.register(function(t){return new QV(t)}),this.register(function(t){return new JV(t)}),this.register(function(t){return new qV(t)}),this.register(function(t){return new tW(t)}),this.register(function(t){return new eW(t)}),this.register(function(t){return new VV(t)}),this.register(function(t){return new o3(t,kt.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new o3(t,kt.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new rW(t)})}load(e,t,i,n){const r=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const c=uo.extractUrlBase(e);a=uo.resolveURL(c,this.path)}else a=uo.extractUrlBase(e);this.manager.itemStart(e);const o=function(c){n?n(c):console.error(c),r.manager.itemError(e),r.manager.itemEnd(e)},l=new gn(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{r.parse(c,a,function(h){t(h),r.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 r;const a={},o={},l=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===l3){try{a[kt.KHR_BINARY_GLTF]=new aW(e)}catch(h){n&&n(h);return}r=JSON.parse(a[kt.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new bW(r,{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(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const d=r.extensionsUsed[h],u=r.extensionsRequired||[];switch(d){case kt.KHR_MATERIALS_UNLIT:a[d]=new WV;break;case kt.KHR_DRACO_MESH_COMPRESSION:a[d]=new oW(r,this.dracoLoader);break;case kt.KHR_TEXTURE_TRANSFORM:a[d]=new lW;break;case kt.KHR_MESH_QUANTIZATION:a[d]=new cW;break;default:u.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,r){i.parse(e,t,n,r)})}}function GV(){let s={};return{get:function(e){return s[e]},add:function(e,t){s[e]=t},remove:function(e){delete s[e]},removeAll:function(){s={}}}}function zi(s,e,t){const i=s.json.materials[e];return i.extensions&&i.extensions[t]?i.extensions[t]:null}const kt={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 VV{constructor(e){this.parser=e,this.name=kt.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 r=t[i];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let n=t.cache.get(i);if(n)return n;const r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let o;const l=new qe(16777215);a.color!==void 0&&l.setRGB(a.color[0],a.color[1],a.color[2],qi);const c=a.range!==void 0?a.range:0;switch(a.type){case"directional":o=new tr(l),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new Ib(l),o.distance=c;break;case"spot":o=new Tb(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),Nr(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],r=(n.extensions&&n.extensions[this.name]||{}).light;return r===void 0?null:this._loadLight(r).then(function(a){return i._getNodeRef(t.cache,r,a)})}}class WV{constructor(){this.name=kt.KHR_MATERIALS_UNLIT}getMaterialType(){return Wt}extendParams(e,t,i){const n=[];e.color=new qe(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const a=r.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],qi),e.opacity=a[3]}r.baseColorTexture!==void 0&&n.push(i.assignTexture(e,"map",r.baseColorTexture,ci))}return Promise.all(n)}}class QV{constructor(e){this.parser=e,this.name=kt.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=zi(this.parser,e,this.name);return i===null||i.emissiveStrength!==void 0&&(t.emissiveIntensity=i.emissiveStrength),Promise.resolve()}}class jV{constructor(e){this.parser=e,this.name=kt.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return zi(this.parser,e,this.name)!==null?Rs:null}extendMaterialParams(e,t){const i=zi(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 r=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new be(r,r)}return Promise.all(n)}}class XV{constructor(e){this.parser=e,this.name=kt.KHR_MATERIALS_DISPERSION}getMaterialType(e){return zi(this.parser,e,this.name)!==null?Rs:null}extendMaterialParams(e,t){const i=zi(this.parser,e,this.name);return i===null||(t.dispersion=i.dispersion!==void 0?i.dispersion:0),Promise.resolve()}}class qV{constructor(e){this.parser=e,this.name=kt.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return zi(this.parser,e,this.name)!==null?Rs:null}extendMaterialParams(e,t){const i=zi(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 YV{constructor(e){this.parser=e,this.name=kt.KHR_MATERIALS_SHEEN}getMaterialType(e){return zi(this.parser,e,this.name)!==null?Rs:null}extendMaterialParams(e,t){const i=zi(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];if(t.sheenColor=new qe(0,0,0),t.sheenRoughness=0,t.sheen=1,i.sheenColorFactor!==void 0){const r=i.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],qi)}return i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&n.push(this.parser.assignTexture(t,"sheenColorMap",i.sheenColorTexture,ci)),i.sheenRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(n)}}class KV{constructor(e){this.parser=e,this.name=kt.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return zi(this.parser,e,this.name)!==null?Rs:null}extendMaterialParams(e,t){const i=zi(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 $V{constructor(e){this.parser=e,this.name=kt.KHR_MATERIALS_VOLUME}getMaterialType(e){return zi(this.parser,e,this.name)!==null?Rs:null}extendMaterialParams(e,t){const i=zi(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 r=i.attenuationColor||[1,1,1];return t.attenuationColor=new qe().setRGB(r[0],r[1],r[2],qi),Promise.all(n)}}class ZV{constructor(e){this.parser=e,this.name=kt.KHR_MATERIALS_IOR}getMaterialType(e){return zi(this.parser,e,this.name)!==null?Rs:null}extendMaterialParams(e,t){const i=zi(this.parser,e,this.name);return i===null||(t.ior=i.ior!==void 0?i.ior:1.5),Promise.resolve()}}class JV{constructor(e){this.parser=e,this.name=kt.KHR_MATERIALS_SPECULAR}getMaterialType(e){return zi(this.parser,e,this.name)!==null?Rs:null}extendMaterialParams(e,t){const i=zi(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 r=i.specularColorFactor||[1,1,1];return t.specularColor=new qe().setRGB(r[0],r[1],r[2],qi),i.specularColorTexture!==void 0&&n.push(this.parser.assignTexture(t,"specularColorMap",i.specularColorTexture,ci)),Promise.all(n)}}class eW{constructor(e){this.parser=e,this.name=kt.EXT_MATERIALS_BUMP}getMaterialType(e){return zi(this.parser,e,this.name)!==null?Rs:null}extendMaterialParams(e,t){const i=zi(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 tW{constructor(e){this.parser=e,this.name=kt.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return zi(this.parser,e,this.name)!==null?Rs:null}extendMaterialParams(e,t){const i=zi(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 iW{constructor(e){this.parser=e,this.name=kt.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 r=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,r.source,a)}}class nW{constructor(e){this.parser=e,this.name=kt.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,i=this.parser,n=i.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.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 sW{constructor(e){this.parser=e,this.name=kt.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,i=this.parser,n=i.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.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 o3{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],r=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 r.then(function(o){const l=n.byteOffset||0,c=n.byteLength||0,h=n.count,d=n.byteStride,u=new Uint8Array(o,l,c);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(h,d,u,n.mode,n.filter).then(function(p){return p.buffer}):a.ready.then(function(){const p=new ArrayBuffer(h*d);return a.decodeGltfBuffer(new Uint8Array(p),h,d,u,n.mode,n.filter),p})})}else return null}}class rW{constructor(e){this.name=kt.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!==Ns.TRIANGLES&&l.mode!==Ns.TRIANGLE_STRIP&&l.mode!==Ns.TRIANGLE_FAN&&l.mode!==void 0)return null;const r=i.extensions[this.name].attributes,a=[],o={};for(const l in r)a.push(this.parser.getDependency("accessor",r[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,u=[];for(const p of h){const m=new Ke,v=new P,g=new Lt,f=new P(1,1,1),A=new hi(p.geometry,p.material,d);for(let b=0;b<d;b++)o.TRANSLATION&&v.fromBufferAttribute(o.TRANSLATION,b),o.ROTATION&&g.fromBufferAttribute(o.ROTATION,b),o.SCALE&&f.fromBufferAttribute(o.SCALE,b),A.setMatrixAt(b,m.compose(v,g,f));for(const b in o)if(b==="_COLOR_0"){const y=o[b];A.instanceColor=new no(y.array,y.itemSize,y.normalized)}else b!=="TRANSLATION"&&b!=="ROTATION"&&b!=="SCALE"&&p.geometry.setAttribute(b,o[b]);Pt.prototype.copy.call(A,p),this.parser.assignFinalMaterial(A),u.push(A)}return c.isGroup?(c.clear(),c.add(...u),c):u[0]}))}}const l3="glTF",hp=12,c3={JSON:1313821514,BIN:5130562};class aW{constructor(e){this.name=kt.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,hp),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!==l3)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-hp,r=new DataView(e,hp);let a=0;for(;a<n;){const o=r.getUint32(a,!0);a+=4;const l=r.getUint32(a,!0);if(a+=4,l===c3.JSON){const c=new Uint8Array(e,hp+a,o);this.content=i.decode(c)}else if(l===c3.BIN){const c=hp+a;this.body=e.slice(c,c+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class oW{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=kt.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,n=this.dracoLoader,r=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},l={},c={};for(const h in a){const d=s1[h]||h.toLowerCase();o[d]=a[h]}for(const h in e.attributes){const d=s1[h]||h.toLowerCase();if(a[h]!==void 0){const u=i.accessors[e.attributes[h]],p=$h[u.componentType];c[d]=p.name,l[d]=u.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(d,u){n.decodeDracoFile(h,function(p){for(const m in p.attributes){const v=p.attributes[m],g=l[m];g!==void 0&&(v.normalized=g)}d(p)},o,c,qi,u)})})}}class lW{constructor(){this.name=kt.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 cW{constructor(){this.name=kt.KHR_MESH_QUANTIZATION}}class h3 extends vl{constructor(e,t,i,n){super(e,t,i,n)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n*3+n;for(let a=0;a!==n;a++)t[a]=i[r+a];return t}interpolate_(e,t,i,n){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=o*2,c=o*3,h=n-t,d=(i-t)/h,u=d*d,p=u*d,m=e*c,v=m-c,g=-2*p+3*u,f=p-u,A=1-g,b=f-u+d;for(let y=0;y!==o;y++){const x=a[v+y+o],_=a[v+y+l]*h,M=a[m+y+o],E=a[m+y]*h;r[y]=A*x+b*_+g*M+f*E}return r}}const hW=new Lt;class dW extends h3{interpolate_(e,t,i,n){const r=super.interpolate_(e,t,i,n);return hW.fromArray(r).normalize().toArray(r),r}}const Ns={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},$h={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},d3={9728:Jt,9729:wt,9984:Fd,9985:Lc,9986:Zo,9987:$n},u3={33071:Bn,33648:Bc,10497:ln},n1={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},s1={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"},Co={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},uW={CUBICSPLINE:void 0,LINEAR:Hc,STEP:zc},r1={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function pW(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new oo({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Yn})),s.DefaultMaterial}function $l(s,e,t){for(const i in t.extensions)s[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=t.extensions[i])}function Nr(s,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(s.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function fW(s,e,t){let i=!1,n=!1,r=!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&&(r=!0),i&&n&&r)break}if(!i&&!n&&!r)return Promise.resolve(s);const a=[],o=[],l=[];for(let c=0,h=e.length;c<h;c++){const d=e[c];if(i){const u=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):s.attributes.position;a.push(u)}if(n){const u=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):s.attributes.normal;o.push(u)}if(r){const u=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):s.attributes.color;l.push(u)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then(function(c){const h=c[0],d=c[1],u=c[2];return i&&(s.morphAttributes.position=h),n&&(s.morphAttributes.normal=d),r&&(s.morphAttributes.color=u),s.morphTargetsRelative=!0,s})}function mW(s,e){if(s.updateMorphTargets(),e.weights!==void 0)for(let t=0,i=e.weights.length;t<i;t++)s.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(s.morphTargetInfluences.length===t.length){s.morphTargetDictionary={};for(let i=0,n=t.length;i<n;i++)s.morphTargetDictionary[t[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function gW(s){let e;const t=s.extensions&&s.extensions[kt.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+a1(t.attributes):e=s.indices+":"+a1(s.attributes)+":"+s.mode,s.targets!==void 0)for(let i=0,n=s.targets.length;i<n;i++)e+=":"+a1(s.targets[i]);return e}function a1(s){let e="";const t=Object.keys(s).sort();for(let i=0,n=t.length;i<n;i++)e+=t[i]+":"+s[t[i]]+";";return e}function o1(s){switch(s){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 vW(s){return s.search(/\.jpe?g($|\?)/i)>0||s.search(/^data\:image\/jpeg/)===0?"image/jpeg":s.search(/\.webp($|\?)/i)>0||s.search(/^data\:image\/webp/)===0?"image/webp":s.search(/\.ktx2($|\?)/i)>0||s.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const AW=new Ke;class bW{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new GV,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,r=!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,r=o.indexOf("Firefox")>-1,a=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&n<17||r&&a<98?this.textureLoader=new lo(this.options.manager):this.textureLoader=new zM(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new gn(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,r=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 $l(r,o,n),Nr(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,r=t.length;n<r;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,r=e.length;n<r;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(),r=(a,o)=>{const l=this.associations.get(a);l!=null&&this.associations.set(o,l);for(const[c,h]of a.children.entries())r(h,o.children[c])};return r(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 r=e(t[n]);r&&i.push(r)}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(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":n=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.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(r,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[kt.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(r,a){i.load(uo.resolveURL(t.uri,n.path),r,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,r=t.byteOffset||0;return i.slice(r,r+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=n1[n.type],o=$h[n.componentType],l=n.normalized===!0,c=new o(n.count*a);return Promise.resolve(new _t(c,a,l))}const r=[];return n.bufferView!==void 0?r.push(this.getDependency("bufferView",n.bufferView)):r.push(null),n.sparse!==void 0&&(r.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(r).then(function(a){const o=a[0],l=n1[n.type],c=$h[n.componentType],h=c.BYTES_PER_ELEMENT,d=h*l,u=n.byteOffset||0,p=n.bufferView!==void 0?i.bufferViews[n.bufferView].byteStride:void 0,m=n.normalized===!0;let v,g;if(p&&p!==d){const f=Math.floor(u/p),A="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+f+":"+n.count;let b=t.cache.get(A);b||(v=new c(o,f*p,n.count*p/h),b=new th(v,p/h),t.cache.add(A,b)),g=new ia(b,l,u%p/h,m)}else o===null?v=new c(n.count*l):v=new c(o,u,n.count*l),g=new _t(v,l,m);if(n.sparse!==void 0){const f=n1.SCALAR,A=$h[n.sparse.indices.componentType],b=n.sparse.indices.byteOffset||0,y=n.sparse.values.byteOffset||0,x=new A(a[1],b,n.sparse.count*f),_=new c(a[2],y,n.sparse.count*l);o!==null&&(g=new _t(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let M=0,E=x.length;M<E;M++){const w=x[M];if(g.setX(w,_[M*l]),l>=2&&g.setY(w,_[M*l+1]),l>=3&&g.setZ(w,_[M*l+2]),l>=4&&g.setW(w,_[M*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=m}return g})}loadTexture(e){const t=this.json,i=this.options,n=t.textures[e].source,r=t.images[n];let a=this.textureLoader;if(r.uri){const o=i.manager.getHandler(r.uri);o!==null&&(a=o)}return this.loadTextureImage(e,n,a)}loadTextureImage(e,t,i){const n=this,r=this.json,a=r.textures[e],o=r.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=(r.samplers||{})[a.sampler]||{};return h.magFilter=d3[d.magFilter]||wt,h.minFilter=d3[d.minFilter]||$n,h.wrapS=u3[d.wrapS]||ln,h.wrapT=u3[d.wrapT]||ln,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==Jt&&h.minFilter!==wt,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,r=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 u=new Blob([d],{type:a.mimeType});return l=o.createObjectURL(u),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(u,p){let m=u;t.isImageBitmapLoader===!0&&(m=function(v){const g=new Ai(v);g.needsUpdate=!0,u(g)}),t.load(uo.resolveURL(d,r.path),m,void 0,p)})}).then(function(d){return c===!0&&o.revokeObjectURL(l),Nr(d,a),d.userData.mimeType=a.mimeType||vW(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 r=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),r.extensions[kt.KHR_TEXTURE_TRANSFORM]){const o=i.extensions!==void 0?i.extensions[kt.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const l=r.associations.get(a);a=r.extensions[kt.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),r.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,r=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 Wm,Ki.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 bi,Ki.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,this.cache.add(o,l)),i=l}if(n||r||a){let o="ClonedMaterial:"+i.uuid+":";n&&(o+="derivative-tangents:"),r&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let l=this.cache.get(o);l||(l=i.clone(),r&&(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 oo}loadMaterial(e){const t=this,i=this.json,n=this.extensions,r=i.materials[e];let a;const o={},l=r.extensions||{},c=[];if(l[kt.KHR_MATERIALS_UNLIT]){const d=n[kt.KHR_MATERIALS_UNLIT];a=d.getMaterialType(),c.push(d.extendParams(o,r,t))}else{const d=r.pbrMetallicRoughness||{};if(o.color=new qe(1,1,1),o.opacity=1,Array.isArray(d.baseColorFactor)){const u=d.baseColorFactor;o.color.setRGB(u[0],u[1],u[2],qi),o.opacity=u[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(o,"map",d.baseColorTexture,ci)),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(u){return u.getMaterialType&&u.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(u){return u.extendMaterialParams&&u.extendMaterialParams(e,o)})))}r.doubleSided===!0&&(o.side=qt);const h=r.alphaMode||r1.OPAQUE;if(h===r1.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===r1.MASK&&(o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&a!==Wt&&(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new be(1,1),r.normalTexture.scale!==void 0)){const d=r.normalTexture.scale;o.normalScale.set(d,d)}if(r.occlusionTexture!==void 0&&a!==Wt&&(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&a!==Wt){const d=r.emissiveFactor;o.emissive=new qe().setRGB(d[0],d[1],d[2],qi)}return r.emissiveTexture!==void 0&&a!==Wt&&c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,ci)),Promise.all(c).then(function(){const d=new a(o);return r.name&&(d.name=r.name),Nr(d,r),t.associations.set(d,{materials:e}),r.extensions&&$l(n,d,r),d})}createUniqueName(e){const t=Qt.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 r(o){return i[kt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(l){return p3(l,o,t)})}const a=[];for(let o=0,l=e.length;o<l;o++){const c=e[o],h=gW(c),d=n[h];if(d)a.push(d.promise);else{let u;c.extensions&&c.extensions[kt.KHR_DRACO_MESH_COMPRESSION]?u=r(c):u=p3(new dt,c,t),n[h]={primitive:c,promise:u},a.push(u)}}return Promise.all(a)}loadMesh(e){const t=this,i=this.json,n=this.extensions,r=i.meshes[e],a=r.primitives,o=[];for(let l=0,c=a.length;l<c;l++){const h=a[l].material===void 0?pW(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 p=0,m=h.length;p<m;p++){const v=h[p],g=a[p];let f;const A=c[p];if(g.mode===Ns.TRIANGLES||g.mode===Ns.TRIANGLE_STRIP||g.mode===Ns.TRIANGLE_FAN||g.mode===void 0)f=r.isSkinnedMesh===!0?new ZA(v,A):new We(v,A),f.isSkinnedMesh===!0&&f.normalizeSkinWeights(),g.mode===Ns.TRIANGLE_STRIP?f.geometry=r3(f.geometry,_A):g.mode===Ns.TRIANGLE_FAN&&(f.geometry=r3(f.geometry,sm));else if(g.mode===Ns.LINES)f=new Oi(v,A);else if(g.mode===Ns.LINE_STRIP)f=new Ci(v,A);else if(g.mode===Ns.LINE_LOOP)f=new nb(v,A);else if(g.mode===Ns.POINTS)f=new Xm(v,A);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(f.geometry.morphAttributes).length>0&&mW(f,r),f.name=t.createUniqueName(r.name||"mesh_"+e),Nr(f,r),g.extensions&&$l(n,f,g),t.assignFinalMaterial(f),d.push(f)}for(let p=0,m=d.length;p<m;p++)t.associations.set(d[p],{meshes:e,primitives:p});if(d.length===1)return r.extensions&&$l(n,d[0],r),d[0];const u=new Si;r.extensions&&$l(n,u,r),t.associations.set(u,{meshes:e});for(let p=0,m=d.length;p<m;p++)u.add(d[p]);return u})}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 wi(Bt.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):i.type==="orthographic"&&(t=new Zi(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),Nr(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let n=0,r=t.joints.length;n<r;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 r=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 u=new Ke;r!==null&&u.fromArray(r.array,c*16),l.push(u)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new vu(o,l)})}loadAnimation(e){const t=this.json,i=this,n=t.animations[e],r=n.name?n.name:"animation_"+e,a=[],o=[],l=[],c=[],h=[];for(let d=0,u=n.channels.length;d<u;d++){const p=n.channels[d],m=n.samplers[p.sampler],v=p.target,g=v.node,f=n.parameters!==void 0?n.parameters[m.input]:m.input,A=n.parameters!==void 0?n.parameters[m.output]:m.output;v.node!==void 0&&(a.push(this.getDependency("node",g)),o.push(this.getDependency("accessor",f)),l.push(this.getDependency("accessor",A)),c.push(m),h.push(v))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(c),Promise.all(h)]).then(function(d){const u=d[0],p=d[1],m=d[2],v=d[3],g=d[4],f=[];for(let b=0,y=u.length;b<y;b++){const x=u[b],_=p[b],M=m[b],E=v[b],w=g[b];if(x===void 0)continue;x.updateMatrix&&x.updateMatrix();const T=i._createAnimationTracks(x,_,M,E,w);if(T)for(let R=0;R<T.length;R++)f.push(T[R])}const A=new uh(r,void 0,f);return Nr(A,n),A})}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(r){const a=i._getNodeRef(i.meshCache,n.mesh,r);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],r=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([r,Promise.all(a),l]).then(function(c){const h=c[0],d=c[1],u=c[2];u!==null&&h.traverse(function(p){p.isSkinnedMesh&&p.bind(u,AW)});for(let p=0,m=d.length;p<m;p++)h.add(d[p]);if(h.userData.pivot!==void 0&&d.length>0){const p=h.userData.pivot,m=d[0];h.pivot=new P().fromArray(p),h.position.x-=p[0],h.position.y-=p[1],h.position.z-=p[2],m.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 r=t.nodes[e],a=r.name?n.createUniqueName(r.name):"",o=[],l=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&o.push(l),r.camera!==void 0&&o.push(n.getDependency("camera",r.camera).then(function(c){return n._getNodeRef(n.cameraCache,r.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(r.isBone===!0?h=new Lm:c.length>1?h=new Si:c.length===1?h=c[0]:h=new Pt,h!==c[0])for(let d=0,u=c.length;d<u;d++)h.add(c[d]);if(r.name&&(h.userData.name=r.name,h.name=a),Nr(h,r),r.extensions&&$l(i,h,r),r.matrix!==void 0){const d=new Ke;d.fromArray(r.matrix),h.applyMatrix4(d)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);if(!n.associations.has(h))n.associations.set(h,{});else if(r.mesh!==void 0&&n.meshCache.refs[r.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,r=new Si;i.name&&(r.name=n.createUniqueName(i.name)),Nr(r,i),i.extensions&&$l(t,r,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 u=l[h];u.parent!==null?r.add(zV(u)):r.add(u)}const c=h=>{const d=new Map;for(const[u,p]of n.associations)(u instanceof Ki||u instanceof Ai)&&d.set(u,p);return h.traverse(u=>{const p=n.associations.get(u);p!=null&&d.set(u,p)}),d};return n.associations=c(r),r})}_createAnimationTracks(e,t,i,n,r){const a=[],o=e.name?e.name:e.uuid,l=[];Co[r.path]===Co.weights?e.traverse(function(u){u.morphTargetInfluences&&l.push(u.name?u.name:u.uuid)}):l.push(o);let c;switch(Co[r.path]){case Co.weights:c=bl;break;case Co.rotation:c=yl;break;case Co.translation:case Co.scale:c=_l;break;default:i.itemSize===1?c=bl:c=_l;break}const h=n.interpolation!==void 0?uW[n.interpolation]:Hc,d=this._getArrayFromAccessor(i);for(let u=0,p=l.length;u<p;u++){const m=new c(l[u]+"."+Co[r.path],t.array,d,h);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),a.push(m)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const i=o1(t.constructor),n=new Float32Array(t.length);for(let r=0,a=t.length;r<a;r++)n[r]=t[r]*i;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(t){const i=this instanceof yl?dW:h3;return new i(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function yW(s,e,t){const i=e.attributes,n=new xt;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 P(l[0],l[1],l[2]),new P(c[0],c[1],c[2])),o.normalized){const h=o1($h[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 r=e.targets;if(r!==void 0){const o=new P,l=new P;for(let c=0,h=r.length;c<h;c++){const d=r[c];if(d.POSITION!==void 0){const u=t.json.accessors[d.POSITION],p=u.min,m=u.max;if(p!==void 0&&m!==void 0){if(l.setX(Math.max(Math.abs(p[0]),Math.abs(m[0]))),l.setY(Math.max(Math.abs(p[1]),Math.abs(m[1]))),l.setZ(Math.max(Math.abs(p[2]),Math.abs(m[2]))),u.normalized){const v=o1($h[u.componentType]);l.multiplyScalar(v)}o.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(o)}s.boundingBox=n;const a=new cn;n.getCenter(a.center),a.radius=n.min.distanceTo(n.max)/2,s.boundingSphere=a}function p3(s,e,t){const i=e.attributes,n=[];function r(a,o){return t.getDependency("accessor",a).then(function(l){s.setAttribute(o,l)})}for(const a in i){const o=s1[a]||a.toLowerCase();o in s.attributes||n.push(r(i[a],o))}if(e.indices!==void 0&&!s.index){const a=t.getDependency("accessor",e.indices).then(function(o){s.setIndex(o)});n.push(a)}return It.workingColorSpace!==qi&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${It.workingColorSpace}" not supported.`),Nr(s,e),yW(s,e,t),Promise.all(n).then(function(){return e.targets!==void 0?fW(s,e.targets,t):s})}var Di=(s=>(s.ModelLoadStart="model-load-start",s.ModelLoadProgress="model-load-progress",s.ModelLoaded="model-loaded",s.ModelError="model-error",s.SelectionChanged="selection-changed",s.HoverChanged="hover-changed",s.Click="click",s.MouseMove="mouse-move",s.CameraChanged="camera-changed",s.CameraIdle="camera-idle",s.EngineFree="engine-free",s.EngineBusy="engine-busy",s.MeasureChanged="measure-changed",s.MeasureClick="measure-click",s.SectionMove="section-move",s.LoadingCompleted="loading_completed",s))(Di||{});let dp=null,up=null,f3=null;const xW=8,m3=24,_W=24,wW=64,EW=200,MW=10;function g3(){return new URL("draco/",document.baseURI).toString()}function v3(){return new URL("basis/",document.baseURI).toString()}function SW(){return dp==null&&(dp=new _V,dp.setDecoderPath(g3()),dp.preload()),dp}function CW(s){return up==null&&(up=new Fs,up.setTranscoderPath(v3())),f3!==s&&(up.detectSupport(s),f3=s),up}function TW(s){const e=new HV;return e.setDRACOLoader(SW()),e.setMeshoptDecoder(EV),s?.renderer?.capabilities!=null&&typeof s.renderer.getContext=="function"&&e.setKTX2Loader(CW(s.renderer)),e}function A3(){return new Promise(s=>{if(typeof requestAnimationFrame=="function"){requestAnimationFrame(()=>s());return}setTimeout(s,16)})}function IW(){const s=navigator?.scheduling;return typeof s?.isInputPending=="function"?s.isInputPending():!1}function PW(s){return s?.engineStatus?.isFree===!1||IW()}async function Ma(s,e,t){if(e)return t;const i=performance.now();return PW(s)||i-t>=xW?(await A3(),performance.now()):t}function DW(s,e){return new Promise((t,i)=>{lp(s,n=>{if(n==null){i(new Error(`[loadLightModel] empty zip json: ${s}`));return}t(n)},()=>{i(new Error(`[loadLightModel] failed to load zip json: ${s}`))},e)})}function RW(s,e){return Pi({method:"get",responseType:"arraybuffer",url:s}).then(async t=>{let i=t.data;return Yh.isEncrypted(t.data)&&(i=await Yh.decryptPzEnc(t.data,e)),S2.loadAsync(i)})}function b3(s){return s.replace(/\\/g,"/").replace(/^\/+/,"")}function y3(s,e){const t=new Set(e.map(i=>b3(i)));for(const i of Object.keys(s.files))if(t.has(b3(i)))return s.files[i];return null}function x3(s,e){const t=y3(s,e);return t==null||t.dir?Promise.resolve(null):t.async("string")}function BW(s){return s.charCodeAt(0)===65279?s.slice(1):s}function l1(s){return JSON.parse(BW(s))}function LW(s,e){const t=y3(s,e);return t==null||t.dir?Promise.resolve(null):t.async("arraybuffer")}function kW(s,e){return new Promise((t,i)=>{TW(s).parse(e,document.baseURI,t,i)})}function k0(s,e){const t=s.models.find(i=>i.url==e);return t!=null&&t.group==null&&(t.group=u0(s,e)??ip(s,e)),t}function _3(s){s.loadStatus==null&&(s.loadStatus={}),s.loadStatus.modelMep==null&&(s.loadStatus.modelMep=!1),s.loadStatus.normal==null&&(s.loadStatus.normal=!1)}function OW(s){return _3(s),s.status==="loaded"&&s.loadStatus.normal===!0&&s.loadStatus.modelMep===!0}function w3(s){const e=s?.engineStatus?.models;!Array.isArray(e)||e.length===0||!e.every(t=>OW(t))||s.__loadingCompletedTriggered===!0||(s.__loadingCompletedTriggered=!0,s.events?.trigger?.(Di.LoadingCompleted,{}))}function E3(s){return s===!0||s==="loading"}function M3(s){return s.index!=null?s.index.count:s.attributes.position?.count??0}async function FW(s,e,t){let i=performance.now();for(let n=0;n<e.length;n++){const r=e[n];r?.geometry!=null&&r.geometry.computeVertexNormals,(n+1)%_W===0&&(i=await Ma(s,t,i))}}async function NW(s,e,t){const i=[],n=[{node:e.octreeBox,visited:!1}];let r=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),r=await Ma(s,t,r);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});r=await Ma(s,t,r)}return i}async function UW(s,e,t,i){const n=k0(s,e.url);if(n?.nodesMap==null)return[];const r=await NW(s,t,i);console.log("[loadLightModel] pending mesh ids",t.path,r.length);const a=[];let o=performance.now(),l=0;for(const c of r){if(!n.nodesMap.has(c))continue;const h=n.nodesMap.get(c),d=Array.isArray(h?.infos)?h.infos:[];for(const u of d){const p=t.glbs?.[u.glb]?.[u.mesh];if(p?.geometry==null||p.material==null)continue;const m=new Ke;m.elements=u.matrix;const v=p.geometry.clone();v.applyMatrix4(m),v.computeBoundingBox();const g=new We(v,p.material);u.box=v.boundingBox?.clone(),u.mesh=g,g.name=Number(c),g.glb=u.glb,g.url=e.url,v.attributes.position!=null&&a.push(g),l++,l%m3===0&&(o=await Ma(s,i,o))}}return a}function zW(s,e,t,i,n){const r=Ea(i.map(o=>o.geometry),!1),a=new We(r,n);return a.castShadow=!0,a.receiveShadow=!0,ip(e,s).add(a),Bx(e,a),a.url=s,a.glb=t,a.materialClone=n,a.geometrys=i.map(o=>o.geometry),a.geometry.computeVertexNormals(),a}function HW(s,e,t,i){return(u0(s,e)?.children??s.scene.children).find(n=>{const r=n;return n instanceof We&&r.url==e&&r.glb==t&&r.materialClone===i})}function GW(s,e){const t=Array.isArray(s.geometrys)?s.geometrys:[],i=e.map(a=>a.geometry),n=[...t,...i],r=Ea(n,!1);s.geometry!=null&&s.geometry.dispose(),s.geometry=r,s.geometrys=n,s.castShadow=!0,s.receiveShadow=!0}async function VW(s,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 r=k0(e,s);let a=performance.now();for(const[o,l]of n.entries()){const c=i?l.length:EW;for(let h=0;h<l.length;h+=c){const d=l.slice(h,h+c);if(d.length===0)continue;const u=JW(d[0].material,e);let p=HW(e,s,o,u),m=0,v=0;p=null,p!=null?(m=Array.isArray(p.geometrys)?p.geometrys.length:0,v=M3(p.geometry),GW(p,d)):p=zW(s,e,o,d,u);const g=new Map;let f=v;d.forEach((A,b)=>{const y=Number(A.name),x=M3(A.geometry),_=g.get(y)??[];if(_.push([f,f+x]),g.set(y,_),r?.nodesMap?.has(y)){const M=r.nodesMap.get(y);M.indexes==null&&(M.indexes=[]),M.indexes.push([p.index,m+b,f,f+x])}f+=x}),p.indexes==null&&(p.indexes=new Map),g.forEach((A,b)=>{const y=p.indexes.get(b)??[];y.push(...A),p.indexes.set(b,y)}),a=await Ma(e,i,a)}}}async function WW(s,e,t,i,n,r){if(i==null||n==null||n.length===0)return;const a=k0(t,s);if(a==null)return;const o=new hi(i.geometry,i.material,n.length);ip(t,s).add(o);const l=Bx(t,o),c=new Float32Array(n.length*3);for(let u=0;u<n.length;u++)c[u*3]=1,c[u*3+1]=1,c[u*3+2]=1;o.instanceColor=new no(c,3);let h=performance.now();const d=[];for(let u=0;u<n.length;u++){const p=n[u],m=new Ke;if(m.elements=p.matrix,o.setMatrixAt(u,m),o.matrixs||(o.matrixs=[]),o.matrixs.push(m.clone()),d.push(m.clone()),a.nodesMap.has(p.id)){const v=a.nodesMap.get(p.id);v.indexes==null&&(v.indexes=[]),v.indexes.push([l,u,0,0])}else a.nodesMap.set(p.id,{instance:!0,info:p,indexes:[[l,u,0,0]]});(u+1)%wW===0&&(h=await Ma(t,r,h))}o.instanceMatrix.needsUpdate=!0,o.instanceColor!=null&&(o.instanceColor.needsUpdate=!0),o.materialClone=i.material,o.url=s,o.glb=i.glb,o.ids=n.map(u=>u.id),o.matrixsClone=d,o.meshIndex=e}async function QW(s,e,t,i){const n=e.instanceNodes;if(n==null)return;let r=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 WW(s.url,o.mesh,t,l,o.children,i)}r=await Ma(t,i,r)}}async function jW(s,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 UW(s,e,t,i);await VW(e.url,s,n,i),await QW(e,t,s,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 XW(s,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 RW(e.url+t.path,e.key),r=await x3(n,["/nodes.json","nodes.json"]);if(r==null)return;const a=l1(r),o=k0(s,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 p=0;p<d.length;p++){const m=d[p];if(m.glb=h,o.nodesMap.has(m.id)===!1)o.nodesMap.set(m.id,{infos:[m]});else{if(!o.nodesMap.get(m.id).infos)continue;o.nodesMap.get(m.id).infos.push(m)}(p+1)%m3===0&&(l=await Ma(s,i,l))}const u=await LW(n,[`/${h}.glb`,`${h}.glb`,h+".glb"]);if(u==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 p=await kW(s,u);t.glbs[h]=p.scene.children,t.glbs[h].forEach(m=>{m.matrixWorld}),await FW(s,t.glbs[h],i)}catch(p){console.error("[loadLightModel] failed to load glb",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,dracoDecoderPath:g3(),basisTranscoderPath:v3(),error:p})}l=await Ma(s,i,l)}const c=await x3(n,["/instances.json","instances.json"]);t.instanceNodes=c!=null?l1(c):null,t.loadSuccess=!0})().finally(()=>{t.preparePromise=null}),await t.preparePromise}}function qW(s,e,t){if(t.boundingBox||(t.boundingBox=new xt,t.boundingBox.min=new P(t.octreeBox.min.X,t.octreeBox.min.Z,-t.octreeBox.min.Y),t.boundingBox.max=new P(t.octreeBox.max.X,t.octreeBox.max.Z,-t.octreeBox.max.Y)),!t.maxSize)return 1e3;const i=t.boundingBox,n=i.min,r=i.max,a=n.clone().add(r.clone()).multiplyScalar(.5),o=n.distanceTo(r),l=new P,c=new P,h=new P,d=new P;if(e.getWorldDirection(h),e.getWorldPosition(d),e.matrixWorld.extractBasis(l,c,new P),e instanceof Zi){const f=Math.max((e.top-e.bottom)/e.zoom,1e-6),A=s?.cameraModule?.perspectiveCamera?.getEffectiveFOV?.()??20,b=Bt.degToRad(A*.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 u=a.clone().sub(d).dot(h);if(u<=0)return 0;const p=d.clone().add(h.multiplyScalar(Math.max(u,o))),m=p.clone().add(l.setLength(t.maxSize)),v=new Kt(e,s.renderer,s.scene).worldToScreen(p),g=new Kt(e,s.renderer,s.scene).worldToScreen(m);return v.distanceTo(g)}async function YW(s,e,t,i){t.maxSize<1e6&&t.path!="/lod0"&&(!(qW(s,s.camera,t)>=MW)||t.status===!0)||(await XW(s,e,t,i),t.loadSuccess===!0&&await jW(s,e,t,i))}function KW(s,e,t){E3(e.loadStatus.modelMep)||(e.loadStatus.modelMep="loading",e.info.modelMep==null&&(e.info.modelMep={}),(async()=>{t||await A3(),NV(s,e.info.modelMep,e.url),e.loadStatus.modelMep=!0,w3(s)})().catch(i=>{e.loadStatus.modelMep=!1,console.error("[loadLightModel] failed to load mep model",i)}))}function $W(s,e,t,i){const n=ip(s,e);s.models||(s.models=[]),window.startTime=Date.now();let r="WDDsBNtzVz6aSh/bCFh3CmjjANEDRryoXF1XCJvJjeE=";DW(e+"/info",r).then(a=>{const o=l1(a);s.__loadingCompletedTriggered=!1,s.engineStatus.models.push({type:"light",info:o,name:o.baseInfo.name,status:"loading",url:e,elements:new Map,loadStatus:{modelMep:!1,normal:!1},key:r}),s.models.push({url:e,group:n,nodesMap:new Map,grids:o.modelGrid,levels:o.modelLevel,rooms:o.modelRoom,views:o.modelView,name:o.baseInfo.name,boundingBox:{min:new P(o.baseInfo.min.X*.3048,o.baseInfo.min.Z*.3048,-o.baseInfo.min.Y*.3048),max:new P(o.baseInfo.max.X*.3048,o.baseInfo.max.Z*.3048,-o.baseInfo.max.Y*.3048)}}),s.models.length==i&&(s.viewCube.CameraGoHome(1),setTimeout(()=>{S3(s,null,!1)},100))}).catch(a=>{console.error("[loadLightModel] failed to load model info",{url:e,error:a})})}async function S3(s,e,t=!1){const i=s.engineStatus.models.filter(n=>e==null||n.url==e);for(const n of i)if(_3(n),!(n.status!=="loading"||n.type!=="light")&&(KW(s,n,t),!E3(n.loadStatus.normal))){n.loadStatus.normal="loading";try{await ZW(s,n,t)}finally{const r=Array.isArray(n.info?.lods)&&n.info.lods.every(a=>a.status===!0);n.loadStatus.normal=r,r&&(n.status="loaded"),w3(s)}}}async function ZW(s,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 YW(s,e,i,t)}function JW(s,e){return s.map!=null&&(s.map.colorSpace=ci,s.map.needsUpdate=!0),s.clipShadows=!0,e?.sectionPlane&&(s.clippingPlanes=e.sectionPlane),s}class eQ{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const n of e)i(n)==="light"&&$W(this.engine,n,t,e.length);function i(n){const r=n.split(".").pop();return r==="glb"||r==="gltf"?"gltf":"light"}}}var To=(s=>(s.ModelLoadStart="model-load-start",s.ModelLoadProgress="model-load-progress",s.ModelLoaded="model-loaded",s.ModelError="model-error",s.SelectionChanged="selection-changed",s.HoverChanged="hover-changed",s.Click="click",s.MouseMove="mouse-move",s.CameraChanged="camera-changed",s.CameraIdle="camera-idle",s.ViewportResize="viewport-resize",s.EngineFree="engine-free",s.EngineBusy="engine-busy",s.MeasureChanged="measure-changed",s.SectionMove="section-move",s.LoadingCompleted="loading_completed",s))(To||{});class tQ{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(To.EngineFree,e=>{this.updateFree(!0),S3(this.engine,e,!1),this.engine?.octreeBox?.requestBvhBuild?.()}),this.engine.events.on(To.EngineBusy,()=>{this.updateFree(!1)})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}let iQ=class{listeners=new Map;debugMode=!1;setDebugMode(s){this.debugMode=s}on(s,e){const t=String(s);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(s,e){const t=String(s);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(s,e){const t=String(s);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,r)=>{try{n(e)}catch(a){console.error(`[EventModule] 事件监听器执行错误 [${t}] #${r}:`,a)}})}};const O0=1,c1=120,nQ=5e3,sQ=1.25,C3=500,rQ=5e4;class aQ{engine;lastShadowHalfSize=0;lastShadowFar=0;constructor(e){this.engine=e}init(){const e=new tr(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=c1;e.shadow.camera.left=-t,e.shadow.camera.right=t,e.shadow.camera.top=t,e.shadow.camera.bottom=-t,e.shadow.radius=2,e.shadow.intensity=O0;const i=new tr(16777215,2);this.engine.scene.add(e),this.engine.scene.add(i),this.engine.scene.dirLight=i;const n=new Lu(16777215,2);this.engine.scene.add(n)}updateShadowCameraRange(e){const t=this.getShadowDirectionalLight();if(!t||!(t.shadow.camera instanceof Zi))return;const i=t.shadow.camera,n=this.getSceneBoundingBox();let r=0,a=0,o=null;if(n){const p=n.getSize(new P);r=Math.max(p.x,p.y,p.z)*.5,a=Math.max(p.length(),1),o=n.getCenter(new P)}const l=this.getCameraHalfExtent(e,o),c=Bt.clamp(Math.max(l*sQ,r*.6,c1),c1,nQ),h=Bt.clamp(Math.max(c*8,a*2,C3),C3,rQ),d=Math.abs(c-this.lastShadowHalfSize)>.5,u=Math.abs(h-this.lastShadowFar)>1;!d&&!u||(i.left=-c,i.right=c,i.top=c,i.bottom=-c,i.near=.1,i.far=h,i.updateProjectionMatrix(),t.shadow.needsUpdate=!0,this.lastShadowHalfSize=c,this.lastShadowFar=h)}getShadowDirectionalLight(){const e=this.engine.scene;if(!e)return null;const t=e.dirLight;return t instanceof tr&&t.castShadow?t:e.children.find(i=>i instanceof tr&&i.castShadow)??null}getSceneBoundingBox(){const e=this.engine.octreeBox?.getBoundingBox?.();if(!e?.min||!e?.max)return null;const t=e.min,i=e.max;if(![t.x,t.y,t.z,i.x,i.y,i.z].every(Number.isFinite))return null;const n=new xt(new P(Math.min(t.x,i.x),Math.min(t.y,i.y),Math.min(t.z,i.z)),new P(Math.max(t.x,i.x),Math.max(t.y,i.y),Math.max(t.z,i.z))),r=n.getSize(new P);return r.lengthSq()<=1e-8||r.length()>1e7?null:n}getCameraHalfExtent(e,t){if(!e)return 0;if(e instanceof Zi){const i=Math.max(e.zoom,1e-6),n=Math.max((e.top-e.bottom)/(2*i),1),r=Math.max((e.right-e.left)/(2*i),1);return Math.max(r,n)}if(e instanceof wi){const i=this.resolveCameraTarget(e,t),n=Math.max(e.position.distanceTo(i),1),r=Bt.degToRad(e.getEffectiveFOV()*.5),a=Math.max(Math.tan(r)*n,1),o=a*Math.max(e.aspect,1e-6);return Math.max(o,a)}return 0}resolveCameraTarget(e,t){const i=this.engine.controls?.target;if(i instanceof P)return i.clone();if(t)return t.clone();const n=new P;return e.getWorldDirection(n),e.position.clone().add(n.multiplyScalar(10))}}class oQ{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 P;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))}handelKeyEscDown(){this.engine.modelToolModule.unhighlightAllModels()}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}e.catch==null&&this.engine.hoverHighLight.clearHighlight()}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.suppressClickForCurrentTick())}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 hi&&(c.has(d[0])||c.set(d[0],[]),c.get(d[0])?.push(d[1]))});const h=[];return c.forEach((d,u)=>{const p=this.getSceneModel(u);d.forEach(m=>{const v=p.geometry.clone();v.applyMatrix4(p.matrixs[m]),h.push(new We(v,p.material))})}),this.hoverOldId==o?[]:(this.hoverOldId=o,t||this.engine.hoverHighLight.clearHighlight(),h)}const i=e.catch.object,n=i.name,r=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(),r)}handleMouseClick(e){if(this.suppressClickOnce){this.suppressClickOnce=!1;return}if(this.isShiftDown){if(e.catch!=null){const i=e.catch.object;this.applyBoxDeselection([{url:i.url,ids:[i.name]}])}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(Di.Click,[{url:n.url,ids:[n.name]}]);const r=new CustomEvent("D3ElementClick",{detail:{id:n.name}});window.dispatchEvent(r);return}const t=new CustomEvent("D3ElementClick",{detail:{id:-1}});window.dispatchEvent(t),this.engine.modelToolModule.unhighlightAllModels()}handleMouseDoubleClick(e){if(!e.catch){this.engine.controlModule?.orbitControls.enabled&&this.engine.viewCube.CameraGoHome(500);return}const t=e.catch;if(this.engine.controlModule?.firstPersonControls?.enabled===!0&&t.point instanceof P){const o=this.engine.camera,l=o.position.clone(),c=t.point.clone(),h=500,d=performance.now(),u=()=>{const p=performance.now()-d,m=Math.min(p/h,1),v=m<.5?2*m*m:1-Math.pow(-2*m+2,2)/2;o.position.lerpVectors(l,c,v),m<1?requestAnimationFrame(u):this.engine.controlModule.firstPersonControls.setCameraHeight(o.position.y)};requestAnimationFrame(u);return}const 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 u=d?.geometry?.boundingSphere;if(!u)return;const p=new xt,m=u.center.clone().applyMatrix4(o),v=u.radius,g=new P().setFromMatrixScale(o),f=v*Math.max(g.x,g.y,g.z)*.15;p.min.set(m.x-f,m.y-f,m.z-f),p.max.set(m.x+f,m.y+f,m.z+f),l.push(p)});const c=this.getMergedBox(l);c!=null&&this.engine.viewCube.zoomToModel(c);return}const r=n.infos.map(o=>o.box).filter(o=>o instanceof xt),a=this.getMergedBox(r);a!=null&&this.engine.viewCube.zoomToModel(a)}handleMouseClickInstance(e){return e.intersectObjects(g2(this.engine),!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)}suppressClickForCurrentTick(){this.suppressClickOnce=!0,setTimeout(()=>{this.suppressClickOnce=!1},0)}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((r,a)=>{const o=this.getNodeWorldBox(r),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,r])=>({url:n,ids:Array.from(r)}))}applyBoxSelection(e){const t=this.excludeHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.highlightModel(t),this.engine.events.trigger(Di.SelectionChanged,t))}applyBoxDeselection(e){const t=this.keepHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.unhighlightModel(t),this.removeModelsFromHighlightState(t),this.engine.events.trigger(Di.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 xt);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]),r=this.getInstanceWorldBox(n,i[1]);r!=null&&t.push(r)}),this.getMergedBox(t)}return null}getInstanceWorldBox(e,t){if(!(e instanceof hi))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 P(e.min.x,e.min.y,e.min.z),new P(e.min.x,e.min.y,e.max.z),new P(e.min.x,e.max.y,e.min.z),new P(e.min.x,e.max.y,e.max.z),new P(e.max.x,e.min.y,e.min.z),new P(e.max.x,e.min.y,e.max.z),new P(e.max.x,e.max.y,e.min.z),new P(e.max.x,e.max.y,e.max.z)];let i=1/0,n=1/0,r=-1/0,a=-1/0;return t.forEach(o=>{const l=new Kt(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),r=Math.max(r,l.x),a=Math.max(a,l.y))}),!Number.isFinite(i)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(a)?null:{left:i,top:n,right:r,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 xt().makeEmpty();return e.forEach(i=>t.union(i)),t.isEmpty()?null:t}getSceneModel(e){return Lx(this.engine,e)}}class lQ{engine;highlightMaterial;translucentMaterial;constructor(e){this.engine=e,this.highlightMaterial=new Wt({color:43775,depthTest:!1,depthWrite:!0,transparent:!0,opacity:.3,side:qt}),this.translucentMaterial=new Wt({color:16777215,transparent:!0,opacity:.05,side:qt}),this.highlightMaterial.clippingPlanes=this.engine.sectionPlane,this.translucentMaterial.clippingPlanes=this.engine.sectionPlane,this.engine.events?.on?.(To.EngineFree,()=>{this.restoreSplitModelsOnIdle()})}split_merge_model(e){if(e.isSplit||e instanceof hi)return;e.geometry!=null&&(e.__mergedGeometryBackup=e.geometry);let t=e.material,i=Ea(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){if(e==null||e instanceof hi||e.isSplit!==!0||this.shouldKeepSplitState(e))return;const t=e.__mergedGeometryBackup;if(t!=null){const r=e.geometry;e.geometry=t,e.material=e.material[0],e.needsUpdate=!0,e.isSplit=!1,r&&r!==t&&typeof r.dispose=="function"&&r.dispose(),console.log("merge");return}if(!Array.isArray(e.geometrys)||e.geometrys.length===0)return;const i=e.geometry,n=Ea(e.geometrys,!1);n!=null&&(n.computeVertexNormals(),e.geometry=n,e.material=e.material[0],e.needsUpdate=!0,e.isSplit=!1,i&&i!==n&&typeof i.dispose=="function"&&i.dispose(),console.log("merge"))}shouldKeepSplitState(e){const t=e?.geometry?.groups;return!Array.isArray(t)||t.length===0?!1:t.some(i=>(typeof i.materialIndex=="number"?i.materialIndex:0)!==0||i.visible===!1)}restoreSplitModelsOnIdle(){this.engine?.scene&&Qh(this.engine,e=>e instanceof We&&!(e instanceof hi)).forEach(e=>{e instanceof We&&e.isSplit===!0&&this.un_split_merge_model(e)})}getSceneModel(e){return Lx(this.engine,e)}updateMaterial(){let e=0;this.engine.engineStatus.highlightModels?.forEach(t=>{e=e+t.ids.length}),e>20?(this.highlightMaterial.depthTest=!0,this.highlightMaterial.transparent=!1):(this.highlightMaterial.depthTest=!1,this.highlightMaterial.transparent=!0)}highlightModel(e){e.forEach(t=>{let i=new Map;t.ids.forEach(r=>{let a=this.engine.models.find(o=>o.url==t.url).nodesMap.get(r);a!=null&&a.indexes!=null&&a.indexes.forEach(o=>{this.getSceneModel(o[0])instanceof hi?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])),this.getSceneModel(o[0]).geometry.groups[o[1]].materialIndex=1)})}),cQ(i,this.engine);let n=this.engine.engineStatus.highlightModels.find(r=>r.url==t.url);n!=null?n.ids.push(...t.ids):this.engine.engineStatus.highlightModels.push(t)}),this.updateMaterial()}unhighlightModel(e){e.forEach(t=>{let i=new Map;t.ids.forEach(n=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(n);r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{this.getSceneModel(a[0])instanceof hi?i.has(a[0])?i.get(a[0])?.push(a[1]):i.set(a[0],[a[1]]):this.getSceneModel(a[0]).geometry.groups.length!=0&&(this.getSceneModel(a[0]).geometry.groups[a[1]].materialIndex=0)})}),T3(i,this.engine,"highlightModel")}),this.updateMaterial()}unhighlightAllModels(e=!0){this.engine.engineStatus.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus.highlightModels=[]),this.updateMaterial()}hideModel(e){e.forEach(t=>{let i=new Map;t.ids.forEach(r=>{let a=this.engine.models.find(o=>o.url==t.url).nodesMap.get(r);this.engine.modelEdge.hideModelEdge(t.url,r),a!=null&&a.indexes!=null&&a.indexes.forEach(o=>{const l=this.getSceneModel(o[0]);l instanceof hi?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&&dQ(i,this.engine);let n=this.engine.engineStatus.hideModels.find(r=>r.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(r=>{let a=this.engine.models.find(o=>o.url==t.url).nodesMap.get(r);this.engine.modelEdge.showModelEdge(t.url,r),a!=null&&a.indexes!=null&&a.indexes.forEach(o=>{const l=this.getSceneModel(o[0]);l instanceof hi?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&&I3(i,this.engine);let n=this.engine.engineStatus.hideModels.find(r=>r.url==t.url);n&&(t.ids.forEach(r=>{const a=n.ids.indexOf(r);a!==-1&&n.ids.splice(a,1)}),n.ids.length===0&&(this.engine.engineStatus.hideModels=this.engine.engineStatus.hideModels.filter(r=>r!==n)))})}isolateModel(e){let t=[];this.engine.models.forEach(i=>{let n={url:i.url,ids:[]},r=e.find(a=>a.url==i.url);for(let a of i.nodesMap)r==null?n.ids.push(a[0]):r.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:[]},r=e.find(a=>a.url==i.url);for(let a of i.nodesMap)r==null?n.ids.push(a[0]):r.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){Qh(this.engine,()=>!0).forEach(t=>{t.isMesh})}restoreAllModelsColor(){Qh(this.engine,()=>!0).forEach(e=>{e.isMesh})}translucentModel(e){this.unhighlightAllModels(),e.forEach(t=>{let i=new Map;t.ids.forEach(r=>{let a=this.engine.models.find(o=>o.url==t.url).nodesMap.get(r);a!=null&&a.indexes!=null&&a.indexes.forEach(o=>{const l=this.getSceneModel(o[0]);l instanceof hi?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)})}),hQ(i,this.engine);let n=this.engine.engineStatus.translucentModels.find(r=>r.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(r=>r.url==e.url).nodesMap.get(i);n!=null&&n.indexes!=null&&n.indexes.forEach(r=>{const a=this.getSceneModel(r[0]);a instanceof hi?t.has(r[0])?t.get(r[0])?.push(r[1]):t.set(r[0],[r[1]]):(this.split_merge_model(this.getSceneModel(r[0])),a.geometry.groups[r[1]].materialIndex=0)})}),t.size>0&&I3(t,this.engine),T3(t,this.engine,"translucentModel")}),this.engine.engineStatus.translucentModels=[]}hideAllModels(){let e=[];this.engine.models.forEach(t=>{let i={url:t.url,ids:[]};for(let n of t.nodesMap)i.ids.push(n[0]);e.push(i)}),this.unhighlightAllModels(),this.hideModel(e)}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 cQ(s,e){s.forEach((t,i)=>{const n=pp(e,i);if(!(n instanceof hi))return;const r=n.geometry,a=new Wt({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:qt});a.clippingPlanes=e.sectionPlane;const o=new hi(r,a,t.length);o.name="highlightModel",o.key=i,o.ids=[],o.matrixs=[],o.url=n.url,t.forEach(d=>{o.ids.push(n.ids[d]),o.matrixs.push(n.matrixs[d])});const l=new Map,c=new Ke,h=new Ke;h.makeScale(0,0,0),t.forEach((d,u)=>{n.getMatrixAt(d,c),l.set(d,c.clone()),n.setMatrixAt(d,h),o.setMatrixAt(u,c)}),n.instanceMatrix.needsUpdate=!0,o.instanceMatrix.needsUpdate=!0,e.scene.add(o)})}function T3(s,e,t){s.forEach((i,n)=>{const r=pp(e,n);if(!(r instanceof hi))return;i.forEach(o=>{const l=r.matrixsClone[o];l&&r.setMatrixAt(o,l)}),r.instanceMatrix.needsUpdate=!0;const a=[];e.scene.traverse(o=>{o.key==n&&o.name==t&&a.push(o)}),a.forEach(o=>{e.scene.remove(o)})})}function hQ(s,e){s.forEach((t,i)=>{const n=pp(e,i);if(!(n instanceof hi))return;const r=n.geometry,a=new Wt({color:16777215,transparent:!0,opacity:.05,side:qt});a.clippingPlanes=e.sectionPlane;const o=new hi(r,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,u)=>{n.getMatrixAt(d,c),l.set(d,c.clone()),n.setMatrixAt(d,h),o.setMatrixAt(u,c)}),n.instanceMatrix.needsUpdate=!0,o.instanceMatrix.needsUpdate=!0,e.scene.add(o)})}function dQ(s,e){const t=[];e.scene.traverse(i=>{i.name=="highlightModel"&&t.push(i)}),t.forEach(i=>{e.scene.remove(i)}),s.forEach((i,n)=>{const r=pp(e,n);if(!(r instanceof hi))return;const a=new Map,o=new Ke,l=new Ke;l.makeScale(0,0,0),i.forEach((c,h)=>{r.getMatrixAt(c,o),a.set(c,o.clone()),r.setMatrixAt(c,l)}),r.instanceMatrix.needsUpdate=!0})}function I3(s,e){s.forEach((t,i)=>{const n=pp(e,i);n instanceof hi&&(t.forEach(r=>{const a=n.matrixs[r];a&&n.setMatrixAt(r,a)}),n.instanceMatrix.needsUpdate=!0)})}function pp(s,e){return Lx(s,e)}const P3="advanced";class uQ{engine;currentMode="";isManualMode=!1;gtaoPass=null;ssaoPass=null;saturationPass=null;outputPass=null;fxaaPass=null;constructor(e){this.engine=e}init(){this.cachePassReferences(),this.autoSwitch(P3)}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){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(!0);break;case"balance":this.setShadows(!0),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!0);break;case"advanced":this.setShadows(!0),this.setGTAO(!0),this.setSSAO(!1),this.setSaturation(!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 tr);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 tr),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 F0{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 r=this.engine.worldToScreen.worldToScreen(t);this.tagDiv?(this.tagDiv.style.left=r.x+10+this.engine.reactBoundingClientRect.left+"px",this.tagDiv.style.top=r.y-10+this.engine.reactBoundingClientRect.top+"px",this.tagDiv.style.display="block"):this.tagDiv&&(this.tagDiv.style.display="none")}init(){this.overlayMaterial=new Wt({color:16777215,transparent:!0,opacity:0,blending:bf,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(r=>r?.geometry);if(n.length===0){this.clearHighlight();return}this.overlayMaterial.color.set(t),this.overlayMaterial.opacity=0,this.overlayMaterial.userData.targetOpacity=i;for(const r of n){let a=r.geometry.clone();a.computeVertexNormals();const o=new We(a,this.overlayMaterial);r.updateWorldMatrix(!0,!1),o.matrix.copy(r.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/F0.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/F0.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 h1={exports:{}},pQ=h1.exports,D3;function fQ(){return D3||(D3=1,(function(s,e){(function(t,i){s.exports=i()})(pQ,function(){var t=function(){function i(p){return a.appendChild(p.dom),p}function n(p){for(var m=0;m<a.children.length;m++)a.children[m].style.display=m===p?"block":"none";r=p}var r=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(p){p.preventDefault(),n(++r%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 u=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 p=(performance||Date).now();if(d.update(p-o,200),p>l+1e3&&(h.update(1e3*c/(p-l),100),l=p,c=0,u)){var m=performance.memory;u.update(m.usedJSHeapSize/1048576,m.jsHeapSizeLimit/1048576)}return p},update:function(){o=this.end()},domElement:a,setMode:n}};return t.Panel=function(i,n,r){var a=1/0,o=0,l=Math.round,c=l(window.devicePixelRatio||1),h=80*c,d=48*c,u=3*c,p=2*c,m=3*c,v=15*c,g=74*c,f=30*c,A=document.createElement("canvas");A.width=h,A.height=d,A.style.cssText="width:80px;height:48px";var b=A.getContext("2d");return b.font="bold "+9*c+"px Helvetica,Arial,sans-serif",b.textBaseline="top",b.fillStyle=r,b.fillRect(0,0,h,d),b.fillStyle=n,b.fillText(i,u,p),b.fillRect(m,v,g,f),b.fillStyle=r,b.globalAlpha=.9,b.fillRect(m,v,g,f),{dom:A,update:function(y,x){a=Math.min(a,y),o=Math.max(o,y),b.fillStyle=r,b.globalAlpha=1,b.fillRect(0,0,h,v),b.fillStyle=n,b.fillText(l(y)+" "+i+" ("+l(a)+"-"+l(o)+")",u,p),b.drawImage(A,m+c,v,g-c,f,m,v,g-c,f),b.fillRect(m+g-c,v,c,f),b.fillStyle=r,b.globalAlpha=.9,b.fillRect(m+g-c,v,c,l((1-y/x)*f))}}},t})})(h1)),h1.exports}var mQ=fQ();const gQ=w2(mQ);var Zh=Object.freeze({Linear:Object.freeze({None:function(s){return s},In:function(s){return s},Out:function(s){return s},InOut:function(s){return s}}),Quadratic:Object.freeze({In:function(s){return s*s},Out:function(s){return s*(2-s)},InOut:function(s){return(s*=2)<1?.5*s*s:-.5*(--s*(s-2)-1)}}),Cubic:Object.freeze({In:function(s){return s*s*s},Out:function(s){return--s*s*s+1},InOut:function(s){return(s*=2)<1?.5*s*s*s:.5*((s-=2)*s*s+2)}}),Quartic:Object.freeze({In:function(s){return s*s*s*s},Out:function(s){return 1- --s*s*s*s},InOut:function(s){return(s*=2)<1?.5*s*s*s*s:-.5*((s-=2)*s*s*s-2)}}),Quintic:Object.freeze({In:function(s){return s*s*s*s*s},Out:function(s){return--s*s*s*s*s+1},InOut:function(s){return(s*=2)<1?.5*s*s*s*s*s:.5*((s-=2)*s*s*s*s+2)}}),Sinusoidal:Object.freeze({In:function(s){return 1-Math.sin((1-s)*Math.PI/2)},Out:function(s){return Math.sin(s*Math.PI/2)},InOut:function(s){return .5*(1-Math.sin(Math.PI*(.5-s)))}}),Exponential:Object.freeze({In:function(s){return s===0?0:Math.pow(1024,s-1)},Out:function(s){return s===1?1:1-Math.pow(2,-10*s)},InOut:function(s){return s===0?0:s===1?1:(s*=2)<1?.5*Math.pow(1024,s-1):.5*(-Math.pow(2,-10*(s-1))+2)}}),Circular:Object.freeze({In:function(s){return 1-Math.sqrt(1-s*s)},Out:function(s){return Math.sqrt(1- --s*s)},InOut:function(s){return(s*=2)<1?-.5*(Math.sqrt(1-s*s)-1):.5*(Math.sqrt(1-(s-=2)*s)+1)}}),Elastic:Object.freeze({In:function(s){return s===0?0:s===1?1:-Math.pow(2,10*(s-1))*Math.sin((s-1.1)*5*Math.PI)},Out:function(s){return s===0?0:s===1?1:Math.pow(2,-10*s)*Math.sin((s-.1)*5*Math.PI)+1},InOut:function(s){return s===0?0:s===1?1:(s*=2,s<1?-.5*Math.pow(2,10*(s-1))*Math.sin((s-1.1)*5*Math.PI):.5*Math.pow(2,-10*(s-1))*Math.sin((s-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(s){var e=1.70158;return s===1?1:s*s*((e+1)*s-e)},Out:function(s){var e=1.70158;return s===0?0:--s*s*((e+1)*s+e)+1},InOut:function(s){var e=2.5949095;return(s*=2)<1?.5*(s*s*((e+1)*s-e)):.5*((s-=2)*s*((e+1)*s+e)+2)}}),Bounce:Object.freeze({In:function(s){return 1-Zh.Bounce.Out(1-s)},Out:function(s){return s<1/2.75?7.5625*s*s:s<2/2.75?7.5625*(s-=1.5/2.75)*s+.75:s<2.5/2.75?7.5625*(s-=2.25/2.75)*s+.9375:7.5625*(s-=2.625/2.75)*s+.984375},InOut:function(s){return s<.5?Zh.Bounce.In(s*2)*.5:Zh.Bounce.Out(s*2-1)*.5+.5}}),generatePow:function(s){return s===void 0&&(s=4),s=s<Number.EPSILON?Number.EPSILON:s,s=s>1e4?1e4:s,{In:function(e){return Math.pow(e,s)},Out:function(e){return 1-Math.pow(1-e,s)},InOut:function(e){return e<.5?Math.pow(e*2,s)/2:(1-Math.pow(2-e*2,s))/2+.5}}}}),fp=function(){return performance.now()},vQ=(function(){function s(){this._tweens={},this._tweensAddedDuringUpdate={}}return s.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},s.prototype.removeAll=function(){this._tweens={}},s.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},s.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},s.prototype.update=function(e,t){e===void 0&&(e=fp()),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 r=this._tweens[i[n]],a=!t;r&&r.update(e,a)===!1&&!t&&delete this._tweens[i[n]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},s})(),d1={Linear:function(s,e){var t=s.length-1,i=t*e,n=Math.floor(i),r=d1.Utils.Linear;return e<0?r(s[0],s[1],i):e>1?r(s[t],s[t-1],t-i):r(s[n],s[n+1>t?t:n+1],i-n)},Utils:{Linear:function(s,e,t){return(e-s)*t+s}}},R3=(function(){function s(){}return s.nextId=function(){return s._nextId++},s._nextId=0,s})(),u1=new vQ,AQ=(function(){function s(e,t){t===void 0&&(t=u1),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=Zh.Linear.None,this._interpolationFunction=d1.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=R3.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return s.prototype.getId=function(){return this._id},s.prototype.isPlaying=function(){return this._isPlaying},s.prototype.isPaused=function(){return this._isPaused},s.prototype.getDuration=function(){return this._duration},s.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},s.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},s.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},s.prototype.start=function(e,t){if(e===void 0&&(e=fp()),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 r in this._valuesEnd)n[r]=this._valuesEnd[r];this._valuesEnd=n}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},s.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},s.prototype._setupProperties=function(e,t,i,n,r){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 u=[o],p=0,m=d.length;p<m;p+=1){var v=this._handleRelativeValue(o,d[p]);if(isNaN(v)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}u.push(v)}h&&(i[a]=u)}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 A={};for(var f in d)A[f]=d[f];i[a]=d=A}this._setupProperties(g,t[a],d,n[a],r)}else(typeof t[a]>"u"||r)&&(t[a]=o),l||(t[a]*=1),h?n[a]=i[a].slice().reverse():n[a]=t[a]||0}}},s.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},s.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},s.prototype.pause=function(e){return e===void 0&&(e=fp()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},s.prototype.resume=function(e){return e===void 0&&(e=fp()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},s.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},s.prototype.group=function(e){return e===void 0&&(e=u1),this._group=e,this},s.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},s.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},s.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},s.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},s.prototype.easing=function(e){return e===void 0&&(e=Zh.Linear.None),this._easingFunction=e,this},s.prototype.interpolation=function(e){return e===void 0&&(e=d1.Linear),this._interpolationFunction=e,this},s.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},s.prototype.onStart=function(e){return this._onStartCallback=e,this},s.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},s.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},s.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},s.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},s.prototype.onStop=function(e){return this._onStopCallback=e,this},s.prototype.update=function(e,t){var i=this,n;if(e===void 0&&(e=fp()),t===void 0&&(t=!0),this._isPaused)return!0;var r,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,A=Math.min(f/i._duration,1);return A===0&&o===i._duration?1:A},d=h(),u=this._easingFunction(d);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,u),this._onUpdateCallback&&this._onUpdateCallback(this._object,d),this._duration===0||o>=this._duration)if(this._repeat>0){var p=Math.min(Math.trunc((o-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=p);for(r in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[r]=="string"&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(this._valuesEnd[r])),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*p,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var m=0,v=this._chainedTweens.length;m<v;m++)this._chainedTweens[m].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},s.prototype._updateProperties=function(e,t,i,n){for(var r in i)if(t[r]!==void 0){var a=t[r]||0,o=i[r],l=Array.isArray(e[r]),c=Array.isArray(o),h=!l&&c;h?e[r]=this._interpolationFunction(o,n):typeof o=="object"&&o?this._updateProperties(e[r],a,o,n):(o=this._handleRelativeValue(a,o),typeof o=="number"&&(e[r]=a+(o-a)*n))}},s.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},s.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},s})();R3.nextId;var Ur=u1;Ur.getAll.bind(Ur),Ur.removeAll.bind(Ur),Ur.add.bind(Ur),Ur.remove.bind(Ur),Ur.update.bind(Ur);var mp={Easing:Zh,Tween:AQ};const B3={type:"change"},p1={type:"start"},L3={type:"end"},N0=new Cr,k3=new $t,bQ=Math.cos(70*Bt.DEG2RAD),rn=new P,rs=2*Math.PI,oi={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},f1=1e-6;class yQ extends wg{constructor(e,t=null){super(e,t),this.state=oi.NONE,this.target=new P,this.cursor=new P,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:ls.ROTATE,MIDDLE:ls.DOLLY,RIGHT:ls.PAN},this.touches={ONE:cs.ROTATE,TWO:cs.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 P,this._lastQuaternion=new Lt,this._lastTargetPosition=new P,this._quat=new Lt().setFromUnitVectors(e.up,new P(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new gh,this._sphericalDelta=new gh,this._scale=1,this._panOffset=new P,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 P,this._mouse=new be,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=_Q.bind(this),this._onPointerDown=xQ.bind(this),this._onPointerUp=wQ.bind(this),this._onContextMenu=PQ.bind(this),this._onMouseWheel=SQ.bind(this),this._onKeyDown=CQ.bind(this),this._onTouchStart=TQ.bind(this),this._onTouchMove=IQ.bind(this),this._onMouseDown=EQ.bind(this),this._onMouseMove=MQ.bind(this),this._interceptControlDown=DQ.bind(this),this._interceptControlUp=RQ.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(B3),this.update(),this.state=oi.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;rn.copy(t).sub(this.target),rn.applyQuaternion(this._quat),this._spherical.setFromVector3(rn),this.autoRotate&&this.state===oi.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+=rs:i>Math.PI&&(i-=rs),n<-Math.PI?n+=rs:n>Math.PI&&(n-=rs),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 r=!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),r=a!=this._spherical.radius}if(rn.setFromSpherical(this._spherical),rn.applyQuaternion(this._quatInverse),t.copy(this.target).add(rn),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=rn.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new P(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(),r=l!==this.object.zoom;const c=new P(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=rn.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):(N0.origin.copy(this.object.position),N0.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(N0.direction))<bQ?this.object.lookAt(this.target):(k3.setFromNormalAndCoplanarPoint(this.object.up,this.target),N0.intersectPlane(k3,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(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>f1||8*(1-this._lastQuaternion.dot(this.object.quaternion))>f1||this._lastTargetPosition.distanceToSquared(this.target)>f1?(this.dispatchEvent(B3),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?rs/60*this.autoRotateSpeed*e:rs/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){rn.setFromMatrixColumn(t,0),rn.multiplyScalar(-e),this._panOffset.add(rn)}_panUp(e,t){this.screenSpacePanning===!0?rn.setFromMatrixColumn(t,1):(rn.setFromMatrixColumn(t,0),rn.crossVectors(this.object.up,rn)),rn.multiplyScalar(e),this._panOffset.add(rn)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;rn.copy(n).sub(this.target);let r=rn.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/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,r=t-i.top,a=i.width,o=i.height;this._mouse.x=n/a*2-1,this._mouse.y=-(r/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(rs*this._rotateDelta.x/t.clientHeight),this._rotateUp(rs*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(rs*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(-rs*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(rs*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(-rs*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,r=Math.sqrt(i*i+n*n);this._dollyStart.set(0,r)}_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),r=.5*(e.pageY+i.y);this._rotateEnd.set(n,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(rs*this._rotateDelta.x/t.clientHeight),this._rotateUp(rs*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,r=Math.sqrt(i*i+n*n);this._dollyEnd.set(0,r),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 xQ(s){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(s.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(s)&&(this._addPointer(s),s.pointerType==="touch"?this._onTouchStart(s):this._onMouseDown(s),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function _Q(s){this.enabled!==!1&&(s.pointerType==="touch"?this._onTouchMove(s):this._onMouseMove(s))}function wQ(s){switch(this._removePointer(s),this._pointers.length){case 0:this.domElement.releasePointerCapture(s.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(L3),this.state=oi.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 EQ(s){let e;switch(s.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 ls.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(s),this.state=oi.DOLLY;break;case ls.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=oi.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=oi.ROTATE}break;case ls.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=oi.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=oi.PAN}break;default:this.state=oi.NONE}this.state!==oi.NONE&&this.dispatchEvent(p1)}function MQ(s){switch(this.state){case oi.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(s);break;case oi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(s);break;case oi.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(s);break}}function SQ(s){this.enabled===!1||this.enableZoom===!1||this.state!==oi.NONE||(s.preventDefault(),this.dispatchEvent(p1),this._handleMouseWheel(this._customWheelEvent(s)),this.dispatchEvent(L3))}function CQ(s){this.enabled!==!1&&this._handleKeyDown(s)}function TQ(s){switch(this._trackPointer(s),this._pointers.length){case 1:switch(this.touches.ONE){case cs.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(s),this.state=oi.TOUCH_ROTATE;break;case cs.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(s),this.state=oi.TOUCH_PAN;break;default:this.state=oi.NONE}break;case 2:switch(this.touches.TWO){case cs.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(s),this.state=oi.TOUCH_DOLLY_PAN;break;case cs.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(s),this.state=oi.TOUCH_DOLLY_ROTATE;break;default:this.state=oi.NONE}break;default:this.state=oi.NONE}this.state!==oi.NONE&&this.dispatchEvent(p1)}function IQ(s){switch(this._trackPointer(s),this.state){case oi.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(s),this.update();break;case oi.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(s),this.update();break;case oi.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(s),this.update();break;case oi.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(s),this.update();break;default:this.state=oi.NONE}}function PQ(s){this.enabled!==!1&&s.preventDefault()}function DQ(s){s.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function RQ(s){s.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const Zl=new fs,In=new P,Io=new P,Ei=new Lt,O3={X:new P(1,0,0),Y:new P(0,1,0),Z:new P(0,0,1)},m1={type:"change"},F3={type:"mouseDown",mode:null},N3={type:"mouseUp",mode:null},U3={type:"objectChange"};class z3 extends wg{constructor(e,t=null){super(void 0,t);const i=new NQ(this);this._root=i;const n=new UQ;this._gizmo=n,i.add(n);const r=new zQ;this._plane=r,i.add(r);const a=this;function o(b,y){let x=y;Object.defineProperty(a,b,{get:function(){return x!==void 0?x:y},set:function(_){x!==_&&(x=_,r[b]=_,n[b]=_,a.dispatchEvent({type:b+"-changed",value:_}),a.dispatchEvent(m1))}}),a[b]=y,r[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 P,c=new P,h=new Lt,d=new Lt,u=new P,p=new Lt,m=new P,v=new P,g=new P,f=0,A=new P;o("worldPosition",l),o("worldPositionStart",c),o("worldQuaternion",h),o("worldQuaternionStart",d),o("cameraPosition",u),o("cameraQuaternion",p),o("pointStart",m),o("pointEnd",v),o("rotationAxis",g),o("rotationAngle",f),o("eye",A),this._offset=new P,this._startNorm=new P,this._endNorm=new P,this._cameraScale=new P,this._parentPosition=new P,this._parentQuaternion=new Lt,this._parentQuaternionInv=new Lt,this._parentScale=new P,this._worldScaleStart=new P,this._worldQuaternionInv=new Lt,this._worldScale=new P,this._positionStart=new P,this._quaternionStart=new Lt,this._scaleStart=new P,this._getPointer=BQ.bind(this),this._onPointerDown=kQ.bind(this),this._onPointerHover=LQ.bind(this),this._onPointerMove=OQ.bind(this),this._onPointerUp=FQ.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&&Zl.setFromCamera(e,this.camera);const t=g1(this._gizmo.picker[this.mode],Zl);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&&Zl.setFromCamera(e,this.camera);const t=g1(this._plane,Zl,!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,F3.mode=this.mode,this.dispatchEvent(F3)}}pointerMove(e){const t=this.axis,i=this.mode,n=this.object;let r=this.space;if(i==="scale"?r="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(r="world"),n===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&Zl.setFromCamera(e,this.camera);const a=g1(this._plane,Zl,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),r==="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),r==="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&&(r==="local"&&(n.position.applyQuaternion(Ei.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)),r==="world"&&(n.parent&&n.position.add(In.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(In.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),Io.set(o,o,o)}else In.copy(this.pointStart),Io.copy(this.pointEnd),In.applyQuaternion(this._worldQuaternionInv),Io.applyQuaternion(this._worldQuaternionInv),Io.divide(In),t.search("X")===-1&&(Io.x=1),t.search("Y")===-1&&(Io.y=1),t.search("Z")===-1&&(Io.z=1);n.scale.copy(this._scaleStart).multiply(Io),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(In.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(In.copy(this.rotationAxis).cross(this.eye))*o):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(O3[t]),In.copy(O3[t]),r==="local"&&In.applyQuaternion(this.worldQuaternion),In.cross(this.eye),In.length()===0?l=!0:this.rotationAngle=this._offset.dot(In.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),r==="local"&&t!=="E"&&t!=="XYZE"?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(Ei.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(Ei.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(m1),this.dispatchEvent(U3)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(N3.mode=this.mode,this.dispatchEvent(N3)),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(m1),this.dispatchEvent(U3),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Zl}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 r=this._gizmo.materialLib;r.xAxis.color.set(e),r.yAxis.color.set(t),r.zAxis.color.set(i),r.active.color.set(n),r.xAxisTransparent.color.set(e),r.yAxisTransparent.color.set(t),r.zAxisTransparent.color.set(i),r.activeTransparent.color.set(n),r.xAxis._color&&r.xAxis._color.set(e),r.yAxis._color&&r.yAxis._color.set(t),r.zAxis._color&&r.zAxis._color.set(i),r.active._color&&r.active._color.set(n),r.xAxisTransparent._color&&r.xAxisTransparent._color.set(e),r.yAxisTransparent._color&&r.yAxisTransparent._color.set(t),r.zAxisTransparent._color&&r.zAxisTransparent._color.set(i),r.activeTransparent._color&&r.activeTransparent._color.set(n)}}function BQ(s){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:s.button};{const e=this.domElement.getBoundingClientRect();return{x:(s.clientX-e.left)/e.width*2-1,y:-(s.clientY-e.top)/e.height*2+1,button:s.button}}}function LQ(s){if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(s));break}}function kQ(s){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(s)),this.pointerDown(this._getPointer(s)))}function OQ(s){this.enabled&&this.pointerMove(this._getPointer(s))}function FQ(s){this.enabled&&(this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(s)))}function g1(s,e,t){const i=e.intersectObject(s,!0);for(let n=0;n<i.length;n++)if(i[n].object.visible||t)return i[n];return!1}const U0=new Yi,di=new P(0,1,0),H3=new P(0,0,0),G3=new Ke,z0=new Lt,H0=new Lt,zr=new P,V3=new Ke,gp=new P(1,0,0),Jl=new P(0,1,0),vp=new P(0,0,1),G0=new P,Ap=new P,bp=new P;class NQ extends Pt{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 UQ extends Pt{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new Wt({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new bi({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const n=t.clone();n.opacity=.5;const r=e.clone();r.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 u=e.clone();u.color.setHex(16776960),u.opacity=.25;const p=e.clone();p.color.setHex(16776960);const m=e.clone();m.color.setHex(7895160),this.materialLib={xAxis:r,yAxis:a,zAxis:o,active:p,xAxisTransparent:l,yAxisTransparent:c,zAxisTransparent:h,activeTransparent:u};const v=new $i(0,.04,.1,12);v.translate(0,.05,0);const g=new fi(.08,.08,.08);g.translate(0,.04,0);const f=new dt;f.setAttribute("position",new it([0,0,0,1,0,0],3));const A=new $i(.0075,.0075,.5,3);A.translate(0,.25,0);function b(O,N){const G=new aa(O,.0075,3,64,N*Math.PI*2);return G.rotateY(Math.PI/2),G.rotateX(Math.PI/2),G}function y(){const O=new dt;return O.setAttribute("position",new it([0,0,0,1,1,1],3)),O}const x={X:[[new We(v,r),[.5,0,0],[0,0,-Math.PI/2]],[new We(v,r),[-.5,0,0],[0,0,Math.PI/2]],[new We(A,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new We(v,a),[0,.5,0]],[new We(v,a),[0,-.5,0],[Math.PI,0,0]],[new We(A,a)]],Z:[[new We(v,o),[0,0,.5],[Math.PI/2,0,0]],[new We(v,o),[0,0,-.5],[-Math.PI/2,0,0]],[new We(A,o),null,[Math.PI/2,0,0]]],XYZ:[[new We(new ra(.1,0),d),[0,0,0]]],XY:[[new We(new fi(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new We(new fi(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new We(new fi(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]]},_={X:[[new We(new $i(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new We(new $i(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new We(new $i(.2,0,.6,4),i),[0,.3,0]],[new We(new $i(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new We(new $i(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new We(new $i(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new We(new ra(.2,0),i)]],XY:[[new We(new fi(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new We(new fi(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new We(new fi(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},M={START:[[new We(new ra(.01,2),n),null,null,null,"helper"]],END:[[new We(new ra(.01,2),n),null,null,null,"helper"]],DELTA:[[new Ci(y(),n),null,null,null,"helper"]],X:[[new Ci(f,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Ci(f,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Ci(f,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},E={XYZE:[[new We(b(.5,1),m),null,[0,Math.PI/2,0]]],X:[[new We(b(.5,.5),r)]],Y:[[new We(b(.5,.5),a),null,[0,0,-Math.PI/2]]],Z:[[new We(b(.5,.5),o),null,[0,Math.PI/2,0]]],E:[[new We(b(.75,1),u),null,[0,Math.PI/2,0]]]},w={AXIS:[[new Ci(f,n),[-1e3,0,0],null,[1e6,1,1],"helper"]]},T={XYZE:[[new We(new ao(.25,10,8),i)]],X:[[new We(new aa(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new We(new aa(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new We(new aa(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new We(new aa(.75,.1,2,24),i)]]},R={X:[[new We(g,r),[.5,0,0],[0,0,-Math.PI/2]],[new We(A,r),[0,0,0],[0,0,-Math.PI/2]],[new We(g,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new We(g,a),[0,.5,0]],[new We(A,a)],[new We(g,a),[0,-.5,0],[0,0,Math.PI]]],Z:[[new We(g,o),[0,0,.5],[Math.PI/2,0,0]],[new We(A,o),[0,0,0],[Math.PI/2,0,0]],[new We(g,o),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new We(new fi(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new We(new fi(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new We(new fi(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new We(new fi(.1,.1,.1),d)]]},D={X:[[new We(new $i(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new We(new $i(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new We(new $i(.2,0,.6,4),i),[0,.3,0]],[new We(new $i(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new We(new $i(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new We(new $i(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new We(new fi(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new We(new fi(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new We(new fi(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new We(new fi(.2,.2,.2),i),[0,0,0]]]},L={X:[[new Ci(f,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Ci(f,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Ci(f,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function I(O){const N=new Pt;for(const G in O)for(let V=O[G].length;V--;){const H=O[G][V][0].clone(),J=O[G][V][1],W=O[G][V][2],X=O[G][V][3],me=O[G][V][4];H.name=G,H.tag=me,J&&H.position.set(J[0],J[1],J[2]),W&&H.rotation.set(W[0],W[1],W[2]),X&&H.scale.set(X[0],X[1],X[2]),H.updateMatrix();const Ee=H.geometry.clone();Ee.applyMatrix4(H.matrix),H.geometry=Ee,H.renderOrder=1/0,H.position.set(0,0,0),H.rotation.set(0,0,0),H.scale.set(1,1,1),N.add(H)}return N}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=I(x)),this.add(this.gizmo.rotate=I(E)),this.add(this.gizmo.scale=I(R)),this.add(this.picker.translate=I(_)),this.add(this.picker.rotate=I(T)),this.add(this.picker.scale=I(D)),this.add(this.helper.translate=I(M)),this.add(this.helper.rotate=I(w)),this.add(this.helper.scale=I(L)),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:H0;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 r=i[n];r.visible=!0,r.rotation.set(0,0,0),r.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),r.scale.set(1,1,1).multiplyScalar(a*this.size/4),r.tag==="helper"){r.visible=!1,r.name==="AXIS"?(r.visible=!!this.axis,this.axis==="X"&&(Ei.setFromEuler(U0.set(0,0,0)),r.quaternion.copy(t).multiply(Ei),Math.abs(di.copy(gp).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Y"&&(Ei.setFromEuler(U0.set(0,0,Math.PI/2)),r.quaternion.copy(t).multiply(Ei),Math.abs(di.copy(Jl).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Z"&&(Ei.setFromEuler(U0.set(0,Math.PI/2,0)),r.quaternion.copy(t).multiply(Ei),Math.abs(di.copy(vp).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="XYZE"&&(Ei.setFromEuler(U0.set(0,Math.PI/2,0)),di.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(G3.lookAt(H3,di,Jl)),r.quaternion.multiply(Ei),r.visible=this.dragging),this.axis==="E"&&(r.visible=!1)):r.name==="START"?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):r.name==="END"?(r.position.copy(this.worldPosition),r.visible=this.dragging):r.name==="DELTA"?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),In.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),In.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(In),r.visible=this.dragging):(r.quaternion.copy(t),this.dragging?r.position.copy(this.worldPositionStart):r.position.copy(this.worldPosition),this.axis&&(r.visible=this.axis.search(r.name)!==-1));continue}r.quaternion.copy(t),this.mode==="translate"||this.mode==="scale"?(r.name==="X"&&Math.abs(di.copy(gp).applyQuaternion(t).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Y"&&Math.abs(di.copy(Jl).applyQuaternion(t).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Z"&&Math.abs(di.copy(vp).applyQuaternion(t).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XY"&&Math.abs(di.copy(vp).applyQuaternion(t).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="YZ"&&Math.abs(di.copy(gp).applyQuaternion(t).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XZ"&&Math.abs(di.copy(Jl).applyQuaternion(t).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):this.mode==="rotate"&&(z0.copy(t),di.copy(this.eye).applyQuaternion(Ei.copy(t).invert()),r.name.search("E")!==-1&&r.quaternion.setFromRotationMatrix(G3.lookAt(this.eye,H3,Jl)),r.name==="X"&&(Ei.setFromAxisAngle(gp,Math.atan2(-di.y,di.z)),Ei.multiplyQuaternions(z0,Ei),r.quaternion.copy(Ei)),r.name==="Y"&&(Ei.setFromAxisAngle(Jl,Math.atan2(di.x,di.z)),Ei.multiplyQuaternions(z0,Ei),r.quaternion.copy(Ei)),r.name==="Z"&&(Ei.setFromAxisAngle(vp,Math.atan2(di.y,di.x)),Ei.multiplyQuaternions(z0,Ei),r.quaternion.copy(Ei))),r.visible=r.visible&&(r.name.indexOf("X")===-1||this.showX),r.visible=r.visible&&(r.name.indexOf("Y")===-1||this.showY),r.visible=r.visible&&(r.name.indexOf("Z")===-1||this.showZ),r.visible=r.visible&&(r.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis?(r.material.color.copy(this.materialLib.active.color),r.material.opacity=1):this.axis.split("").some(function(o){return r.name===o})&&(r.material.color.copy(this.materialLib.active.color),r.material.opacity=1))}super.updateMatrixWorld(e)}}class zQ extends We{constructor(){super(new Ds(1e5,1e5,2,2),new Wt({visible:!1,wireframe:!0,side:qt,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"),G0.copy(gp).applyQuaternion(t==="local"?this.worldQuaternion:H0),Ap.copy(Jl).applyQuaternion(t==="local"?this.worldQuaternion:H0),bp.copy(vp).applyQuaternion(t==="local"?this.worldQuaternion:H0),di.copy(Ap),this.mode){case"translate":case"scale":switch(this.axis){case"X":di.copy(this.eye).cross(G0),zr.copy(G0).cross(di);break;case"Y":di.copy(this.eye).cross(Ap),zr.copy(Ap).cross(di);break;case"Z":di.copy(this.eye).cross(bp),zr.copy(bp).cross(di);break;case"XY":zr.copy(bp);break;case"YZ":zr.copy(G0);break;case"XZ":di.copy(bp),zr.copy(Ap);break;case"XYZ":case"E":zr.set(0,0,0);break}break;default:zr.set(0,0,0)}zr.length()===0?this.quaternion.copy(this.cameraQuaternion):(V3.lookAt(In.set(0,0,0),zr,di),this.quaternion.setFromRotationMatrix(V3)),super.updateMatrixWorld(e)}}class HQ extends TM{constructor(e){super(e),this.type=li}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,A){f=f||1024;let b=g.pos,y=-1,x=0,_="",M=String.fromCharCode.apply(null,new Uint16Array(g.subarray(b,b+128)));for(;0>(y=M.indexOf(`
|
||
`))&&x<f&&b<g.byteLength;)_+=M,x+=M.length,b+=128,M+=String.fromCharCode.apply(null,new Uint16Array(g.subarray(b,b+128)));return-1<y?(g.pos+=x+y+1,_+M.slice(0,y)):!1},n=function(g){const f=/^#\?(\S+)/,A=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,b=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,y=/^\s*FORMAT=(\S+)\s*$/,x=/^\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 M,E;for((g.pos>=g.byteLength||!(M=i(g)))&&t(1,"no header found"),(E=M.match(f))||t(3,"bad initial token"),_.valid|=1,_.programtype=E[1],_.string+=M+`
|
||
`;M=i(g),M!==!1;){if(_.string+=M+`
|
||
`,M.charAt(0)==="#"){_.comments+=M+`
|
||
`;continue}if((E=M.match(A))&&(_.gamma=parseFloat(E[1])),(E=M.match(b))&&(_.exposure=parseFloat(E[1])),(E=M.match(y))&&(_.valid|=2,_.format=E[1]),(E=M.match(x))&&(_.valid|=4,_.height=parseInt(E[1],10),_.width=parseInt(E[2],10)),_.valid&2&&_.valid&4)break}return _.valid&2||t(3,"missing format specifier"),_.valid&4||t(3,"missing image size specifier"),_},r=function(g,f,A){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*A);y.length||t(4,"unable to allocate buffer space");let x=0,_=0;const M=4*b,E=new Uint8Array(4),w=new Uint8Array(M);let T=A;for(;T>0&&_<g.byteLength;){_+4>g.byteLength&&t(1),E[0]=g[_++],E[1]=g[_++],E[2]=g[_++],E[3]=g[_++],(E[0]!=2||E[1]!=2||(E[2]<<8|E[3])!=b)&&t(3,"bad rgbe scanline format");let R=0,D;for(;R<M&&_<g.byteLength;){D=g[_++];const I=D>128;if(I&&(D-=128),(D===0||R+D>M)&&t(3,"bad scanline data"),I){const O=g[_++];for(let N=0;N<D;N++)w[R++]=O}else w.set(g.subarray(_,_+D),R),R+=D,_+=D}const L=b;for(let I=0;I<L;I++){let O=0;y[x]=w[I+O],O+=b,y[x+1]=w[I+O],O+=b,y[x+2]=w[I+O],O+=b,y[x+3]=w[I+O],x+=4}T--}return y},a=function(g,f,A,b){const y=g[f+3],x=Math.pow(2,y-128)/255;A[b+0]=g[f+0]*x,A[b+1]=g[f+1]*x,A[b+2]=g[f+2]*x,A[b+3]=1},o=function(g,f,A,b){const y=g[f+3],x=Math.pow(2,y-128)/255;A[b+0]=hu.toHalfFloat(Math.min(g[f+0]*x,65504)),A[b+1]=hu.toHalfFloat(Math.min(g[f+1]*x,65504)),A[b+2]=hu.toHalfFloat(Math.min(g[f+2]*x,65504)),A[b+3]=hu.toHalfFloat(1)},l=new Uint8Array(e);l.pos=0;const c=n(l),h=c.width,d=c.height,u=r(l.subarray(l.pos),h,d);let p,m,v;switch(this.type){case xi:v=u.length/4;const g=new Float32Array(v*4);for(let A=0;A<v;A++)a(u,A*4,g,A*4);p=g,m=xi;break;case li:v=u.length/4;const f=new Uint16Array(v*4);for(let A=0;A<v;A++)o(u,A*4,f,A*4);p=f,m=li;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:h,height:d,data:p,header:c.string,gamma:c.gamma,exposure:c.exposure,type:m}}setDataType(e){return this.type=e,this}load(e,t,i,n){function r(a,o){switch(a.type){case xi:case li:a.colorSpace=qi,a.minFilter=wt,a.magFilter=wt,a.generateMipmaps=!1,a.flipY=!0;break}t&&t(a,o)}return super.load(e,r,i,n)}}function GQ(){return new ll}function VQ(s,e){s.appendChild(e.domElement)}function WQ(s,e,t){var i=new Object;i.visible=!0;let n=null,r,a,o=[];i.init=function(){r||(c(),h(),v())},i.Hide=function(){r.style.display="none",i.visible=!1},i.Show=function(){r.style.display="block",i.visible=!0},i.RenderScene=function(){if(!d){i.camera.quaternion.copy(e.camera.quaternion);const A=new P(0,0,1).applyQuaternion(e.camera.quaternion);i.camera.position.copy(A.multiplyScalar(100))}i.orbitControls&&i.orbitControls.update(),i.sceneOrtho.renderer.render(i.sceneOrtho,i.camera)},i.ToggleDirectionView=function(A){var b=new P(0,0,0);A=="top"?b=new P(0,1,1e-5):A=="down"?b=new P(0,-1,1e-5):A=="front"?b=new P(0,0,1):A=="left"?b=new P(-1,0,0):A=="back"?b=new P(0,0,-1):A=="right"?b=new P(1,0,0):A=="top_front"?b=new P(1,1,0):A=="top_left"?b=new P(0,1,-1):A=="top_back"?b=new P(-1,1,0):A=="top_right"?b=new P(0,1,1):A=="down_front"?b=new P(1,-1,0):A=="down_left"?b=new P(0,-1,-1):A=="down_back"?b=new P(-1,-1,0):A=="down_right"?b=new P(0,-1,1):A=="front_right"?b=new P(1,0,1):A=="right_back"?b=new P(-1,0,1):A=="back_left"?b=new P(-1,0,-1):A=="left_front"?b=new P(1,0,-1):A=="top_left_front"?b=new P(1,1,-1):A=="top_front_right"?b=new P(1,1,1):A=="top_right_back"?b=new P(-1,1,1):A=="top_back_left"?b=new P(-1,1,-1):A=="button_left_front"?b=new P(1,-1,-1):A=="button_front_right"?b=new P(1,-1,1):A=="button_right_back"?b=new P(-1,1,1):A=="button_back_left"&&(b=new P(-1,-1,-1));var y=s.octreeBox.getBoundingBox(),x=y.min,_=y.max,M=x.clone().add(_.clone()).multiplyScalar(.5),E=M.clone().add(b.multiplyScalar(1*_.distanceTo(x)));l(e.camera.position,E,s.controls.target.clone(),M)},i.GetCameraPose=function(){var A=e.camera.quaternion,b=e.camera.position,y=s.controls.target,x={quaternion:A,position:b,target:y};return x},i.ReductionCameraPose=function(A,b=1e3,y){var x=new Lt(A.quaternion._x,A.quaternion._y,A.quaternion._z,A.quaternion._w),_=new P(A.position.x,A.position.y,A.position.z),M=new P(A.target.x,A.target.y,A.target.z);let E=!1;l(e.camera.position,_,s.controls.target.clone(),M,e.camera.quaternion,x,b,w=>{y&&(E||(y(w),E=!0))}),y&&setTimeout(()=>{E||(y(!0),E=!0)},b+10)},i.CameraGoHome=function(A=1e3){var b=s.octreeBox.getBoundingBox(),y=b.min.clone().add(b.max.clone()).multiplyScalar(.5);let x=new P(1,1,1);var _=b.max.distanceTo(b.min),M=y.clone().add(x.multiplyScalar(_*.8));if(e.camera.isOrthographicCamera){var E=s.container.clientWidth/s.container.clientHeight,w=_*.5;e.camera.left=-w*E,e.camera.right=w*E,e.camera.top=w,e.camera.bottom=-w,e.camera.zoom=1,e.camera.updateProjectionMatrix(),e.camera.far=_*3}else e.camera.far=_*3;s.controlModule.orbitControls.origin=y.clone(),l(e.camera.position,M,s.controls.target.clone(),y,null,null,A)},i.zoomToBox=function(A){if(e.camera.isOrthographicCamera){let $=function(){n=requestAnimationFrame($),Me.update()};var b=A.min.clone().add(A.max.clone()).multiplyScalar(.5),y=e.camera.position.clone().sub(s.controls.target.clone()).normalize(),x=e.camera.position.distanceTo(s.controls.target),_=b.clone().add(y.multiplyScalar(x)),M=e.camera.zoom,E=new P(1,0,0).applyQuaternion(e.camera.quaternion),w=new P(0,1,0).applyQuaternion(e.camera.quaternion),T=[new P(A.min.x,A.min.y,A.min.z),new P(A.max.x,A.min.y,A.min.z),new P(A.min.x,A.max.y,A.min.z),new P(A.max.x,A.max.y,A.min.z),new P(A.min.x,A.min.y,A.max.z),new P(A.max.x,A.min.y,A.max.z),new P(A.min.x,A.max.y,A.max.z),new P(A.max.x,A.max.y,A.max.z)],R=1/0,D=-1/0,L=1/0,I=-1/0;for(var O of T){var N=O.dot(E),G=O.dot(w);R=Math.min(R,N),D=Math.max(D,N),L=Math.min(L,G),I=Math.max(I,G)}var V=(D-R)/2,H=(I-L)/2,J=(e.camera.right-e.camera.left)/2,W=(e.camera.top-e.camera.bottom)/2;M=Math.min(J/V,W/H)*.75;var X=e.camera.position.clone(),me=s.controls.target.clone(),Ee=e.camera.zoom,Me=new mp.Tween({x1:X.x,y1:X.y,z1:X.z,x2:me.x,y2:me.y,z2:me.z,zoom:Ee}).to({x1:_.x,y1:_.y,z1:_.z,x2:b.x,y2:b.y,z2:b.z,zoom:M},1e3);Me.onUpdate(function(se){s.controls&&(e.camera.position.set(se.x1,se.y1,se.z1),s.controls.target.set(se.x2,se.y2,se.z2),e.camera.isOrthographicCamera&&(e.camera.zoom=se.zoom,e.camera.updateProjectionMatrix()),s.controls.auto=!0,s.controls.update(),i.RenderScene())}),Me.onComplete(function(){s.controls&&(s.controls.auto=!1,i.RenderScene(),cancelAnimationFrame(n),n=null)}),Me.easing(mp.Easing.Cubic.InOut),Me.start(),$()}else{var b=A.min.clone().add(A.max.clone()).multiplyScalar(.5);let se=e.camera.position.clone().sub(s.controls.target.clone()).normalize();var _=b.clone().add(se.multiplyScalar(2*A.max.distanceTo(A.min)));l(e.camera.position,_,s.controls.target.clone(),b)}};function l(A,b,y,x,_,M,E=1e3,w){var T;_&&M?(T=new mp.Tween({x1:A.x,y1:A.y,z1:A.z,x2:y.x,y2:y.y,z2:y.z,_x:_._x,_y:_._y,_z:_._z,_w:_._w}),T.to({x1:b.x,y1:b.y,z1:b.z,x2:x.x,y2:x.y,z2:x.z,_x:M._x,_y:M._y,_z:M._z,_w:M._w},E)):(T=new mp.Tween({x1:A.x,y1:A.y,z1:A.z,x2:y.x,y2:y.y,z2:y.z}),T.to({x1:b.x,y1:b.y,z1:b.z,x2:x.x,y2:x.y,z2:x.z},E)),T.onUpdate(function(D){s.controls&&(_&&M?(e.camera.quaternion._x=D._x,e.camera.quaternion._y=D._y,e.camera.quaternion._z=D._z,e.camera.quaternion._w=D._w):s.controls.auto=!0,e.camera.position.x=D.x1,e.camera.position.y=D.y1,e.camera.position.z=D.z1,s.controls.target.x=D.x2,s.controls.target.y=D.y2,s.controls.target.z=D.z2,s.controls.update(),i.RenderScene())}),T.onComplete(function(D){s.controls&&(s.controls.auto=!1,i.RenderScene(),w&&w(!0),cancelAnimationFrame(n),n=null)}),T.easing(mp.Easing.Cubic.InOut);function R(D){n=requestAnimationFrame(R),T.update()}T.start(),R()}function c(){r=document.createElement("div"),r.className="ViewCube",t.appendChild(r),a=document.createElement("div"),a.className="viewSettingWrapper",a.innerHTML="...";var A=document.createElement("div");A.className="homeViewWrapper",A.addEventListener("mousedown",function(){s.viewCube.cameraGoHome(500)}),r.appendChild(A),a.addEventListener("mousedown",function(x){x.stopPropagation(),cameraToggle.classList.contains("show")?(b(),console.log("隐藏功能按钮")):(y(),console.log("显示功能按钮"))});function b(){cameraToggle.classList.remove("show"),screenshot.classList.remove("show"),fullscreen.classList.remove("show")}function y(){cameraToggle.classList.add("show"),screenshot.classList.add("show"),fullscreen.classList.add("show")}}function h(){i.sceneOrtho=GQ();var y=t.clientWidth,x=t.clientWidth,A=y>x?y/x:x/y,b=300;i.camera=new Zi(b*A/-2,b*A/2,b/2,b/-2,.01,1e4);var y=r.clientWidth,x=r.clientHeight,_=new Uu({alpha:!0});_.setSize(y,x),_.setClearAlpha(0),i.sceneOrtho.renderer=_;let M=new Lu(16777215,.8);i.sceneOrtho.add(M),VQ(r,_),i.orbitControls=new yQ(i.camera,r),i.orbitControls.enableZoom=!1,i.orbitControls.enablePan=!1,i.orbitControls.enableDamping=!0,i.orbitControls.dampingFactor=.1,i.orbitControls.rotateSpeed=.5,i.orbitControls.addEventListener("start",u),i.orbitControls.addEventListener("change",p),i.orbitControls.addEventListener("end",m)}let d=!1;function u(){d=!0,s.controls&&(i._mainTarget=s.controls.target.clone(),i._mainDistance=e.camera.position.distanceTo(s.controls.target))}function p(){if(d){if(e.camera.quaternion.copy(i.camera.quaternion),s.controls&&i._mainTarget&&i._mainDistance){const A=new P(0,0,1).applyQuaternion(e.camera.quaternion);e.camera.position.copy(i._mainTarget.clone().add(A.multiplyScalar(i._mainDistance))),s.controls.update()}s.renderer&&e.camera&&s.renderer.render(e,e.camera)}}function m(){d=!1,i._mainTarget=null,i._mainDistance=null}function v(){const A="/assets/viewcube/";let b=[{label:"右",icon:A+"cn_right.png"},{label:"左",icon:A+"cn_left.png"},{label:"顶",icon:A+"cn_top.png"},{label:"底",icon:A+"cn_bottom.png"},{label:"前",icon:A+"cn_front.png"},{label:"后",icon:A+"cn_back.png"}];var y=[];for(const M of b)y.push(new Wt({color:16777215,map:new lo().load(M.icon)}));new Ab({color:255});var x=new We(new fi(110,110,110),y);i.sceneOrtho.add(x),g(122);let _={x:0,y:0};r.addEventListener("mousedown",M=>{_.x=M.clientX,_.y=M.clientY}),r.addEventListener("mouseup",M=>{if(d)return;const E=M.clientX-_.x,w=M.clientY-_.y;if(Math.sqrt(E*E+w*w)>5)return;var T={};T.x=M.offsetX/r.clientWidth*2-1,T.y=-(M.offsetY/r.clientHeight)*2+1;var R=new fs;R.setFromCamera(T,i.camera);const D=R.intersectObjects(o,!1);D.length>0&&i.ToggleDirectionView(D[0].object.name)}),r.addEventListener("mousemove",M=>{var E={};E.x=M.offsetX/r.clientWidth*2-1,E.y=-(M.offsetY/r.clientHeight)*2+1;var w=new fs;w.setFromCamera(E,i.camera);const T=w.intersectObjects(o,!1);for(var R of o)R.material.opacity=.01;T.length>0&&(T[0].object.material.opacity=.2)})}function g(A){for(var b=A*.5-20,y=[{name:"right",a:30,b:75,c:75,point:new P(b,0,0)},{name:"back",a:75,b:75,c:30,point:new P(0,0,-b)},{name:"left",a:30,b:75,c:75,point:new P(-b,0,0)},{name:"front",a:75,b:75,c:30,point:new P(0,0,b)},{name:"top",a:75,b:30,c:75,point:new P(0,b,0)},{name:"button",a:75,b:30,c:75,point:new P(0,-b,0)}],x=[{name:"top_right_back",a:30,b:30,c:30,point:new P(-b,b,b)},{name:"button_front_right",a:30,b:30,c:30,point:new P(-b,-b,b)},{name:"top_front_right",a:30,b:30,c:30,point:new P(b,b,b)},{name:"button_right_back",a:30,b:30,c:30,point:new P(b,-b,b)},{name:"top_back_left",a:30,b:30,c:30,point:new P(-b,b,-b)},{name:"button_back_left",a:30,b:30,c:30,point:new P(-b,-b,-b)},{name:"top_left_front",a:30,b:30,c:30,point:new P(b,b,-b)},{name:"button_left_front",a:30,b:30,c:30,point:new P(b,-b,-b)}],_=[{name:"top_front",a:30,b:30,c:75,point:new P(b,b,0)},{name:"top_right",a:75,b:30,c:30,point:new P(0,b,b)},{name:"top_back",a:30,b:30,c:75,point:new P(-b,b,0)},{name:"top_left",a:75,b:30,c:30,point:new P(0,b,-b)},{name:"button_front",a:30,b:30,c:75,point:new P(b,-b,0)},{name:"button_right",a:75,b:30,c:30,point:new P(0,-b,b)},{name:"button_back",a:30,b:30,c:75,point:new P(-b,-b,0)},{name:"button_left",a:75,b:30,c:30,point:new P(0,-b,-b)},{name:"front_right",a:30,b:75,c:30,point:new P(b,0,b)},{name:"right_back",a:30,b:75,c:30,point:new P(-b,0,b)},{name:"back_left",a:30,b:75,c:30,point:new P(-b,0,-b)},{name:"left_front",a:30,b:75,c:30,point:new P(b,0,-b)}],M=0;M<y.length;M++)o.push(f(y[M]));for(var M=0;M<x.length;M++)o.push(f(x[M]));for(var M=0;M<_.length;M++)o.push(f(_[M]))}function f(A){const b=new fi(A.a,A.b,A.c),y=new Wt({color:"blue",transparent:!0,opacity:.01}),x=new Ke().makeTranslation(A.point.x,A.point.y,A.point.z);let _=b.applyMatrix4(x),M=new We(_,y);return M.name=A.name,i.sceneOrtho.add(M),M}return i.ToggleCameraType=function(){s.cameraModule.switchCurrentCamera()},i.TakeScreenshot=function(){try{if(!s.renderer){console.error("渲染器未初始化");return}s.renderer.render(e,e.camera);const A=s.renderer.domElement.toDataURL("image/png"),b=document.createElement("a"),y=new Date().toISOString().replaceAll(/[:.]/g,"-");b.download=`screenshot_${y}.png`,b.href=A,b.click(),console.log("截图已保存")}catch(A){console.error("截图失败:",A)}},i.ToggleFullscreen=function(){const A=t||document.documentElement;!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.mozFullScreenElement&&!document.msFullscreenElement?(A.requestFullscreen?A.requestFullscreen():A.webkitRequestFullscreen?A.webkitRequestFullscreen():A.mozRequestFullScreen?A.mozRequestFullScreen():A.msRequestFullscreen&&A.msRequestFullscreen(),console.log("已进入全屏模式")):(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),console.log("已退出全屏模式"))},i}class QQ{engine;cubeTool;mainViewPort;constructor(e){this.engine=e}init(){this.cubeTool=WQ(this.engine,this.engine.scene,this.engine.container),this.cubeTool.init()}CameraGoHome(e){if(this.mainViewPort){this.goToMainPort();return}this.cubeTool.CameraGoHome(e)}cameraGoHome(e){if(this.mainViewPort){this.goToMainPort();return}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{}}saveMainViewPort(){const e=this.engine.cameraModule.perspectiveCamera,t=this.engine.cameraModule.orthographicCamera,i=this.engine.controls;return this.mainViewPort={activeCamera:this.engine.cameraModule.getCameraType(),perspectiveCamera:{position:e.position.clone(),quaternion:e.quaternion.clone(),target:i.target.clone(),fov:e.fov,near:e.near,far:e.far,up:e.up.clone()},orthographicCamera:{position:t.position.clone(),quaternion:t.quaternion.clone(),target:i.target.clone(),zoom:t.zoom,left:t.left,right:t.right,top:t.top,bottom:t.bottom,near:t.near,far:t.far,up:t.up.clone()}},this.mainViewPort}setMainViewPort(e){this.mainViewPort=e,this.goToMainPort()}goToMainPort(){const e=this.mainViewPort;if(!e)return;this.engine.cameraModule.getCameraType()!==e.activeCamera&&(e.activeCamera==="orthographic"?this.engine.cameraModule.switchToOrthographicCamera():this.engine.cameraModule.switchToPerspectiveCamera());const t=e.activeCamera==="orthographic"?e.orthographicCamera:e.perspectiveCamera;if(e.activeCamera==="orthographic"){const i=this.engine.cameraModule.orthographicCamera;i.left=t.left,i.right=t.right,i.top=t.top,i.bottom=t.bottom,i.zoom=t.zoom,i.updateProjectionMatrix()}else{const i=this.engine.cameraModule.perspectiveCamera;i.fov=t.fov,i.updateProjectionMatrix()}this.engine.camera.up.copy(t.up),this.cubeTool.ReductionCameraPose(t,500)}resetMainViewPort(){this.mainViewPort=null,this.cubeTool.CameraGoHome()}screenshot(){this.cubeTool.TakeScreenshot()}}function jQ(s){let e=new Object;return e.getBoundingBox=function(){let t=s.models,i=new P(1e8,1e9,1e10),n=new P(-1e8,-1e9,-1e10);t.forEach(d=>{let u=new P(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)),p=new P(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));u.x<i.x&&(i.x=u.x),u.y<i.y&&(i.y=u.y),u.z<i.z&&(i.z=u.z),p.x>n.x&&(n.x=p.x),p.y>n.y&&(n.y=p.y),p.z>n.z&&(n.z=p.z)});let r=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 P(r,a,o),max:new P(l,c,h)}},e.rayInterationModel=function(t,i,n=!0){let r=[];return s.engineStatus.models.forEach(o=>{o.info.lods.forEach(l=>{let c=l.octreeBox;a(t,c,o)})}),r=r.filter(o=>o instanceof We),n&&(r=r.filter(o=>o.geometry.attributes.position.count<1e3)),r.forEach(o=>{o.box||(o.box=new xt().setFromObject(o))}),r=r.filter(o=>t.ray.intersectsBox(o.box,!1)==!0),t.intersectObjects(r,!1);function a(o,l,c){if(l==null)return;let h=new P(l.min.X*.3048,l.min.Z*.3048,-l.min.Y*.3048),d=new P(l.max.X*.3048,l.max.Z*.3048,-l.max.Y*.3048),u=new P(Math.min(h.x,d.x),Math.min(h.y,d.y),Math.min(h.z,d.z)),p=new P(Math.max(d.x,h.x),Math.max(d.y,h.y),Math.max(d.z,h.z)),m=new xt(u,p),v=o.ray.intersectsBox(m);if(!(v==null||v==!1))if(l.children==null||l.children.length==0){if(l.elements!=null)for(var g of l.elements){if(!s.engineStatus.isFree&&i==!1)continue;let f=s.engineStatus.hideModels.find(y=>y.url==c.url)?.ids;if(f!=null&&f.includes(g))continue;let A=s.engineStatus.translucentModels.find(y=>y.url==c.url)?.ids;if(A!=null&&A.includes(g))continue;let b=s.models.find(y=>y.url==c.url).nodesMap.get(g);b!=null&&!b.instance&&b.infos!=null&&b.infos.map(y=>y.mesh).forEach(y=>{r.push(y)})}}else{if(l.elements!=null)for(var g of l.elements){let A=s.engineStatus.hideModels.find(x=>x.url==c.url)?.ids;if(A!=null&&A.includes(g))continue;let b=s.engineStatus.translucentModels.find(x=>x.url==c.url)?.ids;if(b!=null&&b.includes(g))continue;let y=s.models.find(x=>x.url==c.url).nodesMap.get(g);y!=null&&!y.instance&&y.infos!=null&&y.infos.map(x=>x.mesh).forEach(x=>{r.push(x)})}for(let f of l.children)a(o,f,c)}}},e}class XQ{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 Kt(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),r=Math.min(this.startPoint.y,this.endPoint.y),a=Math.max(this.startPoint.y,this.endPoint.y),o=[],l=[{x:i,y:r},{x:n,y:r},{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 xt;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 P;e.getCenter(n);const r=new P;e.getSize(r);const a=Math.max(r.x,r.y,r.z);if(t instanceof wi){const o=t.fov*(Math.PI/180),l=a/(2*Math.tan(o/2))*1.2,c=new P;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 Zi){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 P;t.getWorldDirection(h);const d=a*1.5,u=n.clone().sub(h.multiplyScalar(d));t.position.copy(u),i.target&&i.target.copy(n),t.lookAt(n),i.update()}}}const qQ=Bt.degToRad(10),W3=.001,v1=!1,YQ=[];class KQ{engine;rootGroup=null;isVisible=v1;axes=[];coordinateMapper=e=>new P(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:YQ)}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()}getVisible(){return this.isVisible}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 Zi){const n=(e.top-e.bottom)/e.zoom,r=t.domElement.clientHeight||1;i=30*n/r}this.rootGroup.traverse(n=>{n instanceof gu&&n.scale.set(i,i,1)})}getLocationByPoint(e,t){const{url:i,targetPoint:n}=this.resolvePointLookupArgs(e,t),r=this.getGridData(i);debugger;if(r.length===0)return null;const a=this.toVector3(n),o=new be(a.x,a.z),l=this.buildAxisFamilies(r).sort((u,p)=>p.axes.length-u.axes.length).slice(0,2).map((u,p)=>({...u,familyIndex:p}));if(l.length===0)return null;const c=l.map(u=>this.resolveFamilyLocation(u,o)),h=this.sortFamiliesForDisplay(c),d=h.length===2&&h.every(u=>u.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 Si,this.rootGroup.name="GridRoot",this.rootGroup.visible=v1,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 Si;n.name=`GridAxis_${e.data.Id}`;const r=new dt().setFromPoints([t,i]),a=new bi({color:1609983,depthTest:!1}),o=new Ci(r,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 r=128/2,a=128/2,o=128/2-4;n.beginPath(),n.arc(r,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,r,a);const l=new KE(i),c=new bm({map:l,depthTest:!1,transparent:!0}),h=new gu(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 r=t.find(a=>a.direction.angleTo(n.direction)<=qQ);if(r){r.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,r)=>n.offset-r.offset)}),t}createProjection(e){const t=this.coordinateMapper(e.Points[0]),i=this.coordinateMapper(e.Points[1]),n=new be(t.x,t.z),r=new be(i.x,i.z),a=r.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:r,direction:o,offset:n.dot(l)}}normalizeDirection(e){const t=e.clone().normalize();return(t.x<0||Math.abs(t.x)<=W3&&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)<=W3)??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 r=null,a=null;e.axes.forEach(c=>{if(c.offset<i){r=c;return}a||(a=c)});let o="",l=!1;if(r&&a)o=this.formatAxisPair(r.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:r?.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,r=t<e.length-1?e[t+1]:null;if(!i)return null;if(n&&r){const a=Math.abs(i.offset-n.offset),o=Math.abs(r.offset-i.offset);return a<=o?[n,i]:[i,r]}return n?[n,i]:r?[i,r]: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]],r=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 r<=a?i:n}sortFamiliesForDisplay(e){return[...e].sort((t,i)=>{const n=this.getFamilySampleLabel(t),r=this.getFamilySampleLabel(i),a=this.isNumericLabel(n),o=this.isNumericLabel(r);return a!==o?a?1:-1:this.compareLabels(n,r)})}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 P?e.clone():new P(e.x,e.y,e.z)}}class $Q extends We{constructor(e,t={}){super(e),this.isWater=!0;const i=this,n=t.textureWidth!==void 0?t.textureWidth:512,r=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 P(.70707,.70707,0),d=new qe(t.sunColor!==void 0?t.sunColor:16777215),u=new qe(t.waterColor!==void 0?t.waterColor:8355711),p=t.eye!==void 0?t.eye:new P(0,0,0),m=t.distortionScale!==void 0?t.distortionScale:20,v=t.side!==void 0?t.side:Yn,g=t.fog!==void 0?t.fog:!1,f=new $t,A=new P,b=new P,y=new P,x=new Ke,_=new P(0,0,-1),M=new zt,E=new P,w=new P,T=new zt,R=new Ke,D=new wi,L=new ki(n,r,{type:li}),I={name:"MirrorShader",uniforms:Mn.merge([et.fog,et.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 qe(8355711)},sunDirection:{value:new P(.70707,.70707,0)},eye:{value:new P},waterColor:{value:new qe(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>
|
||
}`},O=new mi({name:I.name,uniforms:Mn.clone(I.uniforms),vertexShader:I.vertexShader,fragmentShader:I.fragmentShader,lights:!0,side:v,fog:g});O.uniforms.mirrorSampler.value=L.texture,O.uniforms.textureMatrix.value=R,O.uniforms.alpha.value=o,O.uniforms.time.value=l,O.uniforms.normalSampler.value=c,O.uniforms.sunColor.value=d,O.uniforms.waterColor.value=u,O.uniforms.sunDirection.value=h,O.uniforms.distortionScale.value=m,O.uniforms.eye.value=p,i.material=O,i.onBeforeRender=function(N,G,V){if(b.setFromMatrixPosition(i.matrixWorld),y.setFromMatrixPosition(V.matrixWorld),x.extractRotation(i.matrixWorld),A.set(0,0,1),A.applyMatrix4(x),E.subVectors(b,y),E.dot(A)>0)return;E.reflect(A).negate(),E.add(b),x.extractRotation(V.matrixWorld),_.set(0,0,-1),_.applyMatrix4(x),_.add(y),w.subVectors(b,_),w.reflect(A).negate(),w.add(b),D.position.copy(E),D.up.set(0,1,0),D.up.applyMatrix4(x),D.up.reflect(A),D.lookAt(w),D.far=V.far,D.updateMatrixWorld(),D.projectionMatrix.copy(V.projectionMatrix),R.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),R.multiply(D.projectionMatrix),R.multiply(D.matrixWorldInverse),f.setFromNormalAndCoplanarPoint(A,b),f.applyMatrix4(D.matrixWorldInverse),M.set(f.normal.x,f.normal.y,f.normal.z,f.constant);const H=D.projectionMatrix;T.x=(Math.sign(M.x)+H.elements[8])/H.elements[0],T.y=(Math.sign(M.y)+H.elements[9])/H.elements[5],T.z=-1,T.w=(1+H.elements[10])/H.elements[14],M.multiplyScalar(2/M.dot(T)),H.elements[2]=M.x,H.elements[6]=M.y,H.elements[10]=M.z+1-a,H.elements[14]=M.w,p.setFromMatrixPosition(V.matrixWorld);const J=N.getRenderTarget(),W=N.xr.enabled,X=N.shadowMap.autoUpdate;i.visible=!1,N.xr.enabled=!1,N.shadowMap.autoUpdate=!1,N.setRenderTarget(L),N.state.buffers.depth.setMask(!0),N.autoClear===!1&&N.clear(),N.render(G,D),i.visible=!0,N.xr.enabled=W,N.shadowMap.autoUpdate=X,N.setRenderTarget(J);const me=V.viewport;me!==void 0&&N.state.viewport(me)}}}const Q3="0",j3=0,X3=!1;class A1{engine;currentId=Q3;groundGroup;groundMesh=null;isWaterAddon=!1;clock;groundY=j3;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 Si,this.groundGroup.name="groundGroup",this.clock=new $M}init(){this.engine.scene.add(this.groundGroup),this.groundGroup.visible=X3}setGround(e,t){if(this._dispose(),this.currentId=e,e==="0")return;const i=this.groundList.find(r=>r.id===e);debugger;if(!i)return;const n=t?.size??3e4;if(i.water){const r=new Ds(n,n),a=A1.DEFAULT_WATER_NORMALS,o=new lo().load(a,p=>{p.wrapS=p.wrapT=ln}),l=t?.sunDirection??new P(.5,.8,.5).normalize(),c=t?.distortionScale??i.distortionScale??3.7,h=t?.waterSize??i.size??1,d=t?.opacity??.92,u=new $Q(r,{textureWidth:512,textureHeight:512,waterNormals:o,sunDirection:l.clone(),sunColor:16777215,waterColor:i.waterColor??28062,distortionScale:c,alpha:d,fog:!!this.engine.scene?.fog});u.rotation.x=-Math.PI/2,u.position.y=-.01,u.name="groundMesh",u.receiveShadow=!0,u.castShadow=!1,this.ensureWaterShadowUniforms(u.material),u.material.uniforms.size.value=h,this.groundMesh=u,this.isWaterAddon=!0,this.groundGroup.add(u)}else{const r=new Ds(n,n,1,1);r.rotateX(-Math.PI/2);const a=new oo({color:i.color,roughness:i.roughness,metalness:i.metalness}),o=t?.textureUrl??i.map;o&&new lo().load(o,c=>{c.wrapS=c.wrapT=ln,c.repeat.set(1e4,1e4),a.map=c,a.needsUpdate=!0},void 0,()=>{});const l=new We(r,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}getVisible(){return this.groundGroup.visible}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}}const Hr="0",ZQ=!0,q3=.2;class JQ{engine;currentHdrId=Hr;isVisible=ZQ;currentIntensity=q3;currentTexture=null;currentEnvironmentTexture=null;skybox=null;textureCache=new Map;previousBackground=null;previousEnvironment=null;previousBackgroundIntensity=1;previousEnvironmentIntensity=1;previousAmbientLightIntensity=1;previousToneMapping=on;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"},{id:"99",names:["默认","默认","default"],url:"assets/hdr/99.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===Hr||!t.url){this._clearHdr(),this.currentHdrId=Hr,this.engine.engineModelModule.setOutputPass(!0);return}if(this.textureCache.has(e)){this._applyTexture(this.textureCache.get(e)),this.currentHdrId=e;return}this.engine.engineModelModule.setOutputPass(!1);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===Hr)&&(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 HQ().load(e,n=>{n.mapping=Dc,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 Ou(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=Yr,this.engine.renderer.toneMappingExposure=1,this._removeSkybox(),this._createSkybox(e),this._setAmbientLightIntensity(0)}_captureSceneState(){this.currentHdrId!==Hr||!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??on,this.previousToneMappingExposure=this.engine.renderer?.toneMappingExposure??1)}_createSkybox(e){if(!this.engine.scene)return;const t=new ao(1e3,64,32),i=new Wt({map:e,side:an,depthWrite:!1,depthTest:!1,fog:!1,toneMapped:!0});this.skybox=new We(t,i),this.skybox.name="hdr_skybox",this.skybox.renderOrder=-1e3,this.skybox.frustumCulled=!1,this.skybox.visible=this.isVisible,this.skybox.onBeforeRender=(n,r,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=on,this.previousToneMappingExposure=1)}_getAmbientLightIntensity(){return this.engine.scene?.children.find(e=>e instanceof Lu)?.intensity??1}_setAmbientLightIntensity(e){this.engine.setting.setAmbientLightIntensity(e)}}const ej=.001,Y3=!1,tj=[{Id:"339",Name:"L1",Elevation:-.32808398950131235},{Id:"2787",Name:"L2",Elevation:16.896325459317584},{Id:"236633",Name:"L3",Elevation:36.745406824146976}];class ij{engine;isVisible=Y3;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:tj,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()}getVisible(){return this.isVisible}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),r=this.getLevelData(i).slice().sort((p,m)=>p.Elevation-m.Elevation);if(r.length===0)return null;const a=n.y,o=r.find(p=>Math.abs(p.Elevation-a)<=ej)??null;if(o)return{pointY:a,description:`${o.Name}`,currentLevel:o,lowerLevel:o,upperLevel:o,isOnLevel:!0,isInside:!0};let l=null,c=null;r.forEach(p=>{if(p.Elevation<a){l=p;return}c||(c=p)});const h=this.pickNearestLevel(a,l,c),d=h?`标高${h.Name}`:"";let u=!1;return l&&c&&(u=!0),{pointY:a,description:d,currentLevel:h,lowerLevel:l,upperLevel:c,isOnLevel:!1,isInside:u}}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 Kt(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 P(t.min.x,t.min.y,t.min.z),n=new P(t.max.x,t.max.y,t.max.z);this.halfSize=n.distanceTo(i);const r=e.data.Elevation,a=new Si,o=new Ds(this.halfSize*2,this.halfSize*2);o.rotateX(-Math.PI/2);const l=new Wt({color:this.COLOR,transparent:!0,opacity:this.PLANE_OPACITY,side:qt,depthWrite:!1}),c=new We(o,l);c.position.y=r,a.add(c);const h=[new P(-this.halfSize,r,-this.halfSize),new P(this.halfSize,r,-this.halfSize),new P(this.halfSize,r,this.halfSize),new P(-this.halfSize,r,this.halfSize),new P(-this.halfSize,r,-this.halfSize)],d=new dt().setFromPoints(h),u=new bi({color:this.COLOR,transparent:!0,opacity:.7});if(a.add(new Ci(d,u)),a.visible=this.isVisible,this.engine.scene.add(a),e.group=a,this.svgOverlay){const p=document.createElementNS("http://www.w3.org/2000/svg","g");p.dataset.levelId=e.data.Id;for(let m=0;m<4;m+=1)p.appendChild(this._makeLabel(e.data.Name,e.data.Elevation));this.svgOverlay.appendChild(p),e.svgGroup=p}}_updateSvgLabels(e){if(!e.svgGroup||!this.worldToScreen)return;const t=e.data.Elevation,i=[new P(-this.halfSize,t,-this.halfSize),new P(this.halfSize,t,-this.halfSize),new P(this.halfSize,t,this.halfSize),new P(-this.halfSize,t,this.halfSize)],n=Array.from(e.svgGroup.children);i.forEach((r,a)=>{const o=this.worldToScreen?.worldToScreen(r);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),r=Math.abs(i.Elevation-e);return n<=r?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 xt;let t=!1;return this.engine.models.forEach(i=>{const n=i.boundingBox;if(!n)return;const r=new P(n.min.x,n.min.y,n.min.z),a=new P(n.max.x,n.max.y,n.max.z);if(!t){e.min.copy(r),e.max.copy(a),t=!0;return}e.expandByPoint(r),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}}}}const b1=!0,K3=.6;class nj{engine;isActive=b1;groupEdge;material;modelEdgeLoaded=!1;modelEdgeLoadingPromise=null;indexes=new Map;constructor(e){this.engine=e,this.groupEdge=this.engine.scene.getObjectByName("groupEdge"),this.material=new bi({color:"#000000",depthTest:!0,transparent:!0,opacity:K3}),this.material.clippingPlanes=this.engine.sectionPlane,this.groupEdge.visible=b1}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})})}isEnabled(){return this.isActive}getOpacity(){return this.material.opacity}hasPendingModelEdges(){return(this.engine?.engineStatus?.models??[]).some(e=>!this.indexes.has(e.url))}loadZipJsonAsync(e,t){return new Promise((i,n)=>{lp(e,r=>{if(r==null){n(new Error(`[ModelEdge] empty edge zip: ${e}`));return}i(r)},()=>{n(new Error(`[ModelEdge] failed to load edge zip: ${e}`))},t)})}async ensureModelEdgeData(e){const t=e?.info??{};if(Array.isArray(t.modelEdge))return t.modelEdge;try{const i=this.engine.engineStatus.models.find(a=>a.url==e.url),n=await this.loadZipJsonAsync(e.url+"/edge",i?.key),r=JSON.parse(n);t.modelEdge=Array.isArray(r)?r:[]}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=[],r=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));r.set(Number(a.id),[o,n.length,a.points])}),this.indexes.set(t.url,r)}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 r=new dt;r.setAttribute("position",new it(n,3));const a=new Oi(r,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[r,a]=n,o=this.groupEdge.children.find(l=>l.url==e);if(o){const l=o.geometry.attributes.position.array;for(let c=r;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[r,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=r;d<a;d+=3){const u=Math.floor(h/6),p=h%6>=3;if(o[u]&&o[u].length===2){const m=p?o[u][1]:o[u][0];c[d]=m.X,c[d+1]=m.Z,c[d+2]=-m.Y}h+=3}l.geometry.attributes.position.needsUpdate=!0}}}}class V0 extends We{constructor(){const e=V0.SkyShader,t=new mi({name:e.name,uniforms:Mn.clone(e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,side:an,depthWrite:!1});super(new fi(1,1,1),t),this.isSky=!0}}V0.SkyShader={name:"SkyShader",uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new P},up:{value:new P(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 $3={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},y1="sunrise_clear",Z3=.2,x1=[{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}}],J3=x1.reduce((s,e)=>(s[e.id]=e,s),{}),eI=2e6;class sj{engine;sky=null;sun=new P;params={...$3,...J3[y1].params};currentPreset=y1;currentIntensity=Z3;currentEnvironmentTarget=null;skyScale=45e4;skyName="bim_engine_sky";savedCameraFar=null;previousBackground=null;previousEnvironment=null;previousBackgroundIntensity=1;previousEnvironmentIntensity=1;previousToneMapping=on;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 V0;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=Yr,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=J3[e];t&&(this.currentPreset=e,this.params={...$3,...t.params},this._applyParamsToSky(),this.engine?.renderer&&(this.engine.renderer.toneMappingExposure=this._getEffectiveExposure()))}getCurrentPreset(){return this.currentPreset}getPresetNames(){return x1.map(e=>e.id)}getPresetList(){return x1.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>=eI||(this.savedCameraFar==null&&(this.savedCameraFar=t),e.far=eI,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=Bt.degToRad(90-this.params.elevation),i=Bt.degToRad(this.params.azimuth);this.sun.setFromSphericalCoords(1,t,i),this._setUniformValue(e,"sunPosition",this.sun),this.engine?.renderer&&(this.engine.renderer.toneMapping=Yr,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??on,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=on,this.previousToneMappingExposure=1,this.hasCapturedSceneState=!1))}_refreshEnvironmentMap(){if(!this.sky||!this.engine?.renderer||!this.engine?.scene)return;this._disposeEnvironmentTarget();const e=new ll,t=this.sky.clone();t.material=this.sky.material.clone(),e.add(t);const i=new Ou(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 P&&typeof n.value?.copy=="function"?n.value.copy(i):n.value=i)}}class rj{engine;defaultSettings;settings;environmentApplyVersion=0;constructor(e){this.engine=e,this.defaultSettings=this._buildDefaultSettingsFromModules(),this.settings=this._clone(this.defaultSettings)}init(){this.defaultSettings=this._buildDefaultSettingsFromModules(),this.settings=this._clone(this.defaultSettings)}getSettings(){return this._syncSettingsFromModules(),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(this.defaultSettings),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.renderer;t&&(t.toneMapping===on&&(t.toneMapping=Yr),t.toneMappingExposure=2*e,t.toneMappingExposure==1?this.engine.renderer.toneMapping=0:this.engine.renderer.toneMapping=Yr)}_syncSettingsFromModules(){this.settings=this._readCurrentSettingsFromModules()}_buildDefaultSettingsFromModules(){const e=this.engine.composerModule?.saturationPass?.uniforms?.saturation?.value,t=this.engine.composerModule?.saturationPass?.uniforms?.contrast?.value,i=this.engine.composerModule?.gtaoPass?.blendIntensity,n=this.engine.renderer?.toneMappingExposure,r=this.engine.modelEdge?.getOpacity?.(),a=this.engine.hdr?.getCurrentHdrId?.()??Hr,o=this.engine.hdr?.getIntensity?.(),l=this.engine.skyManager?.getIntensity?.(),c=this.engine.skyManager?.getCurrentPreset?.()??y1,h=this.engine.skyManager?.isActive?.()===!0;return{render:{mode:this._toRenderMode(this.engine.engineModelModule?.getCurrentMode?.()),contrast:this._uniformToPercent(t,_2),saturation:this._uniformToPercent(e,x2),shadowIntensity:this._shadowToPercent(this._getDirectionalLightShadowIntensity(),O0),lightIntensity:this._exposureToPercent(n,l2),gtaoIntensity:this._unitToPercent(i,y2)},display:{showEdge:this.engine.modelEdge?.isEnabled?.()??b1,edgeOpacity:this._unitToPercent(r,K3),showGrid:this.engine.grid?.getVisible?.()??v1,showLevel:this.engine.level?.getVisible?.()??Y3,showGround:this.engine.ground?.getVisible?.()??X3,groundId:this.engine.ground?.getCurrentId?.()??Q3,groundHeight:this.engine.ground?.getHeight?.()??j3},environment:{type:h?"sky":a!==Hr?"hdr":"none",hdrId:a,hdrIntensity:this._unitToPercent(o,q3),skyPreset:c,skyParams:{},skyIntensity:this._unitToPercent(l,Z3)}}}_readCurrentSettingsFromModules(){const e=this.engine.composerModule?.saturationPass?.uniforms?.saturation?.value,t=this.engine.composerModule?.saturationPass?.uniforms?.contrast?.value,i=this.engine.composerModule?.gtaoPass?.blendIntensity,n=this.engine.renderer?.toneMappingExposure,r=this.engine.modelEdge?.getOpacity?.(),a=this.engine.hdr?.getCurrentHdrId?.()??this.settings.environment.hdrId,o=this.engine.hdr?.getIntensity?.(),l=this.engine.skyManager?.getIntensity?.(),c=this.engine.skyManager?.getCurrentPreset?.()??this.settings.environment.skyPreset,h=this.engine.skyManager?.getParams?.(),d=this.engine.skyManager?.isActive?.()===!0;return{render:{mode:this._toRenderMode(this.engine.engineModelModule?.getCurrentMode?.()??this.settings.render.mode),contrast:this._uniformToPercent(t,this.settings.render.contrast/100+.5),saturation:this._uniformToPercent(e,this.settings.render.saturation/100+.5),shadowIntensity:this._shadowToPercent(this._getDirectionalLightShadowIntensity(),this.settings.render.shadowIntensity/50),lightIntensity:this._exposureToPercent(n,this.settings.render.lightIntensity/50),gtaoIntensity:this._unitToPercent(i,this.settings.render.gtaoIntensity/100)},display:{showEdge:this.engine.modelEdge?.isEnabled?.()??this.settings.display.showEdge,edgeOpacity:this._unitToPercent(r,this.settings.display.edgeOpacity/100),showGrid:this.engine.grid?.getVisible?.()??this.settings.display.showGrid,showLevel:this.engine.level?.getVisible?.()??this.settings.display.showLevel,showGround:this.engine.ground?.getVisible?.()??this.settings.display.showGround,groundId:this.engine.ground?.getCurrentId?.()??this.settings.display.groundId,groundHeight:this.engine.ground?.getHeight?.()??this.settings.display.groundHeight},environment:{type:d?"sky":a!==Hr?"hdr":"none",hdrId:a,hdrIntensity:this._unitToPercent(o,this.settings.environment.hdrIntensity/100),skyPreset:c,skyParams:h?this._clone(h):this._clone(this.settings.environment.skyParams),skyIntensity:this._unitToPercent(l,this.settings.environment.skyIntensity/100)}}}_toRenderMode(e){return e==="simple"||e==="balance"||e==="advanced"?e:P3}_uniformToPercent(e,t){const i=typeof e=="number"?e:t;return this._clampPercent((i-.5)*100)}_shadowToPercent(e,t){const i=typeof e=="number"?e:t;return this._clampPercent(i*50)}_exposureToPercent(e,t){const i=typeof e=="number"?e:t;return this._clampPercent(i*50)}_unitToPercent(e,t){const i=typeof e=="number"?e:t;return this._clampPercent(i*100)}_clampPercent(e){return Math.min(100,Math.max(0,Math.round(e)))}_getDirectionalLightShadowIntensity(){const e=this.engine.scene?.children?.filter(t=>t instanceof tr);return!e||e.length===0?O0:(e.find(t=>t.castShadow)??e[0]).shadow?.intensity??O0}_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(Hr),t===this.environmentApplyVersion&&(this.engine.skyManager?.close(!0),t===this.environmentApplyVersion))switch(e.type){case"none":break;case"hdr":if(e.hdrId!==Hr){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 tr);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 Sa(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(s){var e=Math.random()*16|0,t=s=="x"?e:e&3|8;return t.toString(16)})}class Ca{engine;handelBehaved;setting;constructor(e){this.engine=e,this.handelBehaved=kx(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,t=!0;for(let i in e)for(let n=e[i].length-1;n>=0;n--){let r=e[i][n];r.isSelect==!0&&(r.container.remove(),e[i].splice(n,1),t=!1)}this.engine.measure.clearAllPoints(),t&&(this.engine.events.trigger("quit_measure_draw",!0),this.engine.measure.quitDraw())}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=>{r(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="50" 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(Di.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}let c=new Kt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point1),h=new Kt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point2),d=new Kt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point3),u=e.engine.reactBoundingClientRect.left,p=e.engine.reactBoundingClientRect.top;c.x+=u,c.y+=p,h.x+=u,h.y+=p,d.x+=u,d.y+=p;let m=l.container;m.getElementsByTagName("circle")[0].setAttribute("cx",c.x),m.getElementsByTagName("circle")[0].setAttribute("cy",c.y),m.getElementsByTagName("circle")[1].setAttribute("cx",h.x),m.getElementsByTagName("circle")[1].setAttribute("cy",h.y),m.getElementsByTagName("circle")[2].setAttribute("cx",d.x),m.getElementsByTagName("circle")[2].setAttribute("cy",d.y),m.getElementsByTagName("polyline")[0].setAttribute("points",c.x+","+c.y+" "+h.x+","+h.y),m.getElementsByTagName("polyline")[1].setAttribute("points",h.x+","+h.y+" "+d.x+","+d.y);let v=h.x,g=h.y-30;m.getElementsByTagName("rect")[0].setAttribute("x",v-40),m.getElementsByTagName("rect")[0].setAttribute("y",g-12.5),m.getElementsByTagName("text")[0].setAttribute("x",v),m.getElementsByTagName("text")[0].setAttribute("y",g+4),m.getElementsByTagName("text")[0].innerHTML=l.text,m.style.top="0px",m.style.left="0px"}function i(l){if(l.container==null){let y=['<svg class="measureSvg">','<polygon fill="rgba(0, 0, 255, 0.1)" stroke="none" 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="50" 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=y,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(Di.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}if(!l.points||l.points.length<2)return;let c=e.engine.reactBoundingClientRect.left,h=e.engine.reactBoundingClientRect.top,d=[],u=0,p=0;for(let y=0;y<l.points.length;y++){let x=new Kt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.points[y]);x.x+=c,x.y+=h,d.push(x),u+=x.x,p+=x.y}u=u/d.length,p=p/d.length;let m=d.map(y=>y.x+","+y.y).join(" "),v=[...d];d.length>=3&&v.push(d[0]);let g=v.map(y=>y.x+","+y.y).join(" "),f=l.container;f.getElementsByTagName("polygon")[0].setAttribute("points",d.length>=3?m:""),f.getElementsByTagName("polyline")[0].setAttribute("points",g);let A=u,b=p;f.getElementsByTagName("rect")[0].setAttribute("x",A-40),f.getElementsByTagName("rect")[0].setAttribute("y",b-12.5),f.getElementsByTagName("text")[0].setAttribute("x",A+10),f.getElementsByTagName("text")[0].setAttribute("y",b+4),f.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(l.text,2),f.style.top="0px",f.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(Di.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}let c=new Kt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point1),h=new Kt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point2),d=e.engine.reactBoundingClientRect.left,u=e.engine.reactBoundingClientRect.top;c.x+=d,c.y+=u,h.x+=d,h.y+=u;let p=l.container;p.getElementsByTagName("polyline")[0].setAttribute("points",c.x+","+c.y+" "+h.x+","+h.y);let m=(c.x+h.x)/2,v=(c.y+h.y)/2-30;p.getElementsByTagName("rect")[0].setAttribute("x",m-50),p.getElementsByTagName("rect")[0].setAttribute("y",v-12.5),p.getElementsByTagName("text")[0].setAttribute("x",m),p.getElementsByTagName("text")[0].setAttribute("y",v+4),p.getElementsByTagName("text")[0].innerHTML=l.text,p.style.top="0px",p.style.left="0px"}function r(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="50" 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="50" 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="50" 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(Di.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}let c=l.container,h=new Kt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point),d=e.engine.reactBoundingClientRect.left,u=e.engine.reactBoundingClientRect.top;h.x+=d,h.y+=u,c.style.top="0px",c.style.left="0px";let p=c.getElementsByTagName("circle")[0];p&&(p.setAttribute("cx",h.x),p.setAttribute("cy",h.y));let m=c.getElementsByTagName("rect"),v=c.getElementsByTagName("text"),g=-55;m[0]&&(m[0].setAttribute("x",h.x+10),m[0].setAttribute("y",h.y+10+g)),v[0]&&(v[0].setAttribute("x",h.x+10+50),v[0].setAttribute("y",h.y+10+16+g)),m[1]&&(m[1].setAttribute("x",h.x+10),m[1].setAttribute("y",h.y+10+30+g)),v[1]&&(v[1].setAttribute("x",h.x+10+50),v[1].setAttribute("y",h.y+10+46+g)),m[2]&&(m[2].setAttribute("x",h.x+10),m[2].setAttribute("y",h.y+10+60+g)),v[2]&&(v[2].setAttribute("x",h.x+10+50),v[2].setAttribute("y",h.y+10+76+g)),v[0]&&(v[0].innerHTML="X: "+e.getMeasureText(l.textX,1)),v[1]&&(v[1].innerHTML="Y: "+e.getMeasureText(-l.textZ,1)),v[2]&&(v[2].innerHTML="Z: "+e.getMeasureText(l.textY,1))}function a(l){if(l.container==null){let p=['<svg width="100" height="50" class="measureSvg">','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="50" 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=p,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(Di.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}let c=l.container,h=new Kt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point),d=e.engine.reactBoundingClientRect.left,u=e.engine.reactBoundingClientRect.top;c.style.top=h.y+u-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 m=['<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="50" 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=m,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(Di.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 Kt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point1),d=new Kt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point2),u=e.engine.reactBoundingClientRect.left,p=e.engine.reactBoundingClientRect.top;h.x+=u,h.y+=p,d.x+=u,d.y+=p,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+50-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 aj{engine;isActive=!1;tools;points=[];behavior;catchDir=0;type="point";constructor(e){this.engine=e,this.tools=new Ca(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active(),this.behavior.isClickSimpleModel=!1;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 r=e[n];if(!r)continue;typeof r.updateMatrixWorld=="function"&&r.updateMatrixWorld(!0);const a=new xt().setFromObject(r);!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 r=this.engine.interactionModule.getCatchMeshs(e);var i=this.getMeshesMinMaxY(r);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(r=>r.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:Sa(),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 r=new fs(n.add(new P(0,.01,0)),new P(0,this.catchDir==0?-1:1,0));i.point=this.points[0];const a=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(r))??this.engine.octreeBox.rayInterationModel(r);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(Di.MeasureChanged,t)}else{let n=new fs(e.catch.point.clone().add(new P(0,.01,0)),new P(0,this.catchDir==0?-1:1,0));const r=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(n))??this.engine.octreeBox.rayInterationModel(n);if(r.length===0){t.point2=null;return}t.point1=i.point,t.point2=r[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Di.MeasureChanged,t)}}}class oj{engine;tools;isActive=!1;points=[];behavior;constructor(e){this.engine=e,this.tools=new Ca(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(),this.behavior.isClickSimpleModel=!1;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(Di.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:Sa(),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 lj{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new Ca(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active(),this.behavior.isClickSimpleModel=!1;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:Sa(),isSelect:!0,type:"clear-distance"},this.engine.measure.annotationData.normalAnnotation.push(t));let i=new fs(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 r=e.catch;t.point1=r.point,t.point2=n[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Di.MeasureChanged,t)}}class cj{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new Ca(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active(),this.behavior.isClickSimpleModel=!1,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:Sa(),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(Di.MeasureChanged,t))}}class hj{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new Ca(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active(),this.behavior.isClickSimpleModel=!1,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.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);if(t==null){t={id:Sa(),point:e.catch.point.clone(),text:Math.round(e.catch.point.y)+" m",isSelect:!0,type:"point"},this.engine.measure.annotationData.coordinateAnnotation.push(t);return}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(Di.MeasureChanged,t)}createMeasure(){let e=this.engine.measure.annotationData.coordinateAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1,this.engine.events.trigger(Di.MeasureChanged,e))}}class dj{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new Ca(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active(),this.behavior.isClickSimpleModel=!1;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 P().subVectors(e,t),r=new P().subVectors(i,t),a=n.length(),o=r.length();if(a===0||o===0)return 0;const l=n.dot(r)/(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(Di.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:Sa(),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 uj{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new Ca(e)}getCurrentDrawingMeasure(){return this.engine.measure.annotationData.areaAnnotation.find(e=>e.isSelect==!0)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active(),this.behavior.isClickSimpleModel=!1;const 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;const t=e.length,i=new P(0,0,0);for(let n=0;n<t;n++){const r=(n+1)%t;i.x+=(e[n].y-e[r].y)*(e[n].z+e[r].z),i.y+=(e[n].z-e[r].z)*(e[n].x+e[r].x),i.z+=(e[n].x-e[r].x)*(e[n].y+e[r].y)}return i.length()/2}handleRightMouseClick(){this.finishMeasure()}handleMouseClick(e){if(e.catch==null)return;const t=e.catch;this.points.length===0&&this.engine.measure.tools.clearHighlight(),this.points.push(t.point.clone());let i=this.getCurrentDrawingMeasure();i==null?(i={id:Sa(),points:this.points.map(n=>n.clone()),area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(i)):i.points=this.points.map(n=>n.clone()),this.points.length>=3?(i.area=this.calculateArea(this.points),i.text=i.area):(i.area=0,i.text=0)}handleMouseMove(e){if(e.catch!=null&&this.points.length>=1){let t=this.getCurrentDrawingMeasure();t==null&&(t={id:Sa(),points:[],area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(t));const i=this.points.map(n=>n.clone());i.push(e.catch.point.clone()),t.points=i,i.length>=3?(t.area=this.calculateArea(i),t.text=t.area):(t.area=0,t.text=0)}}handelKeyEnterDown(){this.finishMeasure()}finishMeasure(){const e=this.getCurrentDrawingMeasure();e!=null&&this.points.length>=3?(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(Di.MeasureChanged,e)):this.engine.measure.tools.handelKeyEscDown()}}class pj{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new Ca(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active(),this.behavior.isClickSimpleModel=!1;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,r=t.z-e.z,a=Math.sqrt(n*n+r*r);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(r=>r.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)+"%",i.isSelect=!1,this.points=[],this.engine.events.trigger(Di.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(r=>r.isSelect==!0);i==null&&(i={id:Sa(),point1:this.points[0].clone(),point2:t.point.clone(),slopePercentage:0,slopeAngle:0,heightDiff:0,horizontalDist:0,text:"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)+"%"}}}class fj{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 aj(e),this.distanceMeasure=new oj(e),this.clearDistanceMeasure=new lj(e),this.elevationMeasure=new cj(e),this.pointMeasure=new hj(e),this.angleMeasure=new dj(e),this.areaMeasure=new uj(e),this.slopeMeasure=new pj(e),this.tools=new Ca(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()}quitDraw(){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 mj{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;transformHandleSize=1.05;transformHandleColor=16777215;transformHandleHoverColor=16776960;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(!1),this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0},!1),this.setTransformControlsVisible(!1),this.clearClippingBoxFill(),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},!1),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.updateClippingBoxFill(),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(e=!0){const t=this.engine.octreeBox.getBoundingBox();t.min.x-=.1,t.min.y-=.1,t.min.z-=.1,t.max.x+=.1,t.max.y+=.1,t.max.z+=.1,this.maxBox=JSON.parse(JSON.stringify(t)),this.box=t,this.updata_face(t),e&&this.updateClippingBoxFill()}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),this.updateClippingBoxFill()}setBox(e){this.box=e,this.updata_face(e),this.updateClippingBoxFill()}reverseBox(){}handleMouseDown(e){const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);if(t!=null&&t.length>0){this.clearClippingBoxFill();const i=t[0];this.isDrag=!0,this.pickPoint=i.point.clone(),this.pickMesh=i.object;const n=this.pickMesh?.userData?.dragNormal?.clone?.(),r=i.face?.normal?.clone?.();if(this.pickNormal=(n??r??new P(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 $t;a.setFromNormalAndCoplanarPoint(new P(0,1,0),this.pickPoint),this.plane=a}else{const a=new P(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z),o=new $t;o.setFromNormalAndCoplanarPoint(a.clone().sub(this.pickPoint.clone()).setLength(1),this.pickPoint),this.plane=o}}else this.isDrag=!1}handleMouseUp(e,t=!0){this.isDrag=!1,this.pickPoint=null,this.pickNormal=null,this.pickMesh=null,this.plane=null,this.engine.controls.enabled=!0,t&&this.updateClippingBoxFill()}clampVector3(e,t,i){return new P(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 P;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 r=this.box_.min.clone().add(this.pickNormal.clone().setLength(n));this.box.min=this.clampVector3(r,this.maxBox.min,this.box.max)}else{const r=this.box_.max.clone().add(this.pickNormal.clone().setLength(n));this.box.max=this.clampVector3(r,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),r=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:r},y:{min:a,max:o},z:{min:l,max:c}};this.engine.events.trigger(Di.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 fs,i=new be,n=this.engine.renderer.domElement.clientWidth,r=this.engine.renderer.domElement.clientHeight;return i.x=e.offsetX/n*2-1,i.y=-(e.offsetY/r)*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)})}updateClippingBoxFill(){const e=(Array.isArray(this.engine.sectionPlane)?this.engine.sectionPlane:[]).slice(0,6).filter(t=>t instanceof $t);if(e.length===0){this.clearClippingBoxFill();return}this.engine.clipping?.clippingCSGSimple?.updataFaces?.(e)}clearClippingBoxFill(){this.engine.clipping?.clippingCSGSimple?.clear?.()}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(r=>{if(r?.name!==t||!r.geometry)return;const a=r.geometry;a.boundingBox||a.computeBoundingBox();const o=a.boundingBox;if(!o)return;const l=o.getCenter(new P);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(r)}),n.forEach(r=>{r.parent?.remove(r)})}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 Pt;n.name=`SectionBoxTransformAnchor_${e}`,n.visible=this.isActive,this.engine.scene.add(n);const r=new z3(i,t);r.name=`SectionBoxTransformControl_${e}`,r.setMode("translate"),r.setSpace("local"),r.showX=!0,r.showY=!1,r.showZ=!1,r.size=this.transformHandleSize,r.setColors(this.transformHandleColor,this.transformHandleColor,this.transformHandleColor,this.transformHandleHoverColor),r.enabled=this.isActive,r.attach(n),this.keepSingleDirectionArrow(r,"X"),r.addEventListener("dragging-changed",o=>{this.engine.controls.enabled=!o.value,o.value===!0?this.clearClippingBoxFill():this.updateClippingBoxFill()}),r.addEventListener("objectChange",()=>{this.handleTransformObjectChange(e)});const a=r.getHelper();a.visible=this.isActive,this.engine.scene.add(a),this.transformAnchors.set(e,n),this.transformControls.set(e,r),this.transformHelpers.set(e,a)}updateFaceTransformControl(e,t,i,n){this.ensureFaceTransformControl(e);const r=this.transformAnchors.get(e),a=this.transformControls.get(e);if(!r||!a)return;const o=this.getFaceTransformOffset(),l=new Lt().setFromUnitVectors(new P(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,r.position.copy(c),r.quaternion.copy(l),r.visible=this.isActive,a.object!==r&&a.attach(r),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,r=this.getDominantAxis(n),a=this.getFaceTransformOffset(),o=n[r],l=t.position[r]-o*a;if(i.isMinFace){const c=this.maxBox.min[r],h=this.box.max[r];this.box.min[r]=Math.max(c,Math.min(h,l))}else{const c=this.box.min[r],h=this.maxBox.max[r];this.box.max[r]=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 Si,t.name="ClippingBox",this.engine.scene.add(t)),[{name:"前",normal:new P(0,0,-1),isMinFace:!0,planePoint:e.min,vertices:[new P(e.min.x,e.max.y,e.min.z),new P(e.max.x,e.max.y,e.min.z),new P(e.max.x,e.min.y,e.min.z),new P(e.min.x,e.min.y,e.min.z)]},{name:"后",normal:new P(0,0,1),isMinFace:!1,planePoint:e.max,vertices:[new P(e.min.x,e.min.y,e.max.z),new P(e.max.x,e.min.y,e.max.z),new P(e.max.x,e.max.y,e.max.z),new P(e.min.x,e.max.y,e.max.z)]},{name:"右",normal:new P(1,0,0),isMinFace:!1,planePoint:e.max,vertices:[new P(e.max.x,e.min.y,e.max.z),new P(e.max.x,e.min.y,e.min.z),new P(e.max.x,e.max.y,e.min.z),new P(e.max.x,e.max.y,e.max.z)]},{name:"左",normal:new P(-1,0,0),isMinFace:!0,planePoint:e.min,vertices:[new P(e.min.x,e.min.y,e.min.z),new P(e.min.x,e.min.y,e.max.z),new P(e.min.x,e.max.y,e.max.z),new P(e.min.x,e.max.y,e.min.z)]},{name:"顶",normal:new P(0,1,0),isMinFace:!1,planePoint:e.max,vertices:[new P(e.min.x,e.max.y,e.max.z),new P(e.max.x,e.max.y,e.max.z),new P(e.max.x,e.max.y,e.min.z),new P(e.min.x,e.max.y,e.min.z)]},{name:"底",normal:new P(0,-1,0),isMinFace:!0,planePoint:e.min,vertices:[new P(e.min.x,e.min.y,e.min.z),new P(e.max.x,e.min.y,e.min.z),new P(e.max.x,e.min.y,e.max.z),new P(e.min.x,e.min.y,e.max.z)]}].forEach(i=>{this.createFace(t,i.vertices,i.normal,i.name,i.isMinFace,i.planePoint)}),Rx(this.engine).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,r,a){const o=new dt,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 _t(l,3)),o.setIndex(c);let h=this.meshs.find(f=>f.name===n);if(h==null){const f=new Wt({color:65280,transparent:!0,opacity:this.faceIdleOpacity,side:qt});f.polygonOffset=!0,f.polygonOffsetFactor=1,f.polygonOffsetUnits=4,h=new We(o,f),h.name=n,e.add(h),this.meshs.push(h)}else h.geometry=o;h.userData={dragNormal:i.clone(),isMinFace:r,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]),u=new bi({color:255}),p=new dt;p.setAttribute("position",new _t(d,3));let m=this.meshs.find(f=>f.name===n+"Line");m==null?(m=new Ci(p,u),m.name=n+"Line",e.add(m),this.meshs.push(m)):(m.geometry=p,m.material=u);const v=new P;t.forEach(f=>v.add(f)),v.multiplyScalar(1/t.length),this.updateFaceTransformControl(n,i,v,r);const g=this.engine.sectionPlane.find(f=>f.name==n);g&&g.setFromNormalAndCoplanarPoint(i.clone().setLength(-1),a)}}class gj{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 P(0,0,1);distance=0;center=null;current_center=null;dragStartDistance=0;idleOpacity=.02;hoverOpacity=.05;transformControl=null;transformAnchor=null;transformHelper=null;isSyncingTransformControl=!1;moveEpsilon=1e-5;transformHandleSize=1.15;transformHandleColor=16777215;transformHandleHoverColor=16776960;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,r=Math.min(t.max,Math.max(t.min,n));Math.abs(r-Number(this.distance))>this.moveEpsilon?this.updata_face(r):Math.abs(n-r)>this.moveEpsilon&&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;Rx(e.engine).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},!1),this.setTransformControlVisible(!1),this.clearClippingFaceFill();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 P((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},!1),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 P(0,1,0).applyAxisAngle(new P(1,0,0),e).applyAxisAngle(new P(0,0,1),t).applyAxisAngle(new P(0,1,0),i).normalize(),this.updata_face(0),this.updateClippingFaceFill()}setFaceNormal(e,t=0){this.normal=e.clone().normalize(),this.distance=t,this.updata_face(t),this.updateClippingFaceFill()}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)}this.updateClippingFaceFill()}activateClippingOnly(){if(this.isActive)return;this.isActive=!0;const e=this;Rx(e.engine).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),this.updateClippingFaceFill()}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 Si,t.name="ClippingBox",this.engine.scene.add(t));const i=this.normal.clone().normalize(),n=this.center??new P((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:r,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,u=1/0,p=-1/0;o.forEach(b=>{const y=b.clone().sub(n),x=y.dot(r),_=y.dot(a);h=Math.min(h,x),d=Math.max(d,x),u=Math.min(u,_),p=Math.max(p,_)}),h-=c,d+=c,u-=c,p+=c;const m=i.clone().multiplyScalar(e),v=n.clone().add(r.clone().multiplyScalar(h)).add(a.clone().multiplyScalar(u)).add(m),g=n.clone().add(r.clone().multiplyScalar(d)).add(a.clone().multiplyScalar(u)).add(m),f=n.clone().add(r.clone().multiplyScalar(d)).add(a.clone().multiplyScalar(p)).add(m),A=n.clone().add(r.clone().multiplyScalar(h)).add(a.clone().multiplyScalar(p)).add(m);this.current_center=n.clone().add(m),this.createFace(t,[v,g,f,A],i,"face"),this.updateTransformControl(i)}createFace(e,t,i,n){const r=new dt,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];r.setAttribute("position",new _t(a,3)),r.setIndex(o);let l=this.meshs.find(m=>m.name==n);if(l==null){const m=new Wt({color:65280,transparent:!0,opacity:this.idleOpacity,side:qt});m.polygonOffset=!0,m.polygonOffsetFactor=1,m.polygonOffsetUnits=4,l=new We(r,m),l.name=n,e.add(l),this.meshs.push(l)}else l.geometry=r;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 bi({color:255}),d=new dt;d.setAttribute("position",new _t(c,3));let u=this.meshs.find(m=>m.name==n+"Line");u==null?(u=new Ci(d,h),u.name=n+"Line",e.add(u),this.meshs.push(u)):(u.geometry=d,u.material=h);const p=this.engine.sectionPlane.find(m=>m.name==n);p&&this.current_center&&p.setFromNormalAndCoplanarPoint(i.clone().setLength(this.direction),this.current_center)}getPlaneBasis(e){const t=new P(1,0,0),i=new P(0,1,0),n=new P(0,0,1),r=Math.abs(e.dot(t)),a=Math.abs(e.dot(i)),o=Math.abs(e.dot(n));let l=t;a<=r&&a<=o?l=i:o<=r&&o<=a&&(l=n),l=l.clone().sub(e.clone().multiplyScalar(l.dot(e))).normalize();const c=new P().crossVectors(e,l).normalize();return{tangent:l,bitangent:c}}getBoxCorners(e){return[new P(e.min.x,e.min.y,e.min.z),new P(e.min.x,e.min.y,e.max.z),new P(e.min.x,e.max.y,e.min.z),new P(e.min.x,e.max.y,e.max.z),new P(e.max.x,e.min.y,e.min.z),new P(e.max.x,e.min.y,e.max.z),new P(e.max.x,e.max.y,e.min.z),new P(e.max.x,e.max.y,e.max.z)]}getDistanceRange(e){if(!this.box)return{min:0,max:0};const t=this.center??new P((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,r=-1/0;return i.forEach(a=>{const o=a.clone().sub(t).dot(e);n=Math.min(n,o),r=Math.max(r,o)}),{min:n,max:r}}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(r=>{if(r?.name!==t||!r.geometry)return;const a=r.geometry;a.boundingBox||a.computeBoundingBox();const o=a.boundingBox;if(!o)return;const l=o.getCenter(new P);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(r)}),n.forEach(r=>{r.parent?.remove(r)})}ensureTransformControl(){if(this.transformControl&&this.transformAnchor)return;const e=this.engine.renderer?.domElement,t=this.engine.camera;if(!e||!t)return;const i=new Pt;i.name="SectionFaceTransformAnchor",i.visible=this.isActive,this.engine.scene.add(i);const n=new z3(t,e);n.name="SectionFaceTransformControl",n.setMode("translate"),n.setSpace("local"),n.showX=!0,n.showY=!1,n.showZ=!1,n.size=this.transformHandleSize,n.setColors(this.transformHandleColor,this.transformHandleColor,this.transformHandleColor,this.transformHandleHoverColor),n.enabled=this.isActive,n.attach(i),this.keepSingleDirectionArrow(n,"X"),n.addEventListener("dragging-changed",a=>{this.engine.controls.enabled=!a.value,a.value===!0?this.clearClippingFaceFill():this.updateClippingFaceFill()}),n.addEventListener("objectChange",this.handleTransformObjectChange);const r=n.getHelper();r.visible=this.isActive,this.engine.scene.add(r),this.transformAnchor=i,this.transformControl=n,this.transformHelper=r}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 Lt().setFromUnitVectors(new P(1,0,0),e.clone().normalize().multiplyScalar(-1));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 fs,i=new be,n=this.engine.renderer.domElement.clientWidth,r=this.engine.renderer.domElement.clientHeight;return i.x=e.offsetX/n*2-1,i.y=-(e.offsetY/r)*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)})}updateClippingFaceFill(){const e=this.engine.sectionPlane?.find?.(t=>t.name==="face");if(e){this.engine.clipping?.clippingCSGSimple?.updataFace?.(e);return}this.clearClippingFaceFill()}clearClippingFaceFill(){this.engine.clipping?.clippingCSGSimple?.clear?.()}handleMouseDown(e){const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);if(t!=null&&t.length>0){this.clearClippingFaceFill();const i=t[0],n=i.point.clone();this.isDrag=!0,this.pickPoint=n;const r=(i.face?.normal?.clone()??this.normal.clone()).clone();if(r.dot(this.normal)<0&&r.multiplyScalar(-1),r.normalize(),this.pickNormal=r,this.engine.controls.enabled=!1,this.dragStartDistance=Number(this.distance)||0,r.y==0){const a=new $t;a.setFromNormalAndCoplanarPoint(new P(0,1,0),n),this.plane=a}else{const a=new P(this.engine.camera.position.x,n.y,this.engine.camera.position.z),o=new $t;o.setFromNormalAndCoplanarPoint(a.clone().sub(n.clone()).setLength(1),n),this.plane=o}}else this.isDrag=!1}handleMouseUp(e,t=!0){this.isDrag=!1,this.pickPoint=null,this.pickNormal=null,this.plane=null,this.engine.controls.enabled=!0,t&&this.updateClippingFaceFill()}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,r=this.plane;if(i!=null&&n!=null&&r!=null){const a=new P;if(e.raycaster.ray.intersectPlane(r,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 vj{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==null&&(e.catch.normal=e.catch.face?.normal),!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})}}const tI=0,Aj=1,bj=2,iI=2,_1=1.25,nI=1,Hn=32,pn=Hn/4,sI=65535,yj=Math.pow(2,-24),w1=Symbol("SKIP_GENERATION");function xj(s){return s.index?s.index.count:s.attributes.position.count}function ec(s){return xj(s)/3}function _j(s,e=ArrayBuffer){return s>65535?new Uint32Array(new e(4*s)):new Uint16Array(new e(2*s))}function wj(s,e){if(!s.index){const t=s.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=_j(t,i);s.setIndex(new _t(n,1));for(let r=0;r<t;r++)n[r]=r}}function rI(s,e){const t=ec(s),i=e||s.drawRange,n=i.start/3,r=(i.start+i.count)/3,a=Math.max(0,n),o=Math.min(t,r)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function aI(s,e){if(!s.groups||!s.groups.length)return rI(s,e);const t=[],i=e||s.drawRange,n=i.start/3,r=(i.start+i.count)/3,a=ec(s),o=[];for(const h of s.groups){const{start:d,count:u}=h,p=d/3,m=isFinite(u)?u:a*3-d,v=(d+m)/3;p<r&&v>n&&(o.push({pos:Math.max(n,p),isStart:!0}),o.push({pos:Math.min(r,v),isStart:!1}))}o.sort((h,d)=>h.pos!==d.pos?h.pos-d.pos:h.type==="end"?-1:1);let l=0,c=null;for(const h of o){const d=h.pos;l!==0&&d!==c&&t.push({offset:c,count:d-c}),l+=h.isStart?1:-1,c=d}return t}function E1(s,e,t,i,n){let r=1/0,a=1/0,o=1/0,l=-1/0,c=-1/0,h=-1/0,d=1/0,u=1/0,p=1/0,m=-1/0,v=-1/0,g=-1/0;const f=s.offset||0;for(let A=(e-f)*6,b=(e+t-f)*6;A<b;A+=6){const y=s[A+0],x=s[A+1],_=y-x,M=y+x;_<r&&(r=_),M>l&&(l=M),y<d&&(d=y),y>m&&(m=y);const E=s[A+2],w=s[A+3],T=E-w,R=E+w;T<a&&(a=T),R>c&&(c=R),E<u&&(u=E),E>v&&(v=E);const D=s[A+4],L=s[A+5],I=D-L,O=D+L;I<o&&(o=I),O>h&&(h=O),D<p&&(p=D),D>g&&(g=D)}i[0]=r,i[1]=a,i[2]=o,i[3]=l,i[4]=c,i[5]=h,n[0]=d,n[1]=u,n[2]=p,n[3]=m,n[4]=v,n[5]=g}function oI(s,e,t=null,i=null,n=null){const r=s.attributes.position,a=s.index?s.index.array:null,o=r.normalized;if(n===null)n=new Float32Array(t*6),n.offset=e;else if(e<0||t+e>n.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const l=r.array,c=r.offset||0;let h=3;r.isInterleavedBufferAttribute&&(h=r.data.stride);const d=["getX","getY","getZ"],u=n.offset;for(let p=e,m=e+t;p<m;p++){const v=(i?i[p]:p)*3,g=(p-u)*6;let f=v+0,A=v+1,b=v+2;a&&(f=a[f],A=a[A],b=a[b]),o||(f=f*h+c,A=A*h+c,b=b*h+c);for(let y=0;y<3;y++){let x,_,M;o?(x=r[d[y]](f),_=r[d[y]](A),M=r[d[y]](b)):(x=l[f+y],_=l[A+y],M=l[b+y]);let E=x;_<E&&(E=_),M<E&&(E=M);let w=x;_>w&&(w=_),M>w&&(w=M);const T=(w-E)/2,R=y*2;n[g+R+0]=E+T,n[g+R+1]=T+(Math.abs(E)+T)*yj}}return n}function Ri(s,e,t){return t.min.x=e[s],t.min.y=e[s+1],t.min.z=e[s+2],t.max.x=e[s+3],t.max.y=e[s+4],t.max.z=e[s+5],t}function lI(s){let e=-1,t=-1/0;for(let i=0;i<3;i++){const n=s[i+3]-s[i];n>t&&(t=n,e=i)}return e}function cI(s,e){e.set(s)}function hI(s,e,t){let i,n;for(let r=0;r<3;r++){const a=r+3;i=s[r],n=e[r],t[r]=i<n?i:n,i=s[a],n=e[a],t[a]=i>n?i:n}}function W0(s,e,t){for(let i=0;i<3;i++){const n=e[s+2*i],r=e[s+2*i+1],a=n-r,o=n+r;a<t[i]&&(t[i]=a),o>t[i+3]&&(t[i+3]=o)}}function yp(s){const e=s[3]-s[0],t=s[4]-s[1],i=s[5]-s[2];return 2*(e*t+t*i+i*e)}const Ta=32,Ej=(s,e)=>s.candidate-e.candidate,Po=new Array(Ta).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Q0=new Float32Array(6);function Mj(s,e,t,i,n,r){let a=-1,o=0;if(r===tI)a=lI(e),a!==-1&&(o=(e[a]+e[a+3])/2);else if(r===Aj)a=lI(s),a!==-1&&(o=Sj(t,i,n,a));else if(r===bj){const l=yp(s);let c=_1*n;const h=t.offset||0,d=(i-h)*6,u=(i+n-h)*6;for(let p=0;p<3;p++){const m=e[p],v=(e[p+3]-m)/Ta;if(n<Ta/4){const g=[...Po];g.length=n;let f=0;for(let b=d;b<u;b+=6,f++){const y=g[f];y.candidate=t[b+2*p],y.count=0;const{bounds:x,leftCacheBounds:_,rightCacheBounds:M}=y;for(let E=0;E<3;E++)M[E]=1/0,M[E+3]=-1/0,_[E]=1/0,_[E+3]=-1/0,x[E]=1/0,x[E+3]=-1/0;W0(b,t,x)}g.sort(Ej);let A=n;for(let b=0;b<A;b++){const y=g[b];for(;b+1<A&&g[b+1].candidate===y.candidate;)g.splice(b+1,1),A--}for(let b=d;b<u;b+=6){const y=t[b+2*p];for(let x=0;x<A;x++){const _=g[x];y>=_.candidate?W0(b,t,_.rightCacheBounds):(W0(b,t,_.leftCacheBounds),_.count++)}}for(let b=0;b<A;b++){const y=g[b],x=y.count,_=n-y.count,M=y.leftCacheBounds,E=y.rightCacheBounds;let w=0;x!==0&&(w=yp(M)/l);let T=0;_!==0&&(T=yp(E)/l);const R=nI+_1*(w*x+T*_);R<c&&(a=p,c=R,o=y.candidate)}}else{for(let A=0;A<Ta;A++){const b=Po[A];b.count=0,b.candidate=m+v+A*v;const y=b.bounds;for(let x=0;x<3;x++)y[x]=1/0,y[x+3]=-1/0}for(let A=d;A<u;A+=6){let b=~~((t[A+2*p]-m)/v);b>=Ta&&(b=Ta-1);const y=Po[b];y.count++,W0(A,t,y.bounds)}const g=Po[Ta-1];cI(g.bounds,g.rightCacheBounds);for(let A=Ta-2;A>=0;A--){const b=Po[A],y=Po[A+1];hI(b.bounds,y.rightCacheBounds,b.rightCacheBounds)}let f=0;for(let A=0;A<Ta-1;A++){const b=Po[A],y=b.count,x=b.bounds,_=Po[A+1].rightCacheBounds;y!==0&&(f===0?cI(x,Q0):hI(x,Q0,Q0)),f+=y;let M=0,E=0;f!==0&&(M=yp(Q0)/l);const w=n-f;w!==0&&(E=yp(_)/l);const T=nI+_1*(M*f+E*w);T<c&&(a=p,c=T,o=b.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${r} used.`);return{axis:a,pos:o}}function Sj(s,e,t,i){let n=0;const r=s.offset;for(let a=e,o=e+t;a<o;a++)n+=s[(a-r)*6+i*2];return n/t}class M1{constructor(){this.boundingData=new Float32Array(6)}}function Cj(s,e,t,i,n,r){let a=i,o=i+n-1;const l=r.pos,c=r.axis*2,h=t.offset||0;for(;;){for(;a<=o&&t[(a-h)*6+c]<l;)a++;for(;a<=o&&t[(o-h)*6+c]>=l;)o--;if(a<o){for(let d=0;d<3;d++){let u=e[a*3+d];e[a*3+d]=e[o*3+d],e[o*3+d]=u}for(let d=0;d<6;d++){const u=a-h,p=o-h,m=t[u*6+d];t[u*6+d]=t[p*6+d],t[p*6+d]=m}a++,o--}else return a}}function Tj(s,e,t,i,n,r){let a=i,o=i+n-1;const l=r.pos,c=r.axis*2,h=t.offset||0;for(;;){for(;a<=o&&t[(a-h)*6+c]<l;)a++;for(;a<=o&&t[(o-h)*6+c]>=l;)o--;if(a<o){let d=s[a];s[a]=s[o],s[o]=d;for(let u=0;u<6;u++){const p=a-h,m=o-h,v=t[p*6+u];t[p*6+u]=t[m*6+u],t[m*6+u]=v}a++,o--}else return a}}let dI,j0,S1,uI;const Ij=Math.pow(2,32);function C1(s){return"count"in s?1:1+C1(s.left)+C1(s.right)}function Pj(s,e,t){return dI=new Float32Array(t),j0=new Uint32Array(t),S1=new Uint16Array(t),uI=new Uint8Array(t),T1(s,e)}function T1(s,e){const t=s/4,i=s/2,n="count"in e,r=e.boundingData;for(let a=0;a<6;a++)dI[t+a]=r[a];if(n)return e.buffer?(uI.set(new Uint8Array(e.buffer),s),s+e.buffer.byteLength):(j0[t+6]=e.offset,S1[i+14]=e.count,S1[i+15]=sI,s+Hn);{const{left:a,right:o,splitAxis:l}=e,c=s+Hn;let h=T1(c,a);const d=s/Hn,u=h/Hn-d;if(u>Ij)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return j0[t+6]=u,j0[t+7]=l,T1(h,o)}}function Dj(s,e,t){const i=(s.index?s.index.count:s.attributes.position.count)/3>65536,n=t.reduce((c,h)=>c+h.count,0),r=i?4:2,a=e?new SharedArrayBuffer(n*r):new ArrayBuffer(n*r),o=i?new Uint32Array(a):new Uint16Array(a);let l=0;for(let c=0;c<t.length;c++){const{offset:h,count:d}=t[c];for(let u=0;u<d;u++)o[l+u]=h+u;l+=d}return o}function Rj(s,e,t,i,n){const{maxDepth:r,verbose:a,maxLeafTris:o,strategy:l,onProgress:c,indirect:h}=n,d=s._indirectBuffer,u=s.geometry,p=u.index?u.index.array:null,m=h?Tj:Cj,v=ec(u),g=new Float32Array(6);let f=!1;const A=new M1;return E1(e,t,i,A.boundingData,g),y(A,t,i,g),A;function b(x){c&&c(x/v)}function y(x,_,M,E=null,w=0){if(!f&&w>=r&&(f=!0,a&&(console.warn(`MeshBVH: Max depth of ${r} reached when generating BVH. Consider increasing maxDepth.`),console.warn(u))),M<=o||w>=r)return b(_+M),x.offset=_,x.count=M,x;const T=Mj(x.boundingData,E,e,_,M,l);if(T.axis===-1)return b(_+M),x.offset=_,x.count=M,x;const R=m(d,p,e,_,M,T);if(R===_||R===_+M)b(_+M),x.offset=_,x.count=M;else{x.splitAxis=T.axis;const D=new M1,L=_,I=R-_;x.left=D,E1(e,L,I,D.boundingData,g),y(D,L,I,g,w+1);const O=new M1,N=R,G=M-I;x.right=O,E1(e,N,G,O.boundingData,g),y(O,N,G,g,w+1)}return x}}function Bj(s,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=s.geometry;let n,r;if(e.indirect){const a=aI(i,e.range),o=Dj(i,e.useSharedArrayBuffer,a);s._indirectBuffer=o,n=oI(i,0,o.length,o),r=[{offset:0,count:o.length}]}else{wj(i,e);const a=rI(i,e.range)[0];n=oI(i,a.offset,a.count),r=aI(i,e.range)}s._roots=r.map(a=>{const o=Rj(s,n,a.offset,a.count,e),l=C1(o),c=new t(Hn*l);return Pj(0,o,c),c})}class Ia{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,n=-1/0;for(let r=0,a=e.length;r<a;r++){const o=e[r][t];i=o<i?o:i,n=o>n?o:n}this.min=i,this.max=n}setFromPoints(e,t){let i=1/0,n=-1/0;for(let r=0,a=t.length;r<a;r++){const o=t[r],l=e.dot(o);i=l<i?l:i,n=l>n?l:n}this.min=i,this.max=n}isSeparated(e){return this.min>e.max||e.min>this.max}}Ia.prototype.setFromBox=(function(){const s=new P;return function(e,t){const i=t.min,n=t.max;let r=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let l=0;l<=1;l++)for(let c=0;c<=1;c++){s.x=i.x*o+n.x*(1-o),s.y=i.y*l+n.y*(1-l),s.z=i.z*c+n.z*(1-c);const h=e.dot(s);r=Math.min(h,r),a=Math.max(h,a)}this.min=r,this.max=a}})();const Lj=(function(){const s=new P,e=new P,t=new P;return function(i,n,r){const a=i.start,o=s,l=n.start,c=e;t.subVectors(a,l),s.subVectors(i.end,i.start),e.subVectors(n.end,n.start);const h=t.dot(c),d=c.dot(o),u=c.dot(c),p=t.dot(o),m=o.dot(o)*u-d*d;let v,g;m!==0?v=(h*d-p*u)/m:v=0,g=(h+v*d)/u,r.x=v,r.y=g}})(),I1=(function(){const s=new be,e=new P,t=new P;return function(i,n,r,a){Lj(i,n,s);let o=s.x,l=s.y;if(o>=0&&o<=1&&l>=0&&l<=1){i.at(o,r),n.at(l,a);return}else if(o>=0&&o<=1){l<0?n.at(0,a):n.at(1,a),i.closestPointToPoint(a,!0,r);return}else if(l>=0&&l<=1){o<0?i.at(0,r):i.at(1,r),n.closestPointToPoint(r,!0,a);return}else{let c;o<0?c=i.start:c=i.end;let h;l<0?h=n.start:h=n.end;const d=e,u=t;if(i.closestPointToPoint(h,!0,e),n.closestPointToPoint(c,!0,t),d.distanceToSquared(h)<=u.distanceToSquared(c)){r.copy(d),a.copy(h);return}else{r.copy(c),a.copy(u);return}}}})(),kj=(function(){const s=new P,e=new P,t=new $t,i=new ms;return function(n,r){const{radius:a,center:o}=n,{a:l,b:c,c:h}=r;if(i.start=l,i.end=c,i.closestPointToPoint(o,!0,s).distanceTo(o)<=a||(i.start=l,i.end=h,i.closestPointToPoint(o,!0,s).distanceTo(o)<=a)||(i.start=c,i.end=h,i.closestPointToPoint(o,!0,s).distanceTo(o)<=a))return!0;const d=r.getPlane(t);if(Math.abs(d.distanceToPoint(o))<=a){const u=d.projectPoint(o,e);if(r.containsPoint(u))return!0}return!1}})(),Oj=["x","y","z"],Pa=1e-15,pI=Pa*Pa;function Us(s){return Math.abs(s)<Pa}class zs extends ii{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new P),this.satBounds=new Array(4).fill().map(()=>new Ia),this.points=[this.a,this.b,this.c],this.plane=new $t,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new ms,this.needsUpdate=!0}intersectsSphere(e){return kj(e,this)}update(){const e=this.a,t=this.b,i=this.c,n=this.points,r=this.satAxes,a=this.satBounds,o=r[0],l=a[0];this.getNormal(o),l.setFromPoints(o,n);const c=r[1],h=a[1];c.subVectors(e,t),h.setFromPoints(c,n);const d=r[2],u=a[2];d.subVectors(t,i),u.setFromPoints(d,n);const p=r[3],m=a[3];p.subVectors(i,e),m.setFromPoints(p,n);const v=c.length(),g=d.length(),f=p.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,v<Pa?g<Pa||f<Pa?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(i)):g<Pa?f<Pa?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):f<Pa&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(i),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}zs.prototype.closestPointToSegment=(function(){const s=new P,e=new P,t=new ms;return function(i,n=null,r=null){const{start:a,end:o}=i,l=this.points;let c,h=1/0;for(let d=0;d<3;d++){const u=(d+1)%3;t.start.copy(l[d]),t.end.copy(l[u]),I1(t,i,s,e),c=s.distanceToSquared(e),c<h&&(h=c,n&&n.copy(s),r&&r.copy(e))}return this.closestPointToPoint(a,s),c=a.distanceToSquared(s),c<h&&(h=c,n&&n.copy(s),r&&r.copy(a)),this.closestPointToPoint(o,s),c=o.distanceToSquared(s),c<h&&(h=c,n&&n.copy(s),r&&r.copy(o)),Math.sqrt(h)}})(),zs.prototype.intersectsTriangle=(function(){const s=new zs,e=new Ia,t=new Ia,i=new P,n=new P,r=new P,a=new P,o=new ms,l=new ms,c=new P,h=new be,d=new be;function u(b,y,x,_){const M=i;!b.isDegenerateIntoPoint&&!b.isDegenerateIntoSegment?M.copy(b.plane.normal):M.copy(y.plane.normal);const E=b.satBounds,w=b.satAxes;for(let D=1;D<4;D++){const L=E[D],I=w[D];if(e.setFromPoints(I,y.points),L.isSeparated(e)||(a.copy(M).cross(I),e.setFromPoints(a,b.points),t.setFromPoints(a,y.points),e.isSeparated(t)))return!1}const T=y.satBounds,R=y.satAxes;for(let D=1;D<4;D++){const L=T[D],I=R[D];if(e.setFromPoints(I,b.points),L.isSeparated(e)||(a.crossVectors(M,I),e.setFromPoints(a,b.points),t.setFromPoints(a,y.points),e.isSeparated(t)))return!1}return x&&(_||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),x.start.set(0,0,0),x.end.set(0,0,0)),!0}function p(b,y,x,_,M,E,w,T,R,D,L){let I=w/(w-T);D.x=_+(M-_)*I,L.start.subVectors(y,b).multiplyScalar(I).add(b),I=w/(w-R),D.y=_+(E-_)*I,L.end.subVectors(x,b).multiplyScalar(I).add(b)}function m(b,y,x,_,M,E,w,T,R,D,L){if(M>0)p(b.c,b.a,b.b,_,y,x,R,w,T,D,L);else if(E>0)p(b.b,b.a,b.c,x,y,_,T,w,R,D,L);else if(T*R>0||w!=0)p(b.a,b.b,b.c,y,x,_,w,T,R,D,L);else if(T!=0)p(b.b,b.a,b.c,x,y,_,T,w,R,D,L);else if(R!=0)p(b.c,b.a,b.b,_,y,x,R,w,T,D,L);else return!0;return!1}function v(b,y,x,_){const M=y.degenerateSegment,E=b.plane.distanceToPoint(M.start),w=b.plane.distanceToPoint(M.end);return Us(E)?Us(w)?u(b,y,x,_):(x&&(x.start.copy(M.start),x.end.copy(M.start)),b.containsPoint(M.start)):Us(w)?(x&&(x.start.copy(M.end),x.end.copy(M.end)),b.containsPoint(M.end)):b.plane.intersectLine(M,i)!=null?(x&&(x.start.copy(i),x.end.copy(i)),b.containsPoint(i)):!1}function g(b,y,x){const _=y.a;return Us(b.plane.distanceToPoint(_))&&b.containsPoint(_)?(x&&(x.start.copy(_),x.end.copy(_)),!0):!1}function f(b,y,x){const _=b.degenerateSegment,M=y.a;return _.closestPointToPoint(M,!0,i),M.distanceToSquared(i)<pI?(x&&(x.start.copy(M),x.end.copy(M)),!0):!1}function A(b,y,x,_){if(b.isDegenerateIntoSegment)if(y.isDegenerateIntoSegment){const M=b.degenerateSegment,E=y.degenerateSegment,w=n,T=r;M.delta(w),E.delta(T);const R=i.subVectors(E.start,M.start),D=w.x*T.y-w.y*T.x;if(Us(D))return!1;const L=(R.x*T.y-R.y*T.x)/D,I=-(w.x*R.y-w.y*R.x)/D;if(L<0||L>1||I<0||I>1)return!1;const O=M.start.z+w.z*L,N=E.start.z+T.z*I;return Us(O-N)?(x&&(x.start.copy(M.start).addScaledVector(w,L),x.end.copy(M.start).addScaledVector(w,L)),!0):!1}else return y.isDegenerateIntoPoint?f(b,y,x):v(y,b,x,_);else{if(b.isDegenerateIntoPoint)return y.isDegenerateIntoPoint?y.a.distanceToSquared(b.a)<pI?(x&&(x.start.copy(b.a),x.end.copy(b.a)),!0):!1:y.isDegenerateIntoSegment?f(y,b,x):g(y,b,x);if(y.isDegenerateIntoPoint)return g(b,y,x);if(y.isDegenerateIntoSegment)return v(b,y,x,_)}}return function(b,y=null,x=!1){this.needsUpdate&&this.update(),b.isExtendedTriangle?b.needsUpdate&&b.update():(s.copy(b),s.update(),b=s);const _=A(this,b,y,x);if(_!==void 0)return _;const M=this.plane,E=b.plane;let w=E.distanceToPoint(this.a),T=E.distanceToPoint(this.b),R=E.distanceToPoint(this.c);Us(w)&&(w=0),Us(T)&&(T=0),Us(R)&&(R=0);const D=w*T,L=w*R;if(D>0&&L>0)return!1;let I=M.distanceToPoint(b.a),O=M.distanceToPoint(b.b),N=M.distanceToPoint(b.c);Us(I)&&(I=0),Us(O)&&(O=0),Us(N)&&(N=0);const G=I*O,V=I*N;if(G>0&&V>0)return!1;n.copy(M.normal),r.copy(E.normal);const H=n.cross(r);let J=0,W=Math.abs(H.x);const X=Math.abs(H.y);X>W&&(W=X,J=1),Math.abs(H.z)>W&&(J=2);const me=Oj[J],Ee=this.a[me],Me=this.b[me],$=this.c[me],se=b.a[me],he=b.b[me],Te=b.c[me];if(m(this,Ee,Me,$,D,L,w,T,R,h,o))return u(this,b,y,x);if(m(b,se,he,Te,G,V,I,O,N,d,l))return u(this,b,y,x);if(h.y<h.x){const Le=h.y;h.y=h.x,h.x=Le,c.copy(o.start),o.start.copy(o.end),o.end.copy(c)}if(d.y<d.x){const Le=d.y;d.y=d.x,d.x=Le,c.copy(l.start),l.start.copy(l.end),l.end.copy(c)}return h.y<d.x||d.y<h.x?!1:(y&&(d.x>h.x?y.start.copy(l.start):y.start.copy(o.start),d.y<h.y?y.end.copy(l.end):y.end.copy(o.end)),!0)}})(),zs.prototype.distanceToPoint=(function(){const s=new P;return function(e){return this.closestPointToPoint(e,s),e.distanceTo(s)}})(),zs.prototype.distanceToTriangle=(function(){const s=new P,e=new P,t=["a","b","c"],i=new ms,n=new ms;return function(r,a=null,o=null){const l=a||o?i:null;if(this.intersectsTriangle(r,l))return(a||o)&&(a&&l.getCenter(a),o&&l.getCenter(o)),0;let c=1/0;for(let h=0;h<3;h++){let d;const u=t[h],p=r[u];this.closestPointToPoint(p,s),d=p.distanceToSquared(s),d<c&&(c=d,a&&a.copy(s),o&&o.copy(p));const m=this[u];r.closestPointToPoint(m,s),d=m.distanceToSquared(s),d<c&&(c=d,a&&a.copy(m),o&&o.copy(s))}for(let h=0;h<3;h++){const d=t[h],u=t[(h+1)%3];i.set(this[d],this[u]);for(let p=0;p<3;p++){const m=t[p],v=t[(p+1)%3];n.set(r[m],r[v]),I1(i,n,s,e);const g=s.distanceToSquared(e);g<c&&(c=g,a&&a.copy(s),o&&o.copy(e))}}return Math.sqrt(c)}})();class Gn{constructor(e,t,i){this.isOrientedBox=!0,this.min=new P,this.max=new P,this.matrix=new Ke,this.invMatrix=new Ke,this.points=new Array(8).fill().map(()=>new P),this.satAxes=new Array(3).fill().map(()=>new P),this.satBounds=new Array(3).fill().map(()=>new Ia),this.alignedSatBounds=new Array(3).fill().map(()=>new Ia),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Gn.prototype.update=(function(){return function(){const s=this.matrix,e=this.min,t=this.max,i=this.points;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){const d=1*l|2*c|4*h,u=i[d];u.x=l?t.x:e.x,u.y=c?t.y:e.y,u.z=h?t.z:e.z,u.applyMatrix4(s)}const n=this.satBounds,r=this.satAxes,a=i[0];for(let l=0;l<3;l++){const c=r[l],h=n[l],d=1<<l,u=i[d];c.subVectors(a,u),h.setFromPoints(c,i)}const o=this.alignedSatBounds;o[0].setFromPointsField(i,"x"),o[1].setFromPointsField(i,"y"),o[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})(),Gn.prototype.intersectsBox=(function(){const s=new Ia;return function(e){this.needsUpdate&&this.update();const t=e.min,i=e.max,n=this.satBounds,r=this.satAxes,a=this.alignedSatBounds;if(s.min=t.x,s.max=i.x,a[0].isSeparated(s)||(s.min=t.y,s.max=i.y,a[1].isSeparated(s))||(s.min=t.z,s.max=i.z,a[2].isSeparated(s)))return!1;for(let o=0;o<3;o++){const l=r[o],c=n[o];if(s.setFromBox(l,e),c.isSeparated(s))return!1}return!0}})(),Gn.prototype.intersectsTriangle=(function(){const s=new zs,e=new Array(3),t=new Ia,i=new Ia,n=new P;return function(r){this.needsUpdate&&this.update(),r.isExtendedTriangle?r.needsUpdate&&r.update():(s.copy(r),s.update(),r=s);const a=this.satBounds,o=this.satAxes;e[0]=r.a,e[1]=r.b,e[2]=r.c;for(let d=0;d<3;d++){const u=a[d],p=o[d];if(t.setFromPoints(p,e),u.isSeparated(t))return!1}const l=r.satBounds,c=r.satAxes,h=this.points;for(let d=0;d<3;d++){const u=l[d],p=c[d];if(t.setFromPoints(p,h),u.isSeparated(t))return!1}for(let d=0;d<3;d++){const u=o[d];for(let p=0;p<4;p++){const m=c[p];if(n.crossVectors(u,m),t.setFromPoints(n,e),i.setFromPoints(n,h),t.isSeparated(i))return!1}}return!0}})(),Gn.prototype.closestPointToPoint=(function(){return function(s,e){return this.needsUpdate&&this.update(),e.copy(s).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}})(),Gn.prototype.distanceToPoint=(function(){const s=new P;return function(e){return this.closestPointToPoint(e,s),e.distanceTo(s)}})(),Gn.prototype.distanceToBox=(function(){const s=["x","y","z"],e=new Array(12).fill().map(()=>new ms),t=new Array(12).fill().map(()=>new ms),i=new P,n=new P;return function(r,a=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(r))return(o||l)&&(r.getCenter(n),this.closestPointToPoint(n,i),r.closestPointToPoint(i,n),o&&o.copy(i),l&&l.copy(n)),0;const c=a*a,h=r.min,d=r.max,u=this.points;let p=1/0;for(let v=0;v<8;v++){const g=u[v];n.copy(g).clamp(h,d);const f=g.distanceToSquared(n);if(f<p&&(p=f,o&&o.copy(g),l&&l.copy(n),f<c))return Math.sqrt(f)}let m=0;for(let v=0;v<3;v++)for(let g=0;g<=1;g++)for(let f=0;f<=1;f++){const A=(v+1)%3,b=(v+2)%3,y=g<<A|f<<b,x=1<<v|g<<A|f<<b,_=u[y],M=u[x];e[m].set(_,M);const E=s[v],w=s[A],T=s[b],R=t[m],D=R.start,L=R.end;D[E]=h[E],D[w]=g?h[w]:d[w],D[T]=f?h[T]:d[w],L[E]=d[E],L[w]=g?h[w]:d[w],L[T]=f?h[T]:d[w],m++}for(let v=0;v<=1;v++)for(let g=0;g<=1;g++)for(let f=0;f<=1;f++){n.x=v?d.x:h.x,n.y=g?d.y:h.y,n.z=f?d.z:h.z,this.closestPointToPoint(n,i);const A=n.distanceToSquared(i);if(A<p&&(p=A,o&&o.copy(i),l&&l.copy(n),A<c))return Math.sqrt(A)}for(let v=0;v<12;v++){const g=e[v];for(let f=0;f<12;f++){const A=t[f];I1(g,A,i,n);const b=i.distanceToSquared(n);if(b<p&&(p=b,o&&o.copy(i),l&&l.copy(n),b<c))return Math.sqrt(b)}}return Math.sqrt(p)}})();class P1{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Fj extends P1{constructor(){super(()=>new zs)}}const Hs=new Fj;function fn(s,e){return e[s+15]===sI}function ys(s,e){return e[s+6]}function Gs(s,e){return e[s+14]}function vn(s){return s+pn}function An(s,e){const t=e[s+6];return s+t*pn}function D1(s,e){return e[s+7]}class Nj{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=i=>{t&&e.push(t),t=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const yi=new Nj;let Do,Jh;const ed=[],X0=new P1(()=>new xt);function Uj(s,e,t,i,n,r){Do=X0.getPrimitive(),Jh=X0.getPrimitive(),ed.push(Do,Jh),yi.setBuffer(s._roots[e]);const a=R1(0,s.geometry,t,i,n,r);yi.clearBuffer(),X0.releasePrimitive(Do),X0.releasePrimitive(Jh),ed.pop(),ed.pop();const o=ed.length;return o>0&&(Jh=ed[o-1],Do=ed[o-2]),a}function R1(s,e,t,i,n=null,r=0,a=0){const{float32Array:o,uint16Array:l,uint32Array:c}=yi;let h=s*2;if(fn(h,l)){const d=ys(s,c),u=Gs(h,l);return Ri(s,o,Do),i(d,u,!1,a,r+s/pn,Do)}else{let d=function(R){const{uint16Array:D,uint32Array:L}=yi;let I=R*2;for(;!fn(I,D);)R=vn(R),I=R*2;return ys(R,L)},u=function(R){const{uint16Array:D,uint32Array:L}=yi;let I=R*2;for(;!fn(I,D);)R=An(R,L),I=R*2;return ys(R,L)+Gs(I,D)};const p=vn(s),m=An(s,c);let v=p,g=m,f,A,b,y;if(n&&(b=Do,y=Jh,Ri(v,o,b),Ri(g,o,y),f=n(b),A=n(y),A<f)){v=m,g=p;const R=f;f=A,A=R,b=y}b||(b=Do,Ri(v,o,b));const x=fn(v*2,l),_=t(b,x,f,a+1,r+v/pn);let M;if(_===iI){const R=d(v),D=u(v)-R;M=i(R,D,!0,a+1,r+v/pn,b)}else M=_&&R1(v,e,t,i,n,r,a+1);if(M)return!0;y=Jh,Ri(g,o,y);const E=fn(g*2,l),w=t(y,E,A,a+1,r+g/pn);let T;if(w===iI){const R=d(g),D=u(g)-R;T=i(R,D,!0,a+1,r+g/pn,y)}else T=w&&R1(g,e,t,i,n,r,a+1);return!!T}}const xp=new P,B1=new P;function zj(s,e,t={},i=0,n=1/0){const r=i*i,a=n*n;let o=1/0,l=null;if(s.shapecast({boundsTraverseOrder:h=>(xp.copy(e).clamp(h.min,h.max),xp.distanceToSquared(e)),intersectsBounds:(h,d,u)=>u<o&&u<a,intersectsTriangle:(h,d)=>{h.closestPointToPoint(e,xp);const u=e.distanceToSquared(xp);return u<o&&(B1.copy(xp),o=u,l=d),u<r}}),o===1/0)return null;const c=Math.sqrt(o);return t.point?t.point.copy(B1):t.point=B1.clone(),t.distance=c,t.faceIndex=l,t}const q0=parseInt(Ic)>=169,Hj=parseInt(Ic)<=161,tc=new P,ic=new P,nc=new P,Y0=new be,K0=new be,$0=new be,fI=new P,mI=new P,gI=new P,_p=new P;function Gj(s,e,t,i,n,r,a,o){let l;if(r===an?l=s.intersectTriangle(i,t,e,!0,n):l=s.intersectTriangle(e,t,i,r!==qt,n),l===null)return null;const c=s.origin.distanceTo(n);return c<a||c>o?null:{distance:c,point:n.clone()}}function vI(s,e,t,i,n,r,a,o,l,c,h){tc.fromBufferAttribute(e,r),ic.fromBufferAttribute(e,a),nc.fromBufferAttribute(e,o);const d=Gj(s,tc,ic,nc,_p,l,c,h);if(d){if(i){Y0.fromBufferAttribute(i,r),K0.fromBufferAttribute(i,a),$0.fromBufferAttribute(i,o),d.uv=new be;const p=ii.getInterpolation(_p,tc,ic,nc,Y0,K0,$0,d.uv);q0||(d.uv=p)}if(n){Y0.fromBufferAttribute(n,r),K0.fromBufferAttribute(n,a),$0.fromBufferAttribute(n,o),d.uv1=new be;const p=ii.getInterpolation(_p,tc,ic,nc,Y0,K0,$0,d.uv1);q0||(d.uv1=p),Hj&&(d.uv2=d.uv1)}if(t){fI.fromBufferAttribute(t,r),mI.fromBufferAttribute(t,a),gI.fromBufferAttribute(t,o),d.normal=new P;const p=ii.getInterpolation(_p,tc,ic,nc,fI,mI,gI,d.normal);d.normal.dot(s.direction)>0&&d.normal.multiplyScalar(-1),q0||(d.normal=p)}const u={a:r,b:a,c:o,normal:new P,materialIndex:0};if(ii.getNormal(tc,ic,nc,u.normal),d.face=u,d.faceIndex=r,q0){const p=new P;ii.getBarycoord(_p,tc,ic,nc,p),d.barycoord=p}}return d}function AI(s){return s&&s.isMaterial?s.side:s}function Z0(s,e,t,i,n,r,a){const o=i*3;let l=o+0,c=o+1,h=o+2;const{index:d,groups:u}=s;s.index&&(l=d.getX(l),c=d.getX(c),h=d.getX(h));const{position:p,normal:m,uv:v,uv1:g}=s.attributes;if(Array.isArray(e)){const f=i*3;for(let A=0,b=u.length;A<b;A++){const{start:y,count:x,materialIndex:_}=u[A];if(f>=y&&f<y+x){const M=AI(e[_]),E=vI(t,p,m,v,g,l,c,h,M,r,a);if(E)if(E.faceIndex=i,E.face.materialIndex=_,n)n.push(E);else return E}}}else{const f=AI(e),A=vI(t,p,m,v,g,l,c,h,f,r,a);if(A)if(A.faceIndex=i,A.face.materialIndex=0,n)n.push(A);else return A}return null}function Qi(s,e,t,i){const n=s.a,r=s.b,a=s.c;let o=e,l=e+1,c=e+2;t&&(o=t.getX(o),l=t.getX(l),c=t.getX(c)),n.x=i.getX(o),n.y=i.getY(o),n.z=i.getZ(o),r.x=i.getX(l),r.y=i.getY(l),r.z=i.getZ(l),a.x=i.getX(c),a.y=i.getY(c),a.z=i.getZ(c)}function Vj(s,e,t,i,n,r,a,o){const{geometry:l,_indirectBuffer:c}=s;for(let h=i,d=i+n;h<d;h++)Z0(l,e,t,h,r,a,o)}function Wj(s,e,t,i,n,r,a){const{geometry:o,_indirectBuffer:l}=s;let c=1/0,h=null;for(let d=i,u=i+n;d<u;d++){let p;p=Z0(o,e,t,d,null,r,a),p&&p.distance<c&&(h=p,c=p.distance)}return h}function Qj(s,e,t,i,n,r,a){const{geometry:o}=t,{index:l}=o,c=o.attributes.position;for(let h=s,d=e+s;h<d;h++){let u;if(u=h,Qi(a,u*3,l,c),a.needsUpdate=!0,i(a,u,n,r))return!0}return!1}function jj(s,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=s.geometry,i=t.index?t.index.array:null,n=t.attributes.position;let r,a,o,l,c=0;const h=s._roots;for(let u=0,p=h.length;u<p;u++)r=h[u],a=new Uint32Array(r),o=new Uint16Array(r),l=new Float32Array(r),d(0,c),c+=r.byteLength;function d(u,p,m=!1){const v=u*2;if(fn(v,o)){const g=a[u+6],f=o[v+14];let A=1/0,b=1/0,y=1/0,x=-1/0,_=-1/0,M=-1/0;for(let E=3*g,w=3*(g+f);E<w;E++){let T=i[E];const R=n.getX(T),D=n.getY(T),L=n.getZ(T);R<A&&(A=R),R>x&&(x=R),D<b&&(b=D),D>_&&(_=D),L<y&&(y=L),L>M&&(M=L)}return l[u+0]!==A||l[u+1]!==b||l[u+2]!==y||l[u+3]!==x||l[u+4]!==_||l[u+5]!==M?(l[u+0]=A,l[u+1]=b,l[u+2]=y,l[u+3]=x,l[u+4]=_,l[u+5]=M,!0):!1}else{const g=vn(u),f=An(u,a);let A=m,b=!1,y=!1;if(e){if(!A){const T=g/pn+p/Hn,R=f/pn+p/Hn;b=e.has(T),y=e.has(R),A=!b&&!y}}else b=!0,y=!0;const x=A||b,_=A||y;let M=!1;x&&(M=d(g,p,A));let E=!1;_&&(E=d(f,p,A));const w=M||E;if(w)for(let T=0;T<3;T++){const R=g+T,D=f+T,L=l[R],I=l[R+3],O=l[D],N=l[D+3];l[u+T]=L<O?L:O,l[u+T+3]=I>N?I:N}return w}}}function Ro(s,e,t,i,n){let r,a,o,l,c,h;const d=1/t.direction.x,u=1/t.direction.y,p=1/t.direction.z,m=t.origin.x,v=t.origin.y,g=t.origin.z;let f=e[s],A=e[s+3],b=e[s+1],y=e[s+3+1],x=e[s+2],_=e[s+3+2];return d>=0?(r=(f-m)*d,a=(A-m)*d):(r=(A-m)*d,a=(f-m)*d),u>=0?(o=(b-v)*u,l=(y-v)*u):(o=(y-v)*u,l=(b-v)*u),r>l||o>a||((o>r||isNaN(r))&&(r=o),(l<a||isNaN(a))&&(a=l),p>=0?(c=(x-g)*p,h=(_-g)*p):(c=(_-g)*p,h=(x-g)*p),r>h||c>a)?!1:((c>r||r!==r)&&(r=c),(h<a||a!==a)&&(a=h),r<=n&&a>=i)}function Xj(s,e,t,i,n,r,a,o){const{geometry:l,_indirectBuffer:c}=s;for(let h=i,d=i+n;h<d;h++){let u=c?c[h]:h;Z0(l,e,t,u,r,a,o)}}function qj(s,e,t,i,n,r,a){const{geometry:o,_indirectBuffer:l}=s;let c=1/0,h=null;for(let d=i,u=i+n;d<u;d++){let p;p=Z0(o,e,t,l?l[d]:d,null,r,a),p&&p.distance<c&&(h=p,c=p.distance)}return h}function Yj(s,e,t,i,n,r,a){const{geometry:o}=t,{index:l}=o,c=o.attributes.position;for(let h=s,d=e+s;h<d;h++){let u;if(u=t.resolveTriangleIndex(h),Qi(a,u*3,l,c),a.needsUpdate=!0,i(a,u,n,r))return!0}return!1}function Kj(s,e,t,i,n,r,a){yi.setBuffer(s._roots[e]),L1(0,s,t,i,n,r,a),yi.clearBuffer()}function L1(s,e,t,i,n,r,a){const{float32Array:o,uint16Array:l,uint32Array:c}=yi,h=s*2;if(fn(h,l)){const d=ys(s,c),u=Gs(h,l);Vj(e,t,i,d,u,n,r,a)}else{const d=vn(s);Ro(d,o,i,r,a)&&L1(d,e,t,i,n,r,a);const u=An(s,c);Ro(u,o,i,r,a)&&L1(u,e,t,i,n,r,a)}}const $j=["x","y","z"];function Zj(s,e,t,i,n,r){yi.setBuffer(s._roots[e]);const a=k1(0,s,t,i,n,r);return yi.clearBuffer(),a}function k1(s,e,t,i,n,r){const{float32Array:a,uint16Array:o,uint32Array:l}=yi;let c=s*2;if(fn(c,o)){const h=ys(s,l),d=Gs(c,o);return Wj(e,t,i,h,d,n,r)}else{const h=D1(s,l),d=$j[h],u=i.direction[d]>=0;let p,m;u?(p=vn(s),m=An(s,l)):(p=An(s,l),m=vn(s));const v=Ro(p,a,i,n,r)?k1(p,e,t,i,n,r):null;if(v){const f=v.point[d];if(u?f<=a[m+h]:f>=a[m+h+3])return v}const g=Ro(m,a,i,n,r)?k1(m,e,t,i,n,r):null;return v&&g?v.distance<=g.distance?v:g:v||g||null}}const J0=new xt,td=new zs,id=new zs,wp=new Ke,bI=new Gn,ev=new Gn;function Jj(s,e,t,i){yi.setBuffer(s._roots[e]);const n=O1(0,s,t,i);return yi.clearBuffer(),n}function O1(s,e,t,i,n=null){const{float32Array:r,uint16Array:a,uint32Array:o}=yi;let l=s*2;if(n===null&&(t.boundingBox||t.computeBoundingBox(),bI.set(t.boundingBox.min,t.boundingBox.max,i),n=bI),fn(l,a)){const c=e.geometry,h=c.index,d=c.attributes.position,u=t.index,p=t.attributes.position,m=ys(s,o),v=Gs(l,a);if(wp.copy(i).invert(),t.boundsTree)return Ri(s,r,ev),ev.matrix.copy(wp),ev.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:g=>ev.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(i),g.b.applyMatrix4(i),g.c.applyMatrix4(i),g.needsUpdate=!0;for(let f=m*3,A=(v+m)*3;f<A;f+=3)if(Qi(id,f,h,d),id.needsUpdate=!0,g.intersectsTriangle(id))return!0;return!1}});{const g=ec(t);for(let f=m*3,A=(v+m)*3;f<A;f+=3){Qi(td,f,h,d),td.a.applyMatrix4(wp),td.b.applyMatrix4(wp),td.c.applyMatrix4(wp),td.needsUpdate=!0;for(let b=0,y=g*3;b<y;b+=3)if(Qi(id,b,u,p),id.needsUpdate=!0,td.intersectsTriangle(id))return!0}}}else{const c=vn(s),h=An(s,o);return Ri(c,r,J0),!!(n.intersectsBox(J0)&&O1(c,e,t,i,n)||(Ri(h,r,J0),n.intersectsBox(J0)&&O1(h,e,t,i,n)))}}const tv=new Ke,F1=new Gn,Ep=new Gn,eX=new P,tX=new P,iX=new P,nX=new P;function sX(s,e,t,i={},n={},r=0,a=1/0){e.boundingBox||e.computeBoundingBox(),F1.set(e.boundingBox.min,e.boundingBox.max,t),F1.needsUpdate=!0;const o=s.geometry,l=o.attributes.position,c=o.index,h=e.attributes.position,d=e.index,u=Hs.getPrimitive(),p=Hs.getPrimitive();let m=eX,v=tX,g=null,f=null;n&&(g=iX,f=nX);let A=1/0,b=null,y=null;return tv.copy(t).invert(),Ep.matrix.copy(tv),s.shapecast({boundsTraverseOrder:x=>F1.distanceToBox(x),intersectsBounds:(x,_,M)=>M<A&&M<a?(_&&(Ep.min.copy(x.min),Ep.max.copy(x.max),Ep.needsUpdate=!0),!0):!1,intersectsRange:(x,_)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:M=>Ep.distanceToBox(M),intersectsBounds:(M,E,w)=>w<A&&w<a,intersectsRange:(M,E)=>{for(let w=M,T=M+E;w<T;w++){Qi(p,3*w,d,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let R=x,D=x+_;R<D;R++){Qi(u,3*R,c,l),u.needsUpdate=!0;const L=u.distanceToTriangle(p,m,g);if(L<A&&(v.copy(m),f&&f.copy(g),A=L,b=R,y=w),L<r)return!0}}}});{const M=ec(e);for(let E=0,w=M;E<w;E++){Qi(p,3*E,d,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let T=x,R=x+_;T<R;T++){Qi(u,3*T,c,l),u.needsUpdate=!0;const D=u.distanceToTriangle(p,m,g);if(D<A&&(v.copy(m),f&&f.copy(g),A=D,b=T,y=E),D<r)return!0}}}}}),Hs.releasePrimitive(u),Hs.releasePrimitive(p),A===1/0?null:(i.point?i.point.copy(v):i.point=v.clone(),i.distance=A,i.faceIndex=b,n&&(n.point?n.point.copy(f):n.point=f.clone(),n.point.applyMatrix4(tv),v.applyMatrix4(tv),n.distance=v.sub(n.point).length(),n.faceIndex=y),i)}function rX(s,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=s.geometry,i=t.index?t.index.array:null,n=t.attributes.position;let r,a,o,l,c=0;const h=s._roots;for(let u=0,p=h.length;u<p;u++)r=h[u],a=new Uint32Array(r),o=new Uint16Array(r),l=new Float32Array(r),d(0,c),c+=r.byteLength;function d(u,p,m=!1){const v=u*2;if(fn(v,o)){const g=a[u+6],f=o[v+14];let A=1/0,b=1/0,y=1/0,x=-1/0,_=-1/0,M=-1/0;for(let E=g,w=g+f;E<w;E++){const T=3*s.resolveTriangleIndex(E);for(let R=0;R<3;R++){let D=T+R;D=i?i[D]:D;const L=n.getX(D),I=n.getY(D),O=n.getZ(D);L<A&&(A=L),L>x&&(x=L),I<b&&(b=I),I>_&&(_=I),O<y&&(y=O),O>M&&(M=O)}}return l[u+0]!==A||l[u+1]!==b||l[u+2]!==y||l[u+3]!==x||l[u+4]!==_||l[u+5]!==M?(l[u+0]=A,l[u+1]=b,l[u+2]=y,l[u+3]=x,l[u+4]=_,l[u+5]=M,!0):!1}else{const g=vn(u),f=An(u,a);let A=m,b=!1,y=!1;if(e){if(!A){const T=g/pn+p/Hn,R=f/pn+p/Hn;b=e.has(T),y=e.has(R),A=!b&&!y}}else b=!0,y=!0;const x=A||b,_=A||y;let M=!1;x&&(M=d(g,p,A));let E=!1;_&&(E=d(f,p,A));const w=M||E;if(w)for(let T=0;T<3;T++){const R=g+T,D=f+T,L=l[R],I=l[R+3],O=l[D],N=l[D+3];l[u+T]=L<O?L:O,l[u+T+3]=I>N?I:N}return w}}}function aX(s,e,t,i,n,r,a){yi.setBuffer(s._roots[e]),N1(0,s,t,i,n,r,a),yi.clearBuffer()}function N1(s,e,t,i,n,r,a){const{float32Array:o,uint16Array:l,uint32Array:c}=yi,h=s*2;if(fn(h,l)){const d=ys(s,c),u=Gs(h,l);Xj(e,t,i,d,u,n,r,a)}else{const d=vn(s);Ro(d,o,i,r,a)&&N1(d,e,t,i,n,r,a);const u=An(s,c);Ro(u,o,i,r,a)&&N1(u,e,t,i,n,r,a)}}const oX=["x","y","z"];function lX(s,e,t,i,n,r){yi.setBuffer(s._roots[e]);const a=U1(0,s,t,i,n,r);return yi.clearBuffer(),a}function U1(s,e,t,i,n,r){const{float32Array:a,uint16Array:o,uint32Array:l}=yi;let c=s*2;if(fn(c,o)){const h=ys(s,l),d=Gs(c,o);return qj(e,t,i,h,d,n,r)}else{const h=D1(s,l),d=oX[h],u=i.direction[d]>=0;let p,m;u?(p=vn(s),m=An(s,l)):(p=An(s,l),m=vn(s));const v=Ro(p,a,i,n,r)?U1(p,e,t,i,n,r):null;if(v){const f=v.point[d];if(u?f<=a[m+h]:f>=a[m+h+3])return v}const g=Ro(m,a,i,n,r)?U1(m,e,t,i,n,r):null;return v&&g?v.distance<=g.distance?v:g:v||g||null}}const iv=new xt,nd=new zs,sd=new zs,Mp=new Ke,yI=new Gn,nv=new Gn;function cX(s,e,t,i){yi.setBuffer(s._roots[e]);const n=z1(0,s,t,i);return yi.clearBuffer(),n}function z1(s,e,t,i,n=null){const{float32Array:r,uint16Array:a,uint32Array:o}=yi;let l=s*2;if(n===null&&(t.boundingBox||t.computeBoundingBox(),yI.set(t.boundingBox.min,t.boundingBox.max,i),n=yI),fn(l,a)){const c=e.geometry,h=c.index,d=c.attributes.position,u=t.index,p=t.attributes.position,m=ys(s,o),v=Gs(l,a);if(Mp.copy(i).invert(),t.boundsTree)return Ri(s,r,nv),nv.matrix.copy(Mp),nv.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:g=>nv.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(i),g.b.applyMatrix4(i),g.c.applyMatrix4(i),g.needsUpdate=!0;for(let f=m,A=v+m;f<A;f++)if(Qi(sd,3*e.resolveTriangleIndex(f),h,d),sd.needsUpdate=!0,g.intersectsTriangle(sd))return!0;return!1}});{const g=ec(t);for(let f=m,A=v+m;f<A;f++){const b=e.resolveTriangleIndex(f);Qi(nd,3*b,h,d),nd.a.applyMatrix4(Mp),nd.b.applyMatrix4(Mp),nd.c.applyMatrix4(Mp),nd.needsUpdate=!0;for(let y=0,x=g*3;y<x;y+=3)if(Qi(sd,y,u,p),sd.needsUpdate=!0,nd.intersectsTriangle(sd))return!0}}}else{const c=vn(s),h=An(s,o);return Ri(c,r,iv),!!(n.intersectsBox(iv)&&z1(c,e,t,i,n)||(Ri(h,r,iv),n.intersectsBox(iv)&&z1(h,e,t,i,n)))}}const sv=new Ke,H1=new Gn,Sp=new Gn,hX=new P,dX=new P,uX=new P,pX=new P;function fX(s,e,t,i={},n={},r=0,a=1/0){e.boundingBox||e.computeBoundingBox(),H1.set(e.boundingBox.min,e.boundingBox.max,t),H1.needsUpdate=!0;const o=s.geometry,l=o.attributes.position,c=o.index,h=e.attributes.position,d=e.index,u=Hs.getPrimitive(),p=Hs.getPrimitive();let m=hX,v=dX,g=null,f=null;n&&(g=uX,f=pX);let A=1/0,b=null,y=null;return sv.copy(t).invert(),Sp.matrix.copy(sv),s.shapecast({boundsTraverseOrder:x=>H1.distanceToBox(x),intersectsBounds:(x,_,M)=>M<A&&M<a?(_&&(Sp.min.copy(x.min),Sp.max.copy(x.max),Sp.needsUpdate=!0),!0):!1,intersectsRange:(x,_)=>{if(e.boundsTree){const M=e.boundsTree;return M.shapecast({boundsTraverseOrder:E=>Sp.distanceToBox(E),intersectsBounds:(E,w,T)=>T<A&&T<a,intersectsRange:(E,w)=>{for(let T=E,R=E+w;T<R;T++){const D=M.resolveTriangleIndex(T);Qi(p,3*D,d,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let L=x,I=x+_;L<I;L++){const O=s.resolveTriangleIndex(L);Qi(u,3*O,c,l),u.needsUpdate=!0;const N=u.distanceToTriangle(p,m,g);if(N<A&&(v.copy(m),f&&f.copy(g),A=N,b=L,y=T),N<r)return!0}}}})}else{const M=ec(e);for(let E=0,w=M;E<w;E++){Qi(p,3*E,d,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let T=x,R=x+_;T<R;T++){const D=s.resolveTriangleIndex(T);Qi(u,3*D,c,l),u.needsUpdate=!0;const L=u.distanceToTriangle(p,m,g);if(L<A&&(v.copy(m),f&&f.copy(g),A=L,b=T,y=E),L<r)return!0}}}}}),Hs.releasePrimitive(u),Hs.releasePrimitive(p),A===1/0?null:(i.point?i.point.copy(v):i.point=v.clone(),i.distance=A,i.faceIndex=b,n&&(n.point?n.point.copy(f):n.point=f.clone(),n.point.applyMatrix4(sv),v.applyMatrix4(sv),n.distance=v.sub(n.point).length(),n.faceIndex=y),i)}function mX(){return typeof SharedArrayBuffer<"u"}const Cp=new yi.constructor,rv=new yi.constructor,Bo=new P1(()=>new xt),rd=new xt,ad=new xt,G1=new xt,V1=new xt;let W1=!1;function gX(s,e,t,i){if(W1)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");W1=!0;const n=s._roots,r=e._roots;let a,o=0,l=0;const c=new Ke().copy(t).invert();for(let h=0,d=n.length;h<d;h++){Cp.setBuffer(n[h]),l=0;const u=Bo.getPrimitive();Ri(0,Cp.float32Array,u),u.applyMatrix4(c);for(let p=0,m=r.length;p<m&&(rv.setBuffer(r[p]),a=dr(0,0,t,c,i,o,l,0,0,u),rv.clearBuffer(),l+=r[p].byteLength/Hn,!a);p++);if(Bo.releasePrimitive(u),Cp.clearBuffer(),o+=n[h].byteLength/Hn,a)break}return W1=!1,a}function dr(s,e,t,i,n,r=0,a=0,o=0,l=0,c=null,h=!1){let d,u;h?(d=rv,u=Cp):(d=Cp,u=rv);const p=d.float32Array,m=d.uint32Array,v=d.uint16Array,g=u.float32Array,f=u.uint32Array,A=u.uint16Array,b=s*2,y=e*2,x=fn(b,v),_=fn(y,A);let M=!1;if(_&&x)h?M=n(ys(e,f),Gs(e*2,A),ys(s,m),Gs(s*2,v),l,a+e/pn,o,r+s/pn):M=n(ys(s,m),Gs(s*2,v),ys(e,f),Gs(e*2,A),o,r+s/pn,l,a+e/pn);else if(_){const E=Bo.getPrimitive();Ri(e,g,E),E.applyMatrix4(t);const w=vn(s),T=An(s,m);Ri(w,p,rd),Ri(T,p,ad);const R=E.intersectsBox(rd),D=E.intersectsBox(ad);M=R&&dr(e,w,i,t,n,a,r,l,o+1,E,!h)||D&&dr(e,T,i,t,n,a,r,l,o+1,E,!h),Bo.releasePrimitive(E)}else{const E=vn(e),w=An(e,f);Ri(E,g,G1),Ri(w,g,V1);const T=c.intersectsBox(G1),R=c.intersectsBox(V1);if(T&&R)M=dr(s,E,t,i,n,r,a,o,l+1,c,h)||dr(s,w,t,i,n,r,a,o,l+1,c,h);else if(T)if(x)M=dr(s,E,t,i,n,r,a,o,l+1,c,h);else{const D=Bo.getPrimitive();D.copy(G1).applyMatrix4(t);const L=vn(s),I=An(s,m);Ri(L,p,rd),Ri(I,p,ad);const O=D.intersectsBox(rd),N=D.intersectsBox(ad);M=O&&dr(E,L,i,t,n,a,r,l,o+1,D,!h)||N&&dr(E,I,i,t,n,a,r,l,o+1,D,!h),Bo.releasePrimitive(D)}else if(R)if(x)M=dr(s,w,t,i,n,r,a,o,l+1,c,h);else{const D=Bo.getPrimitive();D.copy(V1).applyMatrix4(t);const L=vn(s),I=An(s,m);Ri(L,p,rd),Ri(I,p,ad);const O=D.intersectsBox(rd),N=D.intersectsBox(ad);M=O&&dr(w,L,i,t,n,a,r,l,o+1,D,!h)||N&&dr(w,I,i,t,n,a,r,l,o+1,D,!h),Bo.releasePrimitive(D)}}return M}const av=new Gn,xI=new xt,vX={strategy:tI,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class Q1{static serialize(e,t={}){t={cloneBuffers:!0,...t};const i=e.geometry,n=e._roots,r=e._indirectBuffer,a=i.getIndex(),o={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(o.roots=n.map(l=>l.slice()),o.index=a?a.array.slice():null,o.indirectBuffer=r?r.slice():null):(o.roots=n,o.index=a?a.array:null,o.indirectBuffer=r),o}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:n,roots:r,indirectBuffer:a}=e;e.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),l(r));const o=new Q1(t,{...i,[w1]:!0});if(o._roots=r,o._indirectBuffer=a||null,i.setIndex){const c=t.getIndex();if(c===null){const h=new _t(e.index,1,!1);t.setIndex(h)}else c.array!==n&&(c.array.set(n),c.needsUpdate=!0)}return o;function l(c){for(let h=0;h<c.length;h++){const d=c[h],u=new Uint32Array(d),p=new Uint16Array(d);for(let m=0,v=d.byteLength/Hn;m<v;m++){const g=pn*m,f=2*g;fn(f,p)||(u[g+6]=u[g+6]/pn-m)}}}}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...vX,[w1]:!1},t),t.useSharedArrayBuffer&&!mX())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[w1]||(Bj(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new xt))),this.resolveTriangleIndex=t.indirect?i=>this._indirectBuffer[i]:i=>i}shiftTriangleOffsets(e){const t=this._indirectBuffer;if(t)for(let i=0,n=t.length;i<n;i++)t[i]+=e;else{const i=this._roots;for(let n=0;n<i.length;n++){const r=i[n],a=new Uint32Array(r),o=new Uint16Array(r),l=r.byteLength/Hn;for(let c=0;c<l;c++){const h=pn*c,d=2*h;fn(d,o)&&(a[h+6]+=e)}}}}refit(e=null){return(this.indirect?rX:jj)(this,e)}traverse(e,t=0){const i=this._roots[t],n=new Uint32Array(i),r=new Uint16Array(i);a(0);function a(o,l=0){const c=o*2,h=fn(c,r);if(h){const d=n[o+6],u=r[c+14];e(l,h,new Float32Array(i,o*4,6),d,u)}else{const d=vn(o),u=An(o,n),p=D1(o,n);e(l,h,new Float32Array(i,o*4,6),p)||(a(d,l+1),a(u,l+1))}}}raycast(e,t=Yn,i=0,n=1/0){const r=this._roots,a=[],o=this.indirect?aX:Kj;for(let l=0,c=r.length;l<c;l++)o(this,l,t,e,a,i,n);return a}raycastFirst(e,t=Yn,i=0,n=1/0){const r=this._roots;let a=null;const o=this.indirect?lX:Zj;for(let l=0,c=r.length;l<c;l++){const h=o(this,l,t,e,i,n);h!=null&&(a==null||h.distance<a.distance)&&(a=h)}return a}intersectsGeometry(e,t){let i=!1;const n=this._roots,r=this.indirect?cX:Jj;for(let a=0,o=n.length;a<o&&(i=r(this,a,e,t),!i);a++);return i}shapecast(e){const t=Hs.getPrimitive(),i=this.indirect?Yj:Qj;let{boundsTraverseOrder:n,intersectsBounds:r,intersectsRange:a,intersectsTriangle:o}=e;if(a&&o){const d=a;a=(u,p,m,v,g)=>d(u,p,m,v,g)?!0:i(u,p,this,o,m,v,t)}else a||(o?a=(d,u,p,m)=>i(d,u,this,o,p,m,t):a=(d,u,p)=>p);let l=!1,c=0;const h=this._roots;for(let d=0,u=h.length;d<u;d++){const p=h[d];if(l=Uj(this,d,r,a,n,c),l)break;c+=p.byteLength/Hn}return Hs.releasePrimitive(t),l}bvhcast(e,t,i){let{intersectsRanges:n,intersectsTriangles:r}=i;const a=Hs.getPrimitive(),o=this.geometry.index,l=this.geometry.attributes.position,c=this.indirect?m=>{const v=this.resolveTriangleIndex(m);Qi(a,v*3,o,l)}:m=>{Qi(a,m*3,o,l)},h=Hs.getPrimitive(),d=e.geometry.index,u=e.geometry.attributes.position,p=e.indirect?m=>{const v=e.resolveTriangleIndex(m);Qi(h,v*3,d,u)}:m=>{Qi(h,m*3,d,u)};if(r){const m=(v,g,f,A,b,y,x,_)=>{for(let M=f,E=f+A;M<E;M++){p(M),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let w=v,T=v+g;w<T;w++)if(c(w),a.needsUpdate=!0,r(a,h,w,M,b,y,x,_))return!0}return!1};if(n){const v=n;n=function(g,f,A,b,y,x,_,M){return v(g,f,A,b,y,x,_,M)?!0:m(g,f,A,b,y,x,_,M)}}else n=m}return gX(this,e,t,n)}intersectsBox(e,t){return av.set(e.min,e.max,t),av.needsUpdate=!0,this.shapecast({intersectsBounds:i=>av.intersectsBox(i),intersectsTriangle:i=>av.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},n={},r=0,a=1/0){return(this.indirect?fX:sX)(this,e,t,i,n,r,a)}closestPointToPoint(e,t={},i=0,n=1/0){return zj(this,e,t,i,n)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{Ri(0,new Float32Array(t),xI),e.union(xI)}),e}}const _I=1e-6,AX=_I*.5,wI=Math.pow(10,-Math.log10(_I)),bX=AX*wI;function Gr(s){return~~(s*wI+bX)}function yX(s){return`${Gr(s.x)},${Gr(s.y)}`}function EI(s){return`${Gr(s.x)},${Gr(s.y)},${Gr(s.z)}`}function xX(s){return`${Gr(s.x)},${Gr(s.y)},${Gr(s.z)},${Gr(s.w)}`}function _X(s,e,t){t.direction.subVectors(e,s).normalize();const i=s.dot(t.direction);return t.origin.copy(s).addScaledVector(t.direction,-i),t}function MI(){return typeof SharedArrayBuffer<"u"}function wX(s){if(s.buffer instanceof SharedArrayBuffer)return s;const e=s.constructor,t=s.buffer,i=new SharedArrayBuffer(t.byteLength),n=new Uint8Array(t);return new Uint8Array(i).set(n,0),new e(i)}function EX(s,e=ArrayBuffer){return s>65535?new Uint32Array(new e(4*s)):new Uint16Array(new e(2*s))}function MX(s,e){if(!s.index){const t=s.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=EX(t,i);s.setIndex(new _t(n,1));for(let r=0;r<t;r++)n[r]=r}}function SX(s){return s.index?s.index.count:s.attributes.position.count}function j1(s){return SX(s)/3}const CX=1e-8,TX=new P;function IX(s){return~~(s/3)}function PX(s){return s%3}function SI(s,e){return s.start-e.start}function CI(s,e){return TX.subVectors(e,s.origin).dot(s.direction)}function DX(s,e,t,i=CX){s.sort(SI),e.sort(SI);for(let o=0;o<s.length;o++){const l=s[o];for(let c=0;c<e.length;c++){const h=e[c];if(!(h.start>l.end)){if(l.end<h.start||h.end<l.start)continue;if(l.start<=h.start&&l.end>=h.end)r(h.end,l.end)||s.splice(o+1,0,{start:h.end,end:l.end,index:l.index}),l.end=h.start,h.start=0,h.end=0;else if(l.start>=h.start&&l.end<=h.end)r(l.end,h.end)||e.splice(c+1,0,{start:l.end,end:h.end,index:h.index}),h.end=l.start,l.start=0,l.end=0;else if(l.start<=h.start&&l.end<=h.end){const d=l.end;l.end=h.start,h.start=d}else if(l.start>=h.start&&l.end>=h.end){const d=h.end;h.end=l.start,l.start=d}else throw new Error}if(t.has(l.index)||t.set(l.index,[]),t.has(h.index)||t.set(h.index,[]),t.get(l.index).push(h.index),t.get(h.index).push(l.index),a(h)&&(e.splice(c,1),c--),a(l)){s.splice(o,1),o--;break}}}n(s),n(e);function n(o){for(let l=0;l<o.length;l++)a(o[l])&&(o.splice(l,1),l--)}function r(o,l){return Math.abs(l-o)<i}function a(o){return Math.abs(o.end-o.start)<i}}const TI=1e-5,II=1e-4;class RX{constructor(){this._rays=[]}addRay(e){this._rays.push(e)}findClosestRay(e){const t=this._rays,i=e.clone();i.direction.multiplyScalar(-1);let n=1/0,r=null;for(let l=0,c=t.length;l<c;l++){const h=t[l];if(a(h,e)&&a(h,i))continue;const d=o(h,e),u=o(h,i),p=Math.min(d,u);p<n&&(n=p,r=h)}return r;function a(l,c){const h=l.origin.distanceTo(c.origin)>TI;return l.direction.angleTo(c.direction)>II||h}function o(l,c){const h=l.origin.distanceTo(c.origin),d=l.direction.angleTo(c.direction);return h/TI+d/II}}}const X1=new P,q1=new P,ov=new Cr;function BX(s,e,t){const i=s.attributes,n=s.index,r=i.position,a=new Map,o=new Map,l=Array.from(e),c=new RX;for(let h=0,d=l.length;h<d;h++){const u=l[h],p=IX(u),m=PX(u);let v=3*p+m,g=3*p+(m+1)%3;n&&(v=n.getX(v),g=n.getX(g)),X1.fromBufferAttribute(r,v),q1.fromBufferAttribute(r,g),_X(X1,q1,ov);let f,A=c.findClosestRay(ov);A===null&&(A=ov.clone(),c.addRay(A)),o.has(A)||o.set(A,{forward:[],reverse:[],ray:A}),f=o.get(A);let b=CI(A,X1),y=CI(A,q1);b>y&&([b,y]=[y,b]),ov.direction.dot(A.direction)<0?f.reverse.push({start:b,end:y,index:u}):f.forward.push({start:b,end:y,index:u})}return o.forEach(({forward:h,reverse:d},u)=>{DX(h,d,a,t),h.length===0&&d.length===0&&o.delete(u)}),{disjointConnectivityMap:a,fragmentMap:o}}const LX=new be,Y1=new P,kX=new zt,K1=["","",""];class OX{constructor(e=null){this.data=null,this.disjointConnections=null,this.unmatchedDisjointEdges=null,this.unmatchedEdges=-1,this.matchedEdges=-1,this.useDrawRange=!0,this.useAllAttributes=!1,this.matchDisjointEdges=!1,this.degenerateEpsilon=1e-8,e&&this.updateFrom(e)}getSiblingTriangleIndex(e,t){const i=this.data[e*3+t];return i===-1?-1:~~(i/3)}getSiblingEdgeIndex(e,t){const i=this.data[e*3+t];return i===-1?-1:i%3}getDisjointSiblingTriangleIndices(e,t){const i=e*3+t,n=this.disjointConnections.get(i);return n?n.map(r=>~~(r/3)):[]}getDisjointSiblingEdgeIndices(e,t){const i=e*3+t,n=this.disjointConnections.get(i);return n?n.map(r=>r%3):[]}isFullyConnected(){return this.unmatchedEdges===0}updateFrom(e){const{useAllAttributes:t,useDrawRange:i,matchDisjointEdges:n,degenerateEpsilon:r}=this,a=t?b:A,o=new Map,{attributes:l}=e,c=t?Object.keys(l):null,h=e.index,d=l.position;let u=j1(e);const p=u;let m=0;i&&(m=e.drawRange.start,e.drawRange.count!==1/0&&(u=~~(e.drawRange.count/3)));let v=this.data;(!v||v.length<3*p)&&(v=new Int32Array(3*p)),v.fill(-1);let g=0,f=new Set;for(let y=m,x=u*3+m;y<x;y+=3){const _=y;for(let M=0;M<3;M++){let E=_+M;h&&(E=h.getX(E)),K1[M]=a(E)}for(let M=0;M<3;M++){const E=(M+1)%3,w=K1[M],T=K1[E],R=`${T}_${w}`;if(o.has(R)){const D=_+M,L=o.get(R);v[D]=L,v[L]=D,o.delete(R),g+=2,f.delete(L)}else{const D=`${w}_${T}`,L=_+M;o.set(D,L),f.add(L)}}}if(n){const{fragmentMap:y,disjointConnectivityMap:x}=BX(e,f,r);f.clear(),y.forEach(({forward:_,reverse:M})=>{_.forEach(({index:E})=>f.add(E)),M.forEach(({index:E})=>f.add(E))}),this.unmatchedDisjointEdges=y,this.disjointConnections=x,g=u*3-f.size}this.matchedEdges=g,this.unmatchedEdges=f.size,this.data=v;function A(y){return Y1.fromBufferAttribute(d,y),EI(Y1)}function b(y){let x="";for(let _=0,M=c.length;_<M;_++){const E=l[c[_]];let w;switch(E.itemSize){case 1:w=Gr(E.getX(y));break;case 2:w=yX(LX.fromBufferAttribute(E,y));break;case 3:w=EI(Y1.fromBufferAttribute(E,y));break;case 4:w=xX(kX.fromBufferAttribute(E,y));break}x!==""&&(x+="|"),x+=w}return x}}}class lv extends We{constructor(...e){super(...e),this.isBrush=!0,this._previousMatrix=new Ke,this._previousMatrix.elements.fill(0)}markUpdated(){this._previousMatrix.copy(this.matrix)}isDirty(){const{matrix:e,_previousMatrix:t}=this,i=e.elements,n=t.elements;for(let r=0;r<16;r++)if(i[r]!==n[r])return!0;return!1}prepareGeometry(){const e=this.geometry,t=e.attributes,i=MI();if(i)for(const n in t){const r=t[n];if(r.isInterleavedBufferAttribute)throw new Error("Brush: InterleavedBufferAttributes are not supported.");r.array=wX(r.array)}if(e.boundsTree||(MX(e,{useSharedArrayBuffer:i}),e.boundsTree=new Q1(e,{maxLeafTris:3,indirect:!0,useSharedArrayBuffer:i})),e.halfEdges||(e.halfEdges=new OX(e)),!e.groupIndices){const n=j1(e),r=new Uint16Array(n),a=e.groups;for(let o=0,l=a.length;o<l;o++){const{start:c,count:h}=a[o];for(let d=c/3,u=(c+h)/3;d<u;d++)r[d]=o}e.groupIndices=r}}disposeCacheData(){const{geometry:e}=this;e.halfEdges=null,e.boundsTree=null,e.groupIndices=null}}const FX=1e-14,$1=new P,PI=new P,DI=new P;function Lo(s,e=FX){$1.subVectors(s.b,s.a),PI.subVectors(s.c,s.a),DI.subVectors(s.b,s.c);const t=$1.angleTo(PI),i=$1.angleTo(DI),n=Math.PI-t-i;return Math.abs(t)<e||Math.abs(i)<e||Math.abs(n)<e||s.a.distanceToSquared(s.b)<e||s.a.distanceToSquared(s.c)<e||s.b.distanceToSquared(s.c)<e}const Z1=1e-10,Tp=1e-10,NX=1e-10,Da=new ms,Hi=new ms,Ra=new P,J1=new P,RI=new P,cv=new $t,e_=new zs;class UX{constructor(){this._pool=[],this._index=0}getTriangle(){return this._index>=this._pool.length&&this._pool.push(new ii),this._pool[this._index++]}clear(){this._index=0}reset(){this._pool.length=0,this._index=0}}class zX{constructor(){this.trianglePool=new UX,this.triangles=[],this.normal=new P,this.coplanarTriangleUsed=!1}initialize(e){this.reset();const{triangles:t,trianglePool:i,normal:n}=this;if(Array.isArray(e))for(let r=0,a=e.length;r<a;r++){const o=e[r];if(r===0)o.getNormal(n);else if(Math.abs(1-o.getNormal(Ra).dot(n))>Z1)throw new Error("Triangle Splitter: Cannot initialize with triangles that have different normals.");const l=i.getTriangle();l.copy(o),t.push(l)}else{e.getNormal(n);const r=i.getTriangle();r.copy(e),t.push(r)}}splitByTriangle(e){const{normal:t,triangles:i}=this;if(e.getNormal(J1).normalize(),Math.abs(1-Math.abs(J1.dot(t)))<NX){this.coplanarTriangleUsed=!0;for(let r=0,a=i.length;r<a;r++){const o=i[r];o.coplanarCount=0}const n=[e.a,e.b,e.c];for(let r=0;r<3;r++){const a=(r+1)%3,o=n[r],l=n[a];Ra.subVectors(l,o).normalize(),RI.crossVectors(J1,Ra),cv.setFromNormalAndCoplanarPoint(RI,o),this.splitByPlane(cv,e)}}else e.getPlane(cv),this.splitByPlane(cv,e)}splitByPlane(e,t){const{triangles:i,trianglePool:n}=this;e_.copy(t),e_.needsUpdate=!0;for(let r=0,a=i.length;r<a;r++){const o=i[r];if(!e_.intersectsTriangle(o,Da,!0))continue;const{a:l,b:c,c:h}=o;let d=0,u=-1,p=!1,m=[],v=[];const g=[l,c,h];for(let f=0;f<3;f++){const A=(f+1)%3;Da.start.copy(g[f]),Da.end.copy(g[A]);const b=e.distanceToPoint(Da.start),y=e.distanceToPoint(Da.end);if(Math.abs(b)<Tp&&Math.abs(y)<Tp){p=!0;break}if(b>0?m.push(f):v.push(f),Math.abs(b)<Tp)continue;let x=!!e.intersectLine(Da,Ra);!x&&Math.abs(y)<Tp&&(Ra.copy(Da.end),x=!0),x&&!(Ra.distanceTo(Da.start)<Z1)&&(Ra.distanceTo(Da.end)<Z1&&(u=f),d===0?Hi.start.copy(Ra):Hi.end.copy(Ra),d++)}if(!p&&d===2&&Hi.distance()>Tp)if(u!==-1){u=(u+1)%3;let f=0;f===u&&(f=(f+1)%3);let A=f+1;A===u&&(A=(A+1)%3);const b=n.getTriangle();b.a.copy(g[A]),b.b.copy(Hi.end),b.c.copy(Hi.start),Lo(b)||i.push(b),o.a.copy(g[f]),o.b.copy(Hi.start),o.c.copy(Hi.end),Lo(o)&&(i.splice(r,1),r--,a--)}else{const f=m.length>=2?v[0]:m[0];if(f===0){let _=Hi.start;Hi.start=Hi.end,Hi.end=_}const A=(f+1)%3,b=(f+2)%3,y=n.getTriangle(),x=n.getTriangle();g[A].distanceToSquared(Hi.start)<g[b].distanceToSquared(Hi.end)?(y.a.copy(g[A]),y.b.copy(Hi.start),y.c.copy(Hi.end),x.a.copy(g[A]),x.b.copy(g[b]),x.c.copy(Hi.start)):(y.a.copy(g[b]),y.b.copy(Hi.start),y.c.copy(Hi.end),x.a.copy(g[A]),x.b.copy(g[b]),x.c.copy(Hi.end)),o.a.copy(g[f]),o.b.copy(Hi.end),o.c.copy(Hi.start),Lo(y)||i.push(y),Lo(x)||i.push(x),Lo(o)&&(i.splice(r,1),r--,a--)}else d===3&&console.warn("TriangleClipper: Coplanar clip not handled")}}reset(){this.triangles.length=0,this.trianglePool.clear(),this.coplanarTriangleUsed=!1}}function HX(s){return s=~~s,s+4-s%4}class BI{constructor(e,t=500){this.expansionFactor=1.5,this.type=e,this.length=0,this.array=null,this.setSize(t)}setType(e){if(this.length!==0)throw new Error("TypeBackedArray: Cannot change the type while there is used data in the buffer.");const t=this.array.buffer;this.array=new e(t),this.type=e}setSize(e){if(this.array&&e===this.array.length)return;const t=this.type,i=MI()?SharedArrayBuffer:ArrayBuffer,n=new t(new i(HX(e*t.BYTES_PER_ELEMENT)));this.array&&n.set(this.array,0),this.array=n}expand(){const{array:e,expansionFactor:t}=this;this.setSize(e.length*t)}push(...e){let{array:t,length:i}=this;i+e.length>t.length&&(this.expand(),t=this.array);for(let n=0,r=e.length;n<r;n++)t[i+n]=e[n];this.length+=e.length}clear(){this.length=0}}class GX{constructor(){this.groupAttributes=[{}],this.groupCount=0}getType(e){return this.groupAttributes[0][e].type}getItemSize(e){return this.groupAttributes[0][e].itemSize}getNormalized(e){return this.groupAttributes[0][e].normalized}getCount(e){if(this.groupCount<=e)return 0;const t=this.getGroupAttrArray("position",e);return t.length/t.itemSize}getTotalLength(e){const{groupCount:t,groupAttributes:i}=this;let n=0;for(let r=0;r<t;r++){const a=i[r];n+=a[e].length}return n}getGroupAttrSet(e=0){const{groupAttributes:t}=this;if(t[e])return this.groupCount=Math.max(this.groupCount,e+1),t[e];const i=t[0];for(this.groupCount=Math.max(this.groupCount,e+1);e>=t.length;){const n={};t.push(n);for(const r in i){const a=i[r],o=new BI(a.type);o.itemSize=a.itemSize,o.normalized=a.normalized,n[r]=o}}return t[e]}getGroupAttrArray(e,t=0){const{groupAttributes:i}=this;if(!i[0][e])throw new Error(`TypedAttributeData: Attribute with "${e}" has not been initialized`);return this.getGroupAttrSet(t)[e]}initializeArray(e,t,i,n){const{groupAttributes:r}=this,a=r[0][e];if(a){if(a.type!==t)for(let o=0,l=r.length;o<l;o++){const c=r[o][e];c.setType(t),c.itemSize=i,c.normalized=n}}else for(let o=0,l=r.length;o<l;o++){const c=new BI(t);c.itemSize=i,c.normalized=n,r[o][e]=c}}clear(){this.groupCount=0;const{groupAttributes:e}=this;e.forEach(t=>{for(const i in t)t[i].clear()})}delete(e){this.groupAttributes.forEach(t=>{delete t[e]})}reset(){this.groupAttributes=[],this.groupCount=0}}class LI{constructor(){this.intersectionSet={},this.ids=[]}add(e,t){const{intersectionSet:i,ids:n}=this;i[e]||(i[e]=[],n.push(e)),i[e].push(t)}}const VX=0,WX=1,QX=2,kI=3,jX=4,OI=5,FI=6,Vs=new Cr,NI=new Ke,Vn=new ii,Ba=new P,UI=new zt,zI=new zt,HI=new zt,t_=new zt,hv=new zt,dv=new zt,GI=new ms,i_=new P,n_=1e-8,XX=1e-15,sc=-1,rc=1,uv=-2,pv=2,Ip=0,ac=1,s_=2,qX=1e-14;let fv=null;function VI(s){fv=s}function WI(s,e){s.getMidpoint(Vs.origin),s.getNormal(Vs.direction);const t=e.raycastFirst(Vs,qt);return t&&Vs.direction.dot(t.face.normal)>0?sc:rc}function YX(s,e){function t(){return Math.random()-.5}s.getNormal(i_),Vs.direction.copy(i_),s.getMidpoint(Vs.origin);const i=3;let n=0,r=1/0;for(let a=0;a<i;a++){Vs.direction.x+=t()*n_,Vs.direction.y+=t()*n_,Vs.direction.z+=t()*n_,Vs.direction.multiplyScalar(-1);const o=e.raycastFirst(Vs,qt);if(o&&Vs.direction.dot(o.face.normal)>0&&n++,o!==null&&(r=Math.min(r,o.distance)),r<=XX)return o.face.normal.dot(i_)>0?pv:uv;if(n/i>.5||(a-n+1)/i>.5)break}return n/i>.5?sc:rc}function KX(s,e){const t=new LI,i=new LI;return NI.copy(s.matrixWorld).invert().multiply(e.matrixWorld),s.geometry.boundsTree.bvhcast(e.geometry.boundsTree,NI,{intersectsTriangles(n,r,a,o){if(!Lo(n)&&!Lo(r)){let l=n.intersectsTriangle(r,GI,!0);if(!l){const c=n.plane,h=r.plane,d=c.normal,u=h.normal;d.dot(u)===1&&Math.abs(c.constant-h.constant)<qX&&(l=!0)}if(l){let c=s.geometry.boundsTree.resolveTriangleIndex(a),h=e.geometry.boundsTree.resolveTriangleIndex(o);t.add(c,h),i.add(h,c),fv&&(fv.addEdge(GI),fv.addIntersectingTriangles(a,n,o,r))}}return!1}}),{aIntersections:t,bIntersections:i}}function $X(s,e,t,i,n,r,a=!1){const o=t.attributes,l=t.index,c=s*3,h=l.getX(c+0),d=l.getX(c+1),u=l.getX(c+2);for(const p in r){const m=o[p],v=r[p];if(!(p in o))throw new Error(`CSG Operations: Attribute ${p} not available on geometry.`);const g=m.itemSize;p==="position"?(Vn.a.fromBufferAttribute(m,h).applyMatrix4(i),Vn.b.fromBufferAttribute(m,d).applyMatrix4(i),Vn.c.fromBufferAttribute(m,u).applyMatrix4(i),r_(Vn.a,Vn.b,Vn.c,e,3,v,a)):p==="normal"?(Vn.a.fromBufferAttribute(m,h).applyNormalMatrix(n),Vn.b.fromBufferAttribute(m,d).applyNormalMatrix(n),Vn.c.fromBufferAttribute(m,u).applyNormalMatrix(n),a&&(Vn.a.multiplyScalar(-1),Vn.b.multiplyScalar(-1),Vn.c.multiplyScalar(-1)),r_(Vn.a,Vn.b,Vn.c,e,3,v,a,!0)):(UI.fromBufferAttribute(m,h),zI.fromBufferAttribute(m,d),HI.fromBufferAttribute(m,u),r_(UI,zI,HI,e,g,v,a))}}function ZX(s,e,t,i,n,r,a,o=!1){a_(s,i,n,r,a,o),a_(o?t:e,i,n,r,a,o),a_(o?e:t,i,n,r,a,o)}function QI(s,e,t=!1){switch(s){case VX:if(e===rc||e===pv&&!t)return ac;break;case WX:if(t){if(e===sc)return Ip}else if(e===rc||e===uv)return ac;break;case QX:if(t){if(e===rc||e===uv)return ac}else if(e===sc)return Ip;break;case jX:if(e===sc)return Ip;if(e===rc)return ac;break;case kI:if(e===sc||e===pv&&!t)return ac;break;case OI:if(!t&&(e===rc||e===uv))return ac;break;case FI:if(!t&&(e===sc||e===pv))return ac;break;default:throw new Error(`Unrecognized CSG operation enum "${s}".`)}return s_}function r_(s,e,t,i,n,r,a=!1,o=!1){const l=c=>{r.push(c.x),n>1&&r.push(c.y),n>2&&r.push(c.z),n>3&&r.push(c.w)};t_.set(0,0,0,0).addScaledVector(s,i.a.x).addScaledVector(e,i.a.y).addScaledVector(t,i.a.z),hv.set(0,0,0,0).addScaledVector(s,i.b.x).addScaledVector(e,i.b.y).addScaledVector(t,i.b.z),dv.set(0,0,0,0).addScaledVector(s,i.c.x).addScaledVector(e,i.c.y).addScaledVector(t,i.c.z),o&&(t_.normalize(),hv.normalize(),dv.normalize()),l(t_),a?(l(dv),l(hv)):(l(hv),l(dv))}function a_(s,e,t,i,n,r=!1){for(const a in n){const o=e[a],l=n[a];if(!(a in e))throw new Error(`CSG Operations: Attribute ${a} no available on geometry.`);const c=o.itemSize;a==="position"?(Ba.fromBufferAttribute(o,s).applyMatrix4(t),l.push(Ba.x,Ba.y,Ba.z)):a==="normal"?(Ba.fromBufferAttribute(o,s).applyNormalMatrix(i),r&&Ba.multiplyScalar(-1),l.push(Ba.x,Ba.y,Ba.z)):(l.push(o.getX(s)),c>1&&l.push(o.getY(s)),c>2&&l.push(o.getZ(s)),c>3&&l.push(o.getW(s)))}}class JX{constructor(e){this.triangle=new ii().copy(e),this.intersects={}}addTriangle(e,t){this.intersects[e]=new ii().copy(t)}getIntersectArray(){const e=[],{intersects:t}=this;for(const i in t)e.push(t[i]);return e}}class jI{constructor(){this.data={}}addTriangleIntersection(e,t,i,n){const{data:r}=this;r[e]||(r[e]=new JX(t)),r[e].addTriangle(i,n)}getTrianglesAsArray(e=null){const{data:t}=this,i=[];if(e!==null)e in t&&i.push(t[e].triangle);else for(const n in t)i.push(t[n].triangle);return i}getTriangleIndices(){return Object.keys(this.data).map(e=>parseInt(e))}getIntersectionIndices(e){const{data:t}=this;return t[e]?Object.keys(t[e].intersects).map(i=>parseInt(i)):[]}getIntersectionsAsArray(e=null,t=null){const{data:i}=this,n=new Set,r=[],a=o=>{if(i[o])if(t!==null)i[o].intersects[t]&&r.push(i[o].intersects[t]);else{const l=i[o].intersects;for(const c in l)n.has(c)||(n.add(c),r.push(l[c]))}};if(e!==null)a(e);else for(const o in i)a(o);return r}reset(){this.data={}}}class eq{constructor(){this.enabled=!1,this.triangleIntersectsA=new jI,this.triangleIntersectsB=new jI,this.intersectionEdges=[]}addIntersectingTriangles(e,t,i,n){const{triangleIntersectsA:r,triangleIntersectsB:a}=this;r.addTriangleIntersection(e,t,i,n),a.addTriangleIntersection(i,n,e,t)}addEdge(e){this.intersectionEdges.push(e.clone())}reset(){this.triangleIntersectsA.reset(),this.triangleIntersectsB.reset(),this.intersectionEdges=[]}init(){this.enabled&&(this.reset(),VI(this))}complete(){this.enabled&&VI(null)}}const ko=new Ke,mv=new yt,oc=new ii,gv=new ii,Oo=new ii,vv=new ii,ur=[],lc=[];function tq(s){for(const e of s)return e}function iq(s,e,t,i,n,r={}){const{useGroups:a=!0}=r,{aIntersections:o,bIntersections:l}=KX(s,e),c=[];let h=null,d;return d=a?0:-1,XI(s,e,o,t,!1,i,n,d),qI(s,e,o,t,!1,n,d),t.findIndex(u=>u!==FI&&u!==OI)!==-1&&(d=a?s.geometry.groups.length||1:-1,XI(e,s,l,t,!0,i,n,d),qI(e,s,l,t,!0,n,d)),ur.length=0,lc.length=0,{groups:c,materials:h}}function XI(s,e,t,i,n,r,a,o=0){const l=s.matrixWorld.determinant()<0;ko.copy(e.matrixWorld).invert().multiply(s.matrixWorld),mv.getNormalMatrix(s.matrixWorld).multiplyScalar(l?-1:1);const c=s.geometry.groupIndices,h=s.geometry.index,d=s.geometry.attributes.position,u=e.geometry.boundsTree,p=e.geometry.index,m=e.geometry.attributes.position,v=t.ids,g=t.intersectionSet;for(let f=0,A=v.length;f<A;f++){const b=v[f],y=o===-1?0:c[b]+o,x=3*b,_=h.getX(x+0),M=h.getX(x+1),E=h.getX(x+2);oc.a.fromBufferAttribute(d,_).applyMatrix4(ko),oc.b.fromBufferAttribute(d,M).applyMatrix4(ko),oc.c.fromBufferAttribute(d,E).applyMatrix4(ko),r.reset(),r.initialize(oc);const w=g[b];for(let R=0,D=w.length;R<D;R++){const L=3*w[R],I=p.getX(L+0),O=p.getX(L+1),N=p.getX(L+2);gv.a.fromBufferAttribute(m,I),gv.b.fromBufferAttribute(m,O),gv.c.fromBufferAttribute(m,N),r.splitByTriangle(gv)}const T=r.triangles;for(let R=0,D=T.length;R<D;R++){const L=T[R],I=r.coplanarTriangleUsed?YX(L,u):WI(L,u);ur.length=0,lc.length=0;for(let O=0,N=i.length;O<N;O++){const G=QI(i[O],I,n);G!==s_&&(lc.push(G),ur.push(a[O].getGroupAttrSet(y)))}if(ur.length!==0){oc.getBarycoord(L.a,vv.a),oc.getBarycoord(L.b,vv.b),oc.getBarycoord(L.c,vv.c);for(let O=0,N=ur.length;O<N;O++){const G=ur[O],V=lc[O]===Ip;$X(b,vv,s.geometry,s.matrixWorld,mv,G,l!==V)}}}}return v.length}function qI(s,e,t,i,n,r,a=0){const o=s.matrixWorld.determinant()<0;ko.copy(e.matrixWorld).invert().multiply(s.matrixWorld),mv.getNormalMatrix(s.matrixWorld).multiplyScalar(o?-1:1);const l=e.geometry.boundsTree,c=s.geometry.groupIndices,h=s.geometry.index,d=s.geometry.attributes,u=d.position,p=[],m=s.geometry.halfEdges,v=new Set,g=j1(s.geometry);for(let f=0,A=g;f<A;f++)f in t.intersectionSet||v.add(f);for(;v.size>0;){const f=tq(v);v.delete(f),p.push(f);const A=3*f,b=h.getX(A+0),y=h.getX(A+1),x=h.getX(A+2);Oo.a.fromBufferAttribute(u,b).applyMatrix4(ko),Oo.b.fromBufferAttribute(u,y).applyMatrix4(ko),Oo.c.fromBufferAttribute(u,x).applyMatrix4(ko);const _=WI(Oo,l);lc.length=0,ur.length=0;for(let M=0,E=i.length;M<E;M++){const w=QI(i[M],_,n);w!==s_&&(lc.push(w),ur.push(r[M]))}for(;p.length>0;){const M=p.pop();for(let E=0;E<3;E++){const w=m.getSiblingTriangleIndex(M,E);w!==-1&&v.has(w)&&(p.push(w),v.delete(w))}if(ur.length!==0){const E=3*M,w=h.getX(E+0),T=h.getX(E+1),R=h.getX(E+2),D=a===-1?0:c[M]+a;if(Oo.a.fromBufferAttribute(u,w),Oo.b.fromBufferAttribute(u,T),Oo.c.fromBufferAttribute(u,R),!Lo(Oo))for(let L=0,I=ur.length;L<I;L++){const O=lc[L],N=ur[L].getGroupAttrSet(D),G=O===Ip;ZX(w,T,R,d,s.matrixWorld,mv,N,G!==o)}}}}}function nq(s){for(let e=0;e<s.length-1;e++){const t=s[e],i=s[e+1];if(t.materialIndex===i.materialIndex){const n=t.start,r=i.start+i.count;i.start=n,i.count=r-n,s.splice(e,1),e--}}}function sq(s,e,t,i){t.clear();const n=s.attributes;for(let r=0,a=i.length;r<a;r++){const o=i[r],l=n[o];t.initializeArray(o,l.array.constructor,l.itemSize,l.normalized)}for(const r in t.attributes)i.includes(r)||t.delete(r);for(const r in e.attributes)i.includes(r)||(e.deleteAttribute(r),e.dispose())}function rq(s,e,t){let i=!1,n=-1;const r=s.attributes,a=e.groupAttributes[0];for(const l in a){const c=e.getTotalLength(l),h=e.getType(l),d=e.getItemSize(l),u=e.getNormalized(l);let p=r[l];(!p||p.array.length<c)&&(p=new _t(new h(c),d,u),s.setAttribute(l,p),i=!0);let m=0;for(let v=0,g=Math.min(t.length,e.groupCount);v<g;v++){const f=t[v].index,{array:A,type:b,length:y}=e.groupAttributes[f][l],x=new b(A.buffer,0,y);p.array.set(x,m),m+=x.length}p.needsUpdate=!0,n=c/p.itemSize}if(s.index){const l=s.index.array;if(l.length<n)s.index=null,i=!0;else for(let c=0,h=l.length;c<h;c++)l[c]=c}let o=0;s.clearGroups();for(let l=0,c=Math.min(t.length,e.groupCount);l<c;l++){const{index:h,materialIndex:d}=t[l],u=e.getCount(h);u!==0&&(s.addGroup(o,u,d),o+=u)}s.setDrawRange(0,n),s.boundsTree=null,i&&s.dispose()}function YI(s,e){let t=e;return Array.isArray(e)||(t=[],s.forEach(i=>{t[i.materialIndex]=e})),t}class aq{constructor(){this.triangleSplitter=new zX,this.attributeData=[],this.attributes=["position","uv","normal"],this.useGroups=!0,this.consolidateGroups=!0,this.debug=new eq}getGroupRanges(e){return!this.useGroups||e.groups.length===0?[{start:0,count:1/0,materialIndex:0}]:e.groups.map(t=>({...t}))}evaluate(e,t,i,n=new lv){let r=!0;if(Array.isArray(i)||(i=[i]),Array.isArray(n)||(n=[n],r=!1),n.length!==i.length)throw new Error("Evaluator: operations and target array passed as different sizes.");e.prepareGeometry(),t.prepareGeometry();const{triangleSplitter:a,attributeData:o,attributes:l,useGroups:c,consolidateGroups:h,debug:d}=this;for(;o.length<n.length;)o.push(new GX);n.forEach((f,A)=>{sq(e.geometry,f.geometry,o[A],l)}),d.init(),iq(e,t,i,a,o,{useGroups:c}),d.complete();const u=this.getGroupRanges(e.geometry),p=YI(u,e.material),m=this.getGroupRanges(t.geometry),v=YI(m,t.material);m.forEach(f=>f.materialIndex+=p.length);let g=[...u,...m].map((f,A)=>({...f,index:A}));if(c){const f=[...p,...v];h&&(g=g.map(b=>{const y=f[b.materialIndex];return b.materialIndex=f.indexOf(y),b}).sort((b,y)=>b.materialIndex-y.materialIndex));const A=[];for(let b=0,y=f.length;b<y;b++){let x=!1;for(let _=0,M=g.length;_<M;_++){const E=g[_];E.materialIndex===b&&(x=!0,E.materialIndex=A.length)}x&&A.push(f[b])}n.forEach(b=>{b.material=A})}else g=[{start:0,count:1/0,index:0,materialIndex:0}],n.forEach(f=>{f.material=p[0]});return n.forEach((f,A)=>{const b=f.geometry;rq(b,o[A],g),h&&nq(b.groups)}),r?n:n[0]}evaluateHierarchy(e,t=new lv){e.updateMatrixWorld(!0);const i=(r,a)=>{const o=r.children;for(let l=0,c=o.length;l<c;l++){const h=o[l];h.isOperationGroup?i(h,a):a(h)}},n=r=>{const a=r.children;let o=!1;for(let c=0,h=a.length;c<h;c++){const d=a[c];o=n(d)||o}const l=r.isDirty();if(l&&r.markUpdated(),o&&!r.isOperationGroup){let c;return i(r,h=>{c?c=this.evaluate(c,h,h.operation):c=this.evaluate(r,h,h.operation)}),r._cachedGeometry=c.geometry,r._cachedMaterials=c.material,!0}else return o||l};return n(e),t.geometry=e._cachedGeometry,t.material=e._cachedMaterials,t}reset(){this.triangleSplitter.reset()}}class oq{engine;evaluator;fillMeshName="ClippingFaceFillMesh";fillMeshes=new Map;maxCandidates=22e5;maxTriangleCountPerMesh=12e4;fillMaterial;fillTextureRepeat=60;fillTextureRotation=0;constructor(e){this.engine=e,this.evaluator=new aq;const t=new URL("/texture/fill.png",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pt&&pt.tagName.toUpperCase()==="SCRIPT"&&pt.src||new URL("iflow-engine.umd.js",document.baseURI).href).href,i=new lo().load(t);i.wrapS=ln,i.wrapT=ln,i.center.set(.5,.5),i.rotation=this.fillTextureRotation,this.fillMaterial=new oo({color:16112010,map:i,side:qt,toneMapped:!1}),this.fillMaterial.clipShadows=!0,this.fillMaterial.clippingPlanes=e.sectionPlane}clear(){this.fillMeshes.forEach(e=>{e.parent?.remove(e),e.geometry?.dispose?.();const t=e.material;Array.isArray(t)?t.forEach(i=>i.dispose?.()):t&&t!==this.fillMaterial&&t.dispose?.()}),this.fillMeshes.clear()}updataFace(e){this.clear(),e instanceof $t&&this.engine.clipping.fillCutFace&&this.buildSinglePlaneFill(e,"face")}updataFaces(e){this.clear(),!(!Array.isArray(e)||e.length===0)&&this.engine.clipping.fillCutFace&&e.forEach((t,i)=>{if(!(t instanceof $t))return;const n=`plane-${i}-${String(t.name??i)}`;this.buildSinglePlaneFill(t,n)})}buildSinglePlaneFill(e,t){const i=this.engine?.octreeBox?.getBoundingBox?.();if(i==null||i.min==null||i.max==null)return;const n=this.collectCandidateMeshesFromOctree(e);if(n.length===0)return;const r=this.filterMeshesByBoxAndComplexity(e,n);if(r.length===0)return;const a=i.min.distanceTo(i.max),o=a*5,l=.1,c=this.createPlaneBrush(e,o,l),h=[];for(const v of r.slice(0,this.maxCandidates)){const g=this.createWorldBrushFromMesh(v);if(g!=null)try{const f=this.evaluator.evaluate(g,c,kI)?.geometry;if(!f)continue;const A=this.extractPlaneCapGeometry(f,e,l);A&&h.push(A),f.dispose()}catch{}finally{g.geometry.dispose()}}if(c.geometry.dispose(),h.length===0)return;const d=Ea(h,!1);if(h.forEach(v=>v.dispose()),!d)return;this.applyPlanarUv(d,e);const u=this.getFaceOffsetDistance(a),p=this.getFaceOffsetSign();d.translate(e.normal.x*u*p,e.normal.y*u*p,e.normal.z*u*p);const m=new We(d,this.fillMaterial);m.name=`${this.fillMeshName}_${t}`,m.frustumCulled=!1,m.renderOrder=20,m.castShadow=!1,m.receiveShadow=!1,this.engine.scene.add(m),this.fillMeshes.set(t,m)}getFaceOffsetDistance(e){return-.001}getFaceOffsetSign(){const e=this.engine?.engineStatus?.clippingFaceOffsetSign;return e===1||e===-1?e:-1}collectCandidateMeshesFromOctree(e){const t=[],i=new Set,n=Array.isArray(this.engine?.engineStatus?.models)?this.engine.engineStatus.models:[];for(const r of n){const a=this.engine.models?.find?.(c=>c.url===r.url);if(!a?.nodesMap)continue;const o=this.getIgnoredIds(r.url),l=Array.isArray(r?.info?.lods)?r.info.lods:[];for(const c of l){const h=c?.octreeBox;if(!h)continue;const d=this.collectIntersectElementIds(h,e);for(const u of d){if(o.has(u))continue;const p=a.nodesMap.get(u);if(!(p?.instance===!0||!Array.isArray(p?.infos)))for(const m of p.infos){const v=m?.mesh;v instanceof We&&(i.has(v.uuid)||(i.add(v.uuid),t.push(v)))}}}}return t}getIgnoredIds(e){const t=new Set,i=Array.isArray(this.engine?.engineStatus?.hideModels)?this.engine.engineStatus.hideModels:[],n=Array.isArray(this.engine?.engineStatus?.translucentModels)?this.engine.engineStatus.translucentModels:[],r=i.find(o=>o.url===e)?.ids;Array.isArray(r)&&r.forEach(o=>t.add(o));const a=n.find(o=>o.url===e)?.ids;return Array.isArray(a)&&a.forEach(o=>t.add(o)),t}collectIntersectElementIds(e,t){const i=new Set,n=[e];for(;n.length>0;){const r=n.pop();if(!r)continue;const a=this.octreeNodeToBox3(r);!a||!t.intersectsBox(a)||(Array.isArray(r.elements)&&r.elements.forEach(o=>i.add(o)),Array.isArray(r.children)&&r.children.forEach(o=>n.push(o)))}return i}octreeNodeToBox3(e){if(!e?.min||!e?.max)return null;const t=new P(e.min.X*.3048,e.min.Z*.3048,-e.min.Y*.3048),i=new P(e.max.X*.3048,e.max.Z*.3048,-e.max.Y*.3048),n=new P(Math.min(t.x,i.x),Math.min(t.y,i.y),Math.min(t.z,i.z)),r=new P(Math.max(t.x,i.x),Math.max(t.y,i.y),Math.max(t.z,i.z));return new xt(n,r)}filterMeshesByBoxAndComplexity(e,t){const i=[],n=new xt;for(const r of t){const a=r.geometry,o=a?.attributes?.position;!a||!o||o.count===0||(a.index?Math.floor(a.index.count/3):Math.floor(o.count/3))>this.maxTriangleCountPerMesh||(a.boundingBox||a.computeBoundingBox(),a.boundingBox&&(n.copy(a.boundingBox),r.updateWorldMatrix(!0,!1),n.applyMatrix4(r.matrixWorld),e.intersectsBox(n)&&(r.geometry.attributes.position.count>500||i.push(r))))}return i}createPlaneBrush(e,t,i){const n=new fi(t,t,i),r=e.coplanarPoint(new P),a=new Lt().setFromUnitVectors(new P(0,0,1),e.normal.clone().normalize()),o=new Ke().compose(r,a,new P(1,1,1));n.applyMatrix4(o);const l=this.toCsgReadyGeometry(n);return n.dispose(),new lv(l)}createWorldBrushFromMesh(e){const t=e.geometry;if(!t||!t.attributes?.position)return null;e.updateWorldMatrix(!0,!1);const i=t.clone();i.applyMatrix4(e.matrixWorld);const n=this.toCsgReadyGeometry(i);return i.dispose(),new lv(n)}toCsgReadyGeometry(e){const t=e.index?e.toNonIndexed():e.clone();t.getAttribute("normal")||t.computeVertexNormals();const i=t.getAttribute("position");if(i&&!t.getAttribute("uv")){const r=new Float32Array(i.count*2);t.setAttribute("uv",new it(r,2))}const n=new Set(["position","normal","uv"]);return Object.keys(t.attributes).forEach(r=>{n.has(r)||t.deleteAttribute(r)}),t}extractPlaneCapGeometry(e,t,i){const n=e.index?e.toNonIndexed():e.clone(),r=n.getAttribute("position");if(!r||r.count<3)return n.dispose(),null;const a=t.normal.clone().normalize(),o=new P,l=new P,c=new P,h=new P,d=new P,u=new P,p=new P,m=new P,v=new P,g=Math.max(i*.35,1e-4),f=Math.max(i*.7,1e-4),A=[];for(let y=0;y<r.count;y+=3){if(h.fromBufferAttribute(r,y),d.fromBufferAttribute(r,y+1),u.fromBufferAttribute(r,y+2),l.subVectors(d,h),c.subVectors(u,h),o.crossVectors(l,c),o.lengthSq()<1e-14||(o.normalize(),Math.abs(o.dot(a))<.9))continue;const x=t.distanceToPoint(h),_=t.distanceToPoint(d),M=t.distanceToPoint(u),E=Math.min(x,_,M);if(Math.max(x,_,M)-E>g)continue;const w=(x+_+M)/3;Math.abs(w)>f||w<0||(p.copy(h).addScaledVector(a,-x),m.copy(d).addScaledVector(a,-_),v.copy(u).addScaledVector(a,-M),o.dot(a)<=0?(A.push(p.x,p.y,p.z),A.push(m.x,m.y,m.z),A.push(v.x,v.y,v.z)):(A.push(p.x,p.y,p.z),A.push(v.x,v.y,v.z),A.push(m.x,m.y,m.z)))}if(n.dispose(),A.length<9)return null;const b=new dt;return b.setAttribute("position",new it(A,3)),b.computeVertexNormals(),b}applyPlanarUv(e,t){const i=e.getAttribute("position");if(!i||i.count===0)return;const{tangent:n,bitangent:r}=this.getPlaneBasis(t.normal.clone().normalize()),a=new P,o=new Float32Array(i.count*2);let l=1/0,c=-1/0,h=1/0,d=-1/0;for(let m=0;m<i.count;m++){a.fromBufferAttribute(i,m);const v=a.dot(n),g=a.dot(r),f=m*2;o[f]=v,o[f+1]=g,l=Math.min(l,v),c=Math.max(c,v),h=Math.min(h,g),d=Math.max(d,g)}const u=Math.max(c-l,1e-6),p=Math.max(d-h,1e-6);for(let m=0;m<o.length;m+=2)o[m]=(o[m]-l)/u*this.fillTextureRepeat,o[m+1]=(o[m+1]-h)/p*this.fillTextureRepeat;e.setAttribute("uv",new _t(o,2))}getPlaneBasis(e){const t=new P(1,0,0),i=new P(0,1,0),n=new P(0,0,1),r=Math.abs(e.dot(t)),a=Math.abs(e.dot(i)),o=Math.abs(e.dot(n));let l=t;a<=r&&a<=o?l=i:o<=r&&o<=a&&(l=n),l=l.clone().sub(e.clone().multiplyScalar(l.dot(e))).normalize();const c=new P().crossVectors(e,l).normalize();return{tangent:l,bitangent:c}}}class lq{engine;clippingTolerance=1e-4;sectionBox;sectionFace;clippingStencil;clippingCSGSimple=null;currentClippingMode="";fillCutFace=!0;constructor(e){this.engine=e;let t=new $t(new P(0,0,1),1e5);t.name="前";let i=new $t(new P(0,0,1),1e5);i.name="左";let n=new $t(new P(0,0,1),1e5);n.name="后";let r=new $t(new P(0,0,1),1e5);r.name="右";let a=new $t(new P(0,0,1),1e5);a.name="顶";let o=new $t(new P(0,0,1),1e5);o.name="底";let l=new $t(new P(0,0,1),1e5);l.name="face",this.engine.sectionPlane=[t,i,n,r,a,o,l]}init(){this.sectionBox=new mj(this.engine),this.sectionFace=new gj(this.engine),this.clippingCSGSimple=new oq(this.engine)}scaleBox(){let e=this.engine.octreeBox.getBoundingBox();this.sectionBox.setBox(e)}setFillCutFace(e){this.fillCutFace=e}getFillCutFace(){return this.fillCutFace}clippingModel(e){let t=[];e.forEach(r=>{let a=this.engine.models.find(o=>o.url===r.url);r.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(r){let a=new P(1e8,1e9,1e10),o=new P(-1e8,-1e9,-1e10);return r.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 xt(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,r=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:r,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.setFaceNormal(new P(-1,0,0));else if(e=="y")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceNormal(new P(0,0,-1));else if(e=="z")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceNormal(new P(0,-1,0));else if(e=="box")this.sectionBox.init(),this.sectionBox.active();else if(e=="face"){let t=new vj(this.engine);t.init(),t.catch_face(i=>{this.sectionFace.init(),this.sectionFace.active();let n=this.engine.octreeBox.getBoundingBox(),r=n.min.clone().add(n.max.clone()).multiplyScalar(.5),a=i.position.clone().sub(r),o=new P(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.clippingCSGSimple?.clear(),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 $t);if(this.currentClippingMode==="x"||this.currentClippingMode==="y"||this.currentClippingMode==="z"||this.currentClippingMode==="face"){const t=e[6];return t instanceof $t?[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 P((i.min.x+i.max.x)/2,(i.min.y+i.max.y)/2,(i.min.z+i.max.z)/2),r=new P(t.x,t.y,t.z).normalize().clone().negate(),a=new P(e.x,e.y,e.z).clone().sub(n).dot(r);this.sectionFace.setFaceNormalPlaneOnly(r,a),this.sectionFace.activateClippingOnly(),this.currentClippingMode="face"}}class cq{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 hq{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 We){const r=n.geometry;if(r&&r.attributes){const a=r.attributes.position;if(a){const o=a.count;e+=o;let l=0;r.index?l=r.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 dq{engine;extended=new Map;constructor(e){this.engine=e}init(){}updateExtended(e,t){let i=this.extended.get(e);i==null?this.extended.set(e,t):t.forEach((n,r)=>{i.set(r,n)})}getModelPropertiesWithName(e,t,i,n){let r=this.extended.get(e),a=this.engine.engineStatus.models.find(l=>l.url===e);a.properties==null?lp(e+"/property",l=>{let c=JSON.parse(l);a.properties=c,setTimeout(()=>{o(c,i,t,n)},100)},()=>{},a?.key):o(a.properties,i,t,n);function o(l,c,h,d){let u={};l.models[h.toString()||""].forEach(p=>{i.includes(l.names[p[1]])&&(u[l.names[p[1]]]=l.values[p[2]])}),r!=null&&r.has(h)&&u.push(r.get(h)),d?.({id:h,properties:u})}}getModelProperties(e,t,i){let n=this.extended.get(e),r=this.engine.engineStatus.models.find(o=>o.url===e);r.properties==null&&lp(e+"/property",o=>{let l=JSON.parse(o);r.properties=l,setTimeout(()=>{a(l,t,i)},100)},()=>{},r?.key),a(r.properties,t,i);function a(o,l,c){let h=[],d=o.models[l.toString()||""],u=d.map(p=>p[0]);u=u.filter((p,m)=>u.indexOf(p)===m),u.forEach(p=>{let m={name:o.categorys[p],children:[]};h.push(m),d.filter(v=>v[0]===p).forEach(v=>{m.children.push({name:o.names[v[1]],value:o.values[v[2]]})})}),n!=null&&n.has(l)&&h.push(n.get(l)),c?.({properties:h,materials:h})}}}class uq{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(r=>{let a={url:r.url,ids:[]};n.push(a),r.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 r={url:n.url,ids:[]};i.push(r),n.info.modelMapper.filter(a=>a.typeName===e).forEach(a=>{r.ids.push(Number(a.id))})}),t&&t(i),i}getModelsWithLevel(e,t){let i=[];return this.engine.engineStatus.models.forEach(n=>{let r={url:n.url,ids:[]};i.push(r),n.info.modelMapper.filter(a=>a.levelName===e).forEach(a=>{r.ids.push(Number(a.id))})}),t&&t(i),i}getModelsWithMajor(e,t){let i=[];return this.engine.engineStatus.models.forEach(n=>{let r={url:n.url,ids:[]};i.push(r),n.info.modelMapper.filter(a=>a.majorName===e).forEach(a=>{r.ids.push(Number(a.id))})}),t&&t(i),i}}class pq{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 r=await n.json().catch(()=>({}));throw new Error(`API请求失败 (${n.status}): ${r.error?.message||r.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 r=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),!r.ok){const c=await r.json().catch(()=>({}));throw new Error(`API请求失败 (${r.status}): ${c.error?.message||c.message||r.statusText}`)}const a=r.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 u of d){const p=u.trim();if(!p||!p.startsWith("data: "))continue;const m=p.slice(6);if(m!=="[DONE]")try{const v=JSON.parse(m).choices?.[0]?.delta?.content;v&&t(v,!1)}catch(v){console.warn("解析流式数据失败:",v)}}}}catch(r){throw clearTimeout(n),r.name==="AbortError"?new Error("请求超时,请重试"):r.message.includes("Failed to fetch")?new Error("网络请求失败,请检查网络连接"):r}}updateConfig(e){this.config={...this.config,...e}}getConfig(){return{...this.config}}}class fq{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 pq(n.llmConfig);try{const r=await Promise.resolve().then(()=>oJ);this.prompts.main=r.default;const a=await Promise.resolve().then(()=>lJ);this.prompts.step=a.default;const o=await Promise.resolve().then(()=>cJ);this.prompts.apiDoc=o.default}catch(r){throw console.error("[AI Manager] 提示词文件加载失败:",r),new Error(`提示词文件加载失败: ${r.message||"未知错误"}`)}}catch(r){throw console.error("[AI Manager] 初始化失败:",r),r}}async conversationV2(e){if(this.conversationHistory.length===0){const n={role:"system",content:`${this.prompts.main}`},r={role:"system",content:`## BIM引擎API文档
|
||
${this.prompts.apiDoc}`};this.conversationHistory.push(n),this.conversationHistory.push(r)}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 r=JSON.parse(i);return this.state="waiting_answer",{state:"waiting_answer",questions:r}}}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 r=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,r,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"))){r=h,a=!0;debugger;throw h}debugger;return h}catch(h){debugger;throw r=h,a=!0,h}}catch(l){if(a||(r=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),r=/(function|const|let|var|return|async|await|=>|engine\.|previousStepOutput)/.test(e);if(!n&&r){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}`},r={role:"user",content:`请根据以下步骤描述生成可执行的JavaScript代码:
|
||
|
||
步骤信息:
|
||
${JSON.stringify(e,null,2)}
|
||
|
||
前序步骤输出数据:
|
||
${t?JSON.stringify(t,null,2):"null"}
|
||
|
||
请严格按照##code##格式输出代码。`},a=[i,n,r],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,r){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}
|
||
\`\`\`
|
||
`:`
|
||
(无)
|
||
`}
|
||
|
||
执行错误信息(第 ${r} 次重试前):
|
||
${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 r=new Function("engine","previousStepOutput",`
|
||
'use strict';
|
||
${n}
|
||
`)(i,t);return r&&typeof r.then=="function"?await r:r}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 mq{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],r=this.points[this.playToIndex],a=this.interpolatePose(n,r,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),r={type:t.type,position:{x:Bt.lerp(e.position.x,t.position.x,n),y:Bt.lerp(e.position.y,t.position.y,n),z:Bt.lerp(e.position.z,t.position.z,n)},rotation:{x:Bt.lerp(e.rotation.x,t.rotation.x,n),y:Bt.lerp(e.rotation.y,t.rotation.y,n),z:Bt.lerp(e.rotation.z,t.rotation.z,n)},quaternion:{x:Bt.lerp(e.quaternion.x,t.quaternion.x,n),y:Bt.lerp(e.quaternion.y,t.quaternion.y,n),z:Bt.lerp(e.quaternion.z,t.quaternion.z,n),w:Bt.lerp(e.quaternion.w,t.quaternion.w,n)}};return e.target&&t.target?r.target={x:Bt.lerp(e.target.x,t.target.x,n),y:Bt.lerp(e.target.y,t.target.y,n),z:Bt.lerp(e.target.z,t.target.z,n)}:t.target&&(r.target={...t.target}),e.zoom!==void 0&&t.zoom!==void 0&&(r.zoom=Bt.lerp(e.zoom,t.zoom,n)),e.orthographicHeight!==void 0&&t.orthographicHeight!==void 0?r.orthographicHeight=Bt.lerp(e.orthographicHeight,t.orthographicHeight,n):t.orthographicHeight!==void 0&&(r.orthographicHeight=t.orthographicHeight),r}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 gq{engine;miniMapCamera=null;miniMapRenderer=null;miniMapContainer=null;overlayCanvas=null;overlayCtx=null;levelToolbar=null;modelSelect=null;levelSelect=null;levelModels=[];levelDataSignature="";selectedModelUrl=null;isVisible=!1;mapSize=200;levelJumpEyeOffset=1.4;currentHalfSize=100;minHalfSize=.01;maxHalfSize=1e5;halfSizeInitialized=!1;camY=1e3;centerX=0;centerZ=0;dragMode=null;moveHandleRadius=12;rotateHandleRadius=40;lastMouseX=0;lastMouseY=0;dragPointerOffsetX=0;dragPointerOffsetY=0;centerInitialized=!1;isMouseInsideMiniMap=!1;loadingCompletedEventName="loading_completed";onLoadingCompleted=()=>{this.refreshLevelSelectors(!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 Uu({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.initLevelSelectors(),this.miniMapCamera=new Zi(-this.currentHalfSize,this.currentHalfSize,this.currentHalfSize,-this.currentHalfSize,.1,1e3),this.miniMapCamera.up.set(0,0,-1),this.setupEvents(),this.engine.events?.on?.(this.loadingCompletedEventName,this.onLoadingCompleted)}initLevelSelectors(){if(!this.miniMapContainer)return;const e=document.createElement("div");e.style.position="absolute",e.style.left="6px",e.style.right="6px",e.style.top="6px",e.style.display="flex",e.style.flexDirection="column",e.style.gap="4px",e.style.zIndex="3",e.style.pointerEvents="auto";const t=this.createSelectElement("选择模型"),i=this.createSelectElement("选择标高");e.appendChild(t),e.appendChild(i),this.miniMapContainer.appendChild(e),this.levelToolbar=e,this.modelSelect=t,this.levelSelect=i,this.modelSelect.addEventListener("change",this.onModelChange),this.levelSelect.addEventListener("change",this.onLevelChange),this.bindControlEventBlock(e),this.bindControlEventBlock(t),this.bindControlEventBlock(i),this.refreshLevelSelectors(!0)}createSelectElement(e){const t=document.createElement("select");t.style.height="24px",t.style.width="100%",t.style.borderRadius="3px",t.style.border="1px solid rgba(255, 255, 255, 0.3)",t.style.background="rgba(26, 26, 46, 0.85)",t.style.color="#ffffff",t.style.fontSize="12px",t.style.padding="0 6px",t.style.outline="none",t.style.boxSizing="border-box";const i=document.createElement("option");return i.value="",i.textContent=e,i.disabled=!0,i.selected=!0,t.appendChild(i),t}bindControlEventBlock(e){["mousedown","mousemove","mouseup","click","dblclick","pointerdown","pointermove","pointerup","wheel"].forEach(t=>{e.addEventListener(t,i=>{i.stopPropagation()})})}onModelChange=()=>{this.modelSelect&&(this.selectedModelUrl=this.modelSelect.value||null,this.refreshLevelOptionsByModel(this.selectedModelUrl))};onLevelChange=()=>{if(!this.levelSelect)return;const e=this.levelSelect.value;if(!e)return;const t=Number(e);Number.isNaN(t)||this.jumpToElevation(t)};refreshLevelSelectors(e=!1){const t=this.collectModelLevels(),i=this.buildLevelSignature(t);if(!e&&i===this.levelDataSignature||(this.levelDataSignature=i,this.levelModels=t,!this.levelToolbar||!this.modelSelect||!this.levelSelect))return;if(this.levelModels.length===0){this.levelToolbar.style.display="none";return}this.levelToolbar.style.display="flex";const n=this.levelModels.length>1;this.modelSelect.style.display=n?"block":"none";const r=this.pickSelectedModelUrl(n);this.selectedModelUrl=r,n&&this.fillModelSelect(r),this.refreshLevelOptionsByModel(r)}pickSelectedModelUrl(e){if(!e)return this.levelModels[0].url;const t=this.levelModels.find(i=>i.url===this.selectedModelUrl);return t?t.url:this.levelModels[0].url}fillModelSelect(e){this.modelSelect&&(this.modelSelect.innerHTML="",this.levelModels.forEach(t=>{const i=document.createElement("option");i.value=t.url,i.textContent=t.name,i.selected=t.url===e,this.modelSelect?.appendChild(i)}))}refreshLevelOptionsByModel(e){if(!this.levelSelect)return;const t=this.levelModels.find(n=>n.url===e)??this.levelModels[0],i=this.levelSelect.value;this.levelSelect.innerHTML="",t.levels.forEach(n=>{const r=document.createElement("option");r.value=String(n.Elevation),r.textContent=`${n.Name} (${n.Elevation.toFixed(3)}m)`,r.selected=r.value===i,this.levelSelect?.appendChild(r)}),this.levelSelect.options.length>0&&this.levelSelect.selectedIndex<0&&(this.levelSelect.selectedIndex=0)}jumpToElevation(e){const t=this.engine.camera;if(!t)return;const i=e+this.levelJumpEyeOffset,n=t.position.y,r=this.engine.controlModule?.firstPersonControls;r?.enabled&&typeof r.setCameraHeight=="function"?r.setCameraHeight(i):t.position.y=i;const a=t.position.y-n,o=this.engine.controls;o?.target&&(o.target.y+=a),o?.update?.()}collectModelLevels(){if(!Array.isArray(this.engine.models))return[];const e=[];return this.engine.models.forEach((t,i)=>{if(!Array.isArray(t.levels))return;const n=t.levels.map((a,o)=>this.normalizeLevelData(a,o)).filter(a=>a!==null).sort((a,o)=>a.Elevation-o.Elevation);if(n.length===0)return;const r=typeof t.url=="string"?t.url:`model-${i+1}`;e.push({url:r,name:this.getModelDisplayName(r,i),levels:n})}),e}normalizeLevelData(e,t){const i=Number(e?.Elevation);if(Number.isNaN(i))return null;const n=e?.Id!=null?String(e.Id):`level-${t+1}`,r=e?.Name!=null&&String(e.Name).trim()!==""?String(e.Name):`Level ${t+1}`;return{Id:n,Name:r,Elevation:i}}getModelDisplayName(e,t){const i=this.engine.engineStatus?.models?.find(r=>r.url===e);if(typeof i?.name=="string"&&i.name.trim()!=="")return i.name;const n=e.split("/").filter(Boolean);return n[n.length-1]??`模型${t+1}`}buildLevelSignature(e){return e.map(t=>{const i=t.levels.map(n=>`${n.Id}|${n.Name}|${n.Elevation}`).join(",");return`${t.url}:${i}`}).join("||")}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}}isRoamingActive(){return!!this.engine.controlModule?.firstPersonControls?.enabled}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("mouseenter",this.onMouseEnter),e.addEventListener("mouseleave",this.onMouseLeave),e.addEventListener("contextmenu",t=>t.preventDefault()),window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp),["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.preventDefault(),e.stopPropagation();const t=this.miniMapContainer.getBoundingClientRect(),i=e.clientX-t.left,n=e.clientY-t.top,r=this.engine.camera;if(!r)return;const a=this.worldToPixel(r.position.x,r.position.z),o=Math.hypot(i-a.x,n-a.y);if(e.button!==0){this.dragMode=null;return}o<=this.moveHandleRadius?(this.dragMode="move",this.miniMapContainer.style.cursor="move",this.dragPointerOffsetX=i-a.x,this.dragPointerOffsetY=n-a.y):o<=this.rotateHandleRadius?(this.dragMode="rotate",this.miniMapContainer.style.cursor="alias"):(this.dragMode="pan",this.miniMapContainer.style.cursor="grabbing"),this.lastMouseX=i,this.lastMouseY=n};onMouseMove=e=>{const t=this.miniMapContainer.getBoundingClientRect(),i=e.clientX-t.left,n=e.clientY-t.top;if(!this.dragMode){const r=this.engine.camera;if(!r||!this.miniMapContainer)return;const a=this.worldToPixel(r.position.x,r.position.z),o=Math.hypot(i-a.x,n-a.y);o<=this.moveHandleRadius?this.miniMapContainer.style.cursor="move":o<=this.rotateHandleRadius?this.miniMapContainer.style.cursor="alias":this.miniMapContainer.style.cursor="crosshair";return}e.stopPropagation(),this.dragMode==="rotate"?this.handleRotateByDrag(i,n):this.dragMode==="move"?this.handleMoveControlByDrag(i-this.dragPointerOffsetX,n-this.dragPointerOffsetY):this.dragMode==="pan"&&this.handlePanMapByDrag(i,n),this.lastMouseX=i,this.lastMouseY=n};onMouseUp=e=>{this.dragMode&&(e.stopPropagation(),this.dragMode=null,this.dragPointerOffsetX=0,this.dragPointerOffsetY=0,this.miniMapContainer&&(this.miniMapContainer.style.cursor="crosshair"))};onMouseEnter=()=>{this.isMouseInsideMiniMap=!0};onMouseLeave=()=>{this.isMouseInsideMiniMap=!1,!this.dragMode&&this.miniMapContainer&&(this.miniMapContainer.style.cursor="crosshair")};handleMoveControlByDrag(e,t){const i=this.engine.camera,n=this.engine.controls;if(!i||!n)return;const{x:r,z:a}=this.pixelToWorld(e,t),o=r-i.position.x,l=a-i.position.z;o===0&&l===0||(i.position.x=r,i.position.z=a,n.target&&(n.target.x+=o,n.target.z+=l),n.update?.())}handlePanMapByDrag(e,t){const i=e-this.lastMouseX,n=t-this.lastMouseY;if(i===0&&n===0)return;const r=2*this.currentHalfSize/this.mapSize;this.centerX-=i*r,this.centerZ-=n*r}handleRotateByDrag(e,t){const i=this.engine.camera,n=this.engine.controls;if(!i||!n)return;const r=this.worldToPixel(i.position.x,i.position.z),a=Math.atan2(this.lastMouseY-r.y,this.lastMouseX-r.x);let o=Math.atan2(t-r.y,e-r.x)-a;o>Math.PI&&(o-=2*Math.PI),o<-Math.PI&&(o+=2*Math.PI);const l=new P().copy(n.target).sub(i.position),c=new gh().setFromVector3(l);c.theta-=o,l.setFromSpherical(c),n.target.copy(i.position).add(l),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.worldToPixel(t.position.x,t.position.z),n=i.x,r=i.y,a=new P;t.getWorldDirection(a);const o=Math.atan2(a.x,-a.z),l=50,c=Math.PI/6;e.save(),e.translate(n,r),e.rotate(o);const h=e.createRadialGradient(0,0,1,0,0,l);h.addColorStop(0,"rgba(0, 230, 130, 0.9)"),h.addColorStop(1,"rgba(0, 230, 130, 0)");const d=-Math.sin(c)*l,u=-Math.cos(c)*l,p=Math.sin(c)*l,m=-Math.cos(c)*l;e.beginPath(),e.moveTo(0,0),e.lineTo(d,u),e.lineTo(p,m),e.closePath(),e.fillStyle=h,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;const e=this.engine.camera;e&&(this.centerX=e.position.x,this.centerZ=e.position.z,this.centerInitialized=!0),this.refreshLevelSelectors(),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.refreshLevelSelectors(),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,r=t.max.y-t.min.y;this.camY=t.max.y+Math.max(i,n,r),!this.halfSizeInitialized&&i+n>0&&(this.currentHalfSize=Math.max(i,n)*.2,this.halfSizeInitialized=!0)}}this.centerInitialized||(this.centerX=e.position.x,this.centerZ=e.position.z,this.centerInitialized=!0),this.isRoamingActive()&&!this.isMouseInsideMiniMap&&(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("mouseenter",this.onMouseEnter),this.miniMapContainer.removeEventListener("mouseleave",this.onMouseLeave)),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp),this.modelSelect?.removeEventListener("change",this.onModelChange),this.levelSelect?.removeEventListener("change",this.onLevelChange),this.engine.events?.off?.(this.loadingCompletedEventName,this.onLoadingCompleted),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,this.levelToolbar=null,this.modelSelect=null,this.levelSelect=null,this.levelModels=[],this.levelDataSignature="",this.selectedModelUrl=null}}class vq{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 r=n.nodesMap.get(i)?.infos?.[0];if(r?.box==null)return null;const a=r.box.min.clone().add(r.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 P?e.clone():new P(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),r=this.getPoint(n);return{url:i,point:r,grid:this.engine.grid?.getLocationByPoint(i??r,i?r:void 0)??null,level:this.engine.level?.getLocationByPoint(i??r,i?r: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 P;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(r=>r.url===t.url)?.ids??[],n=t.ids.filter(r=>i.includes(r));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(),r=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,r,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?.()??Ig.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 Zi&&(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 P(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(r=>r.url===e.url);if(!t)return null;const i=e.ids.map(r=>t.nodesMap.get(r)).flatMap(r=>r?.infos?.map(a=>a?.box).filter(Boolean)??[]);if(i.length===0)return null;const n=new xt;n.copy(i[0]);for(let r=1;r<i.length;r++)n.union(i[r]);return n}normalizeRestorePose(e,t){if(!e||!e.position)return null;const i=this.engine.camera,n={type:e.type??this.engine.cameraModule?.getCameraType?.()??Ig.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 Zi&&n.type===Ig.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 r=i.clone().normalize();return Math.abs(r.dot(e))<.999?r:new P(1,0,0)}}class Aq{engine;constructor(e){}update(){}}let bq=class{engine;constructor(s){this.engine=s,this.active()}active(){window.addEventListener("D2ElementClick",this.listenElementClick)}disActive(){window.removeEventListener("D2ElementClick",this.listenElementClick)}listenElementClick=s=>{let e=!0;this.engine.models.forEach(t=>{t.nodesMap.has(Number(s.detail.id))&&(e=!1,this.engine.modelToolModule.highlightModel([{url:t.url,ids:[Number(s.detail.id)]}]),this.engine.viewCube.zoomToModels({url:t.url,id:Number(s.detail.id)}))}),(Number(s.detail.id)==-1||e)&&this.engine.modelToolModule.unhighlightAllModels()}},yq=class{engine;constructor(s){this.engine=s,this.active()}active(){window.addEventListener("D2ViewControl",this.listenViewUpdate)}disActive(){window.removeEventListener("D2ViewControl",this.listenViewUpdate)}listenViewUpdate=s=>{const e=s?.detail;e&&(e.position&&this.applyPosition(e.position),typeof e.rotation=="number"&&this.applyRotation(e.rotation))};applyPosition(s){const e=this.engine.camera;if(!e)return;const t=this.engine.controls,i=e.position.clone(),n=typeof s.y=="number"?s.y:i.y;e.position.set(s.x,n,s.z),t?.target?(t.target.set(t.target.x+(s.x-i.x),t.target.y+(n-i.y),t.target.z+(s.z-i.z)),t.update(),t.dispatchEvent?.({type:"change"})):e.updateMatrixWorld()}applyRotation(s){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 r=new P(Math.sin(s),0,-Math.cos(s)),a=i?i.y:e.position.y,o=new P(e.position.x+r.x*n,a,e.position.z+r.z*n);t?.target?(t.target.copy(o),t.update(),t.dispatchEvent?.({type:"change"})):e.lookAt(o)}};const xq=`
|
||
## 公路工程WBS标准编码规则(用于开发)
|
||
以下内容严格依据《中交集团基建施工板块公路工程WBS分解标准》(Q/CCCG XG ZY GL01-2022)文件,用于指导AI完成编码解析、校验、映射及代码生成等开发任务。
|
||
|
||
### 一、四类编码的格式定义
|
||
|
||
#### 1. WBS分解编码
|
||
- **格式**:"GL-UxxPxxSxx" + 可选的3位数字子分项(如 "GL-U04P01S02001")
|
||
- **长度**:基础部分10个字符(含分隔符),完整最多13个字符
|
||
- **正则表达式**:"^GL-Ud{2}Pd{2}Sd{2}(d{3})?$"
|
||
- **层级结构**(固定5级,第5级可选):
|
||
|
||
| 位置 | 段 | 含义 | 取值范围(根据文件附录一) |
|
||
|------|-----|------|------------------------------|
|
||
| 1-2 | GL | 工程类型(公路) | 固定 "GL" |
|
||
| 4-5 | Uxx | 单位工程 | "U01"~"U09"(见下表) |
|
||
| 7-8 | Pxx | 分部工程 | "P01"~"P13"(不同单位工程不同) |
|
||
| 10-11 | Sxx | 分项工程 | "S01"~"Sxx"(根据附录一) |
|
||
| 12-14 | 3位数字 | 子分项(可选) | "001"~"999" |
|
||
|
||
**单位工程编码表**:
|
||
|
||
| 编码 | 名称 |
|
||
|------|------|
|
||
| GL-U01 | 总则 |
|
||
| GL-U02 | 路基工程 |
|
||
| GL-U03 | 路面工程 |
|
||
| GL-U04 | 桥涵工程 |
|
||
| GL-U05 | 隧道工程 |
|
||
| GL-U06 | 安全设施及预埋管线工程 |
|
||
| GL-U07 | 绿化及环境保护设施工程 |
|
||
| GL-U08 | 公路沿线管理用房工程 |
|
||
| GL-U09 | 机电工程 |
|
||
|
||
|
||
#### 2. 收入清单编码
|
||
- **格式**:"GL-" + 由数字和字母组成的多级编码,各段以 "-" 分隔
|
||
- **正则表达式**:"^GL-(d+)(-[A-Za-z0-9]+)*$"
|
||
- **层级规则**:不固定位数,第一级为章号(3位数字),后续为子目号(数字或字母)。源自《公路工程标准施工招标文件》(2018年版)清单体系,增加 "GL" 前缀。
|
||
- **示例**:"GL-405-1-a"、"GL-410-4-b-3"、"GL-417-2"
|
||
|
||
#### 3. 分包清单编码
|
||
- **格式**:基于收入清单编码向下扩展,最后一级为工序号(两位数字)
|
||
- **正则表达式**:"^GL-(d+)(-[A-Za-z0-9]+)*-d{2}$"
|
||
- **规则**:同一级分包清单接续原同级编码依次增加;补充下一级时自 "01" 开始递增。
|
||
- **示例**:"GL-405-1-a-01"(表示收入清单 "GL-405-1-a" 下的第1个分包工序)
|
||
|
||
#### 4. 形象进度单元编码
|
||
- **格式**:"GL-" + 6位数字(无分隔符,实际为3级9位编码的紧凑写法)
|
||
- **正则表达式**:"^GL-d{6}$"
|
||
- **层级**(文件第13页4.4.1):
|
||
- 第1级:"GL"(公路工程)
|
||
- 第2级:2位数字(单位工程代码,如 "04" 桥涵)
|
||
- 第3级:2位数字(分部/分项代码,如 "01" 桩基础)
|
||
- 第4级:2位数字(更细单元,如 "01" 桩基础具体)
|
||
- 整体拼接为 "GL-04-01-01" → 写作 "GL-040101"
|
||
|
||
|
||
|
||
**分部分项工程及收入,分包,形象进度编码表**:
|
||
|
||
| 构件名称 | 工程类型 | 单位工程 | WBS分部工程 | WBS分项工程 | 收入清单(章号+子目) | 分包清单(工序) | 形象进度单元 |
|
||
| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
|
||
| 基础开挖及回填 | GL | U04 桥涵工程 | P01 基础及下部构造 | S01 基础开挖及回填 | 404-1(干处挖土方) | 404-1-01 开挖土方 | GL-0409 其它 |
|
||
| 桩基础 | GL | U04 桥涵工程 | P01 基础及下部构造 | S02 桩基础 | 405-1-a(钻孔灌注桩/陆上) | 405-1-a-01 旋挖钻钻孔 | GL-040101 桩基础 |
|
||
| 扩大基础 | GL | U04 桥涵工程 | P01 基础及下部构造 | S03 扩大基础 | 410-1(混凝土基础) | 410-1-01 垫层混凝土施工 | GL-040102 扩大基础 |
|
||
| 沉井基础 | GL | U04 桥涵工程 | P01 基础及下部构造 | S04 沉井基础 | 409-1(钢筋混凝土沉井) | 409-1-a-01 井壁混凝土施工 | GL-040103 沉井基础 |
|
||
| 沉箱基础 | GL | U04 桥涵工程 | P01 基础及下部构造 | S05 沉箱基础 | 422-1(沉箱) | 422-1-01 钢套箱加工 | GL-040104 沉箱基础 |
|
||
| 承台 | GL | U04 桥涵工程 | P01 基础及下部构造 | S06 承台 | 410-1-c(C30混凝土承台) | 410-1-01 垫层施工 | GL-040105 承台 |
|
||
| 桩系梁 | GL | U04 桥涵工程 | P01 基础及下部构造 | S07 桩系梁 | 410-1-a(C30混凝土系梁) | 410-1-01 垫层施工 | GL-040106 系梁 |
|
||
| 支撑梁 | GL | U04 桥涵工程 | P01 基础及下部构造 | S08 支撑梁 | 410-1(混凝土基础) | 410-1-01 垫层施工 | GL-040107 支撑梁 |
|
||
| 墩身 | GL | U04 桥涵工程 | P01 基础及下部构造 | S09 墩身 | 410-2-b(桥墩混凝土) | 410-2-b-03 爬模施工 | GL-040108 墩身 |
|
||
| 柱系梁 | GL | U04 桥涵工程 | P01 基础及下部构造 | S10 柱系梁 | 410-2-b(桥墩混凝土) | 410-2-b-01 滑模施工 | GL-040106 系梁 |
|
||
| 桥台台身 | GL | U04 桥涵工程 | P01 基础及下部构造 | S11 桥台台身 | 410-2-a(桥台混凝土) | 410-2-a-02 混凝土施工 | GL-040109 桥台 |
|
||
| 桥台耳背墙 | GL | U04 桥涵工程 | P01 基础及下部构造 | S12 桥台耳背墙 | 410-2-a(桥台混凝土) | 410-2-a-02 混凝土施工 | GL-040109 桥台 |
|
||
| 盖梁、台帽 | GL | U04 桥涵工程 | P01 基础及下部构造 | S13 盖梁、台帽 | 410-2-c(盖梁混凝土) | 410-2-c-01 盖梁混凝土施工 | GL-040110 盖梁、台帽 |
|
||
| 墩顶固结 | GL | U04 桥涵工程 | P01 基础及下部构造 | S14 墩顶固结 | 410-2-b(桥墩混凝土) | 410-2-b-01 混凝土施工 | GL-0409 其它 |
|
||
| 抗震挡块、挡土板 | GL | U04 桥涵工程 | P01 基础及下部构造 | S15 抗震挡块、挡土板 | 410-6(现浇混凝土附属结构) | 410-6-01 混凝土施工 | GL-0409 其它 |
|
||
| 支座垫石 | GL | U04 桥涵工程 | P01 基础及下部构造 | S16 支座垫石 | 410-6-03(支座垫石、挡块等) | 410-6-0301 现浇混凝土施工 | GL-0409 其它 |
|
||
| 梁底楔形块 | GL | U04 桥涵工程 | P01 基础及下部构造 | S17 梁底楔形块 | 410-6(现浇混凝土附属结构) | 410-6-0301 现浇混凝土施工 | GL-0409 其它 |
|
||
| 实心板 | GL | U04 桥涵工程 | P02 上部构造预制及安装 | S01 实心板 | 410-4-a(混凝土预制) | 410-4-a-01 预制实心板 | GL-040201 梁板预制、安装 |
|
||
| 空心板 | GL | U04 桥涵工程 | P02 上部构造预制及安装 | S02 空心板 | 410-4-a-1(空心板预制) | 410-4-a-01 预制空心板 | GL-040201 梁板预制、安装 |
|
||
| 小箱梁 | GL | U04 桥涵工程 | P02 上部构造预制及安装 | S03 小箱梁 | 410-4-a-2(箱梁预制) | 410-4-a-02 预制箱梁 | GL-040201 梁板预制、安装 |
|
||
| 整体式箱梁 | GL | U04 桥涵工程 | P02 上部构造预制及安装 | S04 整体式箱梁 | 410-4-a-2(箱梁预制) | 410-4-a-02 预制箱梁 | GL-040201 梁板预制、安装 |
|
||
| T梁 | GL | U04 桥涵工程 | P02 上部构造预制及安装 | S05 T梁 | 410-4-b-3(T梁运输安装) | 410-4-a-03 T梁预制 | GL-040201 梁板预制、安装 |
|
||
| 钢结构梁(含钢砼) | GL | U04 桥涵工程 | P02 上部构造预制及安装 | S06 钢结构梁 | 412-4(钢箱梁) | 412-4-01 运输;412-4-02 安装 | GL-040201 梁板预制、安装 |
|
||
| 现浇板 | GL | U04 桥涵工程 | P03 上部构造现场浇筑 | S01 现浇板 | 410-3(现浇混凝土上部结构) | 410-3-03 现浇混凝土 | GL-040301 梁板现浇 |
|
||
| 现浇梁 | GL | U04 桥涵工程 | P03 上部构造现场浇筑 | S02 现浇梁 | 410-3(现浇混凝土上部结构) | 410-3-03 现浇混凝土 | GL-040301 梁板现浇 |
|
||
| 桥面板 | GL | U04 桥涵工程 | P03 上部构造现场浇筑 | S03 桥面板 | 410-3(现浇混凝土上部结构) | 410-3-03 现浇混凝土 | GL-040301 梁板现浇 |
|
||
| 桥面连续 | GL | U04 桥涵工程 | P03 上部构造现场浇筑 | S04 桥面连续 | 410-3(现浇混凝土上部结构) | 410-3-03 现浇混凝土 | GL-040302 桥面连续 |
|
||
| 湿接缝 | GL | U04 桥涵工程 | P03 上部构造现场浇筑 | S05 湿接缝 | 410-3(现浇混凝土上部结构) | 410-3-03 现浇混凝土 | GL-040302 桥面连续 |
|
||
| 铰缝 | GL | U04 桥涵工程 | P03 上部构造现场浇筑 | S06 铰缝 | 410-3(现浇混凝土上部结构) | 410-3-03 现浇混凝土 | GL-040302 桥面连续 |
|
||
| 横隔板 | GL | U04 桥涵工程 | P03 上部构造现场浇筑 | S07 横隔板 | 410-3(现浇混凝土上部结构) | 410-3-03 现浇混凝土 | GL-040302 桥面连续 |
|
||
| 端横梁 | GL | U04 桥涵工程 | P03 上部构造现场浇筑 | S08 端横梁 | 410-3(现浇混凝土上部结构) | 410-3-03 现浇混凝土 | GL-040302 桥面连续 |
|
||
| 中横梁 | GL | U04 桥涵工程 | P03 上部构造现场浇筑 | S09 中横梁 | 410-3(现浇混凝土上部结构) | 410-3-03 现浇混凝土 | GL-040302 桥面连续 |
|
||
| 墩顶负弯矩 | GL | U04 桥涵工程 | P03 上部构造现场浇筑 | S10 墩顶负弯矩 | 411(预应力混凝土工程) | 411-5-01 后张法预应力钢绞线 | GL-040302 桥面连续 |
|
||
| 桥面铺装及防水层 | GL | U04 桥涵工程 | P04 桥面系、附属工程及桥梁总体 | S01 桥面铺装及防水层 | 415-1(沥青混凝土桥面铺装) | 415-1-01 沥青铺装 | GL-0404 桥面系 |
|
||
| 桥面调平层(整体化层) | GL | U04 桥涵工程 | P04 桥面系、附属工程及桥梁总体 | S02 桥面调平层 | 415-2(水泥混凝土桥面铺装) | 415-2-03 水泥混凝土铺装 | GL-0404 桥面系 |
|
||
| 人行道 | GL | U04 桥涵工程 | P05 附属工程 | S01 人行道 | 410-6(现浇混凝土附属结构) | 410-6-01 现浇混凝土 | GL-0409 其它 |
|
||
| 护栏 | GL | U04 桥涵工程 | P05 附属工程 | S02 护栏 | 410-6(现浇混凝土附属结构) | 410-6-01 护栏混凝土施工 | GL-040501 护栏 |
|
||
| 桥头搭板 | GL | U04 桥涵工程 | P05 附属工程 | S03 桥头搭板 | 410-6-02(搭板) | 410-6-0202 搭板混凝土施工 | GL-040502 桥头搭板 |
|
||
| 锥坡防护 | GL | U04 桥涵工程 | P05 附属工程 | S04 锥坡防护 | 413-1(浆砌片石) | 413-1-01 浆砌片石施工 | GL-040503 锥坡防护 |
|
||
| 桥梁支座 | GL | U04 桥涵工程 | P05 附属工程 | S05 桥梁支座 | 416-1(板式橡胶支座) | 416-1-01 矩形板式橡胶支座 | GL-0409 其它 |
|
||
| 伸缩装置 | GL | U04 桥涵工程 | P05 附属工程 | S06 伸缩装置及护栏挡板、防落物 | 417-2(模数式伸缩装置) | 417-2-01 模数式伸缩装置安装 | GL-040504 伸缩缝 |
|
||
| 防抛网 | GL | U04 桥涵工程 | P05 附属工程 | S07 防抛网 | 603-5(防落物网) | 603-5-01 防落物网 | GL-0409 其它 |
|
||
| 桥梁防排水处理 | GL | U04 桥涵工程 | P05 附属工程 | S08 桥梁防排水处理 | 415-4(桥面排水) | 415-4-a-01 竖横向集中排水管 | GL-0409 其它 |
|
||
| 桥梁检测 | GL | U04 桥涵工程 | P05 附属工程 | S09 桥梁检测 | 401-1(桥梁荷载试验) | 401-1-a 荷载试验 | GL-0409 其它 |
|
||
| 其他附属 | GL | U04 桥涵工程 | P05 附属工程 | S10 其他附属 | 427-1(永久钢护筒) | 427-1-01 钢护筒 | GL-0409 其它 |
|
||
| 桥梁预埋 | GL | U04 桥涵工程 | P06 桥梁预埋 | — | 510-1(预埋件) | 510-1-01 通风设施预埋件 | GL-0409 其它 |
|
||
| 拆除结构物 | GL | U04 桥涵工程 | P07 拆除结构物 | — | 202-3(拆除结构物) | 202-3-a-02 凿除钢筋混凝土 | GL-0406 拆除结构物 |
|
||
| 植筋 | GL | U04 桥涵工程 | P08 桥梁加固 | S01 植筋 | 423-1(植筋) | 423-1-01 植筋 | GL-0407 桥梁加固 |
|
||
| 裂缝处理 | GL | U04 桥涵工程 | P08 桥梁加固 | S02 裂缝处理 | 423-2(裂缝处理) | 423-2-c 环氧砂浆 | GL-0407 桥梁加固 |
|
||
| 钢结构加固 | GL | U04 桥涵工程 | P08 桥梁加固 | S03 钢结构加固 | 423-3(钢结构加固) | 423-3-01 钢结构加固 | GL-0407 桥梁加固 |
|
||
| 桥梁涂装 | GL | U04 桥涵工程 | P08 桥梁加固 | S04 桥梁涂装 | 425-1(桥梁外表涂装) | 425-1-01 涂装 | GL-0407 桥梁加固 |
|
||
| 圆管涵 | GL | U04 桥涵工程 | P09 圆管涵、倒虹吸 | S01 开挖及地基处理 | 419-1(单孔钢筋混凝土圆管涵) | 419-1-01 基坑开挖 | GL-040801 涵洞、通道 |
|
||
| 圆管涵 | GL | U04 桥涵工程 | P09 圆管涵、倒虹吸 | S02 涵身及基础 | 419-1(单孔钢筋混凝土圆管涵) | 419-1-02 基础混凝土 | GL-040801 涵洞、通道 |
|
||
| 圆管涵 | GL | U04 桥涵工程 | P09 圆管涵、倒虹吸 | S03 洞口工程 | 419-1(单孔钢筋混凝土圆管涵) | 419-1-04 浆砌防护 | GL-040801 涵洞、通道 |
|
||
| 圆管涵 | GL | U04 桥涵工程 | P09 圆管涵、倒虹吸 | S04 台背回填 | 419-1(单孔钢筋混凝土圆管涵) | 419-1-06 回填 | GL-040801 涵洞、通道 |
|
||
| 圆管涵 | GL | U04 桥涵工程 | P09 圆管涵、倒虹吸 | S05 拆除结构物 | 202-3(拆除结构物) | 202-3-a-02 凿除钢筋混凝土 | GL-040801 涵洞、通道 |
|
||
| 盖板涵 | GL | U04 桥涵工程 | P10 盖板涵 | S01 开挖及地基处理 | 420-1(钢筋混凝土盖板涵) | 420-1-01 基坑开挖 | GL-040801 涵洞、通道 |
|
||
| 盖板涵 | GL | U04 桥涵工程 | P10 盖板涵 | S02 涵身及基础 | 420-1(钢筋混凝土盖板涵) | 420-1-02 基础混凝土 | GL-040801 涵洞、通道 |
|
||
| 盖板涵 | GL | U04 桥涵工程 | P10 盖板涵 | S03 盖板 | 420-1(钢筋混凝土盖板涵) | 420-1-06 盖板预制安装 | GL-040801 涵洞、通道 |
|
||
| 盖板涵 | GL | U04 桥涵工程 | P10 盖板涵 | S04 洞口工程 | 420-1(钢筋混凝土盖板涵) | 420-1-09 浆砌防护 | GL-040801 涵洞、通道 |
|
||
| 盖板涵 | GL | U04 桥涵工程 | P10 盖板涵 | S05 台背回填 | 420-1(钢筋混凝土盖板涵) | 420-1-09 回填 | GL-040801 涵洞、通道 |
|
||
| 盖板涵 | GL | U04 桥涵工程 | P10 盖板涵 | S06 拆除结构物 | 202-3(拆除结构物) | 202-3-a-02 凿除钢筋混凝土 | GL-040801 涵洞、通道 |
|
||
| 拱涵 | GL | U04 桥涵工程 | P11 拱涵 | S01 开挖及地基处理 | 421-1-b(混凝土拱涵) | 421-1-b-01 基坑开挖 | GL-040801 涵洞、通道 |
|
||
| 拱涵 | GL | U04 桥涵工程 | P11 拱涵 | S02 涵身及基础 | 421-1-b(混凝土拱涵) | 421-1-b-02 基础混凝土 | GL-040801 涵洞、通道 |
|
||
| 拱涵 | GL | U04 桥涵工程 | P11 拱涵 | S03 洞口工程 | 421-1-b(混凝土拱涵) | 421-1-b-0303 洞门墙施工 | GL-040801 涵洞、通道 |
|
||
| 拱涵 | GL | U04 桥涵工程 | P11 拱涵 | S04 台背回填 | 421-1-b(混凝土拱涵) | 421-1-b-05 回填 | GL-040801 涵洞、通道 |
|
||
| 拱涵 | GL | U04 桥涵工程 | P11 拱涵 | S05 拆除结构物 | 202-3(拆除结构物) | 202-3-a-02 凿除钢筋混凝土 | GL-040801 涵洞、通道 |
|
||
| 箱涵 | GL | U04 桥涵工程 | P12 箱涵 | S01 开挖及地基处理 | 420-2(钢筋混凝土箱涵) | 420-2-01 基坑开挖 | GL-040801 涵洞、通道 |
|
||
| 箱涵 | GL | U04 桥涵工程 | P12 箱涵 | S02 涵身及基础 | 420-2(钢筋混凝土箱涵) | 420-2-02 基础混凝土 | GL-040801 涵洞、通道 |
|
||
| 箱涵 | GL | U04 桥涵工程 | P12 箱涵 | S03 洞口工程 | 420-2(钢筋混凝土箱涵) | 420-2-04 涵体现浇施工 | GL-040801 涵洞、通道 |
|
||
| 箱涵 | GL | U04 桥涵工程 | P12 箱涵 | S04 台背回填 | 420-2(钢筋混凝土箱涵) | 420-2-06 回填 | GL-040801 涵洞、通道 |
|
||
| 箱涵 | GL | U04 桥涵工程 | P12 箱涵 | S05 拆除结构物 | 202-3(拆除结构物) | 202-3-a-02 凿除钢筋混凝土 | GL-040801 涵洞、通道 |
|
||
| 钢波纹管涵 | GL | U04 桥涵工程 | P13 钢波纹管涵 | S01 开挖及地基处理 | 424-1(单孔钢波纹管涵) | 424-1-01 基坑开挖 | GL-040801 涵洞、通道 |
|
||
| 钢波纹管涵 | GL | U04 桥涵工程 | P13 钢波纹管涵 | S02 涵身及基础 | 424-1(单孔钢波纹管涵) | 424-1-02 基础混凝土 | GL-040801 涵洞、通道 |
|
||
| 钢波纹管涵 | GL | U04 桥涵工程 | P13 钢波纹管涵 | S03 洞口工程 | 424-1(单孔钢波纹管涵) | 424-1-03 涵管安装 | GL-040801 涵洞、通道 |
|
||
| 钢波纹管涵 | GL | U04 桥涵工程 | P13 钢波纹管涵 | S04 台背回填 | 424-1(单孔钢波纹管涵) | 424-1-04 回填 | GL-040801 涵洞、通道 |
|
||
| 钢波纹管涵 | GL | U04 桥涵工程 | P13 钢波纹管涵 | S05 拆除结构物 | 202-3(拆除结构物) | 202-3-a-02 凿除钢筋混凝土 | GL-040801 涵洞、通道 |
|
||
|
||
---
|
||
|
||
### 二、四类编码之间的关联规则
|
||
|
||
根据文件附录二和附录三,关联关系是**多对多**的映射,但存在主要模式:
|
||
|
||
| 关联方向 | 关系类型 | 说明 |
|
||
|----------|----------|------|
|
||
| WBS ↔ 收入 | 一个WBS可对应多个收入子目 | 例如 "GL-U04P01S02"(桩基础)可对应 "GL-405-1-a"(陆上钻孔桩)、"GL-405-1-b"(水中钻孔桩)等 |
|
||
| WBS ↔ 形象进度 | 一个WBS对应一个形象进度编码 | 同类构件共享同一形象进度编码,如所有桩基均为 "GL-040101" |
|
||
| 收入 ↔ 分包 | 一个收入子目可分解为多个分包工序 | 例如 "GL-405-1-a" 分解为 "GL-405-1-a-01"(钻孔)、"GL-405-1-a-02"(钢筋)、"GL-405-1-a-03"(混凝土)等 |
|
||
|
||
|
||
### 输入规则
|
||
- 输入时会将每个构件所属的id,和构件所有的属性信息,
|
||
- 你应该根据已有的所有信息去匹配编码,如无法匹配的构件,不能强行编码
|
||
|
||
|
||
[
|
||
{ "id": 0, "properties": { "族名称": "钻孔灌注桩" } },
|
||
{ "id": 1, "properties": { "族名称": "左幅3号墩盖梁" } },
|
||
{ "id": 2, "properties": { "族名称": "下部结构" } },
|
||
]
|
||
|
||
|
||
### 输出规则
|
||
- 输出必须是严格 JSON,
|
||
- 只能输出 JSON,不能输出说明文字、注释、Markdown,
|
||
- 输出格式固定为数组,
|
||
- 如无法识别的构件,各项编码应返回空值或空字符串
|
||
|
||
以下为从文件附录中提取的部分关联数据(JSON格式):
|
||
[
|
||
{
|
||
"id":0
|
||
"component": "钻孔灌注桩",
|
||
"wbs": "GL-U04P01S02",
|
||
"wbs_str":"【桥涵工程】-【测试桥梁】-【基础及下部构造】-【桩基】",
|
||
"income_codes": ["GL-405-1-a", "GL-405-1-b"],
|
||
"subcontract_codes": ["GL-405-1-a-01", "GL-405-1-a-06", "GL-403-1-b-01"],
|
||
"progress_code": "GL-040101"
|
||
},
|
||
{
|
||
"component": "T梁",
|
||
"wbs": "GL-U04P02S05",
|
||
"wbs_str":"【桥涵工程】-【测试桥梁】-【上部构造预制及安装】-【预制T梁】",
|
||
"income_codes": ["GL-410-4-b-3", "GL-411-8-b"],
|
||
"subcontract_codes": ["GL-410-4-a-03", "GL-410-4-b-0102", "GL-411-5-01"],
|
||
"progress_code": "GL-040201"
|
||
}
|
||
]
|
||
|
||
---
|
||
|
||
**请基于以上规则进行开发。如有超出文件范围的细节,请返回“规则未定义”并建议用户参照项目实际补充。**
|
||
|
||
|
||
`,od={EncodingStart:"encoding-start",EncodingComplete:"encoding-complete",EncodingError:"encoding-error"};class _q{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)+"...")}exitModelCode(e){let t=this.engine.modelProperties.extended?.get(e);return t==null||t.size===0?!1:t.values().next().value?.children?.some(i=>i.name==="wbs编码")??!1}savaModelCodeToStoge(e){let t=this.engine.modelProperties.extended?.get(e);if(t==null||t.size===0){console.warn("没有可保存的编码数据");return}let i=[];t.forEach((n,r)=>{i.push([r,n])}),localStorage.setItem("bim_encoding_"+e,JSON.stringify(i))}readModelCodeFormStoge(e){let t=localStorage.getItem("bim_encoding_"+e);if(!t){console.warn("未找到缓存编码数据:",e);return}let i=JSON.parse(t),n=new Map;i.forEach(([r,a])=>{n.set(r,a)}),this.engine.modelProperties.updateExtended(e,n)}getModelCode(e,t){return new Promise((i,n)=>{const r=["wbs","wbs编码","形象进度编码","输入编码","支出编码"];this.engine.modelProperties.getModelPropertiesWithName(e,t.toString(),r,a=>{a?.properties?i({id:t,url:e,wbs:a.properties.wbs||"",wbsStr:a.properties.wbs编码||"",progressCode:a.properties.形象进度编码||"",incomeCodes:a.properties.输入编码?a.properties.输入编码.split(","):[],subcontractCodes:a.properties.支出编码?a.properties.支出编码.split(","):[]}):n(new Error(`未找到构件 ${t} 的编码属性`))})})}on(e,t){this.engine.events.on(e,t)}off(e,t){this.engine.events.off(e,t)}async start(){let e=["注释","族名称"],t=["梁","墩","桩","墙","面","台","石","支"];this.engine.events.trigger(od.EncodingStart,{message:"编码开始"});let i=[],n="";if(this.engine.models.forEach(c=>{n=c.url,c.nodesMap.forEach((h,d)=>{t.some(u=>h.infos[0].name.includes(u))&&i.push({id:d,url:c.url})})}),i.length===0){this.engine.events.trigger(od.EncodingComplete,{message:"无匹配构件",results:[]});return}let r=await this.queryProperties(i,e);const a=40;let o=[],l=Math.ceil(r.length/a);for(let c=0;c<r.length;c+=a){let h=r.slice(c,c+a),d=Math.floor(c/a)+1;this.engine.events.trigger(od.EncodingStart,{message:`正在编码第 ${d}/${l} 批`,batch:d,totalBatches:l});try{let u=await this.startChat(n,JSON.stringify(h));o=o.concat(u)}catch(u){this.engine.events.trigger(od.EncodingError,{message:`第 ${d} 批编码失败`,error:u})}}this.engine.events.trigger(od.EncodingComplete,{message:"编码完成",url:n,results:o,total:o.length})}queryProperties(e,t){return new Promise(i=>{let n=[],r=0;e.forEach(a=>{this.engine.modelProperties.getModelPropertiesWithName(a.url,a.id,t,o=>{n.push(o),r++,r===e.length&&i(n)})})})}async startChat(e,t){try{let i=await this.chat(t);const n=i.match(/```json\s*([\s\S]*?)\s*```/),r=n?n[1]:i,a=JSON.parse(r);console.log("解析后的编码结果:",a);let o=new Map;return a.forEach(l=>{let c={name:"模型编码",children:[{name:"wbs",value:l.wbs},{name:"wbs编码",value:l.wbs_str},{name:"形象进度编码",value:l.progress_code},{name:"收入编码",value:l.income_codes?.join(",")},{name:"分包编码",value:l.subcontract_codes?.join(",")}]};o.set(l.id,c)}),this.engine.modelProperties.updateExtended(e,o),this.savaModelCodeToStoge(e),a}catch(i){return console.error("编码失败:",i),this.engine.events.trigger(od.EncodingError,{message:"编码失败",error:i}),[]}}async chat(e){let t=xq;try{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,max_tokens:8192})});if(!i.ok){const n=await i.text();throw new Error(`API request failed: ${i.status} - ${n}`)}return(await i.json()).choices[0].message.content}catch(i){throw console.error("DeepSeek API call failed:",i),i}}}class wq{engine;constructor(e){this.engine=e}getAllViewTreeData(){let e=[];return this.engine.models.forEach(t=>{let i=this.getViewTreeData(t.url);e.push({name:t.name,views:i,url:t.url})}),e}getViewTreeData(e){let t=this.engine.models.find(n=>n.url===e)?.views,i={ceilingPlans:[],elevations:[],floorPlans:[],sections:[]};return t.CeilingPlans&&t.CeilingPlans.forEach(n=>{i.ceilingPlans.push({id:n.Id,name:n.Name,url:e})}),t.Elevations&&t.Elevations.forEach(n=>{i.elevations.push({id:n.Id,name:n.Name,url:e})}),t.FloorPlans&&t.FloorPlans.forEach(n=>{i.floorPlans.push({id:n.Id,name:n.Name,url:e})}),t.Sections&&t.Sections.forEach(n=>{i.sections.push({id:n.Id,name:n.Name,url:e})}),i}openView(e,t){let i=this.engine.models.find(h=>h.url===e)?.views;const n=[...i.CeilingPlans,...i.Elevations,...i.FloorPlans,...i.Sections].find(h=>h.id===t||h.Id===t);if(!n)return;let r={X:0,Y:0,Z:0},a=1;n.ViewType=="天花平面"?r={X:0,Y:0,Z:n.Evevation}:n.viewType=="楼层平面"?r={X:0,Y:0,Z:n.Evevation}:n.viewType=="立面视图"?r=n.Origin||n.origin:n.viewType=="剖面视图"&&(r=n.Origin||n.origin,a=-1);const o=n.ViewDirection||n.viewDirection;if(!r||!o)return;const l=new P(r.X??r.x,-(r.Z??r.z),r.Y??r.y).setLength(.3048),c=new P(o.X??o.x,-(o.Z??o.z),o.Y??o.y).setLength(a);this.engine.cameraModule.setViewFromOriginAndDirection(l,c),n.ViewType||n.viewType,this.engine.clipping.setSectionByView(l,c),this.engine.camera.type!="OrthographicCamera"&&this.engine.cameraModule.switchToOrthographicCamera(),this.engine.merge2d.attachSectionPlane(e,t,l,c)}}var xs=(s=>(s.ModelLoadStart="model-load-start",s.ModelLoadProgress="model-load-progress",s.ModelLoaded="model-loaded",s.ModelLoadError="model-load-error",s.RenderStart="render-start",s.RenderEnd="render-end",s.CameraChanged="camera-changed",s.CameraReset="camera-reset",s.SelectionChanged="selection-changed",s.HoverChanged="hover-changed",s.EntityClick="entity-click",s.LayerVisibilityChanged="layer-visibility-changed",s.LayerColorChanged="layer-color-changed",s.ViewZoomChanged="view-zoom-changed",s.ViewPanChanged="view-pan-changed",s.ToolActivated="tool-activated",s.ToolDeactivated="tool-deactivated",s.Error="error",s.Warning="warning",s))(xs||{});class Eq{listeners=new Map;onceListeners=new Map;debugMode=!1;constructor(e=!1){this.debugMode=e,this.initializeEvents()}initializeEvents(){Object.values(xs).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(r=>{try{r(t)}catch(a){console.error(`[EventModule2d] Error in listener for ${e}:`,a)}});const n=this.onceListeners.get(e);n&&n.size>0&&(n.forEach(r=>{try{r(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(xs)}dispose(){this.removeAllListeners(),this.listeners.clear(),this.onceListeners.clear(),this.debugMode&&console.log("[EventModule2d] Disposed")}}class Mq extends hh{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 Sq extends dn{constructor(e){super(e)}load(e,t,i,n){const r=this,a=new gn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){const l=r.parse(JSON.parse(o));t&&t(l)},i,n)}parse(e){return new Cq(e)}}class Cq{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100,i="ltr"){const n=[],r=Tq(e,t,this.data,i);for(let a=0,o=r.length;a<o;a++)n.push(...r[a].toShapes());return n}}function Tq(s,e,t,i){const n=Array.from(s),r=e/t.resolution,a=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*r,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 u=Iq(d,r,l,c,t);i=="tb"?(l=0,c+=t.ascender*r):l+=u.offsetX,o.push(u.path)}}return o}function Iq(s,e,t,i,n){const r=n.glyphs[s]||n.glyphs["?"];if(!r){console.error('THREE.Font: character "'+s+'" does not exists in font family '+n.familyName+".");return}const a=new lS;let o,l,c,h,d,u,p,m;if(r.o){const v=r._cachedOutline||(r._cachedOutline=r.o.split(" "));for(let g=0,f=v.length;g<f;)switch(v[g++]){case"m":o=v[g++]*e+t,l=v[g++]*e+i,a.moveTo(o,l);break;case"l":o=v[g++]*e+t,l=v[g++]*e+i,a.lineTo(o,l);break;case"q":c=v[g++]*e+t,h=v[g++]*e+i,d=v[g++]*e+t,u=v[g++]*e+i,a.quadraticCurveTo(d,u,c,h);break;case"b":c=v[g++]*e+t,h=v[g++]*e+i,d=v[g++]*e+t,u=v[g++]*e+i,p=v[g++]*e+t,m=v[g++]*e+i,a.bezierCurveTo(d,u,p,m,c,h);break}}return{offsetX:r.ha*e,path:a}}class Pp{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 Pp.fromArrayBuffer(n,t)}static fromArrayBuffer(e,t){const i=KR.parse(e);return Pp._convert(i,t?.chars)}static toThreeFont(e){return new Sq().parse(e)}static _convert(e,t){const i={},n=e.unitsPerEm,r=d=>Math.round(d),a=d=>{const u=e.charToGlyph(d);if(!u||u.index===0)return;const p=u.path.commands,m=[];for(const g of p)switch(g.type){case"M":m.push(`m ${r(g.x)} ${r(g.y)}`);break;case"L":m.push(`l ${r(g.x)} ${r(g.y)}`);break;case"Q":m.push(`q ${r(g.x1)} ${r(g.y1)} ${r(g.x)} ${r(g.y)}`);break;case"C":m.push(`b ${r(g.x1)} ${r(g.y1)} ${r(g.x2)} ${r(g.y2)} ${r(g.x)} ${r(g.y)}`);break;case"Z":m.push("z");break}const v=u.getBoundingBox();i[d]={x_min:v.x1,x_max:v.x2,ha:u.advanceWidth??0,o:m.join(" ")}};if(t)for(const d of t)a(d);else{const d=e.tables.cmap?.glyphIndexMap??{};for(const u of Object.keys(d)){const p=Number.parseInt(u,10);p>0&&a(String.fromCodePoint(p))}}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 Pq{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 r=document.createElement("button");r.textContent="×",r.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;
|
||
`,r.onmouseenter=()=>{r.style.color="var(--e2d-close-hover,#fff)"},r.onmouseleave=()=>{r.style.color="var(--e2d-close,#aaa)"},r.onclick=()=>this.hide(),i.appendChild(n),i.appendChild(r),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 u=!this.delegate.isAllVisible();this.delegate.setAllLayersVisible(u),this._renderList(),this._updateEye(o,u)};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),r=document.createElement("span");r.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(r),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(),r=e.offsetParent?.getBoundingClientRect()??{left:0,top:0};e.style.left=n.left-r.left+"px",e.style.top=n.top-r.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-r.left+"px",e.style.top=h.clientY-o-r.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 KI{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 Pq(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(r=>{r.name?.startsWith(n)&&(r.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 $I{engine;data=null;enableValidation=!0;constructor(e){for(this.engine=e,this.engine.modelGroup=new Si,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(xs.ModelLoadStart,{url:e}),lp(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 KI(this.engine)),this.engine.layerManager._loadLayers(),this.engine.events&&this.engine.events.trigger(xs.ModelLoaded,{})},i=>{this._emitProgress(0,"抱歉,图纸加载失败")});else{this.engine.events&&this.engine.events.trigger(xs.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(xs.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 Pp.fromUrl(e);return Pp.toThreeFont(t)}_emitProgress(e,t){this.engine.events&&this.engine.events.trigger(xs.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 dt().setFromPoints(n);let o=parseInt(i.split("||")[1]);if(o==0){var r=this.model.layers.find(d=>d.name==i.split("||")[0]);o=r.color}const l=new bi({color:o}),c=new Oi(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,u)=>{this.model.nodeMap.has(u)?this.model.nodeMap.get(u).push({indexes:[this.engine.modelGroup.children.length-1,h,h+d.length*3],min:new P(Math.min(...d.map(p=>p.x)),Math.min(...d.map(p=>p.y)),0),max:new P(Math.max(...d.map(p=>p.x)),Math.max(...d.map(p=>p.y)),0)}):this.model.nodeMap.set(u,[{indexes:[this.engine.modelGroup.children.length-1,h,h+d.length*3],min:new P(Math.min(...d.map(p=>p.x)),Math.min(...d.map(p=>p.y)),0),max:new P(Math.max(...d.map(p=>p.x)),Math.max(...d.map(p=>p.y)),0)}]),h=h+d.length*3})}}),this._emitProgress(85,"正在加载..."),await Promise.resolve(),this.model.textMap.forEach((t,i)=>{const n=Ea(t.map(c=>c.geometry),!1);let r=Number.parseInt(i.split("||")[1]);if(r===0){const c=this.model.layers.find(h=>h.name===i.split("||")[0]);c&&(r=c.color)}const a=new Wt({color:r,side:qt});i.includes("_hitbox")&&(a.visible=!1);let o=new We(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 P(c.info.min[0],c.info.min[1],0),max:new P(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 P(c.info.min[0],c.info.min[1],0),max:new P(c.info.max[0],c.info.max[1],0)}])})}),this._emitProgress(93,"正在加载..."),await Promise.resolve(),this.model.hatchMap.forEach((t,i)=>{let n=Ea(t.map(h=>h.geometry),!1),r=parseInt(i.split("||")[1]);if(r==0){var a=this.model.layers.find(h=>h.name==i.split("||")[0]);r=a.color}const o=new Wt({color:r,side:qt,transparent:!0,opacity:.5});let l=new We(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 P(h.info.min[0],h.info.min[1],0),max:new P(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 P(h.info.min[0],h.info.min[1],0),max:new P(h.info.max[0],h.info.max[1],0)}])})}),this._emitProgress(100,"加载完成")}loadBlock(e,t,i,n=0){let r=[0,0,0];i&&(r=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,r);break;case"CIRCLE":c=this.getPoint_arc(a,r);break;case"POLYLINE":c=this.getPoint_polyline(a,r);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(u=>{c.push(...u.map(p=>p.clone()))});const d=this.getMatrix(a.position,a.scale,a.rotation);c.forEach(u=>{u.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 P(e.points[n].x,e.points[n].y,0)),i.push(new P(e.points[n+1].x,e.points[n+1].y,0));return e.closed&&(i.push(new P(e.points[e.points.length-1].x,e.points[e.points.length-1].y,0)),i.push(new P(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 sa;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 Cu;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 Ru(l))}if(n.length===0)return;const r=n.length===1?n[0]:Ea(n,!1),a=e.layer+"||"+e.color;this.model.hatchMap.has(a)?this.model.hatchMap.get(a).push({geometry:r,info:e}):this.model.hatchMap.set(a,[{geometry:r,info:e}])}create_text(e){if(!this.font||!e.text)return;const t=new Mq(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 r=t.boundingBox;if(r){const a=r.max.x-r.min.x,o=r.max.y-r.min.y,l=new Ds(a,o);new Wt({visible:!1,side:qt,depthWrite:!1});let c=[(r.min.x+r.max.x)/2,(r.min.y+r.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 P(e.startPoint[0],e.startPoint[1],e.startPoint[2]||0),n=new P(e.endPoint[0],e.endPoint[1],e.endPoint[2]||0);let r=[i,n];return r.forEach(a=>{a[0]=a[0]-t[0],a[1]=a[1]-t[1]}),r}getPoint_arc(e,t){const i=e.center[0],n=e.center[1],r=e.radius,a=new Eu(i,n,r,r,e.startAngle,e.endAngle,!1,0).getPoints(30).map(l=>new P(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 P(e[0],e[1],e[2]),r=new Yi(0,0,i),a=new P(t[0],t[1],t[2]),o=new Lt;o.setFromEuler(r);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 Dq{engine;sectionPlaneGroup=null;loaderModule2d;constructor(e){this.engine=e,this.loaderModule2d=new $I(this.engine)}async attachSectionPlane(e,t,i,n){await this.loaderModule2d.loadModel(e+"/"+t,{chunkSize:1e3,enableChunkedLoading:!0,enableValidation:!0});let r=new P(i.x,i.y,i.z),a=new P(n.x,n.y,n.z);const o=new P().copy(a);let l=r.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 P(e.x,e.y,e.z),n=new Yi(t.x,t.y,t.z),r=new P(1,1,1),a=new Lt;a.setFromEuler(n);const o=new Ke;return o.compose(i,a,r),o}computeMatrixFromOriginAndDirection(e,t){const i=new Ke,n=t.clone().normalize();if(n.length()===0)return console.warn("方向向量长度为零,返回单位矩阵"),i.identity();const r=new P(0,1,0);let a=new P().crossVectors(r,n);if(a.length()<1e-4){const c=new P(0,0,1);a=new P().crossVectors(c,n).normalize()}else a.normalize();const o=new P().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}}var ZI=Object.defineProperty,Dp=(s,e)=>{let t={};for(var i in s)ZI(t,i,{get:s[i],enumerable:!0});return ZI(t,Symbol.toStringTag,{value:"Module"}),t};function Rp(s){return Rp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Rp(s)}function Rq(s){var e=(function(t,i){if(Rp(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,i);if(Rp(r)!="object")return r;throw TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(t)})(s,"string");return Rp(e)=="symbol"?e:e+""}function ue(s,e,t){return(e=Rq(e))in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}var JI=class{constructor(){ue(this,"browserShadowBlurConstant",1),ue(this,"DPI",96),ue(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),ue(this,"perfLimitSizeTotal",2097152),ue(this,"maxCacheSideLimit",4096),ue(this,"minCacheSideLimit",256),ue(this,"disableStyleCopyPaste",!1),ue(this,"enableGLFiltering",!0),ue(this,"textureSize",4096),ue(this,"forceGLPutImageData",!1),ue(this,"cachesBoundsOfCurve",!1),ue(this,"fontPaths",{}),ue(this,"NUM_FRACTION_DIGITS",4)}};const ei=new class extends JI{constructor(s){super(),this.configure(s)}configure(s={}){Object.assign(this,s)}addFonts(s={}){this.fontPaths={...this.fontPaths,...s}}removeFonts(s=[]){s.forEach(e=>{delete this.fontPaths[e]})}clearFonts(){this.fontPaths={}}restoreDefaults(s){let e=new JI,t=s?.reduce((i,n)=>(i[n]=e[n],i),{})||e;this.configure(t)}},Fo=(s,...e)=>console[s]("fabric",...e);var Vr=class extends Error{constructor(s,e){super(`fabric: ${s}`,e)}},Bq=class extends Vr{constructor(s){super(`${s} 'options.signal' is in 'aborted' state`)}},Lq=class{},kq=class extends Lq{testPrecision(s,e){let t=`precision ${e} float;
|
||
void main(){}`,i=s.createShader(s.FRAGMENT_SHADER);return!!i&&(s.shaderSource(i,t),s.compileShader(i),!!s.getShaderParameter(i,s.COMPILE_STATUS))}queryWebGL(s){let e=s.getContext("webgl");e&&(this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.GLPrecision=["highp","mediump","lowp"].find(t=>this.testPrecision(e,t)),e.getExtension("WEBGL_lose_context").loseContext(),Fo("log",`WebGL: max texture size ${this.maxTextureSize}`))}isSupported(s){return!!this.maxTextureSize&&this.maxTextureSize>=s}};const Oq={};let eP;const Wr=()=>eP||(eP={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new kq,dispose(){},copyPasteData:Oq}),ld=()=>Wr().document,cd=()=>Wr().window,tP=()=>{var s;return Math.max((s=ei.devicePixelRatio)==null?cd().devicePixelRatio:s,1)},Bp=new class{constructor(){ue(this,"boundsOfCurveCache",{}),this.charWidthsCache=new Map}getFontCache({fontFamily:s,fontStyle:e,fontWeight:t}){s=s.toLowerCase();let i=this.charWidthsCache;i.has(s)||i.set(s,new Map);let n=i.get(s),r=`${e.toLowerCase()}_${(t+"").toLowerCase()}`;return n.has(r)||n.set(r,new Map),n.get(r)}clearFontCache(s){s?this.charWidthsCache.delete((s||"").toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(s){let{perfLimitSizeTotal:e}=ei,t=Math.sqrt(e*s);return[Math.floor(t),Math.floor(e/t)]}},o_="7.3.1";function Av(){}const No=Math.PI/2,Fq=Math.PI/4,pr=2*Math.PI,l_=Math.PI/180,Wn=Object.freeze([1,0,0,1,0,0]),ui="center",mn="left",iP="bottom",fr="right",bv="none",c_=/\r?\n/,nP="moving",yv="scaling",sP="rotating",rP="rotate",aP="skewing",Lp="resizing",oP="modifyPoly",xv="changed",lP="scale",Uo="scaleX",zo="scaleY",hd="skewX",dd="skewY",as="fill",La="stroke",cP="modified",hP="normal",ud="json",ot=new class{constructor(){this[ud]=new Map,this.svg=new Map}has(s){return this[ud].has(s)}getClass(s){let e=this[ud].get(s);if(!e)throw new Vr(`No class registered for ${s}`);return e}setClass(s,e){e?this[ud].set(e,s):(this[ud].set(s.type,s),this[ud].set(s.type.toLowerCase(),s))}getSVGClass(s){return this.svg.get(s)}setSVGClass(s,e){this.svg.set(e??s.type.toLowerCase(),s)}},_v=new class extends Array{remove(s){let e=this.indexOf(s);e>-1&&this.splice(e,1)}cancelAll(){let s=this.splice(0);return s.forEach(e=>e.abort()),s}cancelByCanvas(s){if(!s)return[];let e=this.filter(t=>{var i;return t.target===s||typeof t.target=="object"&&((i=t.target)==null?void 0:i.canvas)===s});return e.forEach(t=>t.abort()),e}cancelByTarget(s){if(!s)return[];let e=this.filter(t=>t.target===s);return e.forEach(t=>t.abort()),e}};var Nq=class{constructor(){ue(this,"__eventListeners",{})}on(s,e){if(this.__eventListeners||(this.__eventListeners={}),typeof s=="object")return Object.entries(s).forEach(([t,i])=>{this.on(t,i)}),()=>this.off(s);if(e){let t=s;return this.__eventListeners[t]||(this.__eventListeners[t]=[]),this.__eventListeners[t].push(e),()=>this.off(t,e)}return()=>!1}once(s,e){if(typeof s=="object"){let t=[];return Object.entries(s).forEach(([i,n])=>{t.push(this.once(i,n))}),()=>t.forEach(i=>i())}if(e){let t=this.on(s,function(...i){e.call(this,...i),t()});return t}return()=>!1}_removeEventListener(s,e){if(this.__eventListeners[s])if(e){let t=this.__eventListeners[s],i=t.indexOf(e);i>-1&&t.splice(i,1)}else this.__eventListeners[s]=[]}off(s,e){if(this.__eventListeners)if(s===void 0)for(let t in this.__eventListeners)this._removeEventListener(t);else typeof s=="object"?Object.entries(s).forEach(([t,i])=>{this._removeEventListener(t,i)}):this._removeEventListener(s,e)}fire(s,e){var t;if(!this.__eventListeners)return;let i=(t=this.__eventListeners[s])==null?void 0:t.concat();if(i)for(let n=0;n<i.length;n++)i[n].call(this,e||{})}};const cc=(s,e)=>{let t=s.indexOf(e);return t!==-1&&s.splice(t,1),s},mr=s=>{if(s===0)return 1;switch(Math.abs(s)/No){case 1:case 3:return 0;case 2:return-1}return Math.cos(s)},gr=s=>{if(s===0)return 0;let e=s/No,t=Math.sign(s);switch(e){case 1:return t;case 2:return 0;case 3:return-t}return Math.sin(s)};var De=class qn{constructor(e=0,t=0){typeof e=="object"?(this.x=e.x,this.y=e.y):(this.x=e,this.y=t)}add(e){return new qn(this.x+e.x,this.y+e.y)}addEquals(e){return this.x+=e.x,this.y+=e.y,this}scalarAdd(e){return new qn(this.x+e,this.y+e)}scalarAddEquals(e){return this.x+=e,this.y+=e,this}subtract(e){return new qn(this.x-e.x,this.y-e.y)}subtractEquals(e){return this.x-=e.x,this.y-=e.y,this}scalarSubtract(e){return new qn(this.x-e,this.y-e)}scalarSubtractEquals(e){return this.x-=e,this.y-=e,this}multiply(e){return new qn(this.x*e.x,this.y*e.y)}scalarMultiply(e){return new qn(this.x*e,this.y*e)}scalarMultiplyEquals(e){return this.x*=e,this.y*=e,this}divide(e){return new qn(this.x/e.x,this.y/e.y)}scalarDivide(e){return new qn(this.x/e,this.y/e)}scalarDivideEquals(e){return this.x/=e,this.y/=e,this}eq(e){return this.x===e.x&&this.y===e.y}lt(e){return this.x<e.x&&this.y<e.y}lte(e){return this.x<=e.x&&this.y<=e.y}gt(e){return this.x>e.x&&this.y>e.y}gte(e){return this.x>=e.x&&this.y>=e.y}lerp(e,t=.5){return t=Math.max(Math.min(1,t),0),new qn(this.x+(e.x-this.x)*t,this.y+(e.y-this.y)*t)}distanceFrom(e){let t=this.x-e.x,i=this.y-e.y;return Math.sqrt(t*t+i*i)}midPointFrom(e){return this.lerp(e)}min(e){return new qn(Math.min(this.x,e.x),Math.min(this.y,e.y))}max(e){return new qn(Math.max(this.x,e.x),Math.max(this.y,e.y))}toString(){return`${this.x},${this.y}`}setXY(e,t){return this.x=e,this.y=t,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setFromPoint(e){return this.x=e.x,this.y=e.y,this}swap(e){let t=this.x,i=this.y;this.x=e.x,this.y=e.y,e.x=t,e.y=i}clone(){return new qn(this.x,this.y)}rotate(e,t=h_){let i=gr(e),n=mr(e),r=this.subtract(t);return new qn(r.x*n-r.y*i,r.x*i+r.y*n).add(t)}transform(e,t=!1){return new qn(e[0]*this.x+e[2]*this.y+(t?0:e[4]),e[1]*this.x+e[3]*this.y+(t?0:e[5]))}};const h_=new De(0,0),wv=s=>!!s&&Array.isArray(s._objects);function dP(s){class e extends s{constructor(...i){super(...i),ue(this,"_objects",[])}_onObjectAdded(i){}_onObjectRemoved(i){}_onStackOrderChanged(i){}add(...i){let n=this._objects.push(...i);return i.forEach(r=>this._onObjectAdded(r)),n}insertAt(i,...n){return this._objects.splice(i,0,...n),n.forEach(r=>this._onObjectAdded(r)),this._objects.length}remove(...i){let n=this._objects,r=[];return i.forEach(a=>{let o=n.indexOf(a);o!==-1&&(n.splice(o,1),r.push(a),this._onObjectRemoved(a))}),r}forEachObject(i){this.getObjects().forEach((n,r,a)=>i(n,r,a))}getObjects(...i){return i.length===0?[...this._objects]:this._objects.filter(n=>n.isType(...i))}item(i){return this._objects[i]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(i,n){return!!this._objects.includes(i)||!!n&&this._objects.some(r=>r instanceof e&&r.contains(i,!0))}complexity(){return this._objects.reduce((i,n)=>i+=n.complexity?n.complexity():0,0)}sendObjectToBack(i){return!(!i||i===this._objects[0])&&(cc(this._objects,i),this._objects.unshift(i),this._onStackOrderChanged(i),!0)}bringObjectToFront(i){return!(!i||i===this._objects[this._objects.length-1])&&(cc(this._objects,i),this._objects.push(i),this._onStackOrderChanged(i),!0)}sendObjectBackwards(i,n){if(!i)return!1;let r=this._objects.indexOf(i);if(r!==0){let a=this.findNewLowerIndex(i,r,n);return cc(this._objects,i),this._objects.splice(a,0,i),this._onStackOrderChanged(i),!0}return!1}bringObjectForward(i,n){if(!i)return!1;let r=this._objects.indexOf(i);if(r!==this._objects.length-1){let a=this.findNewUpperIndex(i,r,n);return cc(this._objects,i),this._objects.splice(a,0,i),this._onStackOrderChanged(i),!0}return!1}moveObjectTo(i,n){return i!==this._objects[n]&&(cc(this._objects,i),this._objects.splice(n,0,i),this._onStackOrderChanged(i),!0)}findNewLowerIndex(i,n,r){let a;if(r){a=n;for(let o=n-1;o>=0;--o)if(i.isOverlapping(this._objects[o])){a=o;break}}else a=n-1;return a}findNewUpperIndex(i,n,r){let a;if(r){a=n;for(let o=n+1;o<this._objects.length;++o)if(i.isOverlapping(this._objects[o])){a=o;break}}else a=n+1;return a}collectObjects({left:i,top:n,width:r,height:a},{includeIntersecting:o=!0}={}){let l=[],c=new De(i,n),h=c.add(new De(r,a));for(let d=this._objects.length-1;d>=0;d--){let u=this._objects[d];u.selectable&&u.visible&&(o&&u.intersectsWithRect(c,h)||u.isContainedWithinRect(c,h)||o&&u.containsPoint(c)||o&&u.containsPoint(h))&&l.push(u)}return l}}return e}var uP=class extends Nq{_setOptions(s={}){for(let e in s)this.set(e,s[e])}_setObject(s){for(let e in s)this._set(e,s[e])}set(s,e){return typeof s=="object"?this._setObject(s):this._set(s,e),this}_set(s,e){this[s]=e}toggle(s){let e=this.get(s);return typeof e=="boolean"&&this.set(s,!e),this}get(s){return this[s]}};function kp(s){return cd().requestAnimationFrame(s)}function pP(s){return cd().cancelAnimationFrame(s)}let Uq=0;const Ho=()=>Uq++,Qr=()=>{let s=ld().createElement("canvas");if(!s||s.getContext===void 0)throw new Vr("Failed to create `canvas` element");return s},fP=()=>ld().createElement("img"),zq=s=>{var e;let t=_s(s);return(e=t.getContext("2d"))==null||e.drawImage(s,0,0),t},_s=s=>{let e=Qr();return e.width=s.width,e.height=s.height,e},d_=(s,e,t)=>s.toDataURL(`image/${e}`,t),u_=(s,e,t)=>new Promise((i,n)=>{s.toBlob(i,`image/${e}`,t)}),Bi=s=>s*l_,ka=s=>s/l_,mP=s=>s.every((e,t)=>e===Wn[t]),Pn=(s,e,t)=>new De(s).transform(e,t),ws=s=>{let e=1/(s[0]*s[3]-s[1]*s[2]),t=[e*s[3],-e*s[1],-e*s[2],e*s[0],0,0],{x:i,y:n}=new De(s[4],s[5]).transform(t,!0);return t[4]=-i,t[5]=-n,t},Li=(s,e,t)=>[s[0]*e[0]+s[2]*e[1],s[1]*e[0]+s[3]*e[1],s[0]*e[2]+s[2]*e[3],s[1]*e[2]+s[3]*e[3],t?0:s[0]*e[4]+s[2]*e[5]+s[4],t?0:s[1]*e[4]+s[3]*e[5]+s[5]],Ev=(s,e)=>s.reduceRight((t,i)=>i&&t?Li(i,t,e):i||t,void 0)||Wn.concat(),gP=([s,e])=>Math.atan2(e,s),pd=s=>{let e=gP(s),t=s[0]**2+s[1]**2,i=Math.sqrt(t),n=(s[0]*s[3]-s[2]*s[1])/i,r=Math.atan2(s[0]*s[2]+s[1]*s[3],t);return{angle:ka(e),scaleX:i,scaleY:n,skewX:ka(r),skewY:0,translateX:s[4]||0,translateY:s[5]||0}},fd=(s,e=0)=>[1,0,0,1,s,e];function hc({angle:s=0}={},{x:e=0,y:t=0}={}){let i=Bi(s),n=mr(i),r=gr(i);return[n,r,-r,n,e?e-(n*e-r*t):0,t?t-(r*e+n*t):0]}const Mv=(s,e=s)=>[s,0,0,e,0,0],vP=s=>Math.tan(Bi(s)),p_=s=>[1,0,vP(s),1,0,0],f_=s=>[1,vP(s),0,1,0,0],Op=({scaleX:s=1,scaleY:e=1,flipX:t=!1,flipY:i=!1,skewX:n=0,skewY:r=0})=>{let a=Mv(t?-s:s,i?-e:e);return n&&(a=Li(a,p_(n),!0)),r&&(a=Li(a,f_(r),!0)),a},AP=s=>{let{translateX:e=0,translateY:t=0,angle:i=0}=s,n=fd(e,t);i&&(n=Li(n,hc({angle:i})));let r=Op(s);return mP(r)||(n=Li(n,r)),n},Fp=(s,{signal:e,crossOrigin:t=null}={})=>new Promise(function(i,n){if(e&&e.aborted)return n(new Bq("loadImage"));let r=fP(),a;e&&(a=function(l){r.src="",n(l)},e.addEventListener("abort",a,{once:!0}));let o=function(){r.onload=r.onerror=null,a&&e?.removeEventListener("abort",a),i(r)};s?(r.onload=o,r.onerror=function(){a&&e?.removeEventListener("abort",a),n(new Vr(`Error loading ${r.src}`))},t&&(r.crossOrigin=t),r.src=s):o()}),md=(s,{signal:e,reviver:t=Av}={})=>new Promise((i,n)=>{let r=[];e&&e.addEventListener("abort",n,{once:!0}),Promise.allSettled(s.map(a=>ot.getClass(a.type).fromObject(a,{signal:e}))).then(async a=>{for(let[o,l]of a.entries())if(l.status==="fulfilled"&&(await t(s[o],l.value),r.push(l.value)),l.status==="rejected"){let c=await t(s[o],void 0,l.reason);c&&r.push(c)}i(r)}).catch(a=>{r.forEach(o=>{o.dispose&&o.dispose()}),n(a)}).finally(()=>{e&&e.removeEventListener("abort",n)})}),Np=(s,{signal:e}={})=>new Promise((t,i)=>{let n=[];e&&e.addEventListener("abort",i,{once:!0});let r=Object.values(s).map(o=>o&&o.type&&ot.has(o.type)?md([o],{signal:e}).then(([l])=>(n.push(l),l)):o),a=Object.keys(s);Promise.all(r).then(o=>o.reduce((l,c,h)=>(l[a[h]]=c,l),{})).then(t).catch(o=>{n.forEach(l=>{l.dispose&&l.dispose()}),i(o)}).finally(()=>{e&&e.removeEventListener("abort",i)})}),dc=(s,e=[])=>e.reduce((t,i)=>(i in s&&(t[i]=s[i]),t),{}),m_=(s,e)=>Object.keys(s).reduce((t,i)=>(e(s[i],i,s)&&(t[i]=s[i]),t),{}),pi=(s,e)=>parseFloat(Number(s).toFixed(e)),gd=s=>"matrix("+s.map(e=>pi(e,ei.NUM_FRACTION_DIGITS)).join(" ")+")",Ws=s=>!!s&&s.toLive!==void 0,bP=s=>!!s&&typeof s.toObject=="function",yP=s=>!!s&&s.offsetX!==void 0&&"source"in s,uc=s=>!!s&&"multiSelectionStacking"in s;function xP(s){let e=s&&vr(s),t=0,i=0;if(!s||!e)return{left:t,top:i};let n=s,r=e.documentElement,a=e.body||{scrollLeft:0,scrollTop:0};for(;n&&(n.parentNode||n.host)&&(n=n.parentNode||n.host,n===e?(t=a.scrollLeft||r.scrollLeft||0,i=a.scrollTop||r.scrollTop||0):(t+=n.scrollLeft||0,i+=n.scrollTop||0),n.nodeType!==1||n.style.position!=="fixed"););return{left:t,top:i}}const vr=s=>s.ownerDocument||null,_P=s=>{var e;return((e=s.ownerDocument)==null?void 0:e.defaultView)||null},wP=(s,e,{width:t,height:i},n=1)=>{s.width=t,s.height=i,n>1&&(s.setAttribute("width",(t*n).toString()),s.setAttribute("height",(i*n).toString()),e.scale(n,n))},g_=(s,{width:e,height:t})=>{e&&(s.style.width=typeof e=="number"?`${e}px`:e),t&&(s.style.height=typeof t=="number"?`${t}px`:t)};function EP(s){return s.onselectstart!==void 0&&(s.onselectstart=()=>!1),s.style.userSelect=bv,s}var MP=class{constructor(s){ue(this,"_originalCanvasStyle",void 0),ue(this,"lower",void 0);let e=this.createLowerCanvas(s);this.lower={el:e,ctx:e.getContext("2d")}}createLowerCanvas(s){let e=(t=s)&&t.getContext!==void 0?s:s&&ld().getElementById(s)||Qr();var t;if(e.hasAttribute("data-fabric"))throw new Vr("Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?");return this._originalCanvasStyle=e.style.cssText,e.setAttribute("data-fabric","main"),e.classList.add("lower-canvas"),e}cleanupDOM({width:s,height:e}){let{el:t}=this.lower;t.classList.remove("lower-canvas"),t.removeAttribute("data-fabric"),t.setAttribute("width",`${s}`),t.setAttribute("height",`${e}`),t.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(s,e){let{el:t,ctx:i}=this.lower;wP(t,i,s,e)}setCSSDimensions(s){g_(this.lower.el,s)}calcOffset(){return(function(s){var e;let t=s&&vr(s),i={left:0,top:0};if(!t)return i;let n=((e=_P(s))==null?void 0:e.getComputedStyle(s,null))||{};i.left+=parseInt(n.borderLeftWidth,10)||0,i.top+=parseInt(n.borderTopWidth,10)||0,i.left+=parseInt(n.paddingLeft,10)||0,i.top+=parseInt(n.paddingTop,10)||0;let r={left:0,top:0},a=t.documentElement;s.getBoundingClientRect!==void 0&&(r=s.getBoundingClientRect());let o=xP(s);return{left:r.left+o.left-(a.clientLeft||0)+i.left,top:r.top+o.top-(a.clientTop||0)+i.top}})(this.lower.el)}dispose(){Wr().dispose(this.lower.el),delete this.lower}};const Hq={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...Wn],patternQuality:"best"};var Gq=Dp({capitalize:()=>Vq,escapeXml:()=>Ot,graphemeSplit:()=>Sv});const Vq=(s,e=!1)=>`${s.charAt(0).toUpperCase()}${e?s.slice(1):s.slice(1).toLowerCase()}`,Ot=s=>s.toString().replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">");let Up;const Sv=s=>{if(Up||Up||(Up="Intl"in cd()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),Up){let e=Up.segment(s);return Array.from(e).map(({segment:t})=>t)}return Wq(s)},Wq=s=>{let e=[];for(let t,i=0;i<s.length;i++)(t=Qq(s,i))!==!1&&e.push(t);return e},Qq=(s,e)=>{let t=s.charCodeAt(e);if(isNaN(t))return"";if(t<55296||t>57343)return s.charAt(e);if(55296<=t&&t<=56319){if(s.length<=e+1)throw"High surrogate without following low surrogate";let n=s.charCodeAt(e+1);if(56320>n||n>57343)throw"High surrogate without following low surrogate";return s.charAt(e)+s.charAt(e+1)}if(e===0)throw"Low surrogate without preceding high surrogate";let i=s.charCodeAt(e-1);if(55296>i||i>56319)throw"Low surrogate without preceding high surrogate";return!1};var v_=class QR extends dP(uP){get lowerCanvasEl(){var e;return(e=this.elements.lower)==null?void 0:e.el}get contextContainer(){var e;return(e=this.elements.lower)==null?void 0:e.ctx}static getDefaults(){return QR.ownDefaults}constructor(e,t={}){super(),Object.assign(this,this.constructor.getDefaults()),this.set(t),this.initElements(e),this._setDimensionsImpl({width:this.width||this.elements.lower.el.width||0,height:this.height||this.elements.lower.el.height||0}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(e){this.elements=new MP(e)}add(...e){let t=super.add(...e);return e.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(e,...t){let i=super.insertAt(e,...t);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),i}remove(...e){let t=super.remove(...e);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(e){e.canvas&&e.canvas!==this&&(Fo("warn",`Canvas is trying to add an object that belongs to a different canvas.
|
||
Resulting to default behavior: removing object from previous canvas and adding to new canvas`),e.canvas.remove(e)),e._set("canvas",this),e.setCoords(),this.fire("object:added",{target:e}),e.fire("added",{target:this})}_onObjectRemoved(e){e._set("canvas",void 0),this.fire("object:removed",{target:e}),e.fire("removed",{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?tP():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}_setDimensionsImpl(e,{cssOnly:t=!1,backstoreOnly:i=!1}={}){if(!t){let n={width:this.width,height:this.height,...e};this.elements.setDimensions(n,this.getRetinaScaling()),this.hasLostContext=!0,this.width=n.width,this.height=n.height}i||this.elements.setCSSDimensions(e),this.calcOffset()}setDimensions(e,t){this._setDimensionsImpl(e,t),t&&t.cssOnly||this.requestRenderAll()}getZoom(){return this.viewportTransform[0]}setViewportTransform(e){this.viewportTransform=e,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(e,t){let i=e,n=[...this.viewportTransform],r=Pn(e,ws(n));n[0]=t,n[3]=t;let a=Pn(r,n);n[4]+=i.x-a.x,n[5]+=i.y-a.y,this.setViewportTransform(n)}setZoom(e){this.zoomToPoint(new De(0,0),e)}absolutePan(e){let t=[...this.viewportTransform];return t[4]=-e.x,t[5]=-e.y,this.setViewportTransform(t)}relativePan(e){return this.absolutePan(new De(-e.x-this.viewportTransform[4],-e.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(e){e.clearRect(0,0,this.width,this.height)}getContext(){return this.elements.lower.ctx}clear(){this.remove(...this.getObjects()),this.backgroundImage=void 0,this.overlayImage=void 0,this.backgroundColor="",this.overlayColor="",this.clearContext(this.getContext()),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll()}renderAll(){this.cancelRequestedRender(),this.destroyed||this.renderCanvas(this.getContext(),this._objects)}renderAndReset(){this.nextRenderHandle=0,this.renderAll()}requestRenderAll(){this.nextRenderHandle||this.disposed||this.destroyed||(this.nextRenderHandle=kp(()=>this.renderAndReset()))}calcViewportBoundaries(){let e=this.width,t=this.height,i=ws(this.viewportTransform),n=Pn({x:0,y:0},i),r=Pn({x:e,y:t},i),a=n.min(r),o=n.max(r);return this.vptCoords={tl:a,tr:new De(o.x,a.y),bl:new De(a.x,o.y),br:o}}cancelRequestedRender(){this.nextRenderHandle&&(pP(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(e){}renderCanvas(e,t){if(this.destroyed)return;let i=this.viewportTransform,n=this.clipPath;this.calcViewportBoundaries(),this.clearContext(e),e.imageSmoothingEnabled=this.imageSmoothingEnabled,e.patternQuality=this.patternQuality,this.fire("before:render",{ctx:e}),this._renderBackground(e),e.save(),e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this._renderObjects(e,t),e.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(e),n&&(n._set("canvas",this),n.shouldCache(),n._transformDone=!0,n.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(e,n)),this._renderOverlay(e),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(e),this.fire("after:render",{ctx:e}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(e,t){let i=this.viewportTransform;e.save(),e.transform(...i),e.globalCompositeOperation="destination-in",t.transform(e),e.scale(1/t.zoomX,1/t.zoomY),e.drawImage(t._cacheCanvas,-t.cacheTranslationX,-t.cacheTranslationY),e.restore()}_renderObjects(e,t){for(let i=0,n=t.length;i<n;++i)t[i]&&t[i].render(e)}_renderBackgroundOrOverlay(e,t){let i=this[`${t}Color`],n=this[`${t}Image`],r=this.viewportTransform,a=this[`${t}Vpt`];if(!i&&!n)return;let o=Ws(i);if(i){if(e.save(),e.beginPath(),e.moveTo(0,0),e.lineTo(this.width,0),e.lineTo(this.width,this.height),e.lineTo(0,this.height),e.closePath(),e.fillStyle=o?i.toLive(e):i,a&&e.transform(...r),o){e.transform(1,0,0,1,i.offsetX||0,i.offsetY||0);let l=i.gradientTransform||i.patternTransform;l&&e.transform(...l)}e.fill(),e.restore()}if(n){e.save();let{skipOffscreen:l}=this;this.skipOffscreen=a,a&&e.transform(...r),n.render(e),this.skipOffscreen=l,e.restore()}}_renderBackground(e){this._renderBackgroundOrOverlay(e,"background")}_renderOverlay(e){this._renderBackgroundOrOverlay(e,"overlay")}getCenterPoint(){return new De(this.width/2,this.height/2)}centerObjectH(e){return this._centerObject(e,new De(this.getCenterPoint().x,e.getCenterPoint().y))}centerObjectV(e){return this._centerObject(e,new De(e.getCenterPoint().x,this.getCenterPoint().y))}centerObject(e){return this._centerObject(e,this.getCenterPoint())}viewportCenterObject(e){return this._centerObject(e,this.getVpCenter())}viewportCenterObjectH(e){return this._centerObject(e,new De(this.getVpCenter().x,e.getCenterPoint().y))}viewportCenterObjectV(e){return this._centerObject(e,new De(e.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return Pn(this.getCenterPoint(),ws(this.viewportTransform))}_centerObject(e,t){e.setXY(t,ui,ui),e.setCoords(),this.renderOnAddRemove&&this.requestRenderAll()}toDatalessJSON(e){return this.toDatalessObject(e)}toObject(e){return this._toObjectMethod("toObject",e)}toJSON(){return this.toObject()}toDatalessObject(e){return this._toObjectMethod("toDatalessObject",e)}_toObjectMethod(e,t){let i=this.clipPath,n=i&&!i.excludeFromExport?this._toObject(i,e,t):null;return{version:o_,...dc(this,t),objects:this._objects.filter(r=>!r.excludeFromExport).map(r=>this._toObject(r,e,t)),...this.__serializeBgOverlay(e,t),...n?{clipPath:n}:null}}_toObject(e,t,i){let n;this.includeDefaultValues||(n=e.includeDefaultValues,e.includeDefaultValues=!1);let r=e[t](i);return this.includeDefaultValues||(e.includeDefaultValues=!!n),r}__serializeBgOverlay(e,t){let i={},n=this.backgroundImage,r=this.overlayImage,a=this.backgroundColor,o=this.overlayColor;return Ws(a)?a.excludeFromExport||(i.background=a.toObject(t)):a&&(i.background=a),Ws(o)?o.excludeFromExport||(i.overlay=o.toObject(t)):o&&(i.overlay=o),n&&!n.excludeFromExport&&(i.backgroundImage=this._toObject(n,e,t)),r&&!r.excludeFromExport&&(i.overlayImage=this._toObject(r,e,t)),i}toSVG(e={},t){e.reviver=t;let i=[];var n;return this._setSVGPreamble(i,e),this._setSVGHeader(i,e),this.clipPath&&i.push(`<g clip-path="url(#${Ot((n=this.clipPath.clipPathId)==null?"":n)})" >
|
||
`),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",t),this._setSVGObjects(i,t),this.clipPath&&i.push(`</g>
|
||
`),this._setSVGBgOverlayColor(i,"overlay"),this._setSVGBgOverlayImage(i,"overlayImage",t),i.push("</svg>"),i.join("")}_setSVGPreamble(e,t){t.suppressPreamble||e.push('<?xml version="1.0" encoding="',t.encoding||"UTF-8",`" standalone="no" ?>
|
||
`,'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||
`)}_setSVGHeader(e,t){let i=t.width||`${this.width}`,n=t.height||`${this.height}`,r=ei.NUM_FRACTION_DIGITS,a=t.viewBox,o;if(a)o=`viewBox="${a.x} ${a.y} ${a.width} ${a.height}" `;else if(this.svgViewportTransformation){let l=this.viewportTransform;o=`viewBox="${pi(-l[4]/l[0],r)} ${pi(-l[5]/l[3],r)} ${pi(this.width/l[0],r)} ${pi(this.height/l[3],r)}" `}else o=`viewBox="0 0 ${this.width} ${this.height}" `;e.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',i,'" ','height="',n,'" ',o,`xml:space="preserve">
|
||
`,"<desc>Created with Fabric.js ",o_,`</desc>
|
||
`,`<defs>
|
||
`,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(t),`</defs>
|
||
`)}createSVGClipPathMarkup(e){let t=this.clipPath;return t?(t.clipPathId=`CLIPPATH_${Ho()}`,`<clipPath id="${t.clipPathId}" >
|
||
${t.toClipPathSVG(e.reviver)}</clipPath>
|
||
`):""}createSVGRefElementsMarkup(){return["background","overlay"].map(e=>{let t=this[`${e}Color`];if(Ws(t)){let i=this[`${e}Vpt`],n=this.viewportTransform,r={isType:()=>!1,width:this.width/(i?n[0]:1),height:this.height/(i?n[3]:1)};return t.toSVG(r,{additionalTransform:i?gd(n):""})}}).join("")}createSVGFontFacesMarkup(){let e=[],t={},i=ei.fontPaths;this._objects.forEach(function r(a){e.push(a),wv(a)&&a._objects.forEach(r)}),e.forEach(r=>{if(!(a=r)||typeof a._renderText!="function")return;var a;let{styles:o,fontFamily:l}=r;!t[l]&&i[l]&&(t[l]=!0,o&&Object.values(o).forEach(c=>{Object.values(c).forEach(({fontFamily:h=""})=>{!t[h]&&i[h]&&(t[h]=!0)})}))});let n=Object.keys(t).map(r=>` @font-face {
|
||
font-family: '${r}';
|
||
src: url('${i[r]}');
|
||
}
|
||
`).join("");return n?` <style type="text/css"><![CDATA[
|
||
${n}]]></style>
|
||
`:""}_setSVGObjects(e,t){this.forEachObject(i=>{i.excludeFromExport||this._setSVGObject(e,i,t)})}_setSVGObject(e,t,i){e.push(t.toSVG(i))}_setSVGBgOverlayImage(e,t,i){let n=this[t];n&&!n.excludeFromExport&&n.toSVG&&e.push(n.toSVG(i))}_setSVGBgOverlayColor(e,t){let i=this[`${t}Color`];if(i)if(Ws(i)){let n=i.repeat||"",r=this.width,a=this.height,o=this[`${t}Vpt`]?gd(ws(this.viewportTransform)):"";e.push(`<rect transform="${o} translate(${r/2},${a/2})" x="${i.offsetX-r/2}" y="${i.offsetY-a/2}" width="${n!=="repeat-y"&&n!=="no-repeat"||!yP(i)?r:i.source.width}" height="${n!=="repeat-x"&&n!=="no-repeat"||!yP(i)?a:i.source.height}" fill="url(#SVGID_${i.id})"></rect>
|
||
`)}else e.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',i,'"',`></rect>
|
||
`)}loadFromJSON(e,t,{signal:i}={}){if(!e)return Promise.reject(new Vr("`json` is undefined"));let{objects:n=[],...r}=typeof e=="string"?JSON.parse(e):e,{backgroundImage:a,background:o,overlayImage:l,overlay:c,clipPath:h}=r,d=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([md(n,{reviver:t,signal:i}),Np({backgroundImage:a,backgroundColor:o,overlayImage:l,overlayColor:c,clipPath:h},{signal:i})]).then(([u,p])=>(this.clear(),this.add(...u),this.set(r),this.set(p),this.renderOnAddRemove=d,this))}clone(e){let t=this.toObject(e);return this.cloneWithoutData().loadFromJSON(t)}cloneWithoutData(){let e=_s(this);return new this.constructor(e)}toDataURL(e={}){let{format:t="png",quality:i=1,multiplier:n=1,enableRetinaScaling:r=!1}=e,a=n*(r?this.getRetinaScaling():1);return d_(this.toCanvasElement(a,e),t,i)}toBlob(e={}){let{format:t="png",quality:i=1,multiplier:n=1,enableRetinaScaling:r=!1}=e,a=n*(r?this.getRetinaScaling():1);return u_(this.toCanvasElement(a,e),t,i)}toCanvasElement(e=1,{width:t,height:i,left:n,top:r,filter:a}={}){let o=(t||this.width)*e,l=(i||this.height)*e,c=this.getZoom(),h=this.width,d=this.height,u=this.skipControlsDrawing,p=c*e,m=this.viewportTransform,v=[p,0,0,p,(m[4]-(n||0))*e,(m[5]-(r||0))*e],g=this.enableRetinaScaling,f=_s({width:o,height:l}),A=a?this._objects.filter(b=>a(b)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=v,this.width=o,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(f.getContext("2d"),A),this.viewportTransform=m,this.width=h,this.height=d,this.calcViewportBoundaries(),this.enableRetinaScaling=g,this.skipControlsDrawing=u,f}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),_v.cancelByCanvas(this),this.disposed=!0,new Promise((e,t)=>{let i=()=>{this.destroy(),e(!0)};i.kill=t,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?e(!1):this.nextRenderHandle?this.__cleanupTask=i:i()})}destroy(){this.destroyed=!0,this.cancelRequestedRender(),this.forEachObject(e=>e.dispose()),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose(),this.backgroundImage=void 0,this.overlayImage&&this.overlayImage.dispose(),this.overlayImage=void 0,this.elements.dispose()}toString(){return`#<Canvas (${this.complexity()}): { objects: ${this._objects.length} }>`}};ue(v_,"ownDefaults",Hq);const jq=["touchstart","touchmove","touchend"],SP=s=>{let e=xP(s.target),t=(function(i){let n=i.changedTouches;return n&&n[0]?n[0]:i})(s);return new De(t.clientX+e.left,t.clientY+e.top)},Cv=s=>jq.includes(s.type)||s.pointerType==="touch",CP=s=>{s.preventDefault(),s.stopPropagation()},jr=s=>{let e=0,t=0,i=0,n=0;for(let r=0,a=s.length;r<a;r++){let{x:o,y:l}=s[r];(o>i||!r)&&(i=o),(o<e||!r)&&(e=o),(l>n||!r)&&(n=l),(l<t||!r)&&(t=l)}return{left:e,top:t,width:i-e,height:n-t}},Xq=(s,e)=>{vd(s,Li(ws(e),s.calcOwnMatrix()))},TP=(s,e)=>vd(s,Li(e,s.calcOwnMatrix())),vd=(s,e)=>{let{translateX:t,translateY:i,scaleX:n,scaleY:r,...a}=pd(e),o=new De(t,i);s.flipX=!1,s.flipY=!1,Object.assign(s,a),s.set({scaleX:n,scaleY:r}),s.setPositionByOrigin(o,ui,ui)},IP=s=>{s.scaleX=1,s.scaleY=1,s.skewX=0,s.skewY=0,s.flipX=!1,s.flipY=!1,s.rotate(0)},A_=s=>({scaleX:s.scaleX,scaleY:s.scaleY,skewX:s.skewX,skewY:s.skewY,angle:s.angle,left:s.left,flipX:s.flipX,flipY:s.flipY,top:s.top}),Tv=(s,e,t)=>{let i=s/2,n=e/2,r=jr([new De(-i,-n),new De(i,-n),new De(-i,n),new De(i,n)].map(a=>a.transform(t)));return new De(r.width,r.height)},zp=(s=Wn,e=Wn)=>Li(ws(e),s),Oa=(s,e=Wn,t=Wn)=>s.transform(zp(e,t)),PP=(s,e=Wn,t=Wn)=>s.transform(zp(e,t),!0),b_=(s,e,t)=>{let i=zp(e,t);return vd(s,Li(i,s.calcOwnMatrix())),i},qq={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Qn=s=>typeof s=="string"?qq[s]:s-.5,Yq=new De(1,0),DP=new De,y_=(s,e)=>s.rotate(e),Hp=(s,e)=>new De(e).subtract(s),Iv=s=>s.distanceFrom(DP),Pv=(s,e)=>Math.atan2(Ad(s,e),RP(s,e)),x_=s=>Pv(Yq,s),Dv=s=>s.eq(DP)?s:s.scalarDivide(Iv(s)),__=(s,e=!0)=>Dv(new De(-s.y,s.x).scalarMultiply(e?1:-1)),Ad=(s,e)=>s.x*e.y-s.y*e.x,RP=(s,e)=>s.x*e.x+s.y*e.y,w_=(s,e,t)=>{if(s.eq(e)||s.eq(t))return!0;let i=Ad(e,t),n=Ad(e,s),r=Ad(t,s);return i>=0?n>=0&&r<=0:!(n<=0&&r>=0)},E_="not-allowed";function BP(s){return Qn(s.originX)===Qn("center")&&Qn(s.originY)===Qn("center")}function LP(s){return .5-Qn(s)}const Ar=(s,e)=>s[e],M_=(s,e,t,i)=>({e:s,transform:e,pointer:new De(t,i)});function kP(s,e,t){let i=t,n=x_(Hp(Oa(s.getCenterPoint(),s.canvas.viewportTransform,void 0),i))+pr;return Math.round(n%pr/Fq)}function Rv({target:s,corner:e},t,i,n,r){var a;let o=s.controls[e],l=((a=s.canvas)==null?void 0:a.getZoom())||1,c=s.padding/l,h=(function(d,u,p,m){let v=d.getRelativeCenterPoint(),g=p!==void 0&&m!==void 0?d.translateToGivenOrigin(v,ui,ui,p,m):new De(d.left,d.top);return(d.angle?u.rotate(-Bi(d.angle),v):u).subtract(g)})(s,new De(n,r),t,i);return h.x>=c&&(h.x-=c),h.x<=-c&&(h.x+=c),h.y>=c&&(h.y-=c),h.y<=c&&(h.y+=c),h.x-=o.offsetX,h.y-=o.offsetY,h}const Bv=s=>s.replace(/\s+/g," "),OP={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#0FF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000",blanchedalmond:"#FFEBCD",blue:"#00F",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#0FF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",darkgreen:"#006400",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#F0F",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",lightgreen:"#90EE90",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#789",lightslategrey:"#789",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#0F0",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#F0F",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#639",red:"#F00",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFF",whitesmoke:"#F5F5F5",yellow:"#FF0",yellowgreen:"#9ACD32"},S_=(s,e,t)=>(t<0&&(t+=1),t>1&&--t,t<1/6?s+6*(e-s)*t:t<.5?e:t<2/3?s+(e-s)*(2/3-t)*6:s),FP=(s,e,t,i)=>{s/=255,e/=255,t/=255;let n=Math.max(s,e,t),r=Math.min(s,e,t),a,o,l=(n+r)/2;if(n===r)a=o=0;else{let c=n-r;switch(o=l>.5?c/(2-n-r):c/(n+r),n){case s:a=(e-t)/c+(e<t?6:0);break;case e:a=(t-s)/c+2;break;case t:a=(s-e)/c+4}a/=6}return[Math.round(360*a),Math.round(100*o),Math.round(100*l),i]},NP=(s="1")=>parseFloat(s)/(s.endsWith("%")?100:1),Lv=s=>Math.min(Math.round(s),255).toString(16).toUpperCase().padStart(2,"0"),UP=([s,e,t,i=1])=>{let n=Math.round(.3*s+.59*e+.11*t);return[n,n,n,i]};var br=class Rn{constructor(e){if(ue(this,"isUnrecognised",!1),e)if(e instanceof Rn)this.setSource([...e._source]);else if(Array.isArray(e)){let[t,i,n,r=1]=e;this.setSource([t,i,n,r])}else this.setSource(this._tryParsingColor(e));else this.setSource([0,0,0,1])}_tryParsingColor(e){return(e=e.toLowerCase())in OP&&(e=OP[e]),e==="transparent"?[255,255,255,0]:Rn.sourceFromHex(e)||Rn.sourceFromRgb(e)||Rn.sourceFromHsl(e)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(e){this._source=e}toRgb(){let[e,t,i]=this.getSource();return`rgb(${e},${t},${i})`}toRgba(){return`rgba(${this.getSource().join(",")})`}toHsl(){let[e,t,i]=FP(...this.getSource());return`hsl(${e},${t}%,${i}%)`}toHsla(){let[e,t,i,n]=FP(...this.getSource());return`hsla(${e},${t}%,${i}%,${n})`}toHex(){return this.toHexa().slice(0,6)}toHexa(){let[e,t,i,n]=this.getSource();return`${Lv(e)}${Lv(t)}${Lv(i)}${Lv(Math.round(255*n))}`}getAlpha(){return this.getSource()[3]}setAlpha(e){return this._source[3]=e,this}toGrayscale(){return this.setSource(UP(this.getSource())),this}toBlackWhite(e){let[t,,,i]=UP(this.getSource()),n=t<(e||127)?0:255;return this.setSource([n,n,n,i]),this}overlayWith(e){e instanceof Rn||(e=new Rn(e));let t=this.getSource(),i=e.getSource(),[n,r,a]=t.map((o,l)=>Math.round(.5*o+.5*i[l]));return this.setSource([n,r,a,t[3]]),this}static fromRgb(e){return Rn.fromRgba(e)}static fromRgba(e){return new Rn(Rn.sourceFromRgb(e))}static sourceFromRgb(e){let t=Bv(e).match(/^rgba?\(\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d{0,3}(?:\.\d+)?%?)\s?)?\)$/i);if(t){let[i,n,r]=t.slice(1,4).map(a=>{let o=parseFloat(a);return a.endsWith("%")?Math.round(2.55*o):o});return[i,n,r,NP(t[4])]}}static fromHsl(e){return Rn.fromHsla(e)}static fromHsla(e){return new Rn(Rn.sourceFromHsl(e))}static sourceFromHsl(e){let t=Bv(e).match(/^hsla?\(\s?([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d*(?:\.\d+)?%?)\s?)?\)$/i);if(!t)return;let i=(Rn.parseAngletoDegrees(t[1])%360+360)%360/360,n=parseFloat(t[2])/100,r=parseFloat(t[3])/100,a,o,l;if(n===0)a=o=l=r;else{let c=r<=.5?r*(n+1):r+n-r*n,h=2*r-c;a=S_(h,c,i+1/3),o=S_(h,c,i),l=S_(h,c,i-1/3)}return[Math.round(255*a),Math.round(255*o),Math.round(255*l),NP(t[4])]}static fromHex(e){return new Rn(Rn.sourceFromHex(e))}static sourceFromHex(e){if(e.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){let t=e.slice(e.indexOf("#")+1),i;i=t.length<=4?t.split("").map(l=>l+l):t.match(/.{2}/g);let[n,r,a,o=255]=i.map(l=>parseInt(l,16));return[n,r,a,o/255]}}static parseAngletoDegrees(e){let t=e.toLowerCase(),i=parseFloat(t);return t.includes("rad")?ka(i):t.includes("turn")?360*i:i}};const Kq=s=>{let e=["instantiated_by_use","style","id","class"];switch(s){case"linearGradient":return e.concat(["x1","y1","x2","y2","gradientUnits","gradientTransform"]);case"radialGradient":return e.concat(["gradientUnits","gradientTransform","cx","cy","r","fx","fy","fr"]);case"stop":return e.concat(["offset","stop-color","stop-opacity"])}return e},pc=(s,e=16)=>{let t=/\D{0,2}$/.exec(s),i=parseFloat(s),n=ei.DPI;switch(t?.[0]){case"mm":return i*n/25.4;case"cm":return i*n/2.54;case"in":return i*n;case"pt":return i*n/72;case"pc":return i*n/72*12;case"em":return i*e;default:return i}},zP=s=>{let[e,t]=s.trim().split(" "),[i,n]=(r=e)&&r!=="none"?[r.slice(1,4),r.slice(5,8)]:r==="none"?[r,r]:["Mid","Mid"];var r;return{meetOrSlice:t||"meet",alignX:i,alignY:n}},Gp=(s,e,t=!0)=>{let i,n;if(e)if(e.toLive)i=`url(#SVGID_${Ot(e.id)})`;else{let r=new br(e),a=r.getAlpha();i=r.toRgb(),a!==1&&(n=a.toString())}else i="none";return t?`${s}: ${i}; ${n?`${s}-opacity: ${n}; `:""}`:`${s}="${i}" ${n?`${s}-opacity="${n}" `:""}`};var HP=class{getSvgStyles(s){let e=this.fillRule?this.fillRule:"nonzero",t=this.strokeWidth?this.strokeWidth:"0",i=this.strokeDashArray?this.strokeDashArray.join(" "):bv,n=this.strokeDashOffset?this.strokeDashOffset:"0",r=this.strokeLineCap?this.strokeLineCap:"butt",a=this.strokeLineJoin?this.strokeLineJoin:"miter",o=this.strokeMiterLimit?this.strokeMiterLimit:"4",l=this.opacity===void 0?"1":this.opacity,c=this.visible?"":" visibility: hidden;",h=s?"":this.getSvgFilter(),d=Gp(as,this.fill);return[Gp(La,this.stroke),"stroke-width: ",t,"; ","stroke-dasharray: ",i,"; ","stroke-linecap: ",r,"; ","stroke-dashoffset: ",n,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",o,"; ",d,"fill-rule: ",e,"; ","opacity: ",l,";",h,c].map(u=>Ot(u)).join("")}getSvgFilter(){return this.shadow?`filter: url(#SVGID_${Ot(this.shadow.id)});`:""}getSvgCommons(){return[this.id?`id="${Ot(String(this.id))}" `:"",this.clipPath?`clip-path="url(#${this.clipPath.clipPathId})" `:""].join("")}getSvgTransform(s,e=""){return`transform="${gd(s?this.calcTransformMatrix():this.calcOwnMatrix())}${e}" `}_toSVG(s){return[""]}toSVG(s){return this._createBaseSVGMarkup(this._toSVG(s),{reviver:s})}toClipPathSVG(s){return" "+this._createBaseClipPathSVGMarkup(this._toSVG(s),{reviver:s})}_createBaseClipPathSVGMarkup(s,{reviver:e,additionalTransform:t=""}={}){let i=[this.getSvgTransform(!0,t),this.getSvgCommons()].join(""),n=s.indexOf("COMMON_PARTS");return s[n]=i,e?e(s.join("")):s.join("")}_createBaseSVGMarkup(s,{noStyle:e,reviver:t,withShadow:i,additionalTransform:n}={}){let r=e?"":`style="${this.getSvgStyles()}" `,a=i?`style="${this.getSvgFilter()}" `:"",o=this.clipPath,l=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",c=o&&o.absolutePositioned,h=this.stroke,d=this.fill,u=this.shadow,p=[],m=s.indexOf("COMMON_PARTS"),v;return o&&(o.clipPathId=`CLIPPATH_${Ho()}`,v=`<clipPath id="${o.clipPathId}" >
|
||
${o.toClipPathSVG(t)}</clipPath>
|
||
`),c&&p.push("<g ",a,this.getSvgCommons(),` >
|
||
`),p.push("<g ",this.getSvgTransform(!1),c?"":a+this.getSvgCommons(),` >
|
||
`),s[m]=[r,l,e?"":this.addPaintOrder()," ",n?`transform="${n}" `:""].join(""),Ws(d)&&p.push(d.toSVG(this)),Ws(h)&&p.push(h.toSVG(this)),u&&p.push(u.toSVG(this)),o&&p.push(v),p.push(s.join("")),p.push(`</g>
|
||
`),c&&p.push(`</g>
|
||
`),t?t(p.join("")):p.join("")}addPaintOrder(){return this.paintFirst==="fill"?"":` paint-order="${Ot(this.paintFirst)}" `}};function kv(s){return RegExp("^("+s.join("|")+")\\b","i")}const bd="textDecorationThickness",Ov="textDecorationColor",GP=["fontSize","fontWeight","fontFamily","fontStyle"],VP=["underline","overline","linethrough"],WP=[...GP,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],QP=[...WP,...VP,"textBackgroundColor","direction",bd,Ov],$q=[...GP,...VP,La,"strokeWidth",as,"deltaY","textBackgroundColor",bd,Ov],Zq={_reNewline:c_,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,fontSize:40,fontWeight:hP,fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:mn,fontStyle:hP,lineHeight:1.16,textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:mn,pathAlign:"baseline",charSpacing:0,deltaY:0,direction:"ltr",CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.28167,overline:-.81333},_fontSizeMult:1.13,[bd]:66.667},C_="justify",fc=String.raw`[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?`,Jq=RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+fc+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+fc+"))?\\s+(.*)"),eY={cx:mn,x:mn,r:"radius",cy:"top",y:"top",display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","letter-spacing":"charSpacing","paint-order":"paintFirst","stroke-dasharray":"strokeDashArray","stroke-dashoffset":"strokeDashOffset","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"textAnchor",opacity:"opacity","clip-path":"clipPath","clip-rule":"clipRule","vector-effect":"strokeUniform","image-rendering":"imageSmoothing","text-decoration-thickness":bd,"text-decoration-color":Ov},jP="font-size",XP="clip-path";kv(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),kv(["symbol","image","marker","pattern","view","svg"]);const qP=kv(["symbol","g","a","svg","clipPath","defs"]),YP="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",KP=RegExp("(?:\\s|^)"+YP+YP+"("+fc+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");var Vp=class hA{constructor(e={}){let t=typeof e=="string"?hA.parseShadow(e):e;Object.assign(this,hA.ownDefaults,t),this.id=Ho()}static parseShadow(e){let t=e.trim(),[,i=0,n=0,r=0]=(KP.exec(t)||[]).map(a=>parseFloat(a)||0);return{color:(t.replace(KP,"")||"rgb(0,0,0)").trim(),offsetX:i,offsetY:n,blur:r}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(e){let t=y_(new De(this.offsetX,this.offsetY),Bi(-e.angle)),i=ei.NUM_FRACTION_DIGITS,n=new br(this.color),r=40,a=40;return e.width&&e.height&&(r=100*pi((Math.abs(t.x)+this.blur)/e.width,i)+20,a=100*pi((Math.abs(t.y)+this.blur)/e.height,i)+20),e.flipX&&(t.x*=-1),e.flipY&&(t.y*=-1),`<filter id="SVGID_${Ot(this.id)}" y="-${a}%" height="${100+2*a}%" x="-${r}%" width="${100+2*r}%" >
|
||
<feGaussianBlur in="SourceAlpha" stdDeviation="${pi(this.blur?this.blur/2:0,i)}"></feGaussianBlur>
|
||
<feOffset dx="${pi(t.x,i)}" dy="${pi(t.y,i)}" result="oBlur" ></feOffset>
|
||
<feFlood flood-color="${n.toRgb()}" flood-opacity="${n.getAlpha()}"/>
|
||
<feComposite in2="oBlur" operator="in" />
|
||
<feMerge>
|
||
<feMergeNode></feMergeNode>
|
||
<feMergeNode in="SourceGraphic"></feMergeNode>
|
||
</feMerge>
|
||
</filter>
|
||
`}toObject(){let e={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},t=hA.ownDefaults;return this.includeDefaultValues?e:m_(e,(i,n)=>i!==t[n])}static async fromObject(e){return new this(e)}};ue(Vp,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),ue(Vp,"type","shadow"),ot.setClass(Vp,"shadow");const mc=(s,e,t)=>Math.max(s,Math.min(e,t)),tY=["top",mn,Uo,zo,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",hd,dd],Fa=[as,La,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],iY={top:0,left:0,width:0,height:0,angle:0,flipX:!1,flipY:!1,scaleX:1,scaleY:1,minScaleLimit:0,skewX:0,skewY:0,originX:ui,originY:ui,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:as,fill:"rgb(0,0,0)",fillRule:"nonzero",stroke:null,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,globalCompositeOperation:"source-over",backgroundColor:"",shadow:null,visible:!0,includeDefaultValues:!0,excludeFromExport:!1,objectCaching:!0,clipPath:void 0,inverted:!1,absolutePositioned:!1,centeredRotation:!0,centeredScaling:!1,dirty:!0};var nY=Dp({defaultEasing:()=>ZP,easeInBack:()=>MY,easeInBounce:()=>JP,easeInCirc:()=>bY,easeInCubic:()=>sY,easeInElastic:()=>_Y,easeInExpo:()=>gY,easeInOutBack:()=>CY,easeInOutBounce:()=>TY,easeInOutCirc:()=>xY,easeInOutCubic:()=>aY,easeInOutElastic:()=>EY,easeInOutExpo:()=>AY,easeInOutQuad:()=>DY,easeInOutQuart:()=>cY,easeInOutQuint:()=>uY,easeInOutSine:()=>mY,easeInQuad:()=>IY,easeInQuart:()=>oY,easeInQuint:()=>hY,easeInSine:()=>pY,easeOutBack:()=>SY,easeOutBounce:()=>I_,easeOutCirc:()=>yY,easeOutCubic:()=>rY,easeOutElastic:()=>wY,easeOutExpo:()=>vY,easeOutQuad:()=>PY,easeOutQuart:()=>lY,easeOutQuint:()=>dY,easeOutSine:()=>fY});const T_=(s,e,t,i)=>(s<Math.abs(e)?(s=e,i=t/4):i=e===0&&s===0?t/pr*Math.asin(1):t/pr*Math.asin(e/s),{a:s,c:e,p:t,s:i}),$P=(s,e,t,i,n)=>s*2**(10*--i)*Math.sin((i*n-e)*pr/t),ZP=(s,e,t,i)=>-t*Math.cos(s/i*No)+t+e,sY=(s,e,t,i)=>t*(s/i)**3+e,rY=(s,e,t,i)=>t*((s/i-1)**3+1)+e,aY=(s,e,t,i)=>(s/=i/2)<1?t/2*s**3+e:t/2*((s-2)**3+2)+e,oY=(s,e,t,i)=>t*(s/=i)*s**3+e,lY=(s,e,t,i)=>-t*((s=s/i-1)*s**3-1)+e,cY=(s,e,t,i)=>(s/=i/2)<1?t/2*s**4+e:-t/2*((s-=2)*s**3-2)+e,hY=(s,e,t,i)=>t*(s/i)**5+e,dY=(s,e,t,i)=>t*((s/i-1)**5+1)+e,uY=(s,e,t,i)=>(s/=i/2)<1?t/2*s**5+e:t/2*((s-2)**5+2)+e,pY=(s,e,t,i)=>-t*Math.cos(s/i*No)+t+e,fY=(s,e,t,i)=>t*Math.sin(s/i*No)+e,mY=(s,e,t,i)=>-t/2*(Math.cos(Math.PI*s/i)-1)+e,gY=(s,e,t,i)=>s===0?e:t*2**(10*(s/i-1))+e,vY=(s,e,t,i)=>s===i?e+t:t*-(2**(-10*s/i)+1)+e,AY=(s,e,t,i)=>s===0?e:s===i?e+t:(s/=i/2)<1?t/2*2**(10*(s-1))+e:t/2*-(2**(-10*--s)+2)+e,bY=(s,e,t,i)=>-t*(Math.sqrt(1-(s/=i)*s)-1)+e,yY=(s,e,t,i)=>t*Math.sqrt(1-(s=s/i-1)*s)+e,xY=(s,e,t,i)=>(s/=i/2)<1?-t/2*(Math.sqrt(1-s**2)-1)+e:t/2*(Math.sqrt(1-(s-=2)*s)+1)+e,_Y=(s,e,t,i)=>{let n=t,r=0;if(s===0)return e;if((s/=i)===1)return e+t;r||(r=.3*i);let{a,s:o,p:l}=T_(n,t,r,1.70158);return-$P(a,o,l,s,i)+e},wY=(s,e,t,i)=>{let n=t,r=0;if(s===0)return e;if((s/=i)===1)return e+t;r||(r=.3*i);let{a,s:o,p:l,c}=T_(n,t,r,1.70158);return a*2**(-10*s)*Math.sin((s*i-o)*pr/l)+c+e},EY=(s,e,t,i)=>{let n=t,r=0;if(s===0)return e;if((s/=i/2)==2)return e+t;r||(r=.3*1.5*i);let{a,s:o,p:l,c}=T_(n,t,r,1.70158);return s<1?-.5*$P(a,o,l,s,i)+e:a*2**(-10*--s)*Math.sin((s*i-o)*pr/l)*.5+c+e},MY=(s,e,t,i,n=1.70158)=>t*(s/=i)*s*((n+1)*s-n)+e,SY=(s,e,t,i,n=1.70158)=>t*((s=s/i-1)*s*((n+1)*s+n)+1)+e,CY=(s,e,t,i,n=1.70158)=>(s/=i/2)<1?t/2*(s*s*((1+(n*=1.525))*s-n))+e:t/2*((s-=2)*s*((1+(n*=1.525))*s+n)+2)+e,I_=(s,e,t,i)=>(s/=i)<1/2.75?t*(7.5625*s*s)+e:s<2/2.75?t*(7.5625*(s-=1.5/2.75)*s+.75)+e:s<2.5/2.75?t*(7.5625*(s-=2.25/2.75)*s+.9375)+e:t*(7.5625*(s-=2.625/2.75)*s+.984375)+e,JP=(s,e,t,i)=>t-I_(i-s,0,t,i)+e,TY=(s,e,t,i)=>s<i/2?.5*JP(2*s,0,t,i)+e:.5*I_(2*s-i,0,t,i)+.5*t+e,IY=(s,e,t,i)=>t*(s/=i)*s+e,PY=(s,e,t,i)=>-t*(s/=i)*(s-2)+e,DY=(s,e,t,i)=>(s/=i/2)<1?t/2*s**2+e:-t/2*(--s*(s-2)-1)+e,RY=()=>!1;var P_=class{constructor({startValue:s,byValue:e,duration:t=500,delay:i=0,easing:n=ZP,onStart:r=Av,onChange:a=Av,onComplete:o=Av,abort:l=RY,target:c}){ue(this,"_state","pending"),ue(this,"durationProgress",0),ue(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=t,this.delay=i,this.easing=n,this._onStart=r,this._onChange=a,this._onComplete=o,this._abort=l,this.target=c,this.startValue=s,this.byValue=e,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}get state(){return this._state}isDone(){return this._state==="aborted"||this._state==="completed"}start(){let s=e=>{this._state==="pending"&&(this.startTime=e||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?this.timeout=cd().setTimeout(()=>kp(s),this.delay):kp(s)}tick(s){let e=(s||+new Date)-this.startTime,t=Math.min(e,this.duration);this.durationProgress=t/this.duration;let{value:i,valueProgress:n}=this.calculate(t);this.value=Object.freeze(i),this.valueProgress=n,this._state!=="aborted"&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):e>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state="completed",this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister(),this.timeout=null):(this._onChange(this.value,this.valueProgress,this.durationProgress),kp(this.tick)))}register(){_v.push(this)}unregister(){_v.remove(this)}abort(){this._state="aborted",this.unregister(),this.timeout&&cd().clearTimeout(this.timeout)}},BY=class extends P_{constructor({startValue:s=0,endValue:e=100,...t}){super({...t,startValue:s,byValue:e-s})}calculate(s){let e=this.easing(s,this.startValue,this.byValue,this.duration);return{value:e,valueProgress:Math.abs((e-this.startValue)/this.byValue)}}},LY=class extends P_{constructor({startValue:s=[0],endValue:e=[100],...t}){super({...t,startValue:s,byValue:e.map((i,n)=>i-s[n])})}calculate(s){let e=this.startValue.map((t,i)=>this.easing(s,t,this.byValue[i],this.duration,i));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}};const kY=(s,e,t,i)=>e+t*(1-Math.cos(s/i*No)),D_=s=>s&&((e,t,i)=>s(new br(e).toRgba(),t,i));var OY=class extends P_{constructor({startValue:s,endValue:e,easing:t=kY,onChange:i,onComplete:n,abort:r,...a}){let o=new br(s).getSource(),l=new br(e).getSource();super({...a,startValue:o,byValue:l.map((c,h)=>c-o[h]),easing:t,onChange:D_(i),onComplete:D_(n),abort:D_(r)})}calculate(s){let[e,t,i,n]=this.startValue.map((a,o)=>this.easing(s,a,this.byValue[o],this.duration,o)),r=[...[e,t,i].map(Math.round),mc(0,n,1)];return{value:r,valueProgress:r.map((a,o)=>this.byValue[o]===0?0:Math.abs((a-this.startValue[o])/this.byValue[o])).find(a=>a!==0)||0}}};function R_(s){let e=(t=>Array.isArray(t.startValue)||Array.isArray(t.endValue))(s)?new LY(s):new BY(s);return e.start(),e}function eD(s){let e=new OY(s);return e.start(),e}var Wp=class xn{constructor(e){this.status=e,this.points=[]}includes(e){return this.points.some(t=>t.eq(e))}append(...e){return this.points=this.points.concat(e.filter(t=>!this.includes(t))),this}static isPointContained(e,t,i,n=!1){if(t.eq(i))return e.eq(t);if(t.x===i.x)return e.x===t.x&&(n||e.y>=Math.min(t.y,i.y)&&e.y<=Math.max(t.y,i.y));if(t.y===i.y)return e.y===t.y&&(n||e.x>=Math.min(t.x,i.x)&&e.x<=Math.max(t.x,i.x));{let r=Hp(t,i),a=Hp(t,e).divide(r);return n?Math.abs(a.x)===Math.abs(a.y):a.x===a.y&&a.x>=0&&a.x<=1}}static isPointInPolygon(e,t){let i=new De(e).setX(Math.min(e.x-1,...t.map(r=>r.x))),n=0;for(let r=0;r<t.length;r++){let a=this.intersectSegmentSegment(t[r],t[(r+1)%t.length],e,i);if(a.includes(e))return!0;n+=+(a.status==="Intersection")}return n%2==1}static intersectLineLine(e,t,i,n,r=!0,a=!0){let o=t.x-e.x,l=t.y-e.y,c=n.x-i.x,h=n.y-i.y,d=e.x-i.x,u=e.y-i.y,p=c*u-h*d,m=o*u-l*d,v=h*o-c*l;if(v!==0){let g=p/v,f=m/v;return(r||0<=g&&g<=1)&&(a||0<=f&&f<=1)?new xn("Intersection").append(new De(e.x+g*o,e.y+g*l)):new xn}return new xn(p===0||m===0?r||a||xn.isPointContained(e,i,n)||xn.isPointContained(t,i,n)||xn.isPointContained(i,e,t)||xn.isPointContained(n,e,t)?"Coincident":void 0:"Parallel")}static intersectSegmentLine(e,t,i,n){return xn.intersectLineLine(e,t,i,n,!1,!0)}static intersectSegmentSegment(e,t,i,n){return xn.intersectLineLine(e,t,i,n,!1,!1)}static intersectLinePolygon(e,t,i,n=!0){let r=new xn,a=i.length;for(let o,l,c,h=0;h<a;h++){if(o=i[h],l=i[(h+1)%a],c=xn.intersectLineLine(e,t,o,l,n,!1),c.status==="Coincident")return c;r.append(...c.points)}return r.points.length>0&&(r.status="Intersection"),r}static intersectSegmentPolygon(e,t,i){return xn.intersectLinePolygon(e,t,i,!1)}static intersectPolygonPolygon(e,t){let i=new xn,n=e.length,r=[];for(let a=0;a<n;a++){let o=e[a],l=e[(a+1)%n],c=xn.intersectSegmentPolygon(o,l,t);c.status==="Coincident"?(r.push(c),i.append(o,l)):i.append(...c.points)}return r.length>0&&r.length===e.length?new xn("Coincident"):(i.points.length>0&&(i.status="Intersection"),i)}static intersectPolygonRectangle(e,t,i){let n=t.min(i),r=t.max(i),a=new De(r.x,n.y),o=new De(n.x,r.y);return xn.intersectPolygonPolygon(e,[n,a,r,o])}},FY=class extends uP{getX(){return this.getXY().x}setX(s){this.setXY(this.getXY().setX(s))}getY(){return this.getXY().y}setY(s){this.setXY(this.getXY().setY(s))}getRelativeX(){return this.left}setRelativeX(s){this.left=s}getRelativeY(){return this.top}setRelativeY(s){this.top=s}getXY(){let s=this.getRelativeXY();return this.group?Pn(s,this.group.calcTransformMatrix()):s}setXY(s,e,t){this.group&&(s=Pn(s,ws(this.group.calcTransformMatrix()))),this.setRelativeXY(s,e,t)}getRelativeXY(){return new De(this.left,this.top)}setRelativeXY(s,e=this.originX,t=this.originY){this.setPositionByOrigin(s,e,t)}isStrokeAccountedForInDimensions(){return!1}getCoords(){let{tl:s,tr:e,br:t,bl:i}=this.aCoords||(this.aCoords=this.calcACoords()),n=[s,e,t,i];if(this.group){let r=this.group.calcTransformMatrix();return n.map(a=>Pn(a,r))}return n}intersectsWithRect(s,e){return Wp.intersectPolygonRectangle(this.getCoords(),s,e).status==="Intersection"}intersectsWithObject(s){let e=Wp.intersectPolygonPolygon(this.getCoords(),s.getCoords());return e.status==="Intersection"||e.status==="Coincident"||s.isContainedWithinObject(this)||this.isContainedWithinObject(s)}isContainedWithinObject(s){return this.getCoords().every(e=>s.containsPoint(e))}isContainedWithinRect(s,e){let{left:t,top:i,width:n,height:r}=this.getBoundingRect();return t>=s.x&&t+n<=e.x&&i>=s.y&&i+r<=e.y}isOverlapping(s){return this.intersectsWithObject(s)||this.isContainedWithinObject(s)||s.isContainedWithinObject(this)}containsPoint(s){return Wp.isPointInPolygon(s,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;let{tl:s,br:e}=this.canvas.vptCoords;return!!this.getCoords().some(t=>t.x<=e.x&&t.x>=s.x&&t.y<=e.y&&t.y>=s.y)||!!this.intersectsWithRect(s,e)||this.containsPoint(s.midPointFrom(e))}isPartiallyOnScreen(){if(!this.canvas)return!1;let{tl:s,br:e}=this.canvas.vptCoords;return!!this.intersectsWithRect(s,e)||this.getCoords().every(t=>(t.x>=e.x||t.x<=s.x)&&(t.y>=e.y||t.y<=s.y))&&this.containsPoint(s.midPointFrom(e))}getBoundingRect(){return jr(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(s){this._set(Uo,s),this._set(zo,s),this.setCoords()}scaleToWidth(s){let e=this.getBoundingRect().width/this.getScaledWidth();return this.scale(s/this.width/e)}scaleToHeight(s){let e=this.getBoundingRect().height/this.getScaledHeight();return this.scale(s/this.height/e)}getCanvasRetinaScaling(){var s;return((s=this.canvas)==null?void 0:s.getRetinaScaling())||1}getTotalAngle(){return this.group?ka(gP(this.calcTransformMatrix())):this.angle}getViewportTransform(){var s;return((s=this.canvas)==null?void 0:s.viewportTransform)||Wn.concat()}calcACoords(){let s=hc({angle:this.angle}),{x:e,y:t}=this.getRelativeCenterPoint(),i=Li(fd(e,t),s),n=this._getTransformedDimensions(),r=n.x/2,a=n.y/2;return{tl:Pn({x:-r,y:-a},i),tr:Pn({x:r,y:-a},i),bl:Pn({x:-r,y:a},i),br:Pn({x:r,y:a},i)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(s=!1){let e=[];return!s&&this.group&&(e=this.group.transformMatrixKey(s)),e.push(this.top,this.left,this.width,this.height,this.scaleX,this.scaleY,this.angle,this.strokeWidth,this.skewX,this.skewY,+this.flipX,+this.flipY,Qn(this.originX),Qn(this.originY)),e}calcTransformMatrix(s=!1){let e=this.calcOwnMatrix();if(s||!this.group)return e;let t=this.transformMatrixKey(s),i=this.matrixCache;return i&&i.key.every((n,r)=>n===t[r])?i.value:(this.group&&(e=Li(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:t,value:e},e)}calcOwnMatrix(){let s=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key.every((n,r)=>n===s[r]))return e.value;let t=this.getRelativeCenterPoint(),i=AP({angle:this.angle,translateX:t.x,translateY:t.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY});return this.ownMatrixCache={key:s,value:i},i}_getNonTransformedDimensions(){return new De(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(s){return this._getTransformedDimensions(s).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(s={}){let e={scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth,...s},t=e.strokeWidth,i=t,n=0;this.strokeUniform&&(i=0,n=t);let r=e.width+i,a=e.height+i,o;return o=e.skewX===0&&e.skewY===0?new De(r*e.scaleX,a*e.scaleY):Tv(r,a,Op(e)),o.scalarAdd(n)}translateToGivenOrigin(s,e,t,i,n){let r=s.x,a=s.y,o=Qn(i)-Qn(e),l=Qn(n)-Qn(t);if(o||l){let c=this._getTransformedDimensions();r+=o*c.x,a+=l*c.y}return new De(r,a)}translateToCenterPoint(s,e,t){if(e==="center"&&t==="center")return s;let i=this.translateToGivenOrigin(s,e,t,ui,ui);return this.angle?i.rotate(Bi(this.angle),s):i}translateToOriginPoint(s,e,t){let i=this.translateToGivenOrigin(s,ui,ui,e,t);return this.angle?i.rotate(Bi(this.angle),s):i}getCenterPoint(){let s=this.getRelativeCenterPoint();return this.group?Pn(s,this.group.calcTransformMatrix()):s}getRelativeCenterPoint(){return this.translateToCenterPoint(new De(this.left,this.top),this.originX,this.originY)}getPointByOrigin(s,e){return this.getPositionByOrigin(s,e)}getPositionByOrigin(s,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),s,e)}setPositionByOrigin(s,e,t){let i=this.translateToCenterPoint(s,e,t),n=this.translateToOriginPoint(i,this.originX,this.originY);this.set({left:n.x,top:n.y})}_getLeftTopCoords(){return this.getPositionByOrigin(mn,"top")}positionByLeftTop(s){return this.setPositionByOrigin(s,mn,"top")}},Na=class dA extends FY{static getDefaults(){return dA.ownDefaults}get type(){let e=this.constructor.type;return e==="FabricObject"?"object":e.toLowerCase()}set type(e){Fo("warn","Setting type has no effect",e)}constructor(e){super(),ue(this,"_cacheContext",null),Object.assign(this,dA.ownDefaults),this.setOptions(e)}_createCacheCanvas(){this._cacheCanvas=Qr(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(e){let t=e.width,i=e.height,n=ei.maxCacheSideLimit,r=ei.minCacheSideLimit;if(t<=n&&i<=n&&t*i<=ei.perfLimitSizeTotal)return t<r&&(e.width=r),i<r&&(e.height=r),e;let a=t/i,[o,l]=Bp.limitDimsByArea(a),c=mc(r,o,n),h=mc(r,l,n);return t>c&&(e.zoomX/=t/c,e.width=c,e.capped=!0),i>h&&(e.zoomY/=i/h,e.height=h,e.capped=!0),e}_getCacheCanvasDimensions(){let e=this.getTotalObjectScaling(),t=this._getTransformedDimensions({skewX:0,skewY:0}),i=t.x*e.x/this.scaleX,n=t.y*e.y/this.scaleY;return{width:Math.ceil(i+2),height:Math.ceil(n+2),zoomX:e.x,zoomY:e.y,x:i,y:n}}_updateCacheCanvas(){let e=this._cacheCanvas,t=this._cacheContext,{width:i,height:n,zoomX:r,zoomY:a,x:o,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=i!==e.width||n!==e.height,h=this.zoomX!==r||this.zoomY!==a;if(!e||!t)return!1;if(c||h){i!==e.width||n!==e.height?(e.width=i,e.height=n):(t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,e.width,e.height));let d=o/2,u=l/2;return this.cacheTranslationX=Math.round(e.width/2-d)+d,this.cacheTranslationY=Math.round(e.height/2-u)+u,t.translate(this.cacheTranslationX,this.cacheTranslationY),t.scale(r,a),this.zoomX=r,this.zoomY=a,!0}return!1}setOptions(e={}){this._setOptions(e)}transform(e){let t=this.group&&!this.group._transformDone||this.group&&this.canvas&&e===this.canvas.contextTop,i=this.calcTransformMatrix(!t);e.transform(i[0],i[1],i[2],i[3],i[4],i[5])}getObjectScaling(){if(!this.group)return new De(Math.abs(this.scaleX),Math.abs(this.scaleY));let e=pd(this.calcTransformMatrix());return new De(Math.abs(e.scaleX),Math.abs(e.scaleY))}getTotalObjectScaling(){let e=this.getObjectScaling();if(this.canvas){let t=this.canvas.getZoom(),i=this.getCanvasRetinaScaling();return e.scalarMultiply(t*i)}return e}getObjectOpacity(){let e=this.opacity;return this.group&&(e*=this.group.getObjectOpacity()),e}_constrainScale(e){return Math.abs(e)<this.minScaleLimit?e<0?-this.minScaleLimit:this.minScaleLimit:e===0?1e-4:e}_set(e,t){e!=="scaleX"&&e!=="scaleY"||(t=this._constrainScale(t)),e==="scaleX"&&t<0?(this.flipX=!this.flipX,t*=-1):e==="scaleY"&&t<0?(this.flipY=!this.flipY,t*=-1):e!=="shadow"||!t||t instanceof Vp||(t=new Vp(t));let i=this[e]!==t;return this[e]=t,i&&this.constructor.cacheProperties.includes(e)&&(this.dirty=!0),this.parent&&(this.dirty||i&&this.constructor.stateProperties.includes(e))&&this.parent._set("dirty",!0),this}isNotVisible(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible}render(e){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(e.save(),this._setupCompositeOperation(e),this.drawSelectionBackground(e),this.transform(e),this._setOpacity(e),this._setShadow(e),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(e)):(this._removeCacheCanvas(),this.drawObject(e,!1,{}),this.dirty=!1),e.restore())}drawSelectionBackground(e){}renderCache(e){if(e=e||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){let{zoomX:t,zoomY:i,cacheTranslationX:n,cacheTranslationY:r}=this,{width:a,height:o}=this._cacheCanvas;this.drawObject(this._cacheContext,e.forClipping,{zoomX:t,zoomY:i,cacheTranslationX:n,cacheTranslationY:r,width:a,height:o,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return!!this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0}hasFill(){return!!this.fill&&this.fill!=="transparent"}needsItsOwnCache(){return!!(this.paintFirst==="stroke"&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.objectCaching&&(!this.parent||!this.parent.isOnACache())||this.needsItsOwnCache(),this.ownCaching}willDrawShadow(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)}drawClipPathOnCache(e,t,i){e.save(),t.inverted?e.globalCompositeOperation="destination-out":e.globalCompositeOperation="destination-in",e.setTransform(1,0,0,1,0,0),e.drawImage(i,0,0),e.restore()}drawObject(e,t,i){let n=this.fill,r=this.stroke;t?(this.fill="black",this.stroke="",this._setClippingProperties(e)):this._renderBackground(e),this.fire("before:render",{ctx:e}),this._render(e),this._drawClipPath(e,this.clipPath,i),this.fill=n,this.stroke=r}createClipPathLayer(e,t){let i=_s(t),n=i.getContext("2d");if(n.translate(t.cacheTranslationX,t.cacheTranslationY),n.scale(t.zoomX,t.zoomY),e._cacheCanvas=i,t.parentClipPaths.forEach(r=>{r.transform(n)}),t.parentClipPaths.push(e),e.absolutePositioned){let r=ws(this.calcTransformMatrix());n.transform(r[0],r[1],r[2],r[3],r[4],r[5])}return e.transform(n),e.drawObject(n,!0,t),i}_drawClipPath(e,t,i){if(!t)return;t._transformDone=!0;let n=this.createClipPathLayer(t,i);this.drawClipPathOnCache(e,t,n)}drawCacheOnCanvas(e){e.scale(1/this.zoomX,1/this.zoomY),e.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(e=!1){if(this.isNotVisible())return!1;let t=this._cacheCanvas,i=this._cacheContext;return!(!t||!i||e||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(t&&i&&!e&&(i.save(),i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,t.width,t.height),i.restore()),!0)}_renderBackground(e){if(!this.backgroundColor)return;let t=this._getNonTransformedDimensions();e.fillStyle=this.backgroundColor,e.fillRect(-t.x/2,-t.y/2,t.x,t.y),this._removeShadow(e)}_setOpacity(e){this.group&&!this.group._transformDone?e.globalAlpha=this.getObjectOpacity():e.globalAlpha*=this.opacity}_setStrokeStyles(e,t){let i=t.stroke;i&&(e.lineWidth=t.strokeWidth,e.lineCap=t.strokeLineCap,e.lineDashOffset=t.strokeDashOffset,e.lineJoin=t.strokeLineJoin,e.miterLimit=t.strokeMiterLimit,Ws(i)?i.gradientUnits==="percentage"||i.gradientTransform||i.patternTransform?this._applyPatternForTransformedGradient(e,i):(e.strokeStyle=i.toLive(e),this._applyPatternGradientTransform(e,i)):e.strokeStyle=t.stroke)}_setFillStyles(e,{fill:t}){t&&(Ws(t)?(e.fillStyle=t.toLive(e),this._applyPatternGradientTransform(e,t)):e.fillStyle=t)}_setClippingProperties(e){e.globalAlpha=1,e.strokeStyle="transparent",e.fillStyle="#000000"}_setLineDash(e,t){t&&t.length!==0&&e.setLineDash(t)}_setShadow(e){if(!this.shadow)return;let t=this.shadow,i=this.canvas,n=this.getCanvasRetinaScaling(),[r,,,a]=i?.viewportTransform||Wn,o=r*n,l=a*n,c=t.nonScaling?new De(1,1):this.getObjectScaling();e.shadowColor=t.color,e.shadowBlur=t.blur*ei.browserShadowBlurConstant*(o+l)*(c.x+c.y)/4,e.shadowOffsetX=t.offsetX*o*c.x,e.shadowOffsetY=t.offsetY*l*c.y}_removeShadow(e){this.shadow&&(e.shadowColor="",e.shadowBlur=e.shadowOffsetX=e.shadowOffsetY=0)}_applyPatternGradientTransform(e,t){if(!Ws(t))return{offsetX:0,offsetY:0};let i=t.gradientTransform||t.patternTransform,n=-this.width/2+t.offsetX||0,r=-this.height/2+t.offsetY||0;return t.gradientUnits==="percentage"?e.transform(this.width,0,0,this.height,n,r):e.transform(1,0,0,1,n,r),i&&e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:n,offsetY:r}}_renderPaintInOrder(e){this.paintFirst==="stroke"?(this._renderStroke(e),this._renderFill(e)):(this._renderFill(e),this._renderStroke(e))}_render(e){}_renderFill(e){this.fill&&(e.save(),this._setFillStyles(e,this),this.fillRule==="evenodd"?e.fill("evenodd"):e.fill(),e.restore())}_renderStroke(e){if(this.stroke&&this.strokeWidth!==0){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(e),e.save(),this.strokeUniform){let t=this.getObjectScaling();e.scale(1/t.x,1/t.y)}this._setLineDash(e,this.strokeDashArray),this._setStrokeStyles(e,this),e.stroke(),e.restore()}}_applyPatternForTransformedGradient(e,t){var i;let n=this._limitCacheSize(this._getCacheCanvasDimensions()),r=this.getCanvasRetinaScaling(),a=n.x/this.scaleX/r,o=n.y/this.scaleY/r,l=_s({width:Math.ceil(a),height:Math.ceil(o)}),c=l.getContext("2d");c&&(c.beginPath(),c.moveTo(0,0),c.lineTo(a,0),c.lineTo(a,o),c.lineTo(0,o),c.closePath(),c.translate(a/2,o/2),c.scale(n.zoomX/this.scaleX/r,n.zoomY/this.scaleY/r),this._applyPatternGradientTransform(c,t),c.fillStyle=t.toLive(e),c.fill(),e.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),e.scale(r*this.scaleX/n.zoomX,r*this.scaleY/n.zoomY),e.strokeStyle=(i=c.createPattern(l,"no-repeat"))==null?"":i)}_findCenterFromElement(){return new De(this.left+this.width/2,this.top+this.height/2)}clone(e){let t=this.toObject(e);return this.constructor.fromObject(t)}cloneAsImage(e){let t=this.toCanvasElement(e);return new(ot.getClass("image"))(t)}toCanvasElement(e={}){let t=A_(this),i=this.group,n=this.shadow,r=Math.abs,a=e.enableRetinaScaling?tP():1,o=(e.multiplier||1)*a,l=e.canvasProvider||(A=>new v_(A,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,e.withoutTransform&&IP(this),e.withoutShadow&&(this.shadow=null),e.viewportTransform&&b_(this,this.getViewportTransform()),this.setCoords();let c=Qr(),h=this.getBoundingRect(),d=this.shadow,u=new De;if(d){let A=d.blur,b=d.nonScaling?new De(1,1):this.getObjectScaling();u.x=2*Math.round(r(d.offsetX)+A)*r(b.x),u.y=2*Math.round(r(d.offsetY)+A)*r(b.y)}let p=h.width+u.x,m=h.height+u.y;c.width=Math.ceil(p),c.height=Math.ceil(m);let v=l(c);e.format==="jpeg"&&(v.backgroundColor="#fff"),this.setPositionByOrigin(new De(v.width/2,v.height/2),ui,ui);let g=this.canvas;v._objects=[this],this.set("canvas",v),this.setCoords();let f=v.toCanvasElement(o||1,e);return this.set("canvas",g),this.shadow=n,i&&(this.group=i),this.set(t),this.setCoords(),v._objects=[],v.destroy(),f}toDataURL(e={}){return d_(this.toCanvasElement(e),e.format||"png",e.quality||1)}toBlob(e={}){return u_(this.toCanvasElement(e),e.format||"png",e.quality||1)}isType(...e){return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(e){let{centeredRotation:t,originX:i,originY:n}=this;if(t){let{x:r,y:a}=this.getRelativeCenterPoint();this.originX=ui,this.originY=ui,this.left=r,this.top=a}if(this.set("angle",e),t){let{x:r,y:a}=this.getPositionByOrigin(i,n);this.left=r,this.top=a,this.originX=i,this.originY=n}}setOnGroup(){}_setupCompositeOperation(e){this.globalCompositeOperation&&(e.globalCompositeOperation=this.globalCompositeOperation)}dispose(){_v.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&Wr().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(e,t){return Object.entries(e).reduce((i,[n,r])=>(i[n]=this._animate(n,r,t),i),{})}_animate(e,t,i={}){let n=e.split("."),r=this.constructor.colorProperties.includes(n[n.length-1]),{abort:a,startValue:o,onChange:l,onComplete:c}=i,h={...i,target:this,startValue:o??n.reduce((d,u)=>d[u],this),endValue:t,abort:a?.bind(this),onChange:(d,u,p)=>{n.reduce((m,v,g)=>(g===n.length-1&&(m[v]=d),m[v]),this),l&&l(d,u,p)},onComplete:(d,u,p)=>{this.setCoords(),c&&c(d,u,p)}};return r?eD(h):R_(h)}isDescendantOf(e){let{parent:t,group:i}=this;return t===e||i===e||!!t&&t.isDescendantOf(e)||!!i&&i!==t&&i.isDescendantOf(e)}getAncestors(){let e=[],t=this;do t=t.parent,t&&e.push(t);while(t);return e}findCommonAncestors(e){if(this===e)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};let t=this.getAncestors(),i=e.getAncestors();if(t.length===0&&i.length>0&&this===i[i.length-1])return{fork:[],otherFork:[e,...i.slice(0,i.length-1)],common:[this]};for(let n,r=0;r<t.length;r++){if(n=t[r],n===e)return{fork:[this,...t.slice(0,r)],otherFork:[],common:t.slice(r)};for(let a=0;a<i.length;a++){if(this===i[a])return{fork:[],otherFork:[e,...i.slice(0,a)],common:[this,...t]};if(n===i[a])return{fork:[this,...t.slice(0,r)],otherFork:[e,...i.slice(0,a)],common:t.slice(r)}}}return{fork:[this,...t],otherFork:[e,...i],common:[]}}hasCommonAncestors(e){let t=this.findCommonAncestors(e);return t&&!!t.common.length}isInFrontOf(e){if(this===e)return;let t=this.findCommonAncestors(e);if(t.fork.includes(e))return!0;if(t.otherFork.includes(this))return!1;let i=t.common[0]||this.canvas;if(!i)return;let n=t.fork.pop(),r=t.otherFork.pop(),a=i._objects.indexOf(n),o=i._objects.indexOf(r);return a>-1&&a>o}toObject(e=[]){let t=e.concat(dA.customProperties,this.constructor.customProperties||[]),i,n=ei.NUM_FRACTION_DIGITS,{clipPath:r,fill:a,stroke:o,shadow:l,strokeDashArray:c,left:h,top:d,originX:u,originY:p,width:m,height:v,strokeWidth:g,strokeLineCap:f,strokeDashOffset:A,strokeLineJoin:b,strokeUniform:y,strokeMiterLimit:x,scaleX:_,scaleY:M,angle:E,flipX:w,flipY:T,opacity:R,visible:D,backgroundColor:L,fillRule:I,paintFirst:O,globalCompositeOperation:N,skewX:G,skewY:V}=this;r&&!r.excludeFromExport&&(i=r.toObject(t.concat("inverted","absolutePositioned")));let H=W=>pi(W,n),J={...dc(this,t),type:this.constructor.type,version:o_,originX:u,originY:p,left:H(h),top:H(d),width:H(m),height:H(v),fill:bP(a)?a.toObject():a,stroke:bP(o)?o.toObject():o,strokeWidth:H(g),strokeDashArray:c&&c.concat(),strokeLineCap:f,strokeDashOffset:A,strokeLineJoin:b,strokeUniform:y,strokeMiterLimit:H(x),scaleX:H(_),scaleY:H(M),angle:H(E),flipX:w,flipY:T,opacity:H(R),shadow:l&&l.toObject(),visible:D,backgroundColor:L,fillRule:I,paintFirst:O,globalCompositeOperation:N,skewX:H(G),skewY:H(V),...i?{clipPath:i}:null};return this.includeDefaultValues?J:this._removeDefaultValues(J)}toDatalessObject(e){return this.toObject(e)}_removeDefaultValues(e){let t=this.constructor.getDefaults(),i=Object.keys(t).length>0?t:Object.getPrototypeOf(this);return m_(e,(n,r)=>{if(r==="left"||r==="top"||r==="type")return!0;let a=i[r];return n!==a&&!(Array.isArray(n)&&Array.isArray(a)&&n.length===0&&a.length===0)})}toString(){return`#<${this.constructor.type}>`}static _fromObject({type:e,...t},{extraParam:i,...n}={}){return Np(t,n).then(r=>i?(delete r[i],new this(t[i],r)):new this(r))}static fromObject(e,t){return this._fromObject(e,t)}};ue(Na,"stateProperties",tY),ue(Na,"cacheProperties",Fa),ue(Na,"ownDefaults",iY),ue(Na,"type","FabricObject"),ue(Na,"colorProperties",[as,La,"backgroundColor"]),ue(Na,"customProperties",[]),ot.setClass(Na),ot.setClass(Na,"object");const B_=(s,e)=>{var t;let{transform:{target:i}}=e;(t=i.canvas)==null||t.fire(`object:${s}`,{...e,target:i}),i.fire(s,e)},Ua=(s,e,t)=>(i,n,r,a)=>{let o=e(i,n,r,a);return o&&B_(s,{...M_(i,n,r,a),...t}),o};function Go(s){return(e,t,i,n)=>{let{target:r,originX:a,originY:o}=t,l=r.getPositionByOrigin(a,o),c=s(e,t,i,n);return r.setPositionByOrigin(l,t.originX,t.originY),c}}const tD=(s,e,t,i)=>(n,r,a,o)=>{let l=Rv(r,r.originX,r.originY,a,o)[t],c=Qn(r[e]);if(c===0||c>0&&l<0||c<0&&l>0){let{target:h}=r,d=h.strokeWidth/(h.strokeUniform?h[i]:1),u=BP(r)?2:1,p=h[s],m=Math.abs(l*u/h[i])-d;return h.set(s,Math.max(m,1)),p!==h[s]}return!1},iD=tD("width","originX","x","scaleX"),nD=tD("height","originY","y","scaleY"),L_=Ua(Lp,Go(iD)),NY=Ua(Lp,Go(nD));function sD(s,e,t,i,n){s.save();let{stroke:r,xSize:a,ySize:o,opName:l}=this.commonRenderProps(s,e,t,n,i),c=a;a>o?s.scale(1,o/a):o>a&&(c=o,s.scale(a/o,1)),s.beginPath(),s.arc(0,0,c/2,0,pr,!1),s[l](),r&&s.stroke(),s.restore()}function rD(s,e,t,i,n){s.save();let{stroke:r,xSize:a,ySize:o,opName:l}=this.commonRenderProps(s,e,t,n,i),c=a/2,h=o/2;s[`${l}Rect`](-c,-h,a,o),r&&s.strokeRect(-c,-h,a,o),s.restore()}var Es=class{constructor(s){ue(this,"visible",!0),ue(this,"actionName",lP),ue(this,"angle",0),ue(this,"x",0),ue(this,"y",0),ue(this,"offsetX",0),ue(this,"offsetY",0),ue(this,"sizeX",0),ue(this,"sizeY",0),ue(this,"touchSizeX",0),ue(this,"touchSizeY",0),ue(this,"cursorStyle","crosshair"),ue(this,"withConnection",!1),Object.assign(this,s)}getTransformAnchorPoint(){var s;return(s=this.transformAnchorPoint)==null?new De(.5-this.x,.5-this.y):s}shouldActivate(s,e,t,{tl:i,tr:n,br:r,bl:a}){var o;return((o=e.canvas)==null?void 0:o.getActiveObject())===e&&e.isControlVisible(s)&&Wp.isPointInPolygon(t,[i,n,r,a])}getActionHandler(s,e,t){return this.actionHandler}getMouseDownHandler(s,e,t){return this.mouseDownHandler}getMouseUpHandler(s,e,t){return this.mouseUpHandler}cursorStyleHandler(s,e,t,i){return e.cursorStyle}getActionName(s,e,t){return e.actionName}getVisibility(s,e){var t,i;return(t=(i=s._controlsVisibility)==null?void 0:i[e])==null?this.visible:t}setVisibility(s,e,t){this.visible=s}positionHandler(s,e,t,i){return new De(this.x*s.x+this.offsetX,this.y*s.y+this.offsetY).transform(e)}calcCornerCoords(s,e,t,i,n,r){let a=Ev([fd(t,i),hc({angle:s}),Mv((n?this.touchSizeX:this.sizeX)||e,(n?this.touchSizeY:this.sizeY)||e)]);return{tl:new De(-.5,-.5).transform(a),tr:new De(.5,-.5).transform(a),br:new De(.5,.5).transform(a),bl:new De(-.5,.5).transform(a)}}commonRenderProps(s,e,t,i,n={}){let{cornerSize:r,cornerColor:a,transparentCorners:o,cornerStrokeColor:l}=n,c=r||i.cornerSize,h=this.sizeX||c,d=this.sizeY||c,u=o===void 0?i.transparentCorners:o,p=u?La:as,m=l||i.cornerStrokeColor,v=!u&&!!m;return s.fillStyle=a||i.cornerColor||"",s.strokeStyle=m||"",s.translate(e,t),s.rotate(Bi(i.getTotalAngle())),{stroke:v,xSize:h,ySize:d,transparentCorners:u,opName:p}}render(s,e,t,i,n){((i=i||{}).cornerStyle||n.cornerStyle)==="circle"?sD.call(this,s,e,t,i,n):rD.call(this,s,e,t,i,n)}};const aD=(s,e,t)=>t.lockRotation?E_:e.cursorStyle,oD=Ua(sP,Go((s,{target:e,ex:t,ey:i,theta:n,originX:r,originY:a},o,l)=>{let c=e.getPositionByOrigin(r,a);if(Ar(e,"lockRotation"))return!1;let h=Math.atan2(i-c.y,t-c.x),d=ka(Math.atan2(l-c.y,o-c.x)-h+n);if(e.snapAngle&&e.snapAngle>0){let p=e.snapAngle,m=e.snapThreshold||p,v=Math.ceil(d/p)*p,g=Math.floor(d/p)*p;Math.abs(d-g)<m?d=g:Math.abs(d-v)<m&&(d=v)}d<0&&(d=360+d),d%=360;let u=e.angle!==d;return e.angle=d,u}));function lD(s,e){let t=e.canvas,i=s[t.uniScaleKey];return t.uniformScaling&&!i||!t.uniformScaling&&i}function cD(s,e,t){let i=Ar(s,"lockScalingX"),n=Ar(s,"lockScalingY");if(i&&n||!e&&(i||n)&&t||i&&e==="x"||n&&e==="y")return!0;let{width:r,height:a,strokeWidth:o}=s;return r===0&&o===0&&e!=="y"||a===0&&o===0&&e!=="x"}const UY=["e","se","s","sw","w","nw","n","ne","e"],yd=(s,e,t,i)=>{let n=lD(s,t);return cD(t,e.x!==0&&e.y===0?"x":e.x===0&&e.y!==0?"y":"",n)?E_:`${UY[kP(t,0,i)]}-resize`};function k_(s,e,t,i,n={}){let r=e.target,a=n.by,o=lD(s,r),l,c,h,d,u,p;if(cD(r,a,o))return!1;if(e.gestureScale)c=e.scaleX*e.gestureScale,h=e.scaleY*e.gestureScale;else{if(l=Rv(e,e.originX,e.originY,t,i),u=a==="y"?1:Math.sign(l.x||e.signX||1),p=a==="x"?1:Math.sign(l.y||e.signY||1),e.signX||(e.signX=u),e.signY||(e.signY=p),Ar(r,"lockScalingFlip")&&(e.signX!==u||e.signY!==p))return!1;if(d=r._getTransformedDimensions(),o&&!a){let g=Math.abs(l.x)+Math.abs(l.y),{original:f}=e,A=g/(Math.abs(d.x*f.scaleX/r.scaleX)+Math.abs(d.y*f.scaleY/r.scaleY));c=f.scaleX*A,h=f.scaleY*A}else c=Math.abs(l.x*r.scaleX/d.x),h=Math.abs(l.y*r.scaleY/d.y);BP(e)&&(c*=2,h*=2),e.signX!==u&&a!=="y"&&(e.originX=LP(e.originX),c*=-1,e.signX=u),e.signY!==p&&a!=="x"&&(e.originY=LP(e.originY),h*=-1,e.signY=p)}let m=r.scaleX,v=r.scaleY;return a?(a==="x"&&r.set("scaleX",c),a==="y"&&r.set("scaleY",h)):(!Ar(r,"lockScalingX")&&r.set("scaleX",c),!Ar(r,"lockScalingY")&&r.set("scaleY",h)),m!==r.scaleX||v!==r.scaleY}const Qp=Ua(yv,Go((s,e,t,i)=>k_(s,e,t,i))),hD=Ua(yv,Go((s,e,t,i)=>k_(s,e,t,i,{by:"x"}))),dD=Ua(yv,Go((s,e,t,i)=>k_(s,e,t,i,{by:"y"}))),O_={x:{counterAxis:"y",scale:Uo,skew:hd,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:zo,skew:dd,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},zY=["ns","nesw","ew","nwse"],uD=(s,e,t,i)=>e.x!==0&&Ar(t,"lockSkewingY")||e.y!==0&&Ar(t,"lockSkewingX")?E_:`${zY[kP(t,0,i)%4]}-resize`;function pD(s,e,t,i,n){let{target:r}=t,{counterAxis:a,origin:o,lockSkewing:l,skew:c,flip:h}=O_[s];if(Ar(r,l))return!1;let{origin:d,flip:u}=O_[a],p=Qn(t[d])*(r[u]?-1:1),m=-Math.sign(p)*(r[h]?-1:1),v=-(r[c]===0&&Rv(t,"center","center",i,n)[s]>0||r[c]>0?1:-1)*m*.5+.5;return Ua(aP,Go((g,f,A,b)=>(function(y,{target:x,ex:_,ey:M,skewingSide:E,...w},T){let{skew:R}=O_[y],D=T.subtract(new De(_,M)).divide(new De(x.scaleX,x.scaleY))[y],L=x[R],I=w[R],O=Math.tan(Bi(I)),N=y==="y"?x._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:x._getTransformedDimensions({scaleX:1,scaleY:1}).y,G=2*D*E/Math.max(N,1)+O,V=ka(Math.atan(G));x.set(R,V);let H=L!==x[R];if(H&&y==="y"){let{skewX:J,scaleX:W}=x,X=x._getTransformedDimensions({skewY:L}),me=x._getTransformedDimensions(),Ee=J===0?1:X.x/me.x;Ee!==1&&x.set("scaleX",Ee*W)}return H})(s,f,new De(A,b))))(e,{...t,[o]:v,skewingSide:m},i,n)}const fD=(s,e,t,i)=>pD("x",s,e,t,i),mD=(s,e,t,i)=>pD("y",s,e,t,i);function Fv(s,e){return s[e.canvas.altActionKey]}const jp=(s,e,t)=>{let i=Fv(s,t);return e.x===0?i?hd:zo:e.y===0?i?dd:Uo:""},gc=(s,e,t,i)=>Fv(s,t)?uD(0,e,t,i):yd(s,e,t,i),F_=(s,e,t,i)=>Fv(s,e.target)?mD(s,e,t,i):hD(s,e,t,i),N_=(s,e,t,i)=>Fv(s,e.target)?fD(s,e,t,i):dD(s,e,t,i),U_=()=>({ml:new Es({x:-.5,y:0,cursorStyleHandler:gc,actionHandler:F_,getActionName:jp}),mr:new Es({x:.5,y:0,cursorStyleHandler:gc,actionHandler:F_,getActionName:jp}),mb:new Es({x:0,y:.5,cursorStyleHandler:gc,actionHandler:N_,getActionName:jp}),mt:new Es({x:0,y:-.5,cursorStyleHandler:gc,actionHandler:N_,getActionName:jp}),tl:new Es({x:-.5,y:-.5,cursorStyleHandler:yd,actionHandler:Qp}),tr:new Es({x:.5,y:-.5,cursorStyleHandler:yd,actionHandler:Qp}),bl:new Es({x:-.5,y:.5,cursorStyleHandler:yd,actionHandler:Qp}),br:new Es({x:.5,y:.5,cursorStyleHandler:yd,actionHandler:Qp}),mtr:new Es({x:0,y:-.5,actionHandler:oD,cursorStyleHandler:aD,offsetY:-40,withConnection:!0,actionName:rP})}),gD=()=>({mr:new Es({x:.5,y:0,actionHandler:L_,cursorStyleHandler:gc,actionName:Lp}),ml:new Es({x:-.5,y:0,actionHandler:L_,cursorStyleHandler:gc,actionName:Lp})}),vD=()=>({...U_(),...gD()});var AD=class uw extends Na{static getDefaults(){return{...super.getDefaults(),...uw.ownDefaults}}constructor(e){super(),Object.assign(this,this.constructor.createControls(),uw.ownDefaults),this.setOptions(e)}static createControls(){return{controls:U_()}}_updateCacheCanvas(){let e=this.canvas;if(this.noScaleCache&&e&&e._currentTransform){let t=e._currentTransform,i=t.target,n=t.action;if(this===i&&n&&n.startsWith("scale"))return!1}return super._updateCacheCanvas()}getActiveControl(){let e=this.__corner;return e?{key:e,control:this.controls[e],coord:this.oCoords[e]}:void 0}findControl(e,t=!1){if(!this.hasControls||!this.canvas)return;this.__corner=void 0;let i=Object.entries(this.oCoords);for(let n=i.length-1;n>=0;n--){let[r,a]=i[n],o=this.controls[r];if(o.shouldActivate(r,this,e,t?a.touchCorner:a.corner))return this.__corner=r,{key:r,control:o,coord:this.oCoords[r]}}}calcOCoords(){let e=this.getViewportTransform(),t=this.getCenterPoint(),i=Li(Li(e,Li(fd(t.x,t.y),hc({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}))),[1/e[0],0,0,1/e[3],0,0]),n=this.group?pd(this.calcTransformMatrix()):void 0;n&&(n.scaleX=Math.abs(n.scaleX),n.scaleY=Math.abs(n.scaleY));let r=this._calculateCurrentDimensions(n),a={};return this.forEachControl((o,l)=>{let c=o.positionHandler(r,i,this,o);a[l]=Object.assign(c,this._calcCornerCoords(o,c))}),a}_calcCornerCoords(e,t){let i=this.getTotalAngle();return{corner:e.calcCornerCoords(i,this.cornerSize,t.x,t.y,!1,this),touchCorner:e.calcCornerCoords(i,this.touchCornerSize,t.x,t.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(e){for(let t in this.controls)e(this.controls[t],t,this)}drawSelectionBackground(e){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;e.save();let t=this.getRelativeCenterPoint(),i=this._calculateCurrentDimensions(),n=this.getViewportTransform();e.translate(t.x,t.y),e.scale(1/n[0],1/n[3]),e.rotate(Bi(this.angle)),e.fillStyle=this.selectionBackgroundColor,e.fillRect(-i.x/2,-i.y/2,i.x,i.y),e.restore()}strokeBorders(e,t){e.strokeRect(-t.x/2,-t.y/2,t.x,t.y)}_drawBorders(e,t,i={}){let n={hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray,...i};e.save(),e.strokeStyle=n.borderColor,this._setLineDash(e,n.borderDashArray),this.strokeBorders(e,t),n.hasControls&&this.drawControlsConnectingLines(e,t),e.restore()}_renderControls(e,t={}){let{hasBorders:i,hasControls:n}=this,r={hasBorders:i,hasControls:n,...t},a=this.getViewportTransform(),o=r.hasBorders,l=r.hasControls,c=pd(Li(a,this.calcTransformMatrix()));e.save(),e.translate(c.translateX,c.translateY),e.lineWidth=this.borderScaleFactor,this.group===this.parent&&(e.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(c.angle-=180),e.rotate(Bi(this.group?c.angle:this.angle)),o&&this.drawBorders(e,c,t),l&&this.drawControls(e,t),e.restore()}drawBorders(e,t,i){let n;if(i&&i.forActiveSelection||this.group){let r=Tv(this.width,this.height,Op(t)),a=this.isStrokeAccountedForInDimensions()?h_:(this.strokeUniform?new De().scalarAdd(this.canvas?this.canvas.getZoom():1):new De(t.scaleX,t.scaleY)).scalarMultiply(this.strokeWidth);n=r.add(a).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else n=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(e,n,i)}drawControlsConnectingLines(e,t){let i=!1;e.beginPath(),this.forEachControl((n,r)=>{n.withConnection&&n.getVisibility(this,r)&&(i=!0,e.moveTo(n.x*t.x,n.y*t.y),e.lineTo(n.x*t.x+n.offsetX,n.y*t.y+n.offsetY))}),i&&e.stroke()}drawControls(e,t={}){e.save();let i=this.getCanvasRetinaScaling(),{cornerStrokeColor:n,cornerDashArray:r,cornerColor:a}=this,o={cornerStrokeColor:n,cornerDashArray:r,cornerColor:a,...t};e.setTransform(i,0,0,i,0,0),e.strokeStyle=e.fillStyle=o.cornerColor,this.transparentCorners||(e.strokeStyle=o.cornerStrokeColor),this._setLineDash(e,o.cornerDashArray),this.forEachControl((l,c)=>{if(l.getVisibility(this,c)){let h=this.oCoords[c];l.render(e,h.x,h.y,o,this)}}),e.restore()}isControlVisible(e){return this.controls[e]&&this.controls[e].getVisibility(this,e)}setControlVisible(e,t){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[e]=t}setControlsVisibility(e={}){Object.entries(e).forEach(([t,i])=>this.setControlVisible(t,i))}clearContextTop(e){if(!this.canvas)return;let t=this.canvas.contextTop;if(!t)return;let i=this.canvas.viewportTransform;t.save(),t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(t);let n=this.width+4,r=this.height+4;return t.clearRect(-n/2,-r/2,n,r),e||t.restore(),t}onDeselect(e){return!1}onSelect(e){return!1}shouldStartDragging(e){return!1}onDragStart(e){return!1}canDrop(e){return!1}renderDragSourceEffect(e){}renderDropTargetEffect(e){}};function bD(s,e){return e.forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(i=>{i!=="constructor"&&Object.defineProperty(s.prototype,i,Object.getOwnPropertyDescriptor(t.prototype,i)||Object.create(null))})}),s}ue(AD,"ownDefaults",{noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:"rgb(178,204,255)",cornerStrokeColor:"",cornerStyle:"rect",cornerDashArray:null,hasControls:!0,borderColor:"rgb(178,204,255)",borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:"",selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:"down",hoverCursor:null,moveCursor:null});var Dn=class extends AD{};bD(Dn,[HP]),ot.setClass(Dn),ot.setClass(Dn,"object");const yD=(s,e,t,i)=>{let n=2*(i=Math.round(i))+1,{data:r}=s.getImageData(e-i,t-i,n,n);for(let a=3;a<r.length;a+=4)if(r[a]>0)return!1;return!0};var xD=class{constructor(s){this.options=s,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new De(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new De(1/this.options.scaleX,1/this.options.scaleY):new De(1,1)}createSideVector(s,e){let t=Hp(s,e);return this.options.strokeUniform?t.multiply(this.scale):t}projectOrthogonally(s,e,t){return this.applySkew(s.add(this.calcOrthogonalProjection(s,e,t)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(s){let e=new De(s);return e.y+=e.x*Math.tan(Bi(this.options.skewY)),e.x+=e.y*Math.tan(Bi(this.options.skewX)),e}scaleUnitVector(s,e){return s.multiply(this.strokeUniformScalar).scalarMultiply(e)}};const HY=new De;var _D=class uA extends xD{static getOrthogonalRotationFactor(e,t){let i=t?Pv(e,t):x_(e);return Math.abs(i)<No?-1:1}constructor(e,t,i,n){super(n),ue(this,"AB",void 0),ue(this,"AC",void 0),ue(this,"alpha",void 0),ue(this,"bisector",void 0),this.A=new De(e),this.B=new De(t),this.C=new De(i),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=Pv(this.AB,this.AC),this.bisector=Dv(y_(this.AB.eq(HY)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(e,t,i=this.strokeProjectionMagnitude){let n=__(this.createSideVector(e,t)),r=uA.getOrthogonalRotationFactor(n,this.bisector);return this.scaleUnitVector(n,i*r)}projectBevel(){let e=[];return(this.alpha%pr===0?[this.B]:[this.B,this.C]).forEach(t=>{e.push(this.projectOrthogonally(this.A,t)),e.push(this.projectOrthogonally(this.A,t,-this.strokeProjectionMagnitude))}),e}projectMiter(){let e=[],t=Math.abs(this.alpha),i=1/Math.sin(t/2),n=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*i),r=this.options.strokeUniform?Iv(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return Iv(n)/this.strokeProjectionMagnitude<=r&&e.push(this.applySkew(this.A.add(n))),e.push(...this.projectBevel()),e}projectRoundNoSkew(e,t){let i=[],n=new De(uA.getOrthogonalRotationFactor(this.bisector),uA.getOrthogonalRotationFactor(new De(this.bisector.y,this.bisector.x)));return[new De(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(n),new De(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(n)].forEach(r=>{w_(r,e,t)&&i.push(this.A.add(r))}),i}projectRoundWithSkew(e,t){let i=[],{skewX:n,skewY:r,scaleX:a,scaleY:o,strokeUniform:l}=this.options,c=new De(Math.tan(Bi(n)),Math.tan(Bi(r))),h=this.strokeProjectionMagnitude,d=l?h/o/Math.sqrt(1/o**2+1/a**2*c.y**2):h/Math.sqrt(1+c.y**2),u=new De(Math.sqrt(Math.max(h**2-d**2,0)),d),p=l?h/Math.sqrt(1+c.x**2*(1/o)**2/(1/a+1/a*c.x*c.y)**2):h/Math.sqrt(1+c.x**2/(1+c.x*c.y)**2),m=new De(p,Math.sqrt(Math.max(h**2-p**2,0)));return[m,m.scalarMultiply(-1),u,u.scalarMultiply(-1)].map(v=>this.applySkew(l?v.multiply(this.strokeUniformScalar):v)).forEach(v=>{w_(v,e,t)&&i.push(this.applySkew(this.A).add(v))}),i}projectRound(){let e=[];e.push(...this.projectBevel());let t=this.alpha%pr===0,i=this.applySkew(this.A),n=e[t?0:2].subtract(i),r=e[t?1:0].subtract(i),a=Ad(n,t?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)))>0,o=a?n:r,l=a?r:n;return this.isSkewed()?e.push(...this.projectRoundWithSkew(o,l)):e.push(...this.projectRoundNoSkew(o,l)),e}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map(e=>({originPoint:this.A,projectedPoint:e,angle:this.alpha,bisector:this.bisector}))}},wD=class extends xD{constructor(s,e,t){super(t),this.A=new De(s),this.T=new De(e)}calcOrthogonalProjection(s,e,t=this.strokeProjectionMagnitude){let i=this.createSideVector(s,e);return this.scaleUnitVector(__(i),t)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){let s=[];if(!this.isSkewed()&&this.A.eq(this.T)){let e=new De(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);s.push(this.applySkew(this.A.add(e)),this.applySkew(this.A.subtract(e)))}else s.push(...new _D(this.A,this.T,this.T,this.options).projectRound());return s}projectSquare(){let s=[];if(this.A.eq(this.T)){let e=new De(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);s.push(this.A.add(e),this.A.subtract(e))}else{let e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),t=this.scaleUnitVector(Dv(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),i=this.A.add(t);s.push(i.add(e),i.subtract(e))}return s.map(e=>this.applySkew(e))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map(s=>({originPoint:this.A,projectedPoint:s}))}};const ED=(s,e,t=!1)=>{let i=[];if(s.length===0)return i;let n=s.reduce((r,a)=>(r[r.length-1].eq(a)||r.push(new De(a)),r),[new De(s[0])]);if(n.length===1)t=!0;else if(!t){let r=n[0],a=((o,l)=>{for(let c=o.length-1;c>=0;c--)if(l(o[c],c,o))return c;return-1})(n,o=>!o.eq(r));n.splice(a+1)}return n.forEach((r,a,o)=>{let l,c;a===0?(c=o[1],l=t?r:o[o.length-1]):a===o.length-1?(l=o[a-1],c=t?r:o[0]):(l=o[a-1],c=o[a+1]),t&&o.length===1?i.push(...new wD(r,r,e).project()):!t||a!==0&&a!==o.length-1?i.push(...new _D(r,l,c,e).project()):i.push(...new wD(r,a===0?c:l,e).project())}),i},z_=s=>{let e={};return Object.keys(s).forEach(t=>{e[t]={},Object.keys(s[t]).forEach(i=>{e[t][i]={...s[t][i]}})}),e},Nv=(s,e,t=!1)=>s.fill!==e.fill||s.stroke!==e.stroke||s.strokeWidth!==e.strokeWidth||s.fontSize!==e.fontSize||s.fontFamily!==e.fontFamily||s.fontWeight!==e.fontWeight||s.fontStyle!==e.fontStyle||s.textDecorationThickness!==e.textDecorationThickness||s.textDecorationColor!==e.textDecorationColor||s.textBackgroundColor!==e.textBackgroundColor||s.deltaY!==e.deltaY||t&&(s.overline!==e.overline||s.underline!==e.underline||s.linethrough!==e.linethrough),MD=(s,e)=>{let t=e.split(`
|
||
`),i=[],n=-1,r={};s=z_(s);for(let a=0;a<t.length;a++){let o=Sv(t[a]);if(s[a])for(let l=0;l<o.length;l++){n++;let c=s[a][l];c&&Object.keys(c).length>0&&(Nv(r,c,!0)?i.push({start:n,end:n+1,style:c}):i[i.length-1].end++),r=c||{}}else n+=o.length,r={}}return i},SD=(s,e)=>{if(!Array.isArray(s))return z_(s);let t=e.split(c_),i={},n=-1,r=0;for(let a=0;a<t.length;a++){let o=Sv(t[a]);for(let l=0;l<o.length;l++)n++,s[r]&&s[r].start<=n&&n<s[r].end&&(i[a]=i[a]||{},i[a][l]={...s[r].style},n===s[r].end-1&&r++)}return i},Vo=["display","transform",as,"fill-opacity","fill-rule","opacity",La,"stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"];function CD(s,e){let t=s.nodeName,i=s.getAttribute("class"),n=s.getAttribute("id"),r="(?![a-zA-Z\\-]+)",a;if(a=RegExp("^"+t,"i"),e=e.replace(a,""),n&&e.length&&(a=RegExp("#"+n+r,"i"),e=e.replace(a,"")),i&&e.length){let o=i.split(" ");for(let l=o.length;l--;)a=RegExp("\\."+o[l]+r,"i"),e=e.replace(a,"")}return e.length===0}function GY(s,e){let t=!0,i=CD(s,e.pop());return i&&e.length&&(t=(function(n,r){let a,o=!0;for(;n.parentElement&&n.parentElement.nodeType===1&&r.length;)o&&(a=r.pop()),o=CD(n=n.parentElement,a);return r.length===0})(s,e)),i&&t&&e.length===0}function VY(s,e={}){let t={};for(let i in e)GY(s,i.split(" "))&&(t={...t,...e[i]});return t}const WY=s=>{var e;return(e=eY[s])==null?s:e},QY=RegExp(`(${fc})`,"gi"),jn=`(${fc})`,jY=String.raw`(skewX)\(${jn}\)`,XY=String.raw`(skewY)\(${jn}\)`,qY=String.raw`(rotate)\(${jn}(?: ${jn} ${jn})?\)`,YY=String.raw`(scale)\(${jn}(?: ${jn})?\)`,KY=String.raw`(translate)\(${jn}(?: ${jn})?\)`,H_=`(?:${String.raw`(matrix)\(${jn} ${jn} ${jn} ${jn} ${jn} ${jn}\)`}|${KY}|${qY}|${YY}|${jY}|${XY})`,$Y=`(?:${H_}*)`,ZY=String.raw`^\s*(?:${$Y}?)\s*$`,JY=new RegExp(ZY),eK=new RegExp(H_),tK=new RegExp(H_,"g");function G_(s){let e=[];if(!(s=(t=>Bv(t.replace(QY," $1 ").replace(/,/gi," ")))(s).replace(/\s*([()])\s*/gi,"$1"))||s&&!JY.test(s))return[...Wn];for(let t of s.matchAll(tK)){let i=eK.exec(t[0]);if(!i)continue;let n=Wn,[,r,...a]=i.filter(p=>!!p),[o,l,c,h,d,u]=a.map(p=>parseFloat(p));switch(r){case"translate":n=fd(o,l);break;case rP:n=hc({angle:o},{x:l,y:c});break;case lP:n=Mv(o,l);break;case hd:n=p_(o);break;case dd:n=f_(o);break;case"matrix":n=[o,l,c,h,d,u]}e.push(n)}return Ev(e)}function iK(s,e,t,i){let n=Array.isArray(e),r,a=e;if(s!=="fill"&&s!=="stroke"||e!=="none"){if(s==="strokeUniform")return e==="non-scaling-stroke";if(s==="strokeDashArray")a=e==="none"?null:e.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(s==="transformMatrix")a=t&&t.transformMatrix?Li(t.transformMatrix,G_(e)):G_(e);else if(s==="visible")a=e!=="none"&&e!=="hidden",t&&t.visible===!1&&(a=!1);else if(s==="opacity")a=parseFloat(e),t&&t.opacity!==void 0&&(a*=t.opacity);else if(s==="textAnchor")a=e==="start"?mn:e==="end"?fr:ui;else if(s==="charSpacing"||s==="textDecorationThickness")r=pc(e,i)/i*1e3;else if(s==="paintFirst"){let o=e.indexOf(as),l=e.indexOf(La);a=as,(o>-1&&l>-1&&l<o||o===-1&&l>-1)&&(a=La)}else{if(s==="href"||s==="xlink:href"||s==="font"||s==="id")return e;if(s==="imageSmoothing")return e==="optimizeQuality";r=n?e.map(pc):pc(e,i)}}else a="";return!n&&isNaN(r)?a:r}function nK(s,e){s.replace(/;\s*$/,"").split(";").forEach(t=>{if(!t)return;let[i,n]=t.split(":");e[i.trim().toLowerCase()]=n.trim()})}function sK(s){let e={},t=s.getAttribute("style");return t&&(typeof t=="string"?nK(t,e):(function(i,n){Object.entries(i).forEach(([r,a])=>{a!==void 0&&(n[r.toLowerCase()]=a)})})(t,e)),e}const rK={stroke:"strokeOpacity",fill:"fillOpacity"};function za(s,e,t){if(!s)return{};let i,n={},r=16;s.parentNode&&qP.test(s.parentNode.nodeName)&&(n=za(s.parentElement,e,t),n.fontSize&&(i=r=pc(n.fontSize)));let a={...e.reduce((c,h)=>{let d=s.getAttribute(h);return d&&(c[h]=d),c},{}),...VY(s,t),...sK(s)};a["clip-path"]&&s.setAttribute(XP,a[XP]),a["font-size"]&&(i=pc(a[jP],r),a[jP]=`${i}`);let o={};for(let c in a){let h=WY(c);o[h]=iK(h,a[c],n,i)}o&&o.font&&(function(c,h){let d=c.match(Jq);if(!d)return;let u=d[1],p=d[3],m=d[4],v=d[5],g=d[6];u&&(h.fontStyle=u),p&&(h.fontWeight=isNaN(parseFloat(p))?p:parseFloat(p)),m&&(h.fontSize=pc(m)),g&&(h.fontFamily=g),v&&(h.lineHeight=v==="normal"?1:v)})(o.font,o);let l={...n,...o};return qP.test(s.nodeName)?l:(function(c){let h=Dn.getDefaults();return Object.entries(rK).forEach(([d,u])=>{if(c[u]===void 0||c[d]==="")return;if(c[d]===void 0){if(!h[d])return;c[d]=h[d]}if(c[d].indexOf("url(")===0)return;let p=new br(c[d]);c[d]=p.setAlpha(pi(p.getAlpha()*c[u],2)).toRgba()}),c})(l)}const TD=["rx","ry"];var Wo=class pw extends Dn{static getDefaults(){return{...super.getDefaults(),...pw.ownDefaults}}constructor(e){super(),Object.assign(this,pw.ownDefaults),this.setOptions(e),this._initRxRy()}_initRxRy(){let{rx:e,ry:t}=this;e&&!t?this.ry=e:t&&!e&&(this.rx=t)}_render(e){let{width:t,height:i}=this,n=-t/2,r=-i/2,a=this.rx?Math.min(this.rx,t/2):0,o=this.ry?Math.min(this.ry,i/2):0,l=a!==0||o!==0;e.beginPath(),e.moveTo(n+a,r),e.lineTo(n+t-a,r),l&&e.bezierCurveTo(n+t-.4477152502*a,r,n+t,r+.4477152502*o,n+t,r+o),e.lineTo(n+t,r+i-o),l&&e.bezierCurveTo(n+t,r+i-.4477152502*o,n+t-.4477152502*a,r+i,n+t-a,r+i),e.lineTo(n+a,r+i),l&&e.bezierCurveTo(n+.4477152502*a,r+i,n,r+i-.4477152502*o,n,r+i-o),e.lineTo(n,r+o),l&&e.bezierCurveTo(n,r+.4477152502*o,n+.4477152502*a,r,n+a,r),e.closePath(),this._renderPaintInOrder(e)}toObject(e=[]){return super.toObject([...TD,...e])}_toSVG(){let{width:e,height:t,rx:i,ry:n}=this;return["<rect ","COMMON_PARTS",`x="${-e/2}" y="${-t/2}" rx="${Ot(i)}" ry="${Ot(n)}" width="${Ot(e)}" height="${Ot(t)}" />
|
||
`]}static async fromElement(e,t,i){let{left:n=0,top:r=0,width:a=0,height:o=0,visible:l=!0,...c}=za(e,this.ATTRIBUTE_NAMES,i);return new this({...t,...c,left:n,top:r,width:a,height:o,visible:!!(l&&a&&o)})}};ue(Wo,"type","Rect"),ue(Wo,"cacheProperties",[...Fa,...TD]),ue(Wo,"ownDefaults",{rx:0,ry:0}),ue(Wo,"ATTRIBUTE_NAMES",[...Vo,"x","y","rx","ry","width","height"]),ot.setClass(Wo),ot.setSVGClass(Wo);const ID="initialization",V_="added",PD=(s,e)=>{let{strokeUniform:t,strokeWidth:i,width:n,height:r,group:a}=e,o=a&&a!==s?zp(a.calcTransformMatrix(),s.calcTransformMatrix()):null,l=o?e.getRelativeCenterPoint().transform(o):e.getRelativeCenterPoint(),c=!e.isStrokeAccountedForInDimensions(),h=t&&c?PP(new De(i,i),void 0,s.calcTransformMatrix()):h_,d=!t&&c?i:0,u=Tv(n+d,r+d,Ev([o,e.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(u),l.add(u)]};var Uv=class{calcLayoutResult(s,e){if(this.shouldPerformLayout(s))return this.calcBoundingBox(e,s)}shouldPerformLayout({type:s,prevStrategy:e,strategy:t}){return s==="initialization"||s==="imperative"||!!e&&t!==e}shouldLayoutClipPath({type:s,target:{clipPath:e}}){return s!=="initialization"&&e&&!e.absolutePositioned}getInitialSize(s,e){return e.size}calcBoundingBox(s,e){let{type:t,target:i}=e;if(t==="imperative"&&e.overrides)return e.overrides;if(s.length===0)return;let{left:n,top:r,width:a,height:o}=jr(s.map(h=>PD(i,h)).reduce((h,d)=>h.concat(d),[])),l=new De(a,o),c=new De(n,r).add(l.scalarDivide(2));if(t==="initialization"){let h=this.getInitialSize(e,{size:l,center:c});return{center:c,relativeCorrection:new De(0,0),size:h}}return{center:c.transform(i.calcOwnMatrix()),size:l}}};ue(Uv,"type","strategy");var W_=class extends Uv{shouldPerformLayout(s){return!0}};ue(W_,"type","fit-content"),ot.setClass(W_);const DD="layoutManager";var Xp=class{constructor(s=new W_){ue(this,"strategy",void 0),this.strategy=s,this._subscriptions=new Map}performLayout(s){let e={bubbles:!0,strategy:this.strategy,...s,prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}};this.onBeforeLayout(e);let t=this.getLayoutResult(e);t&&this.commitLayout(e,t),this.onAfterLayout(e,t),this._prevLayoutStrategy=e.strategy}attachHandlers(s,e){let{target:t}=e;return[cP,nP,Lp,sP,yv,aP,xv,oP,"modifyPath"].map(i=>s.on(i,n=>this.performLayout(i==="modified"?{type:"object_modified",trigger:i,e:n,target:t}:{type:"object_modifying",trigger:i,e:n,target:t})))}subscribe(s,e){this.unsubscribe(s,e);let t=this.attachHandlers(s,e);this._subscriptions.set(s,t)}unsubscribe(s,e){(this._subscriptions.get(s)||[]).forEach(t=>t()),this._subscriptions.delete(s)}unsubscribeTargets(s){s.targets.forEach(e=>this.unsubscribe(e,s))}subscribeTargets(s){s.targets.forEach(e=>this.subscribe(e,s))}onBeforeLayout(s){let{target:e,type:t}=s,{canvas:i}=e;if(t==="initialization"||t==="added"?this.subscribeTargets(s):t==="removed"&&this.unsubscribeTargets(s),e.fire("layout:before",{context:s}),i&&i.fire("object:layout:before",{target:e,context:s}),t==="imperative"&&s.deep){let{strategy:n,...r}=s;e.forEachObject(a=>a.layoutManager&&a.layoutManager.performLayout({...r,bubbles:!1,target:a}))}}getLayoutResult(s){let{target:e,strategy:t,type:i}=s,n=t.calcLayoutResult(s,e.getObjects());if(!n)return;let r=i==="initialization"?new De:e.getRelativeCenterPoint(),{center:a,correction:o=new De,relativeCorrection:l=new De}=n;return{result:n,prevCenter:r,nextCenter:a,offset:r.subtract(a).add(o).transform(i==="initialization"?Wn:ws(e.calcOwnMatrix()),!0).add(l)}}commitLayout(s,e){let{target:t}=s,{result:{size:i},nextCenter:n}=e;var r,a;t.set({width:i.x,height:i.y}),this.layoutObjects(s,e),s.type==="initialization"?t.set({left:(r=s.x)==null?n.x+i.x*Qn(t.originX):r,top:(a=s.y)==null?n.y+i.y*Qn(t.originY):a}):(t.setPositionByOrigin(n,ui,ui),t.setCoords(),t.set("dirty",!0))}layoutObjects(s,e){let{target:t}=s;t.forEachObject(i=>{i.group===t&&this.layoutObject(s,e,i)}),s.strategy.shouldLayoutClipPath(s)&&this.layoutObject(s,e,t.clipPath)}layoutObject(s,{offset:e},t){t.set({left:t.left+e.x,top:t.top+e.y})}onAfterLayout(s,e){let{target:t,strategy:i,bubbles:n,prevStrategy:r,...a}=s,{canvas:o}=t;t.fire("layout:after",{context:s,result:e}),o&&o.fire("object:layout:after",{context:s,result:e,target:t});let l=t.parent;n&&l!=null&&l.layoutManager&&((a.path||(a.path=[])).push(t),l.layoutManager.performLayout({...a,target:l})),t.set("dirty",!0)}dispose(){let{_subscriptions:s}=this;s.forEach(e=>e.forEach(t=>t())),s.clear()}toObject(){return{type:DD,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}};ot.setClass(Xp,DD);var aK=class extends Xp{performLayout(){}},Qo=class fw extends dP(Dn){static getDefaults(){return{...super.getDefaults(),...fw.ownDefaults}}constructor(e=[],t={}){super(),ue(this,"_activeObjects",[]),ue(this,"__objectSelectionTracker",void 0),ue(this,"__objectSelectionDisposer",void 0),Object.assign(this,fw.ownDefaults),this.setOptions(t),this.groupInit(e,t)}groupInit(e,t){var i;this._objects=[...e],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject(n=>{this.enterGroup(n,!1)}),this.layoutManager=(i=t.layoutManager)==null?new Xp:i,this.layoutManager.performLayout({type:ID,target:this,targets:[...e],x:t.left,y:t.top})}canEnterGroup(e){return e===this||this.isDescendantOf(e)?(Fo("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(e)===-1||(Fo("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(e){return e.filter((t,i,n)=>this.canEnterGroup(t)&&n.indexOf(t)===i)}add(...e){let t=this._filterObjectsBeforeEnteringGroup(e),i=super.add(...t);return this._onAfterObjectsChange(V_,t),i}insertAt(e,...t){let i=this._filterObjectsBeforeEnteringGroup(t),n=super.insertAt(e,...i);return this._onAfterObjectsChange(V_,i),n}remove(...e){let t=super.remove(...e);return this._onAfterObjectsChange("removed",t),t}_onObjectAdded(e){this.enterGroup(e,!0),this.fire("object:added",{target:e}),e.fire("added",{target:this})}_onObjectRemoved(e,t){this.exitGroup(e,t),this.fire("object:removed",{target:e}),e.fire("removed",{target:this})}_onAfterObjectsChange(e,t){this.layoutManager.performLayout({type:e,targets:t,target:this})}_onStackOrderChanged(){this._set("dirty",!0)}_set(e,t){let i=this[e];return super._set(e,t),e==="canvas"&&i!==t&&(this._objects||[]).forEach(n=>{n._set(e,t)}),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(e,{target:t}){let i=this._activeObjects;if(e)i.push(t),this._set("dirty",!0);else if(i.length>0){let n=i.indexOf(t);n>-1&&(i.splice(n,1),this._set("dirty",!0))}}_watchObject(e,t){e&&this._watchObject(!1,t),e?(t.on("selected",this.__objectSelectionTracker),t.on("deselected",this.__objectSelectionDisposer)):(t.off("selected",this.__objectSelectionTracker),t.off("deselected",this.__objectSelectionDisposer))}enterGroup(e,t){e.group&&e.group.remove(e),e._set("parent",this),this._enterGroup(e,t)}_enterGroup(e,t){t&&vd(e,Li(ws(this.calcTransformMatrix()),e.calcTransformMatrix())),this._shouldSetNestedCoords()&&e.setCoords(),e._set("group",this),e._set("canvas",this.canvas),this._watchObject(!0,e);let i=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();i&&(i===e||e.isDescendantOf(i))&&this._activeObjects.push(e)}exitGroup(e,t){this._exitGroup(e,t),e._set("parent",void 0),e._set("canvas",void 0)}_exitGroup(e,t){e._set("group",void 0),t||(vd(e,Li(this.calcTransformMatrix(),e.calcTransformMatrix())),e.setCoords()),this._watchObject(!1,e);let i=this._activeObjects.length>0?this._activeObjects.indexOf(e):-1;i>-1&&this._activeObjects.splice(i,1)}shouldCache(){let e=Dn.prototype.shouldCache.call(this);if(e){for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return this.ownCaching=!1,!1}return e}willDrawShadow(){if(super.willDrawShadow())return!0;for(let e=0;e<this._objects.length;e++)if(this._objects[e].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(e,t,i){this._renderBackground(e);for(let r=0;r<this._objects.length;r++){var n;let a=this._objects[r];(n=this.canvas)!=null&&n.preserveObjectStacking&&a.group!==this?(e.save(),e.transform(...ws(this.calcTransformMatrix())),a.render(e),e.restore()):a.group===this&&a.render(e)}this._drawClipPath(e,this.clipPath,i)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject(e=>e.setCoords())}triggerLayout(e={}){this.layoutManager.performLayout({target:this,type:"imperative",...e})}render(e){this._transformDone=!0,super.render(e),this._transformDone=!1}__serializeObjects(e,t){let i=this.includeDefaultValues;return this._objects.filter(function(n){return!n.excludeFromExport}).map(function(n){let r=n.includeDefaultValues;n.includeDefaultValues=i;let a=n[e||"toObject"](t);return n.includeDefaultValues=r,a})}toObject(e=[]){let t=this.layoutManager.toObject();return{...super.toObject(["subTargetCheck","interactive",...e]),...t.strategy!=="fit-content"||this.includeDefaultValues?{layoutManager:t}:{},objects:this.__serializeObjects("toObject",e)}}toString(){return`#<Group: (${this.complexity()})>`}dispose(){this.layoutManager.unsubscribeTargets({targets:this.getObjects(),target:this}),this._activeObjects=[],this.forEachObject(e=>{this._watchObject(!1,e),e.dispose()}),super.dispose()}_createSVGBgRect(e){if(!this.backgroundColor)return"";let t=Wo.prototype._toSVG.call(this),i=t.indexOf("COMMON_PARTS");t[i]='for="group" ';let n=t.join("");return e?e(n):n}_toSVG(e){let t=["<g ","COMMON_PARTS",` >
|
||
`],i=this._createSVGBgRect(e);i&&t.push(" ",i);for(let n=0;n<this._objects.length;n++)t.push(" ",this._objects[n].toSVG(e));return t.push(`</g>
|
||
`),t}getSvgStyles(){let e=this.opacity!==void 0&&this.opacity!==1?`opacity: ${Ot(this.opacity)};`:"",t=this.visible?"":" visibility: hidden;";return[e,this.getSvgFilter(),t].join("")}toClipPathSVG(e){let t=[],i=this._createSVGBgRect(e);i&&t.push(" ",i);for(let n=0;n<this._objects.length;n++)t.push(" ",this._objects[n].toClipPathSVG(e));return this._createBaseClipPathSVGMarkup(t,{reviver:e})}static fromObject({type:e,objects:t=[],layoutManager:i,...n},r){return Promise.all([md(t,r),Np(n,r)]).then(([a,o])=>{let l=new this(a,{...n,...o,layoutManager:new aK});return l.layoutManager=i?new(ot.getClass(i.type))(new(ot.getClass(i.strategy))):new Xp,l.layoutManager.subscribeTargets({type:ID,target:l,targets:l.getObjects()}),l.setCoords(),l})}};ue(Qo,"type","Group"),ue(Qo,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),ot.setClass(Qo);const oK=(s,e)=>s&&s.length===1?s[0]:new Qo(s,e),RD=(s,e)=>Math.min(e.width/s.width,e.height/s.height),BD=(s,e)=>Math.max(e.width/s.width,e.height/s.height),Q_="\\s*,?\\s*",qp=`${Q_}(${fc})`,lK=`${qp}${qp}${qp}${Q_}([01])${Q_}([01])${qp}${qp}`,cK={m:"l",M:"L"},hK=(s,e,t,i,n,r,a,o,l,c,h)=>{let d=mr(s),u=gr(s),p=mr(e),m=gr(e),v=t*n*p-i*r*m+a,g=i*n*p+t*r*m+o;return["C",c+l*(-t*n*u-i*r*d),h+l*(-i*n*u+t*r*d),v+l*(t*n*m+i*r*p),g+l*(i*n*m-t*r*p),v,g]},LD=(s,e,t,i)=>{let n=Math.atan2(e,s),r=Math.atan2(i,t);return r>=n?r-n:2*Math.PI-(n-r)};function j_(s,e,t,i,n,r,a,o){let l;if(ei.cachesBoundsOfCurve&&(l=[...arguments].join(),Bp.boundsOfCurveCache[l]))return Bp.boundsOfCurveCache[l];let c=Math.sqrt,h=Math.abs,d=[],u=[[0,0],[0,0]],p=6*s-12*t+6*n,m=-3*s+9*t-9*n+3*a,v=3*t-3*s;for(let y=0;y<2;++y){if(y>0&&(p=6*e-12*i+6*r,m=-3*e+9*i-9*r+3*o,v=3*i-3*e),h(m)<1e-12){if(h(p)<1e-12)continue;let w=-v/p;0<w&&w<1&&d.push(w);continue}let x=p*p-4*v*m;if(x<0)continue;let _=c(x),M=(-p+_)/(2*m);0<M&&M<1&&d.push(M);let E=(-p-_)/(2*m);0<E&&E<1&&d.push(E)}let g=d.length,f=g,A=OD(s,e,t,i,n,r,a,o);for(;g--;){let{x:y,y:x}=A(d[g]);u[0][g]=y,u[1][g]=x}u[0][f]=s,u[1][f]=e,u[0][f+1]=a,u[1][f+1]=o;let b=[new De(Math.min(...u[0]),Math.min(...u[1])),new De(Math.max(...u[0]),Math.max(...u[1]))];return ei.cachesBoundsOfCurve&&(Bp.boundsOfCurveCache[l]=b),b}const dK=(s,e,[t,i,n,r,a,o,l,c])=>{let h=((d,u,p,m,v,g,f)=>{if(p===0||m===0)return[];let A=0,b=0,y=0,x=Math.PI,_=f*l_,M=gr(_),E=mr(_),w=.5*(-E*d-M*u),T=.5*(-E*u+M*d),R=p**2,D=m**2,L=T**2,I=w**2,O=R*D-R*L-D*I,N=Math.abs(p),G=Math.abs(m);if(O<0){let Te=Math.sqrt(1-O/(R*D));N*=Te,G*=Te}else y=(v===g?-1:1)*Math.sqrt(O/(R*L+D*I));let V=y*N*T/G,H=-y*G*w/N,J=E*V-M*H+.5*d,W=M*V+E*H+.5*u,X=LD(1,0,(w-V)/N,(T-H)/G),me=LD((w-V)/N,(T-H)/G,(-w-V)/N,(-T-H)/G);g===0&&me>0?me-=2*x:g===1&&me<0&&(me+=2*x);let Ee=Math.ceil(Math.abs(me/x*2)),Me=[],$=me/Ee,se=8/3*Math.sin($/4)*Math.sin($/4)/Math.sin($/2),he=X+$;for(let Te=0;Te<Ee;Te++)Me[Te]=hK(X,he,E,M,N,G,J,W,se,A,b),A=Me[Te][5],b=Me[Te][6],X=he,he+=$;return Me})(l-s,c-e,i,n,a,o,r);for(let d=0,u=h.length;d<u;d++)h[d][1]+=s,h[d][2]+=e,h[d][3]+=s,h[d][4]+=e,h[d][5]+=s,h[d][6]+=e;return h},kD=s=>{let e=0,t=0,i=0,n=0,r=[],a,o=0,l=0;for(let c of s){let h=[...c],d;switch(h[0]){case"l":h[1]+=e,h[2]+=t;case"L":e=h[1],t=h[2],d=["L",e,t];break;case"h":h[1]+=e;case"H":e=h[1],d=["L",e,t];break;case"v":h[1]+=t;case"V":t=h[1],d=["L",e,t];break;case"m":h[1]+=e,h[2]+=t;case"M":e=h[1],t=h[2],i=h[1],n=h[2],d=["M",e,t];break;case"c":h[1]+=e,h[2]+=t,h[3]+=e,h[4]+=t,h[5]+=e,h[6]+=t;case"C":o=h[3],l=h[4],e=h[5],t=h[6],d=["C",h[1],h[2],o,l,e,t];break;case"s":h[1]+=e,h[2]+=t,h[3]+=e,h[4]+=t;case"S":a==="C"?(o=2*e-o,l=2*t-l):(o=e,l=t),e=h[3],t=h[4],d=["C",o,l,h[1],h[2],e,t],o=d[3],l=d[4];break;case"q":h[1]+=e,h[2]+=t,h[3]+=e,h[4]+=t;case"Q":o=h[1],l=h[2],e=h[3],t=h[4],d=["Q",o,l,e,t];break;case"t":h[1]+=e,h[2]+=t;case"T":a==="Q"?(o=2*e-o,l=2*t-l):(o=e,l=t),e=h[1],t=h[2],d=["Q",o,l,e,t];break;case"a":h[6]+=e,h[7]+=t;case"A":dK(e,t,h).forEach(u=>r.push(u)),e=h[6],t=h[7];break;case"z":case"Z":e=i,t=n,d=["Z"]}d?(r.push(d),a=d[0]):a=""}return r},zv=(s,e,t,i)=>Math.sqrt((t-s)**2+(i-e)**2),OD=(s,e,t,i,n,r,a,o)=>l=>{let c=l**3,h=(p=>3*p**2*(1-p))(l),d=(p=>3*p*(1-p)**2)(l),u=(p=>(1-p)**3)(l);return new De(a*c+n*h+t*d+s*u,o*c+r*h+i*d+e*u)},FD=s=>s**2,ND=s=>2*s*(1-s),UD=s=>(1-s)**2,uK=(s,e,t,i,n,r,a,o)=>l=>{let c=FD(l),h=ND(l),d=UD(l),u=3*(d*(t-s)+h*(n-t)+c*(a-n)),p=3*(d*(i-e)+h*(r-i)+c*(o-r));return Math.atan2(p,u)},pK=(s,e,t,i,n,r)=>a=>{let o=FD(a),l=ND(a),c=UD(a);return new De(n*o+t*l+s*c,r*o+i*l+e*c)},fK=(s,e,t,i,n,r)=>a=>{let o=1-a,l=2*(o*(t-s)+a*(n-t)),c=2*(o*(i-e)+a*(r-i));return Math.atan2(c,l)},zD=(s,e,t)=>{let i=new De(e,t),n=0;for(let r=1;r<=100;r+=1){let a=s(r/100);n+=zv(i.x,i.y,a.x,a.y),i=a}return n},mK=(s,e)=>{let t,i=0,n=0,r={x:s.x,y:s.y},a={...r},o=.01,l=0,c=s.iterator,h=s.angleFinder;for(;n<e&&o>1e-4;)a=c(i),l=i,t=zv(r.x,r.y,a.x,a.y),t+n>e?(i-=o,o/=2):(r=a,i+=o,n+=t);return{...a,angle:h(l)}},X_=s=>{let e,t,i=0,n=0,r=0,a=0,o=0,l=[];for(let c of s){let h={x:n,y:r,command:c[0],length:0};switch(c[0]){case"M":t=h,t.x=a=n=c[1],t.y=o=r=c[2];break;case"L":t=h,t.length=zv(n,r,c[1],c[2]),n=c[1],r=c[2];break;case"C":e=OD(n,r,c[1],c[2],c[3],c[4],c[5],c[6]),t=h,t.iterator=e,t.angleFinder=uK(n,r,c[1],c[2],c[3],c[4],c[5],c[6]),t.length=zD(e,n,r),n=c[5],r=c[6];break;case"Q":e=pK(n,r,c[1],c[2],c[3],c[4]),t=h,t.iterator=e,t.angleFinder=fK(n,r,c[1],c[2],c[3],c[4]),t.length=zD(e,n,r),n=c[3],r=c[4];break;case"Z":t=h,t.destX=a,t.destY=o,t.length=zv(n,r,a,o),n=a,r=o}i+=t.length,l.push(t)}return l.push({length:i,x:n,y:r}),l},HD=(s,e,t=X_(s))=>{let i=0;for(;e-t[i].length>0&&i<t.length-2;)e-=t[i].length,i++;let n=t[i],r=e/n.length,a=s[i];switch(n.command){case"M":return{x:n.x,y:n.y,angle:0};case"Z":return{...new De(n.x,n.y).lerp(new De(n.destX,n.destY),r),angle:Math.atan2(n.destY-n.y,n.destX-n.x)};case"L":return{...new De(n.x,n.y).lerp(new De(a[1],a[2]),r),angle:Math.atan2(a[2]-n.y,a[1]-n.x)};case"C":case"Q":return mK(n,e)}},gK=RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),GD=new RegExp(lK,"g"),vK=new RegExp(fc,"gi"),AK={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},VD=s=>{var e;let t=[],i=(e=s.match(gK))==null?[]:e;for(let n of i){let r=n[0];if(r==="z"||r==="Z"){t.push([r]);continue}let a=AK[r.toLowerCase()],o=[];if(r==="a"||r==="A"){GD.lastIndex=0;for(let l=null;l=GD.exec(n);)o.push(...l.slice(1))}else o=n.match(vK)||[];for(let l=0;l<o.length;l+=a){let c=Array(a),h=cK[r];c[0]=l>0&&h?h:r;for(let d=0;d<a;d++)c[d+1]=parseFloat(o[l+d]);t.push(c)}}return t},bK=(s,e=0)=>{let t=new De(s[0]),i=new De(s[1]),n=1,r=0,a=[],o=s.length,l=o>2,c;for(l&&(n=s[2].x<i.x?-1:s[2].x===i.x?0:1,r=s[2].y<i.y?-1:s[2].y===i.y?0:1),a.push(["M",t.x-n*e,t.y-r*e]),c=1;c<o;c++){if(!t.eq(i)){let h=t.midPointFrom(i);a.push(["Q",t.x,t.y,h.x,h.y])}t=s[c],c+1<s.length&&(i=s[c+1])}return l&&(n=t.x>s[c-2].x?1:t.x===s[c-2].x?0:-1,r=t.y>s[c-2].y?1:t.y===s[c-2].y?0:-1),a.push(["L",t.x+n*e,t.y+r*e]),a},yK=(s,e,t)=>(t&&(e=Li(e,[1,0,0,1,-t.x,-t.y])),s.map(i=>{let n=[...i];for(let r=1;r<i.length-1;r+=2){let{x:a,y:o}=Pn({x:i[r],y:i[r+1]},e);n[r]=a,n[r+1]=o}return n})),xK=(s,e)=>{let t=2*Math.PI/s,i=-No;s%2==0&&(i+=t/2);let n=Array(s+1);for(let r=0;r<s;r++){let a=r*t+i,{x:o,y:l}=new De(mr(a),gr(a)).scalarMultiply(e);n[r]=[r===0?"M":"L",o,l]}return n[s]=["Z"],n},WD=(s,e)=>s.map(t=>t.map((i,n)=>n===0||e===void 0?i:pi(i,e)).join(" ")).join(" "),_K=(s,e)=>{var t;let i=s,n=e;i.inverted&&!n.inverted&&(i=e,n=s),b_(n,(t=n.group)==null?void 0:t.calcTransformMatrix(),i.calcTransformMatrix());let r=i.inverted&&n.inverted;return r&&(i.inverted=n.inverted=!1),new Qo([i],{clipPath:n,inverted:r})},wK=(s,e)=>Math.floor(Math.random()*(e-s+1))+s,EK=(s,e)=>{let t=s._findCenterFromElement();s.transformMatrix&&((i=>{if(i.transformMatrix){let{scaleX:n,scaleY:r,angle:a,skewX:o}=pd(i.transformMatrix);i.flipX=!1,i.flipY=!1,i.set(Uo,n),i.set(zo,r),i.angle=a,i.skewX=o,i.skewY=0}})(s),t=t.transform(s.transformMatrix)),delete s.transformMatrix,e&&(s.scaleX*=e.scaleX,s.scaleY*=e.scaleY,s.cropX=e.cropX,s.cropY=e.cropY,t.x+=e.offsetLeft,t.y+=e.offsetTop,s.width=e.width,s.height=e.height),s.setPositionByOrigin(t,ui,ui)};Dp({addTransformToObject:()=>TP,animate:()=>R_,animateColor:()=>eD,applyTransformToObject:()=>vd,calcAngleBetweenVectors:()=>Pv,calcDimensionsMatrix:()=>Op,calcPlaneChangeMatrix:()=>zp,calcVectorRotation:()=>x_,cancelAnimFrame:()=>pP,capValue:()=>mc,composeMatrix:()=>AP,copyCanvasElement:()=>zq,cos:()=>mr,createCanvasElement:()=>Qr,createImage:()=>fP,createRotateMatrix:()=>hc,createScaleMatrix:()=>Mv,createSkewXMatrix:()=>p_,createSkewYMatrix:()=>f_,createTranslateMatrix:()=>fd,createVector:()=>Hp,crossProduct:()=>Ad,degreesToRadians:()=>Bi,dotProduct:()=>RP,ease:()=>nY,enlivenObjectEnlivables:()=>Np,enlivenObjects:()=>md,findScaleToCover:()=>BD,findScaleToFit:()=>RD,getBoundsOfCurve:()=>j_,getOrthonormalVector:()=>__,getPathSegmentsInfo:()=>X_,getPointOnPath:()=>HD,getPointer:()=>SP,getRandomInt:()=>wK,getRegularPolygonPath:()=>xK,getSmoothPathFromPoints:()=>bK,getSvgAttributes:()=>Kq,getUnitVector:()=>Dv,groupSVGElements:()=>oK,hasStyleChanged:()=>Nv,invertTransform:()=>ws,isBetweenVectors:()=>w_,isIdentityMatrix:()=>mP,isTouchEvent:()=>Cv,isTransparent:()=>yD,joinPath:()=>WD,loadImage:()=>Fp,magnitude:()=>Iv,makeBoundingBoxFromPoints:()=>jr,makePathSimpler:()=>kD,matrixToSVG:()=>gd,mergeClipPaths:()=>_K,multiplyTransformMatrices:()=>Li,multiplyTransformMatrixArray:()=>Ev,parsePath:()=>VD,parsePreserveAspectRatioAttribute:()=>zP,parseUnit:()=>pc,pick:()=>dc,projectStrokeOnPoints:()=>ED,qrDecompose:()=>pd,radiansToDegrees:()=>ka,removeFromArray:()=>cc,removeTransformFromObject:()=>Xq,removeTransformMatrixForSvgParsing:()=>EK,requestAnimFrame:()=>kp,resetObjectTransform:()=>IP,rotateVector:()=>y_,saveObjectTransform:()=>A_,sendObjectToPlane:()=>b_,sendPointToPlane:()=>Oa,sendVectorToPlane:()=>PP,sin:()=>gr,sizeAfterTransform:()=>Tv,string:()=>Gq,stylesFromArray:()=>SD,stylesToArray:()=>MD,toBlob:()=>u_,toDataURL:()=>d_,toFixed:()=>pi,transformPath:()=>yK,transformPoint:()=>Pn});function q_(s,e){let t=s.style;t&&Object.entries(e).forEach(([i,n])=>t.setProperty(i,n))}var MK=class extends MP{constructor(s,{allowTouchScrolling:e=!1,containerClass:t=""}={}){super(s),ue(this,"upper",void 0),ue(this,"container",void 0);let{el:i}=this.lower,n=this.createUpperCanvas();this.upper={el:n,ctx:n.getContext("2d")},this.applyCanvasStyle(i,{allowTouchScrolling:e}),this.applyCanvasStyle(n,{allowTouchScrolling:e,styles:{position:"absolute",left:"0",top:"0"}});let r=this.createContainerElement();r.classList.add(t),i.parentNode&&i.parentNode.replaceChild(r,i),r.append(i,n),this.container=r}createUpperCanvas(){let{el:s}=this.lower,e=Qr();return e.className=s.className,e.classList.remove("lower-canvas"),e.classList.add("upper-canvas"),e.setAttribute("data-fabric","top"),e.style.cssText=s.style.cssText,e.setAttribute("draggable","true"),e}createContainerElement(){let s=ld().createElement("div");return s.setAttribute("data-fabric","wrapper"),q_(s,{position:"relative"}),EP(s),s}applyCanvasStyle(s,e){let{styles:t,allowTouchScrolling:i}=e;q_(s,{...t,"touch-action":i?"manipulation":bv}),EP(s)}setDimensions(s,e){super.setDimensions(s,e);let{el:t,ctx:i}=this.upper;wP(t,i,s,e)}setCSSDimensions(s){super.setCSSDimensions(s),g_(this.upper.el,s),g_(this.container,s)}cleanupDOM(s){let e=this.container,{el:t}=this.lower,{el:i}=this.upper;super.cleanupDOM(s),e.removeChild(i),e.removeChild(t),e.parentNode&&e.parentNode.replaceChild(t,e)}dispose(){super.dispose(),Wr().dispose(this.upper.el),delete this.upper,delete this.container}};const QD=(s,e,t,i)=>{let{target:n,offsetX:r,offsetY:a}=e,o=t-r,l=i-a,c=!Ar(n,"lockMovementX")&&n.left!==o,h=!Ar(n,"lockMovementY")&&n.top!==l;return c&&n.set("left",o),h&&n.set("top",l),(c||h)&&B_(nP,M_(s,e,t,i)),c||h},jD=oP,XD=s=>function(e,t,i){let{points:n,pathOffset:r}=i;return new De(n[s]).subtract(r).transform(Li(i.getViewportTransform(),i.calcTransformMatrix()))},qD=(s,e,t,i)=>{let{target:n,pointIndex:r}=e,a=n,o=Oa(new De(t,i),void 0,a.calcOwnMatrix());return a.points[r]=o.add(a.pathOffset),a.setDimensions(),a.set("dirty",!0),!0},YD=(s,e)=>function(t,i,n,r){let a=i.target,o=new De(a.points[(s>0?s:a.points.length)-1]),l=o.subtract(a.pathOffset).transform(a.calcOwnMatrix()),c=e(t,{...i,pointIndex:s},n,r),h=o.subtract(a.pathOffset).transform(a.calcOwnMatrix()).subtract(l);return a.left-=h.x,a.top-=h.y,c},KD=s=>Ua(jD,YD(s,qD));function SK(s,e={}){let t={};for(let i=0;i<(typeof s=="number"?s:s.points.length);i++)t[`p${i}`]=new Es({actionName:jD,positionHandler:XD(i),actionHandler:KD(i),...e});return t}const Y_=(s,e,t)=>{let{path:i,pathOffset:n}=s,r=i[e];return new De(r[t]-n.x,r[t+1]-n.y).transform(Li(s.getViewportTransform(),s.calcTransformMatrix()))};function CK(s,e,t){let{commandIndex:i,pointIndex:n}=this;return Y_(t,i,n)}function TK(s,e,t,i){let{target:n}=e,{commandIndex:r,pointIndex:a}=this,o=((l,c,h,d,u)=>{let{path:p,pathOffset:m}=l,v=p[(d>0?d:p.length)-1],g=new De(v[u],v[u+1]),f=g.subtract(m).transform(l.calcOwnMatrix()),A=Oa(new De(c,h),void 0,l.calcOwnMatrix());p[d][u]=A.x+m.x,p[d][u+1]=A.y+m.y,l.setDimensions();let b=g.subtract(l.pathOffset).transform(l.calcOwnMatrix()).subtract(f);return l.left-=b.x,l.top-=b.y,l.set("dirty",!0),!0})(n,t,i,r,a);return B_(this.actionName,{...M_(s,e,t,i),commandIndex:r,pointIndex:a}),o}var $D=class extends Es{constructor(s){super(s)}render(s,e,t,i,n){let r={...i,cornerColor:this.controlFill,cornerStrokeColor:this.controlStroke,transparentCorners:!this.controlFill};super.render(s,e,t,r,n)}},IK=class extends $D{constructor(s){super(s)}render(s,e,t,i,n){let{path:r}=n,{commandIndex:a,pointIndex:o,connectToCommandIndex:l,connectToPointIndex:c}=this;s.save(),s.strokeStyle=this.controlStroke,this.connectionDashArray&&s.setLineDash(this.connectionDashArray);let[h]=r[a],d=Y_(n,l,c);if(h==="Q"){let u=Y_(n,a,o+2);s.moveTo(u.x,u.y),s.lineTo(e,t)}else s.moveTo(e,t);s.lineTo(d.x,d.y),s.stroke(),s.restore(),super.render(s,e,t,i,n)}};const Hv=(s,e,t,i,n,r)=>new(t?IK:$D)({commandIndex:s,pointIndex:e,actionName:"modifyPath",positionHandler:CK,actionHandler:TK,connectToCommandIndex:n,connectToPointIndex:r,...i,...t?i.controlPointStyle:i.pointStyle});function PK(s,e={}){let t={},i="M";return s.path.forEach((n,r)=>{let a=n[0];switch(a!=="Z"&&(t[`c_${r}_${a}`]=Hv(r,n.length-2,!1,e)),a){case"C":t[`c_${r}_C_CP_1`]=Hv(r,1,!0,e,r-1,(o=>o==="C"?5:o==="Q"?3:1)(i)),t[`c_${r}_C_CP_2`]=Hv(r,3,!0,e,r,5);break;case"Q":t[`c_${r}_Q_CP_1`]=Hv(r,1,!0,e,r,3)}i=a}),t}Dp({changeHeight:()=>NY,changeObjectHeight:()=>nD,changeObjectWidth:()=>iD,changeWidth:()=>L_,createObjectDefaultControls:()=>U_,createPathControls:()=>PK,createPolyActionHandler:()=>KD,createPolyControls:()=>SK,createPolyPositionHandler:()=>XD,createResizeControls:()=>gD,createTextboxDefaultControls:()=>vD,dragHandler:()=>QD,factoryPolyActionHandler:()=>YD,getLocalPoint:()=>Rv,polyActionHandler:()=>qD,renderCircleControl:()=>sD,renderSquareControl:()=>rD,rotationStyleHandler:()=>aD,rotationWithSnapping:()=>oD,scaleCursorStyleHandler:()=>yd,scaleOrSkewActionName:()=>jp,scaleSkewCursorStyleHandler:()=>gc,scalingEqually:()=>Qp,scalingX:()=>hD,scalingXOrSkewingY:()=>F_,scalingY:()=>dD,scalingYOrSkewingX:()=>N_,skewCursorStyleHandler:()=>uD,skewHandlerX:()=>fD,skewHandlerY:()=>mD,wrapWithFireEvent:()=>Ua,wrapWithFixedAnchor:()=>Go});var ZD=class jR extends v_{constructor(...e){super(...e),ue(this,"_hoveredTargets",[]),ue(this,"_currentTransform",null),ue(this,"_groupSelector",null),ue(this,"contextTopDirty",!1)}static getDefaults(){return{...super.getDefaults(),...jR.ownDefaults}}get upperCanvasEl(){var e;return(e=this.elements.upper)==null?void 0:e.el}get contextTop(){var e;return(e=this.elements.upper)==null?void 0:e.ctx}get wrapperEl(){return this.elements.container}initElements(e){this.elements=new MK(e,{allowTouchScrolling:this.allowTouchScrolling,containerClass:this.containerClass}),this._createCacheCanvas()}_onObjectAdded(e){this._objectsToRender=void 0,super._onObjectAdded(e)}_onObjectRemoved(e){this._objectsToRender=void 0,e===this._activeObject&&(this.fire("before:selection:cleared",{deselected:[e]}),this._discardActiveObject(),this.fire("selection:cleared",{deselected:[e]}),e.fire("deselected",{target:e})),e===this._hoveredTarget&&(this._hoveredTarget=void 0,this._hoveredTargets=[]),super._onObjectRemoved(e)}_onStackOrderChanged(){this._objectsToRender=void 0,super._onStackOrderChanged()}_chooseObjectsToRender(){let e=this._activeObject;return!this.preserveObjectStacking&&e?this._objects.filter(t=>!t.group&&t!==e).concat(e):this._objects}renderAll(){this.cancelRequestedRender(),this.destroyed||(!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1),!this._objectsToRender&&(this._objectsToRender=this._chooseObjectsToRender()),this.renderCanvas(this.getContext(),this._objectsToRender))}renderTopLayer(e){e.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(e),this.contextTopDirty=!0),e.restore()}renderTop(){let e=this.contextTop;this.clearContext(e),this.renderTopLayer(e),this.fire("after:render",{ctx:e})}setTargetFindTolerance(e){e=Math.round(e),this.targetFindTolerance=e;let t=this.getRetinaScaling(),i=Math.ceil((2*e+1)*t);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=i,this.pixelFindContext.scale(t,t)}isTargetTransparent(e,t,i){let n=this.targetFindTolerance,r=this.pixelFindContext;this.clearContext(r),r.save(),r.translate(-t+n,-i+n),r.transform(...this.viewportTransform);let a=e.selectionBackgroundColor;e.selectionBackgroundColor="",e.render(r),e.selectionBackgroundColor=a,r.restore();let o=Math.round(n*this.getRetinaScaling());return yD(r,o,o,o)}_isSelectionKeyPressed(e){let t=this.selectionKey;return!!t&&(Array.isArray(t)?!!t.find(i=>!!i&&e[i]===!0):e[t])}_shouldClearSelection(e,t){let i=this.getActiveObjects(),n=this._activeObject;return!!(!t||t&&n&&i.length>1&&i.indexOf(t)===-1&&n!==t&&!this._isSelectionKeyPressed(e)||t&&!t.evented||t&&!t.selectable&&n&&n!==t)}_shouldCenterTransform(e,t,i){if(!e)return;let n;return t==="scale"||t==="scaleX"||t==="scaleY"||t==="resizing"?n=this.centeredScaling||e.centeredScaling:t==="rotate"&&(n=this.centeredRotation||e.centeredRotation),n?!i:i}_getOriginFromCorner(e,t){let i=t?e.controls[t].getTransformAnchorPoint():{x:e.originX,y:e.originY};return t&&(["ml","tl","bl"].includes(t)?i.x=fr:["mr","tr","br"].includes(t)&&(i.x=mn),["tl","mt","tr"].includes(t)?i.y=iP:["bl","mb","br"].includes(t)&&(i.y="top")),i}_setupCurrentTransform(e,t,i){var n;let r=t.group?Oa(this.getScenePoint(e),void 0,t.group.calcTransformMatrix()):this.getScenePoint(e),{key:a="",control:o}=t.getActiveControl()||{},l=i&&o?(n=o.getActionHandler(e,t,o))==null?void 0:n.bind(o):QD,c=((E,w,T,R)=>{if(!w||!E)return"drag";let D=R.controls[w];return D.getActionName(T,D,R)})(i,a,e,t),h=e[this.centeredKey],d=this._shouldCenterTransform(t,c,h)?{x:ui,y:ui}:this._getOriginFromCorner(t,a),{scaleX:u,scaleY:p,skewX:m,skewY:v,left:g,top:f,angle:A,width:b,height:y,cropX:x,cropY:_}=t,M={target:t,action:c,actionHandler:l,actionPerformed:!1,corner:a,scaleX:u,scaleY:p,skewX:m,skewY:v,offsetX:r.x-g,offsetY:r.y-f,originX:d.x,originY:d.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,theta:Bi(A),width:b,height:y,shiftKey:e.shiftKey,altKey:h,original:{...A_(t),originX:d.x,originY:d.y,cropX:x,cropY:_}};this._currentTransform=M,this.fire("before:transform",{e,transform:M})}setCursor(e){this.upperCanvasEl.style.cursor=e}_drawSelection(e){let{x:t,y:i,deltaX:n,deltaY:r}=this._groupSelector,a=new De(t,i).transform(this.viewportTransform),o=new De(t+n,i+r).transform(this.viewportTransform),l=this.selectionLineWidth/2,c=Math.min(a.x,o.x),h=Math.min(a.y,o.y),d=Math.max(a.x,o.x),u=Math.max(a.y,o.y);this.selectionColor&&(e.fillStyle=this.selectionColor,e.fillRect(c,h,d-c,u-h)),this.selectionLineWidth&&this.selectionBorderColor&&(e.lineWidth=this.selectionLineWidth,e.strokeStyle=this.selectionBorderColor,c+=l,h+=l,d-=l,u-=l,Dn.prototype._setLineDash.call(this,e,this.selectionDashArray),e.strokeRect(c,h,d-c,u-h))}findTarget(e){if(this._targetInfo)return this._targetInfo;if(this.skipTargetFind)return{subTargets:[],currentSubTargets:[]};let t=this.getScenePoint(e),i=this._activeObject,n=this.getActiveObjects(),r=this.searchPossibleTargets(this._objects,t),{subTargets:a,container:o,target:l}=r,c={...r,currentSubTargets:a,currentContainer:o,currentTarget:l};if(!i)return c;let h={...this.searchPossibleTargets([i],t),currentSubTargets:a,currentContainer:o,currentTarget:l};return i.findControl(this.getViewportPoint(e),Cv(e))?{...h,target:i}:h.target&&(n.length>1||!this.preserveObjectStacking||this.preserveObjectStacking&&e[this.altSelectionKey])?h:c}_pointIsInObjectSelectionArea(e,t){let i=e.getCoords(),n=this.getZoom(),r=e.padding/n;if(r){let[a,o,l,c]=i,h=Math.atan2(o.y-a.y,o.x-a.x),d=mr(h)*r,u=gr(h)*r,p=d+u,m=d-u;i=[new De(a.x-m,a.y-p),new De(o.x+p,o.y-m),new De(l.x+m,l.y+p),new De(c.x-p,c.y+m)]}return Wp.isPointInPolygon(t,i)}_checkTarget(e,t){if(e&&e.visible&&e.evented&&this._pointIsInObjectSelectionArea(e,t)){if(!this.perPixelTargetFind&&!e.perPixelTargetFind||e.isEditing)return!0;{let i=t.transform(this.viewportTransform);if(!this.isTargetTransparent(e,i.x,i.y))return!0}}return!1}_searchPossibleTargets(e,t,i){let n=e.length;for(;n--;){let r=e[n];if(this._checkTarget(r,t)){if(wv(r)&&r.subTargetCheck){let{target:a}=this._searchPossibleTargets(r._objects,t,i);a&&i.push(a)}return{target:r,subTargets:i}}}return{subTargets:[]}}searchPossibleTargets(e,t){let i=this._searchPossibleTargets(e,t,[]);i.container=i.target;let{container:n,subTargets:r}=i;if(n&&wv(n)&&n.interactive&&r[0]){for(let a=r.length-1;a>0;a--){let o=r[a];if(!wv(o)||!o.interactive)return i.target=o,i}return i.target=r[0],i}return i}getViewportPoint(e){return this._viewportPoint?this._viewportPoint:this._getPointerImpl(e,!0)}getScenePoint(e){return this._scenePoint?this._scenePoint:this._getPointerImpl(e)}_getPointerImpl(e,t=!1){let i=this.upperCanvasEl,n=i.getBoundingClientRect(),r=SP(e),a=n.width||0,o=n.height||0;a&&o||("top"in n&&"bottom"in n&&(o=Math.abs(n.top-n.bottom)),"right"in n&&"left"in n&&(a=Math.abs(n.right-n.left))),this.calcOffset(),r.x-=this._offset.left,r.y-=this._offset.top,t||(r=Oa(r,void 0,this.viewportTransform));let l=this.getRetinaScaling();l!==1&&(r.x/=l,r.y/=l);let c=a===0||o===0?new De(1,1):new De(i.width/a,i.height/o);return r.multiply(c)}_setDimensionsImpl(e,t){this._resetTransformEventData(),super._setDimensionsImpl(e,t),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=Qr(),this.pixelFindContext=this.pixelFindCanvasEl.getContext("2d",{willReadFrequently:!0}),this.setTargetFindTolerance(this.targetFindTolerance)}getTopContext(){return this.elements.upper.ctx}getSelectionContext(){return this.elements.upper.ctx}getSelectionElement(){return this.elements.upper.el}getActiveObject(){return this._activeObject}getActiveObjects(){let e=this._activeObject;return uc(e)?e.getObjects():e?[e]:[]}_fireSelectionEvents(e,t){let i=!1,n=!1,r=this.getActiveObjects(),a=[],o=[];e.forEach(l=>{r.includes(l)||(i=!0,l.fire("deselected",{e:t,target:l}),o.push(l))}),r.forEach(l=>{e.includes(l)||(i=!0,l.fire("selected",{e:t,target:l}),a.push(l))}),e.length>0&&r.length>0?(n=!0,i&&this.fire("selection:updated",{e:t,selected:a,deselected:o})):r.length>0?(n=!0,this.fire("selection:created",{e:t,selected:a})):e.length>0&&(n=!0,this.fire("selection:cleared",{e:t,deselected:o})),n&&(this._objectsToRender=void 0)}setActiveObject(e,t){let i=this.getActiveObjects(),n=this._setActiveObject(e,t);return this._fireSelectionEvents(i,t),n}_setActiveObject(e,t){let i=this._activeObject;return i!==e&&!(!this._discardActiveObject(t,e)&&this._activeObject)&&!e.onSelect({e:t})&&(this._activeObject=e,uc(e)&&i!==e&&e.set("canvas",this),e.setCoords(),!0)}_discardActiveObject(e,t){let i=this._activeObject;return!!i&&!i.onDeselect({e,object:t})&&(this._currentTransform&&this._currentTransform.target===i&&this.endCurrentTransform(e),uc(i)&&i===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(e){let t=this.getActiveObjects(),i=this.getActiveObject();t.length&&this.fire("before:selection:cleared",{e,deselected:[i]});let n=this._discardActiveObject(e);return this._fireSelectionEvents(t,e),n}endCurrentTransform(e){let t=this._currentTransform;this._finalizeCurrentTransform(e),t&&t.target&&(t.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(e){let t=this._currentTransform,i=t.target,n={e,target:i,transform:t,action:t.action};i._scaling&&(i._scaling=!1),i.setCoords(),t.actionPerformed&&(this.fire("object:modified",n),i.fire(cP,n))}setViewportTransform(e){super.setViewportTransform(e);let t=this._activeObject;t&&t.setCoords()}destroy(){let e=this._activeObject;uc(e)&&(e.removeAll(),e.dispose()),delete this._activeObject,super.destroy(),this.pixelFindContext=null,this.pixelFindCanvasEl=void 0}clear(){this.discardActiveObject(),this._activeObject=void 0,this.clearContext(this.contextTop),super.clear()}drawControls(e){let t=this._activeObject;t&&t._renderControls(e)}_toObject(e,t,i){let n=this._realizeGroupTransformOnObject(e),r=super._toObject(e,t,i);return e.set(n),r}_realizeGroupTransformOnObject(e){let{group:t}=e;if(t&&uc(t)&&this._activeObject===t){let i=dc(e,["angle","flipX","flipY",mn,Uo,zo,hd,dd,"top"]);return TP(e,t.calcOwnMatrix()),i}return{}}_setSVGObject(e,t,i){let n=this._realizeGroupTransformOnObject(t);super._setSVGObject(e,t,i),t.set(n)}};ue(ZD,"ownDefaults",{uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",selection:!0,selectionKey:"shiftKey",selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,selectionFullyContained:!1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",notAllowedCursor:"not-allowed",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,stopContextMenu:!0,fireRightClick:!0,fireMiddleClick:!0,enablePointerEvents:!1,containerClass:"canvas-container",preserveObjectStacking:!0});var DK=class{constructor(s){ue(this,"targets",[]),ue(this,"__disposer",void 0);let e=()=>{let{hiddenTextarea:i}=s.getActiveObject()||{};i&&i.focus()},t=s.upperCanvasEl;t.addEventListener("click",e),this.__disposer=()=>t.removeEventListener("click",e)}exitTextEditing(){this.target=void 0,this.targets.forEach(s=>{s.isEditing&&s.exitEditing()})}add(s){this.targets.push(s)}remove(s){this.unregister(s),cc(this.targets,s)}register(s){this.target=s}unregister(s){s===this.target&&(this.target=void 0)}onMouseMove(s){var e;(e=this.target)!=null&&e.isEditing&&this.target.updateSelectionOnMouseMove(s)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}};const Ms={passive:!1},xd=(s,e)=>({viewportPoint:s.getViewportPoint(e),scenePoint:s.getScenePoint(e)}),jo=(s,...e)=>s.addEventListener(...e),Qs=(s,...e)=>s.removeEventListener(...e),RK={mouse:{in:"over",out:"out",targetIn:"mouseover",targetOut:"mouseout",canvasIn:"mouse:over",canvasOut:"mouse:out"},drag:{in:"enter",out:"leave",targetIn:"dragenter",targetOut:"dragleave",canvasIn:"drag:enter",canvasOut:"drag:leave"}};var K_=class extends ZD{constructor(s,e={}){super(s,e),ue(this,"_isClick",void 0),ue(this,"textEditingManager",new DK(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach(t=>{this[t]=this[t].bind(this)}),this.addOrRemove(jo)}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(s,e=!1){let t=this.upperCanvasEl,i=this._getEventPrefix();s(_P(t),"resize",this._onResize),s(t,i+"down",this._onMouseDown),s(t,`${i}move`,this._onMouseMove,Ms),s(t,`${i}out`,this._onMouseOut),s(t,`${i}enter`,this._onMouseEnter),s(t,"wheel",this._onMouseWheel,{passive:!1}),s(t,"contextmenu",this._onContextMenu),e||(s(t,"click",this._onClick),s(t,"dblclick",this._onClick)),s(t,"dragstart",this._onDragStart),s(t,"dragend",this._onDragEnd),s(t,"dragover",this._onDragOver),s(t,"dragenter",this._onDragEnter),s(t,"dragleave",this._onDragLeave),s(t,"drop",this._onDrop),this.enablePointerEvents||s(t,"touchstart",this._onTouchStart,Ms)}removeListeners(){this.addOrRemove(Qs);let s=this._getEventPrefix(),e=vr(this.upperCanvasEl);Qs(e,`${s}up`,this._onMouseUp),Qs(e,"touchend",this._onTouchEnd,Ms),Qs(e,`${s}move`,this._onMouseMove,Ms),Qs(e,"touchmove",this._onMouseMove,Ms),clearTimeout(this._willAddMouseDown)}_onMouseWheel(s){this._cacheTransformEventData(s),this._handleEvent(s,"wheel"),this._resetTransformEventData()}_onMouseOut(s){let e=this._hoveredTarget,t={e:s,...xd(this,s)};this.fire("mouse:out",{...t,target:e}),this._hoveredTarget=void 0,e&&e.fire("mouseout",{...t}),this._hoveredTargets.forEach(i=>{this.fire("mouse:out",{...t,target:i}),i&&i.fire("mouseout",{...t})}),this._hoveredTargets=[]}_onMouseEnter(s){let{target:e}=this.findTarget(s);this._currentTransform||e||(this.fire("mouse:over",{e:s,...xd(this,s)}),this._hoveredTarget=void 0,this._hoveredTargets=[])}_onDragStart(s){this._isClick=!1;let e=this.getActiveObject();if(e&&e.onDragStart(s)){this._dragSource=e;let t={e:s,target:e};this.fire("dragstart",t),e.fire("dragstart",t),jo(this.upperCanvasEl,"drag",this._onDragProgress);return}CP(s)}_renderDragEffects(s,e,t){let i=!1,n=this._dropTarget;n&&n!==e&&n!==t&&(n.clearContextTop(),i=!0),e?.clearContextTop(),t!==e&&t?.clearContextTop();let r=this.contextTop;r.save(),r.transform(...this.viewportTransform),e&&(r.save(),e.transform(r),e.renderDragSourceEffect(s),r.restore(),i=!0),t&&(r.save(),t.transform(r),t.renderDropTargetEffect(s),r.restore(),i=!0),r.restore(),i&&(this.contextTopDirty=!0)}_onDragEnd(s){let{currentSubTargets:e}=this.findTarget(s),t=!!s.dataTransfer&&s.dataTransfer.dropEffect!=="none",i=t?this._activeObject:void 0,n={e:s,target:this._dragSource,subTargets:e,dragSource:this._dragSource,didDrop:t,dropTarget:i};Qs(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",n),this._dragSource&&this._dragSource.fire("dragend",n),delete this._dragSource,this._onMouseUp(s)}_onDragProgress(s){let e={e:s,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire("drag",e),this._dragSource&&this._dragSource.fire("drag",e)}_onDragOver(s){let e="dragover",{currentContainer:t,currentSubTargets:i}=this.findTarget(s),n=this._dragSource,r={e:s,target:t,subTargets:i,dragSource:n,canDrop:!1,dropTarget:void 0},a;this.fire(e,r),this._fireEnterLeaveEvents(s,t,r),t&&(t.canDrop(s)&&(a=t),t.fire(e,r));for(let o=0;o<i.length;o++){let l=i[o];l.canDrop(s)&&(a=l),l.fire(e,r)}this._renderDragEffects(s,n,a),this._dropTarget=a}_onDragEnter(s){let{currentContainer:e,currentSubTargets:t}=this.findTarget(s),i={e:s,target:e,subTargets:t,dragSource:this._dragSource};this.fire("dragenter",i),this._fireEnterLeaveEvents(s,e,i)}_onDragLeave(s){let{currentSubTargets:e}=this.findTarget(s),t={e:s,target:this._draggedoverTarget,subTargets:e,dragSource:this._dragSource};this.fire("dragleave",t),this._fireEnterLeaveEvents(s,void 0,t),this._renderDragEffects(s,this._dragSource),this._dropTarget=void 0,this._hoveredTargets=[]}_onDrop(s){let{currentContainer:e,currentSubTargets:t}=this.findTarget(s),i=this._basicEventHandler("drop:before",{e:s,target:e,subTargets:t,dragSource:this._dragSource,...xd(this,s)});i.didDrop=!1,i.dropTarget=void 0,this._basicEventHandler("drop",i),this.fire("drop:after",i)}_onContextMenu(s){let{target:e,subTargets:t}=this.findTarget(s),i=this._basicEventHandler("contextmenu:before",{e:s,target:e,subTargets:t});return this.stopContextMenu&&CP(s),this._basicEventHandler("contextmenu",i),!1}_onClick(s){let e=s.detail;e>3||e<2||(this._cacheTransformEventData(s),e==2&&s.type==="dblclick"&&this._handleEvent(s,"dblclick"),e==3&&this._handleEvent(s,"tripleclick"),this._resetTransformEventData())}fireEventFromPointerEvent(s,e,t,i={}){this._cacheTransformEventData(s);let{target:n,subTargets:r}=this.findTarget(s),a={e:s,target:n,subTargets:r,...xd(this,s),transform:this._currentTransform,...i};this.fire(e,a),n&&n.fire(t,a);for(let o=0;o<r.length;o++)r[o]!==n&&r[o].fire(t,a);this._resetTransformEventData()}getPointerId(s){let e=s.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?s.pointerId:-1}_isMainEvent(s){return s.isPrimary===!0||s.isPrimary!==!1&&(s.type==="touchend"&&s.touches.length===0||!s.changedTouches||s.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(s){this._cacheTransformEventData(s);let e=!this.allowTouchScrolling,t=this._activeObject;this.mainTouchId===void 0&&(this.mainTouchId=this.getPointerId(s)),this.__onMouseDown(s);let{target:i}=this.findTarget(s);(this.isDrawingMode||t&&i===t)&&(e=!0),e&&s.preventDefault();let n=this.upperCanvasEl,r=this._getEventPrefix(),a=vr(n);jo(a,"touchend",this._onTouchEnd,Ms),e&&jo(a,"touchmove",this._onMouseMove,Ms),Qs(n,`${r}down`,this._onMouseDown),this._resetTransformEventData()}_onMouseDown(s){this._cacheTransformEventData(s),this.__onMouseDown(s);let e=this.upperCanvasEl,t=this._getEventPrefix();Qs(e,`${t}move`,this._onMouseMove,Ms);let i=vr(e);jo(i,`${t}up`,this._onMouseUp),jo(i,`${t}move`,this._onMouseMove,Ms),this._resetTransformEventData()}_onTouchEnd(s){if(s.touches.length>0)return;this._cacheTransformEventData(s),this.__onMouseUp(s),this._resetTransformEventData(),delete this.mainTouchId;let e=this._getEventPrefix(),t=vr(this.upperCanvasEl);Qs(t,"touchend",this._onTouchEnd,Ms),Qs(t,"touchmove",this._onMouseMove,Ms),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{jo(this.upperCanvasEl,`${e}down`,this._onMouseDown),this._willAddMouseDown=0},400)}_onMouseUp(s){this._cacheTransformEventData(s),this.__onMouseUp(s);let e=this.upperCanvasEl,t=this._getEventPrefix();if(this._isMainEvent(s)){let i=vr(this.upperCanvasEl);Qs(i,`${t}up`,this._onMouseUp),Qs(i,`${t}move`,this._onMouseMove,Ms),jo(e,`${t}move`,this._onMouseMove,Ms)}this._resetTransformEventData()}_onMouseMove(s){this._cacheTransformEventData(s);let e=this.getActiveObject();!this.allowTouchScrolling&&(!e||!e.shouldStartDragging(s))&&s.preventDefault&&s.preventDefault(),this.__onMouseMove(s),this._resetTransformEventData()}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(s){let e=this.getActiveObject();return!!e!=!!s||e&&s&&e!==s}__onMouseUp(s){var e;this._handleEvent(s,"up:before");let t=this._currentTransform,i=this._isClick,{target:n}=this.findTarget(s),{button:r}=s;if(r)return void((this.fireMiddleClick&&r===1||this.fireRightClick&&r===2)&&this._handleEvent(s,"up"));if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(s);if(!this._isMainEvent(s))return;let a,o,l=!1;if(t&&(this._finalizeCurrentTransform(s),l=t.actionPerformed),!i){let c=n===this._activeObject;this.handleSelection(s),l||(l=this._shouldRender(n)||!c&&n===this._activeObject)}if(n){let{key:c,control:h}=n.findControl(this.getViewportPoint(s),Cv(s))||{};if(o=c,n.selectable&&n!==this._activeObject&&n.activeOn==="up")this.setActiveObject(n,s),l=!0;else if(h){let d=h.getMouseUpHandler(s,n,h);d&&(a=this.getScenePoint(s),d.call(h,s,t,a.x,a.y))}n.isMoving=!1}if(t&&(t.target!==n||t.corner!==o)){let c=t.target&&t.target.controls[t.corner],h=c&&c.getMouseUpHandler(s,t.target,c);a=a||this.getScenePoint(s),h&&h.call(c,s,t,a.x,a.y)}this._setCursorFromEvent(s,n),this._handleEvent(s,"up"),this._groupSelector=null,this._currentTransform=null,n&&(n.__corner=void 0),l?this.requestRenderAll():i||(e=this._activeObject)!=null&&e.isEditing||this.renderTop()}_basicEventHandler(s,e){let{target:t,subTargets:i=[]}=e;this.fire(s,e),t&&t.fire(s,e);for(let n=0;n<i.length;n++)i[n]!==t&&i[n].fire(s,e);return e}_handleEvent(s,e,t){let{target:i,subTargets:n}=this.findTarget(s),r={e:s,target:i,subTargets:n,...xd(this,s),transform:this._currentTransform,...e==="down:before"||e==="down"?t:{}};e!=="up:before"&&e!=="up"||(r.isClick=this._isClick),this.fire(`mouse:${e}`,r),i&&i.fire(`mouse${e}`,r);for(let a=0;a<n.length;a++)n[a]!==i&&n[a].fire(`mouse${e}`,r)}_onMouseDownInDrawingMode(s){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(s),this.requestRenderAll());let e=this.getScenePoint(s);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseDown(e,{e:s,pointer:e}),this._handleEvent(s,"down",{alreadySelected:!1})}_onMouseMoveInDrawingMode(s){if(this._isCurrentlyDrawing){let e=this.getScenePoint(s);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(e,{e:s,pointer:e})}this.setCursor(this.freeDrawingCursor),this._handleEvent(s,"move")}_onMouseUpInDrawingMode(s){let e=this.getScenePoint(s);this.freeDrawingBrush?this._isCurrentlyDrawing=!!this.freeDrawingBrush.onMouseUp({e:s,pointer:e}):this._isCurrentlyDrawing=!1,this._handleEvent(s,"up")}__onMouseDown(s){this._isClick=!0,this._handleEvent(s,"down:before");let{target:e}=this.findTarget(s),t=!!e&&e===this._activeObject,{button:i}=s;if(i)return void((this.fireMiddleClick&&i===1||this.fireRightClick&&i===2)&&this._handleEvent(s,"down",{alreadySelected:t}));if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(s);if(!this._isMainEvent(s)||this._currentTransform)return;let n=this._shouldRender(e),r=!1;if(this.handleMultiSelection(s,e)?(e=this._activeObject,r=!0,n=!0):this._shouldClearSelection(s,e)&&this.discardActiveObject(s),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){let a=this.getScenePoint(s);this._groupSelector={x:a.x,y:a.y,deltaY:0,deltaX:0}}if(t=!!e&&e===this._activeObject,e){e.selectable&&e.activeOn==="down"&&this.setActiveObject(e,s);let a=e.findControl(this.getViewportPoint(s),Cv(s));if(e===this._activeObject&&(a||!r)){this._setupCurrentTransform(s,e,t);let o=a?a.control:void 0,l=this.getScenePoint(s),c=o&&o.getMouseDownHandler(s,e,o);c&&c.call(o,s,this._currentTransform,l.x,l.y)}}n&&(this._objectsToRender=void 0),this._handleEvent(s,"down",{alreadySelected:t}),n&&this.requestRenderAll()}_resetTransformEventData(){this._targetInfo=this._viewportPoint=this._scenePoint=void 0}_cacheTransformEventData(s){this._resetTransformEventData(),this._viewportPoint=this.getViewportPoint(s),this._scenePoint=Oa(this._viewportPoint,void 0,this.viewportTransform),this._targetInfo=this.findTarget(s),this._currentTransform&&(this._targetInfo.target=this._currentTransform.target)}__onMouseMove(s){if(this._isClick=!1,this._handleEvent(s,"move:before"),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(s);if(!this._isMainEvent(s))return;let e=this._groupSelector;if(e){let t=this.getScenePoint(s);e.deltaX=t.x-e.x,e.deltaY=t.y-e.y,this.renderTop()}else if(this._currentTransform)this._transformObject(s);else{let{target:t}=this.findTarget(s);this._setCursorFromEvent(s,t),this._fireOverOutEvents(s,t)}this.textEditingManager.onMouseMove(s),this._handleEvent(s,"move")}_fireOverOutEvents(s,e){let{_hoveredTarget:t,_hoveredTargets:i}=this,{subTargets:n,currentTarget:r}=this.findTarget(s),a=Math.max(i.length,n.length);this.fireSyntheticInOutEvents("mouse",{e:s,target:e,oldTarget:t,actualTarget:r,oldActualTarget:this._hoveredActualTarget,fireCanvas:!0});for(let o=0;o<a;o++)n[o]===e||i[o]&&i[o]===t||this.fireSyntheticInOutEvents("mouse",{e:s,target:n[o],oldTarget:i[o]});this._hoveredActualTarget=r,this._hoveredTarget=e,this._hoveredTargets=n}_fireEnterLeaveEvents(s,e,t){let i=this._draggedoverTarget,n=this._hoveredTargets,{subTargets:r}=this.findTarget(s),a=Math.max(n.length,r.length);this.fireSyntheticInOutEvents("drag",{...t,target:e,oldTarget:i,fireCanvas:!0});for(let o=0;o<a;o++)this.fireSyntheticInOutEvents("drag",{...t,target:r[o],oldTarget:n[o]});this._draggedoverTarget=e}fireSyntheticInOutEvents(s,{target:e,oldTarget:t,actualTarget:i,oldActualTarget:n,fireCanvas:r,e:a,...o}){let{targetIn:l,targetOut:c,canvasIn:h,canvasOut:d}=RK[s],u=t!==e,p=n!==i,m=e&&u,v=i&&p,g=t&&u,f=n&&p,A={...o,e:a,...xd(this,a)},b={...A,target:t,nextTarget:e,actualTarget:n,nextActualTarget:i};(g||f)&&r&&this.fire(d,b),g&&t.fire(c,b),f&&t!==n&&n.fire(c,b);let y={...A,target:e,previousTarget:t,actualTarget:i,previousActualTarget:n};(m||v)&&r&&this.fire(h,y),m&&e.fire(l,y),v&&i!==e&&i.fire(l,y)}_transformObject(s){let e=this.getScenePoint(s),t=this._currentTransform,i=t.target,n=i.group?Oa(e,void 0,i.group.calcTransformMatrix()):e;t.shiftKey=s.shiftKey,t.altKey=!!this.centeredKey&&s[this.centeredKey],this._performTransformAction(s,t,n),t.actionPerformed&&this.requestRenderAll()}_performTransformAction(s,e,t){let{action:i,actionHandler:n,target:r}=e,a=!!n&&n(s,e,t.x,t.y);a&&r.setCoords(),i==="drag"&&a&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||a}_setCursorFromEvent(s,e){if(!e)return void this.setCursor(this.defaultCursor);let t=e.hoverCursor||this.hoverCursor,i=uc(this._activeObject)?this._activeObject:null,n=(!i||e.group!==i)&&e.findControl(this.getViewportPoint(s));if(n){let{control:r,coord:a}=n;this.setCursor(r.cursorStyleHandler(s,r,e,a))}else{if(e.subTargetCheck){let{subTargets:r}=this.findTarget(s);r.concat().reverse().forEach(a=>{t=a.hoverCursor||t})}this.setCursor(t)}}handleMultiSelection(s,e){let t=this._activeObject,i=uc(t);if(t&&this._isSelectionKeyPressed(s)&&this.selection&&e&&e.selectable&&(t!==e||i)&&(i||!e.isDescendantOf(t)&&!t.isDescendantOf(e))&&!e.onSelect({e:s})&&!t.getActiveControl()){if(i){let n=t.getObjects(),r=[];if(e===t){let a=this.getScenePoint(s),o=this.searchPossibleTargets(n,a);if(o.target?(e=o.target,r=o.subTargets):(o=this.searchPossibleTargets(this._objects,a),e=o.target,r=o.subTargets),!e||!e.selectable)return!1}e.group===t?(t.remove(e),this._hoveredTarget=e,this._hoveredTargets=r,t.size()===1&&this._setActiveObject(t.item(0),s)):(t.multiSelectAdd(e),this._hoveredTarget=t,this._hoveredTargets=r),this._fireSelectionEvents(n,s)}else{t.isEditing&&t.exitEditing();let n=new(ot.getClass("ActiveSelection"))([],{canvas:this});n.multiSelectAdd(t,e),this._hoveredTarget=n,this._setActiveObject(n,s),this._fireSelectionEvents([t],s)}return!0}return!1}handleSelection(s){if(!this.selection||!this._groupSelector)return!1;let{x:e,y:t,deltaX:i,deltaY:n}=this._groupSelector,r=new De(e,t),a=r.add(new De(i,n)),o=r.min(a),l=r.max(a).subtract(o),c=this.collectObjects({left:o.x,top:o.y,width:l.x,height:l.y},{includeIntersecting:!this.selectionFullyContained}),h=r.eq(a)?c[0]?[c[0]]:[]:c.length>1?c.filter(d=>!d.onSelect({e:s})).reverse():c;if(h.length===1)this.setActiveObject(h[0],s);else if(h.length>1){let d=ot.getClass("ActiveSelection");this.setActiveObject(new d(h,{canvas:this}),s)}return this._groupSelector=null,!0}toCanvasElement(s=1,e){let{upper:t}=this.elements;t.ctx=void 0;let i=super.toCanvasElement(s,e);return t.ctx=t.el.getContext("2d"),i}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}};const JD={x1:0,y1:0,x2:0,y2:0},BK={...JD,r1:0,r2:0},_d=(s,e)=>isNaN(s)&&typeof e=="number"?e:s;function eR(s){return s&&/%$/.test(s)&&Number.isFinite(parseFloat(s))}function tR(s,e){return mc(0,_d(typeof s=="number"?s:typeof s=="string"?parseFloat(s)/(eR(s)?100:1):NaN,e),1)}const LK=/\s*;\s*/,kK=/\s*:\s*/;function OK(s,e){let t,i,n=s.getAttribute("style");if(n){let a=n.split(LK);a[a.length-1]===""&&a.pop();for(let o=a.length;o--;){let[l,c]=a[o].split(kK).map(h=>h.trim());l==="stop-color"?t=c:l==="stop-opacity"&&(i=c)}}t=t||s.getAttribute("stop-color")||"rgb(0,0,0)",i=_d(parseFloat(i||s.getAttribute("stop-opacity")||""),1);let r=new br(t);return r.setAlpha(r.getAlpha()*i*e),{offset:tR(s.getAttribute("offset"),0),color:r.toRgba()}}function FK(s,e){let t=[],i=s.getElementsByTagName("stop"),n=tR(e,1);for(let r=i.length;r--;)t.push(OK(i[r],n));return t}function iR(s){return s.nodeName==="linearGradient"||s.nodeName==="LINEARGRADIENT"?"linear":"radial"}function nR(s){return s.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function yr(s,e){return s.getAttribute(e)}function NK(s,e){return(function(t,{width:i,height:n,gradientUnits:r}){let a;return Object.entries(t).reduce((o,[l,c])=>{if(c==="Infinity")a=1;else if(c==="-Infinity")a=0;else{let h=typeof c=="string";a=h?parseFloat(c):c,h&&eR(c)&&(a*=.01,r==="pixels"&&(l!=="x1"&&l!=="x2"&&l!=="r2"||(a*=i),l!=="y1"&&l!=="y2"||(a*=n)))}return o[l]=a,o},{})})(iR(s)==="linear"?(function(t){return{x1:yr(t,"x1")||0,y1:yr(t,"y1")||0,x2:yr(t,"x2")||"100%",y2:yr(t,"y2")||0}})(s):(function(t){return{x1:yr(t,"fx")||yr(t,"cx")||"50%",y1:yr(t,"fy")||yr(t,"cy")||"50%",r1:0,x2:yr(t,"cx")||"50%",y2:yr(t,"cy")||"50%",r2:yr(t,"r")||"50%"}})(s),{...e,gradientUnits:nR(s)})}var Gv=class{constructor(s){let{type:e="linear",gradientUnits:t="pixels",coords:i={},colorStops:n=[],offsetX:r=0,offsetY:a=0,gradientTransform:o,id:l}=s||{};Object.assign(this,{type:e,gradientUnits:t,coords:{...e==="radial"?BK:JD,...i},colorStops:n,offsetX:r,offsetY:a,gradientTransform:o,id:l?`${l}_${Ho()}`:Ho()})}addColorStop(s){for(let e in s)this.colorStops.push({offset:parseFloat(e),color:s[e]});return this}toObject(s){return{...dc(this,s),type:this.type,coords:{...this.coords},colorStops:this.colorStops.map(e=>({...e})),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0}}toSVG(s,{additionalTransform:e}={}){let t=[],i=this.gradientTransform?this.gradientTransform.concat():Wn.concat(),n=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",r=this.colorStops.map(d=>({...d})).sort((d,u)=>d.offset-u.offset),a=-this.offsetX,o=-this.offsetY;var l;n==="objectBoundingBox"?(a/=s.width,o/=s.height):(a+=s.width/2,o+=s.height/2),(l=s)&&typeof l._renderPathCommands=="function"&&this.gradientUnits!=="percentage"&&(a-=s.pathOffset.x,o-=s.pathOffset.y),i[4]-=a,i[5]-=o;let c=[`id="SVGID_${Ot(String(this.id))}"`,`gradientUnits="${n}"`,`gradientTransform="${e?e+" ":""}${gd(i)}"`,""].join(" "),h=d=>parseFloat(String(d));if(this.type==="linear"){let{x1:d,y1:u,x2:p,y2:m}=this.coords,v=h(d),g=h(u),f=h(p),A=h(m);t.push("<linearGradient ",c,' x1="',v,'" y1="',g,'" x2="',f,'" y2="',A,`">
|
||
`)}else if(this.type==="radial"){let{x1:d,y1:u,x2:p,y2:m,r1:v,r2:g}=this.coords,f=h(d),A=h(u),b=h(p),y=h(m),x=h(v),_=h(g),M=x>_;t.push("<radialGradient ",c,' cx="',M?f:b,'" cy="',M?A:y,'" r="',M?x:_,'" fx="',M?b:f,'" fy="',M?y:A,`">
|
||
`),M&&(r.reverse(),r.forEach(w=>{w.offset=1-w.offset}));let E=Math.min(x,_);if(E>0){let w=E/Math.max(x,_);r.forEach(T=>{T.offset+=w*(1-T.offset)})}}return r.forEach(({color:d,offset:u})=>{t.push(`<stop offset="${100*u}%" style="stop-color:${d};"/>
|
||
`)}),t.push(this.type==="linear"?"</linearGradient>":"</radialGradient>",`
|
||
`),t.join("")}toLive(s){let{x1:e,y1:t,x2:i,y2:n,r1:r,r2:a}=this.coords,o=this.type==="linear"?s.createLinearGradient(e,t,i,n):s.createRadialGradient(e,t,r,i,n,a);return this.colorStops.forEach(({color:l,offset:c})=>{o.addColorStop(c,l)}),o}static async fromObject(s){let{colorStops:e,gradientTransform:t}=s;return new this({...s,colorStops:e?e.map(i=>({...i})):void 0,gradientTransform:t?[...t]:void 0})}static fromElement(s,e,t){let i=nR(s),n=e._findCenterFromElement();return new this({id:s.getAttribute("id")||void 0,type:iR(s),coords:NK(s,{width:t.viewBoxWidth||t.width,height:t.viewBoxHeight||t.height}),colorStops:FK(s,t.opacity),gradientUnits:i,gradientTransform:G_(s.getAttribute("gradientTransform")||""),...i==="pixels"?{offsetX:e.width/2-n.x,offsetY:e.height/2-n.y}:{offsetX:0,offsetY:0}})}};ue(Gv,"type","Gradient"),ot.setClass(Gv,"gradient"),ot.setClass(Gv,"linear"),ot.setClass(Gv,"radial");var $_=class{get type(){return"pattern"}set type(s){Fo("warn","Setting type has no effect",s)}constructor(s){ue(this,"repeat","repeat"),ue(this,"offsetX",0),ue(this,"offsetY",0),ue(this,"crossOrigin",""),this.id=Ho(),Object.assign(this,s)}isImageSource(){return!!this.source&&typeof this.source.src=="string"}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():""}toLive(s){return this.source&&(!this.isImageSource()||this.source.complete&&this.source.naturalWidth!==0&&this.source.naturalHeight!==0)?s.createPattern(this.source,this.repeat):null}toObject(s=[]){let{repeat:e,crossOrigin:t}=this;return{...dc(this,s),type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:t,offsetX:pi(this.offsetX,ei.NUM_FRACTION_DIGITS),offsetY:pi(this.offsetY,ei.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null}}toSVG({width:s,height:e}){let{source:t,repeat:i,id:n}=this,r=_d(this.offsetX/s,0),a=_d(this.offsetY/e,0),o=i==="repeat-y"||i==="no-repeat"?1+Math.abs(r||0):_d(t.width/s,0),l=i==="repeat-x"||i==="no-repeat"?1+Math.abs(a||0):_d(t.height/e,0);return[`<pattern id="SVGID_${Ot(n)}" x="${r}" y="${a}" width="${o}" height="${l}">`,`<image x="0" y="0" width="${t.width}" height="${t.height}" xlink:href="${Ot(this.sourceToString())}"></image>`,"</pattern>",""].join(`
|
||
`)}static async fromObject({type:s,source:e,patternTransform:t,...i},n){let r=await Fp(e,{...n,crossOrigin:i.crossOrigin});return new this({...i,patternTransform:t&&t.slice(0),source:r})}};ue($_,"type","Pattern"),ot.setClass($_),ot.setClass($_,"pattern");var vc=class XR extends Dn{constructor(e,{path:t,left:i,top:n,...r}={}){super(),Object.assign(this,XR.ownDefaults),this.setOptions(r),this._setPath(e||[],!0),typeof i=="number"&&this.set("left",i),typeof n=="number"&&this.set("top",n)}_setPath(e,t){this.path=kD(Array.isArray(e)?e:VD(e)),this.setBoundingBox(t)}_findCenterFromElement(){let e=this._calcBoundsFromPath();return new De(e.left+e.width/2,e.top+e.height/2)}_renderPathCommands(e){let t=-this.pathOffset.x,i=-this.pathOffset.y;e.beginPath();for(let n of this.path)switch(n[0]){case"L":e.lineTo(n[1]+t,n[2]+i);break;case"M":e.moveTo(n[1]+t,n[2]+i);break;case"C":e.bezierCurveTo(n[1]+t,n[2]+i,n[3]+t,n[4]+i,n[5]+t,n[6]+i);break;case"Q":e.quadraticCurveTo(n[1]+t,n[2]+i,n[3]+t,n[4]+i);break;case"Z":e.closePath()}}_render(e){this._renderPathCommands(e),this._renderPaintInOrder(e)}toString(){return`#<Path (${this.complexity()}): { "top": ${this.top}, "left": ${this.left} }>`}toObject(e=[]){return{...super.toObject(e),path:this.path.map(t=>t.slice())}}toDatalessObject(e=[]){let t=this.toObject(e);return this.sourcePath&&(delete t.path,t.sourcePath=this.sourcePath),t}_toSVG(){return["<path ","COMMON_PARTS",`d="${WD(this.path,ei.NUM_FRACTION_DIGITS)}" stroke-linecap="round" />
|
||
`]}_getOffsetTransform(){let e=ei.NUM_FRACTION_DIGITS;return` translate(${pi(-this.pathOffset.x,e)}, ${pi(-this.pathOffset.y,e)})`}toClipPathSVG(e){let t=this._getOffsetTransform();return" "+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:e,additionalTransform:t})}toSVG(e){let t=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:e,additionalTransform:t})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(e){let{width:t,height:i,pathOffset:n}=this._calcDimensions();this.set({width:t,height:i,pathOffset:n}),e&&this.setPositionByOrigin(n,"center","center")}_calcBoundsFromPath(){let e=[],t=0,i=0,n=0,r=0;for(let a of this.path)switch(a[0]){case"L":n=a[1],r=a[2],e.push({x:t,y:i},{x:n,y:r});break;case"M":n=a[1],r=a[2],t=n,i=r;break;case"C":e.push(...j_(n,r,a[1],a[2],a[3],a[4],a[5],a[6])),n=a[5],r=a[6];break;case"Q":e.push(...j_(n,r,a[1],a[2],a[1],a[2],a[3],a[4])),n=a[3],r=a[4];break;case"Z":n=t,r=i}return jr(e)}_calcDimensions(){let e=this._calcBoundsFromPath();return{...e,pathOffset:new De(e.left+e.width/2,e.top+e.height/2)}}static fromObject(e){return this._fromObject(e,{extraParam:"path"})}static async fromElement(e,t,i){let{d:n,...r}=za(e,this.ATTRIBUTE_NAMES,i);return new this(n,{...r,...t,left:void 0,top:void 0})}};ue(vc,"type","Path"),ue(vc,"cacheProperties",[...Fa,"path","fillRule"]),ue(vc,"ATTRIBUTE_NAMES",[...Vo,"d"]),ot.setClass(vc),ot.setSVGClass(vc);const sR=["radius","startAngle","endAngle","counterClockwise"];var Ac=class mw extends Dn{static getDefaults(){return{...super.getDefaults(),...mw.ownDefaults}}constructor(e){super(),Object.assign(this,mw.ownDefaults),this.setOptions(e)}_set(e,t){return super._set(e,t),e==="radius"&&this.setRadius(t),this}_render(e){e.beginPath(),e.arc(0,0,this.radius,Bi(this.startAngle),Bi(this.endAngle),this.counterClockwise),this._renderPaintInOrder(e)}getRadiusX(){return this.get("radius")*this.get(Uo)}getRadiusY(){return this.get("radius")*this.get(zo)}setRadius(e){this.radius=e,this.set({width:2*e,height:2*e})}toObject(e=[]){return super.toObject([...sR,...e])}_toSVG(){let{radius:e,startAngle:t,endAngle:i}=this,n=(i-t)%360;if(n===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',`${Ot(e)}`,`" />
|
||
`];{let r=Bi(t),a=Bi(i),o=mr(r)*e,l=gr(r)*e,c=mr(a)*e,h=gr(a)*e;return[`<path d="M ${o} ${l} A ${e} ${e} 0 ${n>180?1:0} ${this.counterClockwise?0:1} ${c} ${h}" `,"COMMON_PARTS",` />
|
||
`]}}static async fromElement(e,t,i){let{left:n=0,top:r=0,radius:a=0,...o}=za(e,this.ATTRIBUTE_NAMES,i);return new this({...o,radius:a,left:n-a,top:r-a})}static fromObject(e){return super._fromObject(e)}};ue(Ac,"type","Circle"),ue(Ac,"cacheProperties",[...Fa,...sR]),ue(Ac,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),ue(Ac,"ATTRIBUTE_NAMES",["cx","cy","r",...Vo]),ot.setClass(Ac),ot.setSVGClass(Ac);const Z_=["x1","x2","y1","y2"];var Xo=class qR extends Dn{constructor([e,t,i,n]=[0,0,0,0],r={}){super(),Object.assign(this,qR.ownDefaults),this.setOptions(r),this.x1=e,this.x2=i,this.y1=t,this.y2=n,this._setWidthHeight();let{left:a,top:o}=r;typeof a=="number"&&this.set("left",a),typeof o=="number"&&this.set("top",o)}_setWidthHeight(){let{x1:e,y1:t,x2:i,y2:n}=this;this.width=Math.abs(i-e),this.height=Math.abs(n-t);let{left:r,top:a,width:o,height:l}=jr([{x:e,y:t},{x:i,y:n}]),c=new De(r+o/2,a+l/2);this.setPositionByOrigin(c,ui,ui)}_set(e,t){return super._set(e,t),Z_.includes(e)&&this._setWidthHeight(),this}_render(e){e.beginPath();let t=this.calcLinePoints();e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.lineWidth=this.strokeWidth;let i=e.strokeStyle;var n;Ws(this.stroke)?e.strokeStyle=this.stroke.toLive(e):e.strokeStyle=(n=this.stroke)==null?e.fillStyle:n,this.stroke&&this._renderStroke(e),e.strokeStyle=i}_findCenterFromElement(){return new De((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(e=[]){return{...super.toObject(e),...this.calcLinePoints()}}_getNonTransformedDimensions(){let e=super._getNonTransformedDimensions();return this.strokeLineCap==="butt"&&(this.width===0&&(e.y-=this.strokeWidth),this.height===0&&(e.x-=this.strokeWidth)),e}calcLinePoints(){let{x1:e,x2:t,y1:i,y2:n,width:r,height:a}=this,o=e<=t?-.5:.5,l=i<=n?-.5:.5;return{x1:o*r,x2:o*-r,y1:l*a,y2:l*-a}}_toSVG(){let{x1:e,x2:t,y1:i,y2:n}=this.calcLinePoints();return["<line ","COMMON_PARTS",`x1="${e}" y1="${i}" x2="${t}" y2="${n}" />
|
||
`]}static async fromElement(e,t,i){let{x1:n=0,y1:r=0,x2:a=0,y2:o=0,...l}=za(e,this.ATTRIBUTE_NAMES,i);return new this([n,r,a,o],l)}static fromObject({x1:e,y1:t,x2:i,y2:n,...r}){return this._fromObject({...r,points:[e,t,i,n]},{extraParam:"points"})}};ue(Xo,"type","Line"),ue(Xo,"cacheProperties",[...Fa,...Z_]),ue(Xo,"ATTRIBUTE_NAMES",Vo.concat(Z_)),ot.setClass(Xo),ot.setSVGClass(Xo);var Vv=class gw extends Dn{static getDefaults(){return{...super.getDefaults(),...gw.ownDefaults}}constructor(e){super(),Object.assign(this,gw.ownDefaults),this.setOptions(e)}_render(e){let t=this.width/2,i=this.height/2;e.beginPath(),e.moveTo(-t,i),e.lineTo(0,-i),e.lineTo(t,i),e.closePath(),this._renderPaintInOrder(e)}_toSVG(){let e=this.width/2,t=this.height/2;return["<polygon ","COMMON_PARTS",'points="',`${-e} ${t},0 ${-t},${e} ${t}`,'" />']}};ue(Vv,"type","Triangle"),ue(Vv,"ownDefaults",{width:100,height:100}),ot.setClass(Vv),ot.setSVGClass(Vv);const rR=["rx","ry"];var wd=class vw extends Dn{static getDefaults(){return{...super.getDefaults(),...vw.ownDefaults}}constructor(e){super(),Object.assign(this,vw.ownDefaults),this.setOptions(e)}_set(e,t){switch(super._set(e,t),e){case"rx":this.rx=t,this.set("width",2*t);break;case"ry":this.ry=t,this.set("height",2*t)}return this}getRx(){return this.get("rx")*this.get(Uo)}getRy(){return this.get("ry")*this.get(zo)}toObject(e=[]){return super.toObject([...rR,...e])}_toSVG(){return["<ellipse ","COMMON_PARTS",`cx="0" cy="0" rx="${Ot(this.rx)}" ry="${Ot(this.ry)}" />
|
||
`]}_render(e){e.beginPath(),e.save(),e.transform(1,0,0,this.ry/this.rx,0,0),e.arc(0,0,this.rx,0,pr,!1),e.restore(),this._renderPaintInOrder(e)}static async fromElement(e,t,i){let n=za(e,this.ATTRIBUTE_NAMES,i);return n.left=(n.left||0)-n.rx,n.top=(n.top||0)-n.ry,new this(n)}};ue(wd,"type","Ellipse"),ue(wd,"cacheProperties",[...Fa,...rR]),ue(wd,"ownDefaults",{rx:0,ry:0}),ue(wd,"ATTRIBUTE_NAMES",[...Vo,"cx","cy","rx","ry"]),ot.setClass(wd),ot.setSVGClass(wd);const aR={exactBoundingBox:!1};var qo=class Aw extends Dn{static getDefaults(){return{...super.getDefaults(),...Aw.ownDefaults}}constructor(e=[],t={}){super(),ue(this,"strokeDiff",void 0),Object.assign(this,Aw.ownDefaults),this.setOptions(t),this.points=e;let{left:i,top:n}=t;this.initialized=!0,this.setBoundingBox(!0),typeof i=="number"&&this.set("left",i),typeof n=="number"&&this.set("top",n)}isOpen(){return!0}_projectStrokeOnPoints(e){return ED(this.points,e,this.isOpen())}_calcDimensions(e){e={scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:this.strokeMiterLimit,strokeUniform:this.strokeUniform,strokeWidth:this.strokeWidth,...e||{}};let t=this.exactBoundingBox?this._projectStrokeOnPoints(e).map(c=>c.projectedPoint):this.points;if(t.length===0)return{left:0,top:0,width:0,height:0,pathOffset:new De,strokeOffset:new De,strokeDiff:new De};let i=jr(t),n=Op({...e,scaleX:1,scaleY:1}),r=jr(this.points.map(c=>Pn(c,n,!0))),a=new De(this.scaleX,this.scaleY),o=i.left+i.width/2,l=i.top+i.height/2;return this.exactBoundingBox&&(o-=l*Math.tan(Bi(this.skewX)),l-=o*Math.tan(Bi(this.skewY))),{...i,pathOffset:new De(o,l),strokeOffset:new De(r.left,r.top).subtract(new De(i.left,i.top)).multiply(a),strokeDiff:new De(i.width,i.height).subtract(new De(r.width,r.height)).multiply(a)}}_findCenterFromElement(){let e=jr(this.points);return new De(e.left+e.width/2,e.top+e.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(e){let{left:t,top:i,width:n,height:r,pathOffset:a,strokeOffset:o,strokeDiff:l}=this._calcDimensions();this.set({width:n,height:r,pathOffset:a,strokeOffset:o,strokeDiff:l}),e&&this.setPositionByOrigin(new De(t+n/2,i+r/2),"center","center")}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new De(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(e={}){if(this.exactBoundingBox){let a;if(Object.keys(e).some(o=>this.strokeUniform||this.constructor.layoutProperties.includes(o))){var t,i;let{width:o,height:l}=this._calcDimensions(e);a=new De((t=e.width)==null?o:t,(i=e.height)==null?l:i)}else{var n,r;a=new De((n=e.width)==null?this.width:n,(r=e.height)==null?this.height:r)}return a.multiply(new De(e.scaleX||this.scaleX,e.scaleY||this.scaleY))}return super._getTransformedDimensions(e)}_set(e,t){let i=this.initialized&&this[e]!==t,n=super._set(e,t);return this.exactBoundingBox&&i&&((e==="scaleX"||e==="scaleY")&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(e))&&this.setDimensions(),n}toObject(e=[]){return{...super.toObject(e),points:this.points.map(({x:t,y:i})=>({x:t,y:i}))}}_toSVG(){let e=this.pathOffset.x,t=this.pathOffset.y,i=ei.NUM_FRACTION_DIGITS,n=this.points.map(({x:r,y:a})=>`${pi(r-e,i)},${pi(a-t,i)}`).join(" ");return[`<${Ot(this.constructor.type).toLowerCase()} `,"COMMON_PARTS",`points="${n}" />
|
||
`]}_render(e){let t=this.points.length,i=this.pathOffset.x,n=this.pathOffset.y;if(t&&!isNaN(this.points[t-1].y)){e.beginPath(),e.moveTo(this.points[0].x-i,this.points[0].y-n);for(let r=0;r<t;r++){let a=this.points[r];e.lineTo(a.x-i,a.y-n)}!this.isOpen()&&e.closePath(),this._renderPaintInOrder(e)}}complexity(){return this.points.length}static async fromElement(e,t,i){let n=(function(l){if(!l)return[];let c=l.replace(/,/g," ").trim().split(/\s+/),h=[];for(let d=0;d<c.length;d+=2)h.push({x:parseFloat(c[d]),y:parseFloat(c[d+1])});return h})(e.getAttribute("points")),{left:r,top:a,...o}=za(e,this.ATTRIBUTE_NAMES,i);return new this(n,{...o,...t})}static fromObject(e){return this._fromObject(e,{extraParam:"points"})}};ue(qo,"ownDefaults",aR),ue(qo,"type","Polyline"),ue(qo,"layoutProperties",[hd,dd,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),ue(qo,"cacheProperties",[...Fa,"points"]),ue(qo,"ATTRIBUTE_NAMES",[...Vo]),ot.setClass(qo),ot.setSVGClass(qo);var Wv=class extends qo{isOpen(){return!1}};ue(Wv,"ownDefaults",aR),ue(Wv,"type","Polygon"),ot.setClass(Wv),ot.setSVGClass(Wv);var oR=class extends Dn{isEmptyStyles(s){if(!this.styles||s!==void 0&&!this.styles[s])return!0;let e=s===void 0?this.styles:{line:this.styles[s]};for(let t in e)for(let i in e[t])for(let n in e[t][i])return!1;return!0}styleHas(s,e){if(!this.styles||e!==void 0&&!this.styles[e])return!1;let t=e===void 0?this.styles:{0:this.styles[e]};for(let i in t)for(let n in t[i])if(t[i][n][s]!==void 0)return!0;return!1}cleanStyle(s){if(!this.styles)return!1;let e=this.styles,t,i,n=0,r=!0,a=0;for(let o in e){t=0;for(let l in e[o]){let c=e[o][l]||{};n++,c[s]===void 0?r=!1:(i?c[s]!==i&&(r=!1):i=c[s],c[s]===this[s]&&delete c[s]),Object.keys(c).length===0?delete e[o][l]:t++}t===0&&delete e[o]}for(let o=0;o<this._textLines.length;o++)a+=this._textLines[o].length;r&&n===a&&(this[s]=i,this.removeStyle(s))}removeStyle(s){if(!this.styles)return;let e=this.styles,t,i,n;for(i in e){for(n in t=e[i],t)delete t[n][s],Object.keys(t[n]).length===0&&delete t[n];Object.keys(t).length===0&&delete e[i]}}_extendStyles(s,e){let{lineIndex:t,charIndex:i}=this.get2DCursorLocation(s);this._getLineStyle(t)||this._setLineStyle(t);let n=m_({...this._getStyleDeclaration(t,i),...e},r=>r!==void 0);this._setStyleDeclaration(t,i,n)}getSelectionStyles(s,e,t){let i=[];for(let n=s;n<(e||s);n++)i.push(this.getStyleAtPosition(n,t));return i}getStyleAtPosition(s,e){let{lineIndex:t,charIndex:i}=this.get2DCursorLocation(s);return e?this.getCompleteStyleDeclaration(t,i):this._getStyleDeclaration(t,i)}setSelectionStyles(s,e,t){for(let i=e;i<(t||e);i++)this._extendStyles(i,s);this._forceClearCache=!0}_getStyleDeclaration(s,e){var t;let i=this.styles&&this.styles[s];return i&&(t=i[e])!=null?t:{}}getCompleteStyleDeclaration(s,e){return{...dc(this,this.constructor._styleProperties),...this._getStyleDeclaration(s,e)}}_setStyleDeclaration(s,e,t){this.styles[s][e]=t}_deleteStyleDeclaration(s,e){delete this.styles[s][e]}_getLineStyle(s){return!!this.styles[s]}_setLineStyle(s){this.styles[s]={}}_deleteLineStyle(s){delete this.styles[s]}};ue(oR,"_styleProperties",$q);const UK=/ +/g,zK=/"/g;function J_(s,e,t,i,n){return` ${((r,{left:a,top:o,width:l,height:c},h=ei.NUM_FRACTION_DIGITS)=>{let d=Gp(as,r,!1),[u,p,m,v]=[a,o,l,c].map(g=>pi(g,h));return`<rect ${d} x="${u}" y="${p}" width="${m}" height="${v}"></rect>`})(s,{left:e,top:t,width:i,height:n})}
|
||
`}let ew;var Xr=class vf extends oR{static getDefaults(){return{...super.getDefaults(),...vf.ownDefaults}}constructor(e,t){super(),ue(this,"__charBounds",[]),Object.assign(this,vf.ownDefaults),this.setOptions(t),this.styles||(this.styles={}),this.text=e,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){let e=this.path;e&&(e.segmentsInfo=X_(e.path))}_splitText(){let e=this._splitTextIntoLines(this.text);return this.textLines=e.lines,this._textLines=e.graphemeLines,this._unwrappedTextLines=e._unwrappedLines,this._text=e.graphemeText,e}initDimensions(){this._splitText(),this._clearCache(),this.dirty=!0,this.path?(this.width=this.path.width,this.height=this.path.height):(this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.height=this.calcTextHeight()),this.textAlign.includes("justify")&&this.enlargeSpaces()}enlargeSpaces(){let e,t,i,n,r,a,o;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign==="justify"||l!==c-1&&!this.isEndOfWrapping(l))&&(n=0,r=this._textLines[l],t=this.getLineWidth(l),t<this.width&&(o=this.textLines[l].match(this._reSpacesAndTabs)))){i=o.length,e=(this.width-t)/i;for(let h=0;h<=r.length;h++)a=this.__charBounds[l][h],this._reSpaceAndTab.test(r[h])?(a.width+=e,a.kernedWidth+=e,a.left+=n,n+=e):a.left+=n}}isEndOfWrapping(e){return e===this._textLines.length-1}missingNewlineOffset(e){return 1}get2DCursorLocation(e,t){let i=t?this._unwrappedTextLines:this._textLines,n;for(n=0;n<i.length;n++){if(e<=i[n].length)return{lineIndex:n,charIndex:e};e-=i[n].length+this.missingNewlineOffset(n,t)}return{lineIndex:n-1,charIndex:i[n-1].length<e?i[n-1].length:e}}toString(){return`#<Text (${this.complexity()}): { "text": "${this.text}", "fontFamily": "${this.fontFamily}" }>`}_getCacheCanvasDimensions(){let e=super._getCacheCanvasDimensions(),t=this.fontSize;return e.width+=t*e.zoomX,e.height+=t*e.zoomY,e}_render(e){let t=this.path;t&&!t.isNotVisible()&&t._render(e),this._setTextStyles(e),this._renderTextLinesBackground(e),this._renderTextDecoration(e,"underline"),this._renderText(e),this._renderTextDecoration(e,"overline"),this._renderTextDecoration(e,"linethrough")}_renderText(e){this.paintFirst==="stroke"?(this._renderTextStroke(e),this._renderTextFill(e)):(this._renderTextFill(e),this._renderTextStroke(e))}_setTextStyles(e,t,i){if(e.textBaseline="alphabetic",this.path)switch(this.pathAlign){case ui:e.textBaseline="middle";break;case"ascender":e.textBaseline="top";break;case"descender":e.textBaseline=iP}e.font=this._getFontDeclaration(t,i)}calcTextWidth(){let e=this.getLineWidth(0);for(let t=1,i=this._textLines.length;t<i;t++){let n=this.getLineWidth(t);n>e&&(e=n)}return e}_renderTextLine(e,t,i,n,r,a){this._renderChars(e,t,i,n,r,a)}_renderTextLinesBackground(e){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;let t=e.fillStyle,i=this._getLeftOffset(),n=this._getTopOffset();for(let r=0,a=this._textLines.length;r<a;r++){let o=this.getHeightOfLine(r);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",r)){n+=o;continue}let l=this._textLines[r].length,c=this._getLineLeftOffset(r),h,d,u=0,p=0,m=this.getValueOfPropertyAt(r,0,"textBackgroundColor"),v=this.getHeightOfLineImpl(r);for(let g=0;g<l;g++){let f=this.__charBounds[r][g];d=this.getValueOfPropertyAt(r,g,"textBackgroundColor"),this.path?(e.save(),e.translate(f.renderLeft,f.renderTop),e.rotate(f.angle),e.fillStyle=d,d&&e.fillRect(-f.width/2,-v*(1-this._fontSizeFraction),f.width,v),e.restore()):d===m?u+=f.kernedWidth:(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-u),e.fillStyle=m,m&&e.fillRect(h,n,u,v),p=f.left,u=f.width,m=d)}d&&!this.path&&(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-u),e.fillStyle=d,e.fillRect(h,n,u,v)),n+=o}e.fillStyle=t,this._removeShadow(e)}_measureChar(e,t,i,n){let r=Bp.getFontCache(t),a=this._getFontDeclaration(t),o=i?i+e:e,l=i&&a===this._getFontDeclaration(n),c=t.fontSize/this.CACHE_FONT_SIZE,h,d,u,p;if(i&&r.has(i)&&(u=r.get(i)),r.has(e)&&(p=h=r.get(e)),l&&r.has(o)&&(d=r.get(o),p=d-u),h===void 0||u===void 0||d===void 0){let m=(ew||(ew=_s({width:0,height:0}).getContext("2d")),ew);this._setTextStyles(m,t,!0),h===void 0&&(p=h=m.measureText(e).width,r.set(e,h)),u===void 0&&l&&i&&(u=m.measureText(i).width,r.set(i,u)),l&&d===void 0&&(d=m.measureText(o).width,r.set(o,d),p=d-u)}return{width:h*c,kernedWidth:p*c}}getHeightOfChar(e,t){return this.getValueOfPropertyAt(e,t,"fontSize")}measureLine(e){let t=this._measureLine(e);return this.charSpacing!==0&&(t.width-=this._getWidthOfCharSpacing()),t.width<0&&(t.width=0),t}_measureLine(e){let t,i,n=0,r=this.pathSide===fr,a=this.path,o=this._textLines[e],l=o.length,c=Array(l);this.__charBounds[e]=c;for(let h=0;h<l;h++){let d=o[h];i=this._getGraphemeBox(d,e,h,t),c[h]=i,n+=i.kernedWidth,t=d}if(c[l]={left:i?i.left+i.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},a&&a.segmentsInfo){let h=0,d=a.segmentsInfo[a.segmentsInfo.length-1].length;switch(this.textAlign){case mn:h=r?d-n:0;break;case ui:h=(d-n)/2;break;case fr:h=r?0:d-n}h+=this.pathStartOffset*(r?-1:1);for(let u=r?l-1:0;r?u>=0:u<l;r?u--:u++)i=c[u],h>d?h%=d:h<0&&(h+=d),this._setGraphemeOnPath(h,i),h+=i.kernedWidth}return{width:n,numOfSpaces:0}}_setGraphemeOnPath(e,t){let i=e+t.kernedWidth/2,n=this.path,r=HD(n.path,i,n.segmentsInfo);t.renderLeft=r.x-n.pathOffset.x,t.renderTop=r.y-n.pathOffset.y,t.angle=r.angle+(this.pathSide==="right"?Math.PI:0)}_getGraphemeBox(e,t,i,n,r){let a=this.getCompleteStyleDeclaration(t,i),o=n?this.getCompleteStyleDeclaration(t,i-1):{},l=this._measureChar(e,a,n,o),c,h=l.kernedWidth,d=l.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),d+=c,h+=c);let u={width:d,left:0,height:a.fontSize,kernedWidth:h,deltaY:a.deltaY};if(i>0&&!r){let p=this.__charBounds[t][i-1];u.left=p.left+p.width+l.kernedWidth-l.width}return u}getHeightOfLineImpl(e){let t=this.__lineHeights;if(t[e])return t[e];let i=this.getHeightOfChar(e,0);for(let n=1,r=this._textLines[e].length;n<r;n++)i=Math.max(this.getHeightOfChar(e,n),i);return t[e]=i*this._fontSizeMult}getHeightOfLine(e){return this.getHeightOfLineImpl(e)*this.lineHeight}calcTextHeight(){let e=0;for(let t=0,i=this._textLines.length;t<i;t++)e+=t===i-1?this.getHeightOfLineImpl(t):this.getHeightOfLine(t);return e}_getLeftOffset(){return this.direction==="ltr"?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(e,t){e.save();let i=0,n=this._getLeftOffset(),r=this._getTopOffset();for(let a=0,o=this._textLines.length;a<o;a++)this._renderTextLine(t,e,this._textLines[a],n+this._getLineLeftOffset(a),r+i+this.getHeightOfLineImpl(a),a),i+=this.getHeightOfLine(a);e.restore()}_renderTextFill(e){(this.fill||this.styleHas("fill"))&&this._renderTextCommon(e,"fillText")}_renderTextStroke(e){(this.stroke&&this.strokeWidth!==0||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(e),e.save(),this._setLineDash(e,this.strokeDashArray),e.beginPath(),this._renderTextCommon(e,"strokeText"),e.closePath(),e.restore())}_renderChars(e,t,i,n,r,a){let o=this.textAlign.includes(C_),l=this.path,c=!o&&this.charSpacing===0&&this.isEmptyStyles(a)&&!l,h=this.direction==="ltr",d=this.direction==="ltr"?1:-1,u=t.direction,p,m,v,g,f,A="",b=0;if(t.save(),u!==this.direction&&(t.canvas.setAttribute("dir",h?"ltr":"rtl"),t.direction=h?"ltr":"rtl",t.textAlign=h?mn:fr),r-=this.getHeightOfLineImpl(a)*this._fontSizeFraction,c)return this._renderChar(e,t,a,0,i.join(""),n,r),void t.restore();for(let y=0,x=i.length-1;y<=x;y++)g=y===x||this.charSpacing||l,A+=i[y],v=this.__charBounds[a][y],b===0?(n+=d*(v.kernedWidth-v.width),b+=v.width):b+=v.kernedWidth,o&&!g&&this._reSpaceAndTab.test(i[y])&&(g=!0),g||(p=p||this.getCompleteStyleDeclaration(a,y),m=this.getCompleteStyleDeclaration(a,y+1),g=Nv(p,m,!1)),g&&(l?(t.save(),t.translate(v.renderLeft,v.renderTop),t.rotate(v.angle),this._renderChar(e,t,a,y,A,-b/2,0),t.restore()):(f=n,this._renderChar(e,t,a,y,A,f,r)),A="",p=m,n+=d*b,b=0);t.restore()}_applyPatternGradientTransformText(e){let t=this.width+this.strokeWidth,i=this.height+this.strokeWidth,n=_s({width:t,height:i}),r=n.getContext("2d");return n.width=t,n.height=i,r.beginPath(),r.moveTo(0,0),r.lineTo(t,0),r.lineTo(t,i),r.lineTo(0,i),r.closePath(),r.translate(t/2,i/2),r.fillStyle=e.toLive(r),this._applyPatternGradientTransform(r,e),r.fill(),r.createPattern(n,"no-repeat")}handleFiller(e,t,i){let n,r;return Ws(i)?i.gradientUnits==="percentage"||i.gradientTransform||i.patternTransform?(n=-this.width/2,r=-this.height/2,e.translate(n,r),e[t]=this._applyPatternGradientTransformText(i),{offsetX:n,offsetY:r}):(e[t]=i.toLive(e),this._applyPatternGradientTransform(e,i)):(e[t]=i,{offsetX:0,offsetY:0})}_setStrokeStyles(e,{stroke:t,strokeWidth:i}){return e.lineWidth=i,e.lineCap=this.strokeLineCap,e.lineDashOffset=this.strokeDashOffset,e.lineJoin=this.strokeLineJoin,e.miterLimit=this.strokeMiterLimit,this.handleFiller(e,"strokeStyle",t)}_setFillStyles(e,{fill:t}){return this.handleFiller(e,"fillStyle",t)}_renderChar(e,t,i,n,r,a,o){let l=this._getStyleDeclaration(i,n),c=this.getCompleteStyleDeclaration(i,n),h=e==="fillText"&&c.fill,d=e==="strokeText"&&c.stroke&&c.strokeWidth;if(d||h){if(t.save(),t.font=this._getFontDeclaration(c),l.textBackgroundColor&&this._removeShadow(t),l.deltaY&&(o+=l.deltaY),h){let u=this._setFillStyles(t,c);t.fillText(r,a-u.offsetX,o-u.offsetY)}if(d){let u=this._setStrokeStyles(t,c);t.strokeText(r,a-u.offsetX,o-u.offsetY)}t.restore()}}setSuperscript(e,t){this._setScript(e,t,this.superscript)}setSubscript(e,t){this._setScript(e,t,this.subscript)}_setScript(e,t,i){let n=this.get2DCursorLocation(e,!0),r=this.getValueOfPropertyAt(n.lineIndex,n.charIndex,"fontSize"),a=this.getValueOfPropertyAt(n.lineIndex,n.charIndex,"deltaY"),o={fontSize:r*i.size,deltaY:a+r*i.baseline};this.setSelectionStyles(o,e,t)}_getLineLeftOffset(e){let t=this.getLineWidth(e),i=this.width-t,n=this.textAlign,r=this.direction,a=this.isEndOfWrapping(e),o=0;return n==="justify"||n==="justify-center"&&!a||n==="justify-right"&&!a||n==="justify-left"&&!a?0:(n==="center"&&(o=i/2),n==="right"&&(o=i),n==="justify-center"&&(o=i/2),n==="justify-right"&&(o=i),r==="rtl"&&(n==="right"||n==="justify-right"?o=0:n==="left"||n==="justify-left"?o=-i:n!=="center"&&n!=="justify-center"||(o=-i/2)),o)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(e){if(this.__lineWidths[e]!==void 0)return this.__lineWidths[e];let{width:t}=this.measureLine(e);return this.__lineWidths[e]=t,t}_getWidthOfCharSpacing(){return this.charSpacing===0?0:this.fontSize*this.charSpacing/1e3}getValueOfPropertyAt(e,t,i){var n;return(n=this._getStyleDeclaration(e,t)[i])==null?this[i]:n}_renderTextDecoration(e,t){if(!this[t]&&!this.styleHas(t))return;let i=this._getTopOffset(),n=this._getLeftOffset(),r=this.path,a=this._getWidthOfCharSpacing(),o=t==="linethrough"?.5:t==="overline"?1:0,l=this.offsets[t];for(let c=0,h=this._textLines.length;c<h;c++){let d=this.getHeightOfLine(c);if(!this[t]&&!this.styleHas(t,c)){i+=d;continue}let u=this._textLines[c],p=d/this.lineHeight,m=this._getLineLeftOffset(c),v=0,g=0,f=this.getValueOfPropertyAt(c,0,t),A=this.getValueOfPropertyAt(c,0,as),b=this.getValueOfPropertyAt(c,0,"textDecorationColor")||A,y=this.getValueOfPropertyAt(c,0,bd),x=f,_=A,M=b,E=y,w=i+p*(1-this._fontSizeFraction),T=this.getHeightOfChar(c,0),R=this.getValueOfPropertyAt(c,0,"deltaY");for(let I=0,O=u.length;I<O;I++){let N=this.__charBounds[c][I];x=this.getValueOfPropertyAt(c,I,t),_=this.getValueOfPropertyAt(c,I,as),M=this.getValueOfPropertyAt(c,I,"textDecorationColor")||_,E=this.getValueOfPropertyAt(c,I,bd);let G=this.getHeightOfChar(c,I),V=this.getValueOfPropertyAt(c,I,"deltaY");if(r&&x&&_){let H=this.fontSize*E/1e3;e.save(),e.fillStyle=M,e.translate(N.renderLeft,N.renderTop),e.rotate(N.angle),e.fillRect(-N.kernedWidth/2,l*G+V-o*H,N.kernedWidth,H),e.restore()}else if((x!==f||_!==A||M!==b||G!==T||E!==y||V!==R)&&g>0){let H=this.fontSize*y/1e3,J=n+m+v;this.direction==="rtl"&&(J=this.width-J-g),f&&b&&y&&(e.fillStyle=b,e.fillRect(J,w+l*T+R-o*H,g,H)),v=N.left,g=N.width,f=x,b=M,y=E,A=_,T=G,R=V}else g+=N.kernedWidth}let D=n+m+v;this.direction==="rtl"&&(D=this.width-D-g),e.fillStyle=M;let L=this.fontSize*E/1e3;x&&M&&E&&e.fillRect(D,w+l*T+R-o*L,g-a,L),i+=d}this._removeShadow(e)}_getFontDeclaration({fontFamily:e=this.fontFamily,fontStyle:t=this.fontStyle,fontWeight:i=this.fontWeight,fontSize:n=this.fontSize}={},r){let a=e.includes("'")||e.includes('"')||e.includes(",")||vf.genericFonts.includes(e.toLowerCase())?e:`"${e}"`;return[t,i,`${r?this.CACHE_FONT_SIZE:n}px`,a].join(" ")}render(e){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(e)))}graphemeSplit(e){return Sv(e)}_splitTextIntoLines(e){let t=e.split(this._reNewline),i=Array(t.length),n=[`
|
||
`],r=[];for(let a=0;a<t.length;a++)i[a]=this.graphemeSplit(t[a]),r=r.concat(i[a],n);return r.pop(),{_unwrappedLines:i,lines:t,graphemeText:r,graphemeLines:i}}toObject(e=[]){return{...super.toObject([...QP,...e]),styles:MD(this.styles,this.text),...this.path?{path:this.path.toObject()}:{}}}set(e,t){let{textLayoutProperties:i}=this.constructor;super.set(e,t);let n=!1,r=!1;if(typeof e=="object")for(let a in e)a==="path"&&this.setPathInfo(),n=n||i.includes(a),r=r||a==="path";else n=i.includes(e),r=e==="path";return r&&this.setPathInfo(),n&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(e,t,i){let n=za(e,vf.ATTRIBUTE_NAMES,i),{textAnchor:r=mn,textDecoration:a="",dx:o=0,dy:l=0,top:c=0,left:h=0,fontSize:d=16,strokeWidth:u=1,...p}={...t,...n},m=new this(Bv(e.textContent||"").trim(),{left:h+o,top:c+l,underline:a.includes("underline"),overline:a.includes("overline"),linethrough:a.includes("line-through"),strokeWidth:0,fontSize:d,...p}),v=m.getScaledHeight()/m.height,g=((m.height+m.strokeWidth)*m.lineHeight-m.height)*v,f=m.getScaledHeight()+g,A=0;return r==="center"&&(A=m.getScaledWidth()/2),r==="right"&&(A=m.getScaledWidth()),m.set({left:m.left-A,top:m.top-(f-m.fontSize*(.07+m._fontSizeFraction))/m.lineHeight,strokeWidth:u}),m}static fromObject(e){return this._fromObject({...e,styles:SD(e.styles||{},e.text)},{extraParam:"text"})}};ue(Xr,"textLayoutProperties",WP),ue(Xr,"cacheProperties",[...Fa,...QP]),ue(Xr,"ownDefaults",Zq),ue(Xr,"type","Text"),ue(Xr,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),ue(Xr,"ATTRIBUTE_NAMES",Vo.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-decoration-thickness","text-decoration-color","text-anchor")),bD(Xr,[class extends HP{_toSVG(){let s=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(s.textTop,s.textLeft);return this._wrapSVGTextAndBg(e)}toSVG(s){let e=this._createBaseSVGMarkup(this._toSVG(),{reviver:s,noStyle:!0,withShadow:!0}),t=this.path;return t?e+t._createBaseSVGMarkup(t._toSVG(),{reviver:s,withShadow:!0,additionalTransform:gd(this.calcOwnMatrix())}):e}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg({textBgRects:s,textSpans:e}){let t=this.getSvgTextDecoration(this);return[s.join(""),' <text xml:space="preserve" ',`font-family="${Ot(this.fontFamily.replace(zK,"'"))}" `,`font-size="${Ot(this.fontSize)}" `,this.fontStyle?`font-style="${Ot(this.fontStyle)}" `:"",this.fontWeight?`font-weight="${Ot(this.fontWeight)}" `:"",t?`text-decoration="${t}" `:"",this.direction==="rtl"?'direction="rtl" ':"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",e.join(""),`</text>
|
||
`]}_getSVGTextAndBg(s,e){let t=[],i=[],n,r=s;this.backgroundColor&&i.push(J_(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let a=0,o=this._textLines.length;a<o;a++)n=this._getLineLeftOffset(a),this.direction==="rtl"&&(n+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",a))&&this._setSVGTextLineBg(i,a,e+n,r),this._setSVGTextLineText(t,a,e+n,r),r+=this.getHeightOfLine(a);return{textSpans:t,textBgRects:i}}_createTextCharSpan(s,e,t,i,n){let r=ei.NUM_FRACTION_DIGITS,a=this.getSvgSpanStyles(e,s!==s.trim()||!!s.match(UK)),o=a?`style="${a}"`:"",l=e.deltaY,c=l?` dy="${pi(l,r)}" `:"",{angle:h,renderLeft:d,renderTop:u,width:p}=n,m="";if(d!==void 0){let v=p/2;h&&(m=` rotate="${pi(ka(h),r)}"`);let g=hc({angle:ka(h)});g[4]=d,g[5]=u;let f=new De(-v,0).transform(g);t=f.x,i=f.y}return`<tspan x="${pi(t,r)}" y="${pi(i,r)}" ${c}${m}${o}>${Ot(s)}</tspan>`}_setSVGTextLineText(s,e,t,i){let n=this.getHeightOfLine(e),r=this.textAlign.includes(C_),a=this._textLines[e],o,l,c,h,d,u="",p=0;i+=n*(1-this._fontSizeFraction)/this.lineHeight;for(let m=0,v=a.length-1;m<=v;m++)d=m===v||this.charSpacing||this.path,u+=a[m],c=this.__charBounds[e][m],p===0?(t+=c.kernedWidth-c.width,p+=c.width):p+=c.kernedWidth,r&&!d&&this._reSpaceAndTab.test(a[m])&&(d=!0),d||(o=o||this.getCompleteStyleDeclaration(e,m),l=this.getCompleteStyleDeclaration(e,m+1),d=Nv(o,l,!0)),d&&(h=this._getStyleDeclaration(e,m),s.push(this._createTextCharSpan(u,h,t,i,c)),u="",o=l,this.direction==="rtl"?t-=p:t+=p,p=0)}_setSVGTextLineBg(s,e,t,i){let n=this._textLines[e],r=this.getHeightOfLine(e)/this.lineHeight,a,o=0,l=0,c=this.getValueOfPropertyAt(e,0,"textBackgroundColor");for(let h=0;h<n.length;h++){let{left:d,width:u,kernedWidth:p}=this.__charBounds[e][h];a=this.getValueOfPropertyAt(e,h,"textBackgroundColor"),a===c?o+=p:(c&&s.push(J_(c,t+l,i,o,r)),l=d,o=u,c=a)}a&&s.push(J_(c,t+l,i,o,r))}getSvgStyles(s){let e=this.textDecorationColor?` text-decoration-color: ${Ot(this[Ov])};`:"";return`${super.getSvgStyles(s)} text-decoration-thickness: ${pi(this.textDecorationThickness*this.getObjectScaling().y/10,ei.NUM_FRACTION_DIGITS)}%;${e} white-space: pre;`}getSvgSpanStyles(s,e){let{fontFamily:t,strokeWidth:i,stroke:n,fill:r,fontSize:a,fontStyle:o,fontWeight:l,textDecorationThickness:c,textDecorationColor:h,linethrough:d,overline:u,underline:p}=s,m=this.getSvgTextDecoration({underline:p??this.underline,overline:u??this.overline,linethrough:d??this.linethrough}),v=c||this.textDecorationThickness,g=h||this.textDecorationColor;return[n?Gp(La,n):"",i?`stroke-width: ${Ot(i)}; `:"",t?`font-family: ${t.includes("'")||t.includes('"')?Ot(t):`'${Ot(t)}'`}; `:"",a?`font-size: ${Ot(a)}px; `:"",o?`font-style: ${Ot(o)}; `:"",l?`font-weight: ${Ot(l)}; `:"",m?`text-decoration: ${m}; text-decoration-thickness: ${pi(v*this.getObjectScaling().y/10,ei.NUM_FRACTION_DIGITS)}%;${g?` text-decoration-color: ${Ot(g)};`:""} `:"",r?Gp(as,r):"",e?"white-space: pre; ":""].join("")}getSvgTextDecoration(s){return["overline","underline","line-through"].filter(e=>s[e.replace("-","")]).join(" ")}}]),ot.setClass(Xr),ot.setSVGClass(Xr);var HK=class{constructor(s){ue(this,"target",void 0),ue(this,"__mouseDownInPlace",!1),ue(this,"__dragStartFired",!1),ue(this,"__isDraggingOver",!1),ue(this,"__dragStartSelection",void 0),ue(this,"__dragImageDisposer",void 0),ue(this,"_dispose",void 0),this.target=s;let e=[this.target.on("dragenter",this.dragEnterHandler.bind(this)),this.target.on("dragover",this.dragOverHandler.bind(this)),this.target.on("dragleave",this.dragLeaveHandler.bind(this)),this.target.on("dragend",this.dragEndHandler.bind(this)),this.target.on("drop",this.dropHandler.bind(this))];this._dispose=()=>{e.forEach(t=>t()),this._dispose=void 0}}isPointerOverSelection(s){let e=this.target,t=e.getSelectionStartFromPointer(s);return e.isEditing&&t>=e.selectionStart&&t<=e.selectionEnd&&e.selectionStart<e.selectionEnd}start(s){return this.__mouseDownInPlace=this.isPointerOverSelection(s)}isActive(){return this.__mouseDownInPlace}end(s){let e=this.isActive();return e&&!this.__dragStartFired&&(this.target.setCursorByClick(s),this.target.initDelayedCursor(!0)),this.__mouseDownInPlace=!1,this.__dragStartFired=!1,this.__isDraggingOver=!1,e}getDragStartSelection(){return this.__dragStartSelection}setDragImage(s,{selectionStart:e,selectionEnd:t}){var i;let n=this.target,r=n.canvas,a=new De(n.flipX?-1:1,n.flipY?-1:1),o=n._getCursorBoundaries(e),l=new De(o.left+o.leftOffset,o.top+o.topOffset).multiply(a).transform(n.calcTransformMatrix()),c=r.getScenePoint(s).subtract(l),h=n.getCanvasRetinaScaling(),d=n.getBoundingRect(),u=l.subtract(new De(d.left,d.top)),p=r.viewportTransform,m=u.add(c).transform(p,!0),v=n.backgroundColor,g=z_(n.styles);n.backgroundColor="";let f={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};n.setSelectionStyles(f,0,e),n.setSelectionStyles(f,t,n.text.length),n.dirty=!0;let A=n.toCanvasElement({enableRetinaScaling:r.enableRetinaScaling,viewportTransform:!0});n.backgroundColor=v,n.styles=g,n.dirty=!0,q_(A,{position:"fixed",left:-A.width+"px",border:bv,width:A.width/h+"px",height:A.height/h+"px"}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{A.remove()},vr(s.target||this.target.hiddenTextarea).body.appendChild(A),(i=s.dataTransfer)==null||i.setDragImage(A,m.x,m.y)}onDragStart(s){this.__dragStartFired=!0;let e=this.target,t=this.isActive();if(t&&s.dataTransfer){let i=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},n=e._text.slice(i.selectionStart,i.selectionEnd).join(""),r={text:e.text,value:n,...i};s.dataTransfer.setData("text/plain",n),s.dataTransfer.setData("application/fabric",JSON.stringify({value:n,styles:e.getSelectionStyles(i.selectionStart,i.selectionEnd,!0)})),s.dataTransfer.effectAllowed="copyMove",this.setDragImage(s,r)}return e.abortCursorAnimation(),t}canDrop(s){if(this.target.editable&&!this.target.getActiveControl()&&!s.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){let e=this.target.getSelectionStartFromPointer(s),t=this.__dragStartSelection;return e<t.selectionStart||e>t.selectionEnd}return!0}return!1}targetCanDrop(s){return this.target.canDrop(s)}dragEnterHandler({e:s}){let e=this.targetCanDrop(s);!this.__isDraggingOver&&e&&(this.__isDraggingOver=!0)}dragOverHandler(s){let{e}=s,t=this.targetCanDrop(e);!this.__isDraggingOver&&t?this.__isDraggingOver=!0:this.__isDraggingOver&&!t&&(this.__isDraggingOver=!1),this.__isDraggingOver&&(e.preventDefault(),s.canDrop=!0,s.dropTarget=this.target)}dragLeaveHandler(){(this.__isDraggingOver||this.isActive())&&(this.__isDraggingOver=!1)}dropHandler(s){var e;let{e:t}=s,i=t.defaultPrevented;this.__isDraggingOver=!1,t.preventDefault();let n=(e=t.dataTransfer)==null?void 0:e.getData("text/plain");if(n&&!i){let r=this.target,a=r.canvas,o=r.getSelectionStartFromPointer(t),{styles:l}=t.dataTransfer.types.includes("application/fabric")?JSON.parse(t.dataTransfer.getData("application/fabric")):{},c=n[Math.max(0,n.length-1)];if(this.__dragStartSelection){let h=this.__dragStartSelection.selectionStart,d=this.__dragStartSelection.selectionEnd;o>h&&o<=d?o=h:o>d&&(o-=d-h),r.removeChars(h,d),delete this.__dragStartSelection}r._reNewline.test(c)&&(r._reNewline.test(r._text[o])||o===r._text.length)&&(n=n.trimEnd()),s.didDrop=!0,s.dropTarget=r,r.insertChars(n,l,o),a.setActiveObject(r),r.enterEditing(t),r.selectionStart=Math.min(o+0,r._text.length),r.selectionEnd=Math.min(r.selectionStart+n.length,r._text.length),r.hiddenTextarea.value=r.text,r._updateTextarea(),r.hiddenTextarea.focus(),r.fire(xv,{index:o+0,action:"drop"}),a.fire("text:changed",{target:r}),a.contextTopDirty=!0,a.requestRenderAll()}}dragEndHandler({e:s}){if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var e;let t=this.target,i=this.target.canvas,{selectionStart:n,selectionEnd:r}=this.__dragStartSelection,a=((e=s.dataTransfer)==null?void 0:e.dropEffect)||"none";a==="none"?(t.selectionStart=n,t.selectionEnd=r,t._updateTextarea(),t.hiddenTextarea.focus()):(t.clearContextTop(),a==="move"&&(t.removeChars(n,r),t.selectionStart=t.selectionEnd=n,t.hiddenTextarea&&(t.hiddenTextarea.value=t.text),t._updateTextarea(),t.fire(xv,{index:n,action:"dragend"}),i.fire("text:changed",{target:t}),i.requestRenderAll()),t.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}};const lR=/[ \n\.,;!\?\-]/;var GK=class extends Xr{constructor(...s){super(...s),ue(this,"_currentCursorOpacity",1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(s){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(s)}_animateCursor({toValue:s,duration:e,delay:t,onComplete:i}){return R_({startValue:this._currentCursorOpacity,endValue:s,duration:e,delay:t,onComplete:i,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:n=>{this._currentCursorOpacity=n,this.renderCursorOrSelection()}})}_tick(s){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(s||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var s;(s=this._currentTickCompleteState)==null||s.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(s){this.abortCursorAnimation(),this._tick(s?0:this.cursorDelay)}abortCursorAnimation(){let s=!1;[this._currentTickState,this._currentTickCompleteState].forEach(e=>{e&&!e.isDone()&&(s=!0,e.abort())}),this._currentCursorOpacity=1,s&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some(s=>!s||s.isDone())&&this.initDelayedCursor()}selectAll(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this}cmdAll(){this.selectAll(),this.renderCursorOrSelection()}getSelectedText(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")}findWordBoundaryLeft(s){let e=0,t=s-1;if(this._reSpace.test(this._text[t]))for(;this._reSpace.test(this._text[t]);)e++,t--;for(;/\S/.test(this._text[t])&&t>-1;)e++,t--;return s-e}findWordBoundaryRight(s){let e=0,t=s;if(this._reSpace.test(this._text[t]))for(;this._reSpace.test(this._text[t]);)e++,t++;for(;/\S/.test(this._text[t])&&t<this._text.length;)e++,t++;return s+e}findLineBoundaryLeft(s){let e=0,t=s-1;for(;!/\n/.test(this._text[t])&&t>-1;)e++,t--;return s-e}findLineBoundaryRight(s){let e=0,t=s;for(;!/\n/.test(this._text[t])&&t<this._text.length;)e++,t++;return s+e}searchWordBoundary(s,e){let t=this._text,i=s>0&&this._reSpace.test(t[s])&&(e===-1||!c_.test(t[s-1]))?s-1:s,n=t[i];for(;i>0&&i<t.length&&!lR.test(n);)i+=e,n=t[i];return e===-1&&lR.test(n)&&i++,i}selectWord(s){var e;s=(e=s)==null?this.selectionStart:e;let t=this.searchWordBoundary(s,-1),i=Math.max(t,this.searchWordBoundary(s,1));this.selectionStart=t,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(s){var e;s=(e=s)==null?this.selectionStart:e;let t=this.findLineBoundaryLeft(s),i=this.findLineBoundaryRight(s);this.selectionStart=t,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea()}enterEditing(s){!this.isEditing&&this.editable&&(this.enterEditingImpl(),this.fire("editing:entered",s?{e:s}:void 0),this._fireSelectionChanged(),this.canvas&&(this.canvas.fire("text:editing:entered",{target:this,e:s}),this.canvas.requestRenderAll()))}enterEditingImpl(){this.canvas&&(this.canvas.calcOffset(),this.canvas.textEditingManager.exitTextEditing()),this.isEditing=!0,this.initHiddenTextarea(),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick()}updateSelectionOnMouseMove(s){if(this.getActiveControl())return;let e=this.hiddenTextarea;vr(e).activeElement!==e&&e.focus();let t=this.getSelectionStartFromPointer(s),i=this.selectionStart,n=this.selectionEnd;(t===this.__selectionStartOnMouseDown&&i!==n||i!==t&&n!==t)&&(t>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=t):(this.selectionStart=t,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===i&&this.selectionEnd===n||(this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}_setEditingProps(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0}fromStringToGraphemeSelection(s,e,t){let i=t.slice(0,s),n=this.graphemeSplit(i).length;if(s===e)return{selectionStart:n,selectionEnd:n};let r=t.slice(s,e);return{selectionStart:n,selectionEnd:n+this.graphemeSplit(r).length}}fromGraphemeToStringSelection(s,e,t){let i=t.slice(0,s).join("").length;return s===e?{selectionStart:i,selectionEnd:i}:{selectionStart:i,selectionEnd:i+t.slice(s,e).join("").length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){let s=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=s.selectionStart,this.hiddenTextarea.selectionEnd=s.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){let{hiddenTextarea:s,direction:e,textAlign:t,inCompositionMode:i}=this;if(!s)return;let n=t==="justify"?e==="ltr"?mn:fr:t.replace("justify-",""),r=this.getPositionByOrigin(n,"top");this.cursorOffsetCache={},this.text=s.value,this.set("dirty",!0),this.initDimensions(),this.setPositionByOrigin(r,n,"top"),this.setCoords();let a=this.fromStringToGraphemeSelection(s.selectionStart,s.selectionEnd,s.value);this.selectionEnd=this.selectionStart=a.selectionEnd,i||(this.selectionStart=a.selectionStart),this.updateTextareaPosition()}updateTextareaPosition(){if(this.selectionStart===this.selectionEnd){let s=this._calcTextareaPosition();this.hiddenTextarea.style.left=s.left,this.hiddenTextarea.style.top=s.top}}_calcTextareaPosition(){if(!this.canvas)return{left:"1px",top:"1px"};let s=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(s),t=this.get2DCursorLocation(s),i=t.lineIndex,n=t.charIndex,r=this.getValueOfPropertyAt(i,n,"fontSize")*this.lineHeight,a=e.leftOffset,o=this.getCanvasRetinaScaling(),l=this.canvas.upperCanvasEl,c=l.width/o,h=l.height/o,d=c-r,u=h-r,p=new De(e.left+a,e.top+e.topOffset+r).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new De(l.clientWidth/c,l.clientHeight/h));return p.x<0&&(p.x=0),p.x>d&&(p.x=d),p.y<0&&(p.y=0),p.y>u&&(p.y=u),p.x+=this.canvas._offset.left,p.y+=this.canvas._offset.top,{left:`${p.x}px`,top:`${p.y}px`,fontSize:`${r}px`,charHeight:r}}_saveEditingProps(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}}_restoreEditingProps(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor||this.canvas.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor||this.canvas.moveCursor),delete this._savedProps)}exitEditingImpl(){let s=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,s&&(s.blur&&s.blur(),s.parentNode&&s.parentNode.removeChild(s)),this.hiddenTextarea=null,this.abortCursorAnimation(),this.selectionStart!==this.selectionEnd&&this.clearContextTop(),this.selectionEnd=this.selectionStart,this._restoreEditingProps(),this._forceClearCache&&(this.initDimensions(),this.setCoords())}exitEditing(){let s=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire("editing:exited"),s&&this.fire("modified"),this.canvas&&(this.canvas.fire("text:editing:exited",{target:this}),s&&this.canvas.fire("object:modified",{target:this})),this}_removeExtraneousStyles(){for(let s in this.styles)this._textLines[s]||delete this.styles[s]}removeStyleFromTo(s,e){let{lineIndex:t,charIndex:i}=this.get2DCursorLocation(s,!0),{lineIndex:n,charIndex:r}=this.get2DCursorLocation(e,!0);if(t!==n){if(this.styles[t])for(let a=i;a<this._unwrappedTextLines[t].length;a++)delete this.styles[t][a];if(this.styles[n])for(let a=r;a<this._unwrappedTextLines[n].length;a++){let o=this.styles[n][a];o&&(this.styles[t]||(this.styles[t]={}),this.styles[t][i+a-r]=o)}for(let a=t+1;a<=n;a++)delete this.styles[a];this.shiftLineStyles(n,t-n)}else if(this.styles[t]){let a=this.styles[t],o=r-i;for(let l=i;l<r;l++)delete a[l];for(let l in this.styles[t]){let c=parseInt(l,10);c>=r&&(a[c-o]=a[l],delete a[l])}}}shiftLineStyles(s,e){let t=Object.assign({},this.styles);for(let i in this.styles){let n=parseInt(i,10);n>s&&(this.styles[n+e]=t[n],t[n-e]||delete this.styles[n])}}insertNewlineStyleObject(s,e,t,i){let n={},r=this._unwrappedTextLines[s].length,a=r===e,o=!1;t||(t=1),this.shiftLineStyles(s,t);let l=this.styles[s]?this.styles[s][e===0?e:e-1]:void 0;for(let h in this.styles[s]){let d=parseInt(h,10);d>=e&&(o=!0,n[d-e]=this.styles[s][h],a&&e===0||delete this.styles[s][h])}let c=!1;for(o&&!a&&(this.styles[s+t]=n,c=!0),(c||r>e)&&t--;t>0;)i&&i[t-1]?this.styles[s+t]={0:{...i[t-1]}}:l?this.styles[s+t]={0:{...l}}:delete this.styles[s+t],t--;this._forceClearCache=!0}insertCharStyleObject(s,e,t,i){this.styles||(this.styles={});let n=this.styles[s],r=n?{...n}:{};t||(t=1);for(let o in r){let l=parseInt(o,10);l>=e&&(n[l+t]=r[l],r[l-t]||delete n[l])}if(this._forceClearCache=!0,i){for(;t--;)Object.keys(i[t]).length&&(this.styles[s]||(this.styles[s]={}),this.styles[s][e+t]={...i[t]});return}if(!n)return;let a=n[e?e-1:1];for(;a&&t--;)this.styles[s][e+t]={...a}}insertNewStyleBlock(s,e,t){let i=this.get2DCursorLocation(e,!0),n=[0],r,a=0;for(let o=0;o<s.length;o++)s[o]===`
|
||
`?(a++,n[a]=0):n[a]++;for(n[0]>0&&(this.insertCharStyleObject(i.lineIndex,i.charIndex,n[0],t),t=t&&t.slice(n[0]+1)),a&&this.insertNewlineStyleObject(i.lineIndex,i.charIndex+n[0],a),r=1;r<a;r++)n[r]>0?this.insertCharStyleObject(i.lineIndex+r,0,n[r],t):t&&this.styles[i.lineIndex+r]&&t[0]&&(this.styles[i.lineIndex+r][0]=t[0]),t=t&&t.slice(n[r]+1);n[r]>0&&this.insertCharStyleObject(i.lineIndex+r,0,n[r],t)}removeChars(s,e=s+1){this.removeStyleFromTo(s,e),this._text.splice(s,e-s),this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(s,e,t,i=t){i>t&&this.removeStyleFromTo(t,i);let n=this.graphemeSplit(s);this.insertNewStyleBlock(n,t,e),this._text=[...this._text.slice(0,t),...n,...this._text.slice(i)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(s,e,t){t<=s?(e===s?this._selectionDirection=mn:this._selectionDirection==="right"&&(this._selectionDirection=mn,this.selectionEnd=s),this.selectionStart=t):t>s&&t<e?this._selectionDirection==="right"?this.selectionEnd=t:this.selectionStart=t:(e===s?this._selectionDirection=fr:this._selectionDirection==="left"&&(this._selectionDirection=fr,this.selectionStart=e),this.selectionEnd=t)}},VK=class extends GK{initHiddenTextarea(){let s=this.canvas&&vr(this.canvas.getElement())||ld(),e=s.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off",name:"fabricTextarea"}).map(([r,a])=>e.setAttribute(r,a));let{top:t,left:i,fontSize:n}=this._calcTextareaPosition();e.style.cssText=`position: absolute; top: ${t}; left: ${i}; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ${n};`,(this.hiddenTextareaContainer||s.body).appendChild(e),Object.entries({blur:"blur",keydown:"onKeyDown",keyup:"onKeyUp",input:"onInput",copy:"copy",cut:"copy",paste:"paste",compositionstart:"onCompositionStart",compositionupdate:"onCompositionUpdate",compositionend:"onCompositionEnd"}).map(([r,a])=>e.addEventListener(r,this[a].bind(this))),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(s){if(!this.isEditing)return;let e=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(s.keyCode in e)this[e[s.keyCode]](s);else{if(!(s.keyCode in this.ctrlKeysMapDown)||!s.ctrlKey&&!s.metaKey)return;this[this.ctrlKeysMapDown[s.keyCode]](s)}s.stopImmediatePropagation(),s.preventDefault(),s.keyCode>=33&&s.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(s){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:s.keyCode in this.ctrlKeysMapUp&&(s.ctrlKey||s.metaKey)&&(this[this.ctrlKeysMapUp[s.keyCode]](s),s.stopImmediatePropagation(),s.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(s){let e=this.fromPaste,{value:t,selectionStart:i,selectionEnd:n}=this.hiddenTextarea;if(this.fromPaste=!1,s&&s.stopPropagation(),!this.isEditing)return;let r=()=>{this.updateFromTextArea(),this.fire(xv),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(this.hiddenTextarea.value==="")return this.styles={},void r();let a=this._splitTextIntoLines(t).graphemeText,o=this._text.length,l=a.length,c=this.selectionStart,h=this.selectionEnd,d=c!==h,u,p,m,v,g=l-o,f=this.fromStringToGraphemeSelection(i,n,t),A=c>f.selectionStart;d?(p=this._text.slice(c,h),g+=h-c):l<o&&(p=A?this._text.slice(h+g,h):this._text.slice(c,c-g));let b=a.slice(f.selectionEnd-g,f.selectionEnd);if(p&&p.length&&(b.length&&(u=this.getSelectionStyles(c,c+1,!1),u=b.map(()=>u[0])),d?(m=c,v=h):A?(m=h-p.length,v=h):(m=h,v=h+p.length),this.removeStyleFromTo(m,v)),b.length){let{copyPasteData:y}=Wr();e&&b.join("")===y.copiedText&&!ei.disableStyleCopyPaste&&(u=y.copiedTextStyle),this.insertNewStyleBlock(b,c,u)}r()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate({target:s}){let{selectionStart:e,selectionEnd:t}=s;this.compositionStart=e,this.compositionEnd=t,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;let{copyPasteData:s}=Wr();s.copiedText=this.getSelectedText(),ei.disableStyleCopyPaste?s.copiedTextStyle=void 0:s.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0}paste(){this.fromPaste=!0}_getWidthBeforeCursor(s,e){let t,i=this._getLineLeftOffset(s);return e>0&&(t=this.__charBounds[s][e-1],i+=t.left+t.width),i}getDownCursorOffset(s,e){let t=this._getSelectionForOffset(s,e),i=this.get2DCursorLocation(t),n=i.lineIndex;if(n===this._textLines.length-1||s.metaKey||s.keyCode===34)return this._text.length-t;let r=i.charIndex,a=this._getWidthBeforeCursor(n,r),o=this._getIndexOnLine(n+1,a);return this._textLines[n].slice(r).length+o+1+this.missingNewlineOffset(n)}_getSelectionForOffset(s,e){return s.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(s,e){let t=this._getSelectionForOffset(s,e),i=this.get2DCursorLocation(t),n=i.lineIndex;if(n===0||s.metaKey||s.keyCode===33)return-t;let r=i.charIndex,a=this._getWidthBeforeCursor(n,r),o=this._getIndexOnLine(n-1,a),l=this._textLines[n].slice(0,r),c=this.missingNewlineOffset(n-1);return-this._textLines[n-1].length+o-l.length+(1-c)}_getIndexOnLine(s,e){let t=this._textLines[s],i,n,r=this._getLineLeftOffset(s),a=0;for(let o=0,l=t.length;o<l;o++)if(i=this.__charBounds[s][o].width,r+=i,r>e){n=!0;let c=r-i,h=r,d=Math.abs(c-e);a=Math.abs(h-e)<d?o:o-1;break}return n||(a=t.length-1),a}moveCursorDown(s){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",s)}moveCursorUp(s){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",s)}_moveCursorUpOrDown(s,e){let t=this[`get${s}CursorOffset`](e,this._selectionDirection===fr);if(e.shiftKey?this.moveCursorWithShift(t):this.moveCursorWithoutShift(t),t!==0){let i=this.text.length;this.selectionStart=mc(0,this.selectionStart,i),this.selectionEnd=mc(0,this.selectionEnd,i),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(s){let e=this._selectionDirection==="left"?this.selectionStart+s:this.selectionEnd+s;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),s!==0}moveCursorWithoutShift(s){return s<0?(this.selectionStart+=s,this.selectionEnd=this.selectionStart):(this.selectionEnd+=s,this.selectionStart=this.selectionEnd),s!==0}moveCursorLeft(s){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",s)}_move(s,e,t){let i;if(s.altKey)i=this[`findWordBoundary${t}`](this[e]);else{if(!s.metaKey&&s.keyCode!==35&&s.keyCode!==36)return this[e]+=t==="Left"?-1:1,!0;i=this[`findLineBoundary${t}`](this[e])}return i!==void 0&&this[e]!==i&&(this[e]=i,!0)}_moveLeft(s,e){return this._move(s,e,"Left")}_moveRight(s,e){return this._move(s,e,"Right")}moveCursorLeftWithoutShift(s){let e=!0;return this._selectionDirection=mn,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(s,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(s){return this._selectionDirection==="right"&&this.selectionStart!==this.selectionEnd?this._moveLeft(s,"selectionEnd"):this.selectionStart===0?void 0:(this._selectionDirection=mn,this._moveLeft(s,"selectionStart"))}moveCursorRight(s){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",s)}_moveCursorLeftOrRight(s,e){let t=`moveCursor${s}${e.shiftKey?"WithShift":"WithoutShift"}`;this._currentCursorOpacity=1,this[t](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(s){return this._selectionDirection==="left"&&this.selectionStart!==this.selectionEnd?this._moveRight(s,"selectionStart"):this.selectionEnd===this._text.length?void 0:(this._selectionDirection=fr,this._moveRight(s,"selectionEnd"))}moveCursorRightWithoutShift(s){let e=!0;return this._selectionDirection=fr,this.selectionStart===this.selectionEnd?(e=this._moveRight(s,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}};const cR=s=>!!s.button;var WK=class extends VK{constructor(...s){super(...s),ue(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("mousetripleclick",this.tripleClickHandler),this.draggableTextDelegate=new HK(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(s){return this.draggableTextDelegate.onDragStart(s)}canDrop(s){return this.draggableTextDelegate.canDrop(s)}doubleClickHandler(s){this.isEditing&&(this.selectWord(this.getSelectionStartFromPointer(s.e)),this.renderCursorOrSelection())}tripleClickHandler(s){this.isEditing&&(this.selectLine(this.getSelectionStartFromPointer(s.e)),this.renderCursorOrSelection())}_mouseDownHandler({e:s,alreadySelected:e}){this.canvas&&this.editable&&!cR(s)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(s)||(this.canvas.textEditingManager.register(this),e&&(this.inCompositionMode=!1,this.setCursorByClick(s)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||(this.selected=e||this.isEditing)))}mouseUpHandler({e:s,transform:e}){let t=this.draggableTextDelegate.end(s);if(this.canvas){this.canvas.textEditingManager.unregister(this);let i=this.canvas._activeObject;if(i&&i!==this)return}!this.editable||this.group&&!this.group.interactive||e&&e.actionPerformed||cR(s)||t||this.selected&&!this.getActiveControl()&&(this.enterEditing(s),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection())}setCursorByClick(s){let e=this.getSelectionStartFromPointer(s),t=this.selectionStart,i=this.selectionEnd;s.shiftKey?this.setSelectionStartEndWithShift(t,i,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(s){let e=this.canvas.getScenePoint(s).transform(ws(this.calcTransformMatrix())).add(new De(-this._getLeftOffset(),-this._getTopOffset())),t=0,i=0,n=0;for(let l=0;l<this._textLines.length&&t<=e.y;l++)t+=this.getHeightOfLine(l),n=l,l>0&&(i+=this._textLines[l-1].length+this.missingNewlineOffset(l-1));let r=Math.abs(this._getLineLeftOffset(n)),a=this._textLines[n].length,o=this.__charBounds[n];for(let l=0;l<a;l++){let c=r+o[l].kernedWidth;if(e.x<=c){Math.abs(e.x-c)<=Math.abs(e.x-r)&&i++;break}r=c,i++}return Math.min(this.flipX?a-i:i,this._text.length)}};const Qv="moveCursorUp",jv="moveCursorDown",Xv="moveCursorLeft",qv="moveCursorRight",Yv="exitEditing",hR=(s,e)=>{let t=e.getRetinaScaling();s.setTransform(t,0,0,t,0,0);let i=e.viewportTransform;s.transform(i[0],i[1],i[2],i[3],i[4],i[5])},QK={selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,keysMap:{9:Yv,27:Yv,33:Qv,34:jv,35:qv,36:Xv,37:Xv,38:Qv,39:qv,40:jv},keysMapRtl:{9:Yv,27:Yv,33:Qv,34:jv,35:Xv,36:qv,37:qv,38:Qv,39:Xv,40:jv},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"},_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1};var bc=class bw extends WK{static getDefaults(){return{...super.getDefaults(),...bw.ownDefaults}}get type(){let e=super.type;return e==="itext"?"i-text":e}constructor(e,t){super(e,{...bw.ownDefaults,...t}),this.initBehavior()}_set(e,t){return this.isEditing&&this._savedProps&&e in this._savedProps?(this._savedProps[e]=t,this):(e==="canvas"&&(this.canvas instanceof K_&&this.canvas.textEditingManager.remove(this),t instanceof K_&&t.textEditingManager.add(this)),super._set(e,t))}setSelectionStart(e){e=Math.max(e,0),this._updateAndFire("selectionStart",e)}setSelectionEnd(e){e=Math.min(e,this.text.length),this._updateAndFire("selectionEnd",e)}_updateAndFire(e,t){this[e]!==t&&(this._fireSelectionChanged(),this[e]=t),this._updateTextarea()}_fireSelectionChanged(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})}initDimensions(){this.isEditing&&this.initDelayedCursor(),super.initDimensions()}getSelectionStyles(e=this.selectionStart||0,t=this.selectionEnd,i){return super.getSelectionStyles(e,t,i)}setSelectionStyles(e,t=this.selectionStart||0,i=this.selectionEnd){return super.setSelectionStyles(e,t,i)}get2DCursorLocation(e=this.selectionStart,t){return super.get2DCursorLocation(e,t)}render(e){super.render(e),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(e){let t=this.isEditing;this.isEditing=!1;let i=super.toCanvasElement(e);return this.isEditing=t,i}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;let e=this.clearContextTop(!0);if(!e)return;let t=this._getCursorBoundaries(),i=this.findAncestorsWithClipPath(),n=i.length>0,r,a=e;if(n){r=_s(e.canvas),a=r.getContext("2d"),hR(a,this.canvas);let o=this.calcTransformMatrix();a.transform(o[0],o[1],o[2],o[3],o[4],o[5])}if(this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(a,t):this.renderCursor(a,t),n)for(let o of i){let l=o.clipPath,c=_s(e.canvas),h=c.getContext("2d");if(hR(h,this.canvas),!l.absolutePositioned){let d=o.calcTransformMatrix();h.transform(d[0],d[1],d[2],d[3],d[4],d[5])}l.transform(h),l.drawObject(h,!0,{}),this.drawClipPathOnCache(a,l,c)}n&&(e.setTransform(1,0,0,1,0,0),e.drawImage(r,0,0)),this.canvas.contextTopDirty=!0,e.restore()}findAncestorsWithClipPath(){let e=[],t=this;for(;t;)t.clipPath&&e.push(t),t=t.parent;return e}_getCursorBoundaries(e=this.selectionStart,t){let i=this._getLeftOffset(),n=this._getTopOffset(),r=this._getCursorBoundariesOffsets(e,t);return{left:i,top:n,leftOffset:r.left,topOffset:r.top}}_getCursorBoundariesOffsets(e,t){return t?this.__getCursorBoundariesOffsets(e):this.cursorOffsetCache&&"top"in this.cursorOffsetCache?this.cursorOffsetCache:this.cursorOffsetCache=this.__getCursorBoundariesOffsets(e)}__getCursorBoundariesOffsets(e){let t=0,i=0,{charIndex:n,lineIndex:r}=this.get2DCursorLocation(e),{textAlign:a,direction:o}=this;for(let d=0;d<r;d++)t+=this.getHeightOfLine(d);let l=this._getLineLeftOffset(r),c=this.__charBounds[r][n];c&&(i=c.left),this.charSpacing!==0&&n===this._textLines[r].length&&(i-=this._getWidthOfCharSpacing());let h=l+(i>0?i:0);return o==="rtl"&&(a==="right"||a==="justify"||a==="justify-right"?h*=-1:a==="left"||a==="justify-left"?h=l-(i>0?i:0):a!=="center"&&a!=="justify-center"||(h=l-(i>0?i:0))),{top:t,left:h}}renderCursorAt(e){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(e,!0),e)}renderCursor(e,t){this._renderCursor(e,t,this.selectionStart)}getCursorRenderingData(e=this.selectionStart,t=this._getCursorBoundaries(e)){let i=this.get2DCursorLocation(e),n=i.lineIndex,r=i.charIndex>0?i.charIndex-1:0,a=this.getValueOfPropertyAt(n,r,"fontSize"),o=this.getObjectScaling().x*this.canvas.getZoom(),l=this.cursorWidth/o,c=this.getValueOfPropertyAt(n,r,"deltaY"),h=t.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(n)/this.lineHeight-a*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(n,r,"fill"),opacity:this._currentCursorOpacity,left:t.left+t.leftOffset-l/2,top:h+t.top+c,width:l,height:a}}_renderCursor(e,t,i){let{color:n,opacity:r,left:a,top:o,width:l,height:c}=this.getCursorRenderingData(i,t);e.fillStyle=n,e.globalAlpha=r,e.fillRect(a,o,l,c)}renderSelection(e,t){let i={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(e,i,t)}renderDragSourceEffect(){let e=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,e,this._getCursorBoundaries(e.selectionStart,!0))}renderDropTargetEffect(e){let t=this.getSelectionStartFromPointer(e);this.renderCursorAt(t)}_renderSelection(e,t,i){let{textAlign:n,direction:r}=this,a=t.selectionStart,o=t.selectionEnd,l=n.includes(C_),c=this.get2DCursorLocation(a),h=this.get2DCursorLocation(o),d=c.lineIndex,u=h.lineIndex,p=c.charIndex<0?0:c.charIndex,m=h.charIndex<0?0:h.charIndex;for(let v=d;v<=u;v++){let g=this._getLineLeftOffset(v)||0,f=this.getHeightOfLine(v),A=0,b=0,y=0;if(v===d&&(b=this.__charBounds[d][p].left),v>=d&&v<u)y=l&&!this.isEndOfWrapping(v)?this.width:this.getLineWidth(v)||5;else if(v===u)if(m===0)y=this.__charBounds[u][m].left;else{let w=this._getWidthOfCharSpacing();y=this.__charBounds[u][m-1].left+this.__charBounds[u][m-1].width-w}A=f,(this.lineHeight<1||v===u&&this.lineHeight>1)&&(f/=this.lineHeight);let x=i.left+g+b,_=f,M=0,E=y-b;this.inCompositionMode?(e.fillStyle=this.compositionColor||"black",_=1,M=f):e.fillStyle=this.selectionColor,r==="rtl"&&(n==="right"||n==="justify"||n==="justify-right"?x=this.width-x-E:n==="left"||n==="justify-left"?x=i.left+g-y:n!=="center"&&n!=="justify-center"||(x=i.left+g-y)),e.fillRect(x,i.top+i.topOffset+M,E,_),i.topOffset+=A}}getCurrentCharFontSize(){let e=this._getCurrentCharIndex();return this.getValueOfPropertyAt(e.l,e.c,"fontSize")}getCurrentCharColor(){let e=this._getCurrentCharIndex();return this.getValueOfPropertyAt(e.l,e.c,as)}_getCurrentCharIndex(){let e=this.get2DCursorLocation(this.selectionStart,!0),t=e.charIndex>0?e.charIndex-1:0;return{l:e.lineIndex,c:t}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}};ue(bc,"ownDefaults",QK),ue(bc,"type","IText"),ot.setClass(bc),ot.setClass(bc,"i-text");var Kv=class yw extends bc{static getDefaults(){return{...super.getDefaults(),...yw.ownDefaults}}constructor(e,t){super(e,{...yw.ownDefaults,...t})}static createControls(){return{controls:vD()}}initDimensions(){this.initialized&&(this.isEditing&&this.initDelayedCursor(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this.textAlign.includes("justify")&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(e){let t=0,i=0,n=0,r={};for(let a=0;a<e.graphemeLines.length;a++)e.graphemeText[n]===`
|
||
`&&a>0?(i=0,n++,t++):!this.splitByGrapheme&&this._reSpaceAndTab.test(e.graphemeText[n])&&a>0&&(i++,n++),r[a]={line:t,offset:i},n+=e.graphemeLines[a].length,i+=e.graphemeLines[a].length;return r}styleHas(e,t){if(this._styleMap&&!this.isWrapping){let i=this._styleMap[t];i&&(t=i.line)}return super.styleHas(e,t)}isEmptyStyles(e){if(!this.styles)return!0;let t,i=0,n=e+1,r=!1,a=this._styleMap[e],o=this._styleMap[e+1];a&&(e=a.line,i=a.offset),o&&(n=o.line,r=n===e,t=o.offset);let l=e===void 0?this.styles:{line:this.styles[e]};for(let c in l)for(let h in l[c]){let d=parseInt(h,10);if(d>=i&&(!r||d<t))for(let u in l[c][h])return!1}return!0}_getStyleDeclaration(e,t){if(this._styleMap&&!this.isWrapping){let i=this._styleMap[e];if(!i)return{};e=i.line,t=i.offset+t}return super._getStyleDeclaration(e,t)}_setStyleDeclaration(e,t,i){let n=this._styleMap[e];super._setStyleDeclaration(n.line,n.offset+t,i)}_deleteStyleDeclaration(e,t){let i=this._styleMap[e];super._deleteStyleDeclaration(i.line,i.offset+t)}_getLineStyle(e){let t=this._styleMap[e];return!!this.styles[t.line]}_setLineStyle(e){let t=this._styleMap[e];super._setLineStyle(t.line)}_wrapText(e,t){this.isWrapping=!0;let i=this.getGraphemeDataForRender(e),n=[];for(let r=0;r<i.wordsData.length;r++)n.push(...this._wrapLine(r,t,i));return this.isWrapping=!1,n}getGraphemeDataForRender(e){let t=this.splitByGrapheme,i=t?"":" ",n=0;return{wordsData:e.map((r,a)=>{let o=0,l=t?this.graphemeSplit(r):this.wordSplit(r);return l.length===0?[{word:[],width:0}]:l.map(c=>{let h=t?[c]:this.graphemeSplit(c),d=this._measureWord(h,a,o);return n=Math.max(d,n),o+=h.length+i.length,{word:h,width:d}})}),largestWordWidth:n}}_measureWord(e,t,i=0){let n,r=0;for(let a=0,o=e.length;a<o;a++)r+=this._getGraphemeBox(e[a],t,a+i,n,!0).kernedWidth,n=e[a];return r}wordSplit(e){return e.split(this._wordJoiners)}_wrapLine(e,t,{largestWordWidth:i,wordsData:n},r=0){let a=this._getWidthOfCharSpacing(),o=this.splitByGrapheme,l=[],c=o?"":" ",h=0,d=[],u=0,p=0,m=!0;t-=r;let v=Math.max(t,i,this.dynamicMinWidth),g=n[e],f;for(u=0,f=0;f<g.length;f++){let{word:A,width:b}=g[f];u+=A.length,h+=p+b-a,h>v&&!m?(l.push(d),d=[],h=b,m=!0):h+=a,m||o||d.push(c),d=d.concat(A),p=o?0:this._measureWord([c],e,u),u++,m=!1}return f&&l.push(d),i+r>this.dynamicMinWidth&&(this.dynamicMinWidth=i-a+r),l}isEndOfWrapping(e){return!this._styleMap[e+1]||this._styleMap[e+1].line!==this._styleMap[e].line}missingNewlineOffset(e,t){return this.splitByGrapheme&&!t?this.isEndOfWrapping(e)?1:0:1}_splitTextIntoLines(e){let t=super._splitTextIntoLines(e),i=this._wrapText(t.lines,this.width),n=Array(i.length);for(let r=0;r<i.length;r++)n[r]=i[r].join("");return t.lines=n,t.graphemeLines=i,t}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){let e=new Map;for(let t in this._styleMap){let i=parseInt(t,10);if(this._textLines[i]){let n=this._styleMap[t].line;e.set(`${n}`,!0)}}for(let t in this.styles)e.has(t)||delete this.styles[t]}toObject(e=[]){return super.toObject(["minWidth","splitByGrapheme",...e])}};ue(Kv,"type","Textbox"),ue(Kv,"textLayoutProperties",[...bc.textLayoutProperties,"width"]),ue(Kv,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),ot.setClass(Kv);var dR=class extends Uv{shouldPerformLayout(s){return!!s.target.clipPath&&super.shouldPerformLayout(s)}shouldLayoutClipPath(){return!1}calcLayoutResult(s,e){let{target:t}=s,{clipPath:i,group:n}=t;if(!i||!this.shouldPerformLayout(s))return;let{width:r,height:a}=jr(PD(t,i)),o=new De(r,a);if(i.absolutePositioned)return{center:Oa(i.getRelativeCenterPoint(),void 0,n?n.calcTransformMatrix():void 0),size:o};{let l=i.getRelativeCenterPoint().transform(t.calcOwnMatrix(),!0);if(this.shouldPerformLayout(s)){let{center:c=new De,correction:h=new De}=this.calcBoundingBox(e,s)||{};return{center:c.add(l),correction:h.subtract(l),size:o}}return{center:t.getRelativeCenterPoint().add(l),size:o}}}};ue(dR,"type","clip-path"),ot.setClass(dR);var uR=class extends Uv{getInitialSize({target:s},{size:e}){return new De(s.width||e.x,s.height||e.y)}};ue(uR,"type","fixed"),ot.setClass(uR);var jK=class extends Xp{subscribeTargets(s){let e=s.target;s.targets.reduce((t,i)=>(i.parent&&t.add(i.parent),t),new Set).forEach(t=>{t.layoutManager.subscribeTargets({target:t,targets:[e]})})}unsubscribeTargets(s){let e=s.target,t=e.getObjects();s.targets.reduce((i,n)=>(n.parent&&i.add(n.parent),i),new Set).forEach(i=>{!t.some(n=>n.parent===i)&&i.layoutManager.unsubscribeTargets({target:i,targets:[e]})})}},$v=class xw extends Qo{static getDefaults(){return{...super.getDefaults(),...xw.ownDefaults}}constructor(e=[],t={}){super(),Object.assign(this,xw.ownDefaults),this.setOptions(t);let{left:i,top:n,layoutManager:r}=t;this.groupInit(e,{left:i,top:n,layoutManager:r??new jK})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(...e){this.multiSelectionStacking==="selection-order"?this.add(...e):e.forEach(t=>{let i=this._objects.findIndex(r=>r.isInFrontOf(t)),n=i===-1?this.size():i;this.insertAt(n,t)})}canEnterGroup(e){return this.getObjects().some(t=>t.isDescendantOf(e)||e.isDescendantOf(t))?(Fo("error","ActiveSelection: circular object trees are not supported, this call has no effect"),!1):super.canEnterGroup(e)}enterGroup(e,t){e.parent&&e.parent===e.group?e.parent._exitGroup(e):e.group&&e.parent!==e.group&&e.group.remove(e),this._enterGroup(e,t)}exitGroup(e,t){this._exitGroup(e,t),e.parent&&e.parent._enterGroup(e,!0)}_onAfterObjectsChange(e,t){super._onAfterObjectsChange(e,t);let i=new Set;t.forEach(n=>{let{parent:r}=n;r&&i.add(r)}),e==="removed"?i.forEach(n=>{n._onAfterObjectsChange(V_,t)}):i.forEach(n=>{n._set("dirty",!0)})}onDeselect(){return this.removeAll(),!1}toString(){return`#<ActiveSelection: (${this.complexity()})>`}shouldCache(){return!1}isOnACache(){return!1}_renderControls(e,t,i){e.save(),e.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;let n={hasControls:!1,...i,forActiveSelection:!0};for(let r=0;r<this._objects.length;r++)this._objects[r]._renderControls(e,n);super._renderControls(e,t),e.restore()}};ue($v,"type","ActiveSelection"),ue($v,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),ot.setClass($v),ot.setClass($v,"activeSelection");var XK=class{constructor(){ue(this,"resources",{})}applyFilters(s,e,t,i,n){let r=n.getContext("2d",{willReadFrequently:!0,desynchronized:!0});if(!r)return;r.drawImage(e,0,0,t,i);let a={sourceWidth:t,sourceHeight:i,imageData:r.getImageData(0,0,t,i),originalEl:e,originalImageData:r.getImageData(0,0,t,i),canvasEl:n,ctx:r,filterBackend:this};s.forEach(l=>{l.applyTo(a)});let{imageData:o}=a;return o.width===t&&o.height===i||(n.width=o.width,n.height=o.height),r.putImageData(o,0,0),a}},pR=class{constructor({tileSize:s=ei.textureSize}={}){ue(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),ue(this,"resources",{}),this.tileSize=s,this.setupGLContext(s,s),this.captureGPUInfo()}setupGLContext(s,e){this.dispose(),this.createWebGLCanvas(s,e)}createWebGLCanvas(s,e){let t=_s({width:s,height:e}),i=t.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});i&&(i.clearColor(0,0,0,0),this.canvas=t,this.gl=i)}applyFilters(s,e,t,i,n,r){let a=this.gl,o=n.getContext("2d");if(!a||!o)return;let l;r&&(l=this.getCachedTexture(r,e));let c={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:t,sourceHeight:i,destinationWidth:t,destinationHeight:i,context:a,sourceTexture:this.createTexture(a,t,i,l?void 0:e),targetTexture:this.createTexture(a,t,i),originalTexture:l||this.createTexture(a,t,i,l?void 0:e),passes:s.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:n},h=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,h),s.forEach(d=>{d&&d.applyTo(c)}),(function(d){let u=d.targetCanvas,p=u.width,m=u.height,v=d.destinationWidth,g=d.destinationHeight;p===v&&m===g||(u.width=v,u.height=g)})(c),this.copyGLTo2D(a,c),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(c.sourceTexture),a.deleteTexture(c.targetTexture),a.deleteFramebuffer(h),o.setTransform(1,0,0,1,0,0),c}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(s,e,t,i,n){let{NEAREST:r,TEXTURE_2D:a,RGBA:o,UNSIGNED_BYTE:l,CLAMP_TO_EDGE:c,TEXTURE_MAG_FILTER:h,TEXTURE_MIN_FILTER:d,TEXTURE_WRAP_S:u,TEXTURE_WRAP_T:p}=s,m=s.createTexture();return s.bindTexture(a,m),s.texParameteri(a,h,n||r),s.texParameteri(a,d,n||r),s.texParameteri(a,u,c),s.texParameteri(a,p,c),i?s.texImage2D(a,0,o,o,l,i):s.texImage2D(a,0,o,e,t,0,o,l,null),m}getCachedTexture(s,e,t){let{textureCache:i}=this;if(i[s])return i[s];{let n=this.createTexture(this.gl,e.width,e.height,e,t);return n&&(i[s]=n),n}}evictCachesForKey(s){this.textureCache[s]&&(this.gl.deleteTexture(this.textureCache[s]),delete this.textureCache[s])}copyGLTo2D(s,e){let t=s.canvas,i=e.targetCanvas,n=i.getContext("2d");if(!n)return;n.translate(0,i.height),n.scale(1,-1);let r=t.height-i.height;n.drawImage(t,0,r,i.width,i.height,0,0,i.width,i.height)}copyGLTo2DPutImageData(s,e){let t=e.targetCanvas.getContext("2d"),i=e.destinationWidth,n=e.destinationHeight,r=i*n*4;if(!t)return;let a=new Uint8Array(this.imageBuffer,0,r),o=new Uint8ClampedArray(this.imageBuffer,0,r);s.readPixels(0,0,i,n,s.RGBA,s.UNSIGNED_BYTE,a);let l=new ImageData(o,i,n);t.putImageData(l,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;let s=this.gl,e={renderer:"",vendor:""};if(!s)return e;let t=s.getExtension("WEBGL_debug_renderer_info");if(t){let i=s.getParameter(t.UNMASKED_RENDERER_WEBGL),n=s.getParameter(t.UNMASKED_VENDOR_WEBGL);i&&(e.renderer=i.toLowerCase()),n&&(e.vendor=n.toLowerCase())}return this.gpuInfo=e,e}};let tw;function qK(){let{WebGLProbe:s}=Wr();return s.queryWebGL(Qr()),ei.enableGLFiltering&&s.isSupported(ei.textureSize)?new pR({tileSize:ei.textureSize}):new XK}function iw(s=!0){return!tw&&s&&(tw=qK()),tw}const fR=["cropX","cropY"];var yc=class _w extends Dn{static getDefaults(){return{...super.getDefaults(),..._w.ownDefaults}}constructor(e,t){super(),ue(this,"_lastScaleX",1),ue(this,"_lastScaleY",1),ue(this,"_filterScalingX",1),ue(this,"_filterScalingY",1),this.filters=[],Object.assign(this,_w.ownDefaults),this.setOptions(t),this.cacheKey=`texture${Ho()}`,this.setElement(typeof e=="string"?(this.canvas&&vr(this.canvas.getElement())||ld()).getElementById(e):e,t)}getElement(){return this._element}setElement(e,t={}){this.removeTexture(this.cacheKey),this.removeTexture(`${this.cacheKey}_filtered`),this._element=e,this._originalElement=e,this._setWidthHeight(t),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(e){let t=iw(!1);t instanceof pR&&t.evictCachesForKey(e)}dispose(){super.dispose(),this.removeTexture(this.cacheKey),this.removeTexture(`${this.cacheKey}_filtered`),this._cacheContext=null,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach(e=>{let t=this[e];t&&Wr().dispose(t),this[e]=void 0})}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){let e=this.getElement();return e?{width:e.naturalWidth||e.width,height:e.naturalHeight||e.height}:{width:0,height:0}}_stroke(e){if(!this.stroke||this.strokeWidth===0)return;let t=this.width/2,i=this.height/2;e.beginPath(),e.moveTo(-t,-i),e.lineTo(t,-i),e.lineTo(t,i),e.lineTo(-t,i),e.lineTo(-t,-i),e.closePath()}toObject(e=[]){let t=[];return this.filters.forEach(i=>{i&&t.push(i.toObject())}),{...super.toObject([...fR,...e]),src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:t,...this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{}}}hasCrop(){return!!this.cropX||!!this.cropY||this.width<this._element.width||this.height<this._element.height}_toSVG(){let e=[],t=this._element,i=-this.width/2,n=-this.height/2,r=[],a=[],o="",l="";if(!t)return[];if(this.hasCrop()){let c=Ho();r.push('<clipPath id="imageCrop_'+c+`">
|
||
`,' <rect x="'+i+'" y="'+n+'" width="'+Ot(this.width)+'" height="'+Ot(this.height)+`" />
|
||
`,`</clipPath>
|
||
`),o=' clip-path="url(#imageCrop_'+c+')" '}if(this.imageSmoothing||(l=' image-rendering="optimizeSpeed"'),e.push(" <image ","COMMON_PARTS",`xlink:href="${Ot(this.getSrc(!0))}" x="${i-this.cropX}" y="${n-this.cropY}" width="${t.width||t.naturalWidth}" height="${t.height||t.naturalHeight}"${l}${o}></image>
|
||
`),this.stroke||this.strokeDashArray){let c=this.fill;this.fill=null,a=[` <rect x="${i}" y="${n}" width="${Ot(this.width)}" height="${Ot(this.height)}" style="${this.getSvgStyles()}" />
|
||
`],this.fill=c}return r=this.paintFirst==="fill"?r.concat(e,a):r.concat(a,e),r}getSrc(e){let t=e?this._element:this._originalElement;return t?t.toDataURL?t.toDataURL():this.srcFromAttribute?t.getAttribute("src")||"":t.src:this.src||""}getSvgSrc(e){return this.getSrc(e)}setSrc(e,{crossOrigin:t,signal:i}={}){return Fp(e,{crossOrigin:t,signal:i}).then(n=>{t!==void 0&&this.set({crossOrigin:t}),this.setElement(n)})}toString(){return`#<Image: { src: "${this.getSrc()}" }>`}applyResizeFilters(){let e=this.resizeFilter,t=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),n=i.x,r=i.y,a=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!e||n>t&&r>t)return this._element=a,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=n,void(this._lastScaleY=r);let o=_s(a),{width:l,height:c}=a;this._element=o,this._lastScaleX=e.scaleX=n,this._lastScaleY=e.scaleY=r,iw().applyFilters([e],a,l,c,this._element),this._filterScalingX=o.width/this._originalElement.width,this._filterScalingY=o.height/this._originalElement.height}applyFilters(e=this.filters||[]){if(e=e.filter(r=>r&&!r.isNeutralState()),this.set("dirty",!0),this.removeTexture(`${this.cacheKey}_filtered`),e.length===0)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);let t=this._originalElement,i=t.naturalWidth||t.width,n=t.naturalHeight||t.height;if(this._element===this._originalElement){let r=_s({width:i,height:n});this._element=r,this._filteredEl=r}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,n),this._lastScaleX=1,this._lastScaleY=1);iw().applyFilters(e,this._originalElement,i,n,this._element,this.cacheKey),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height)}_render(e){e.imageSmoothingEnabled=this.imageSmoothing,this.isMoving!==!0&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(e),this._renderPaintInOrder(e)}drawCacheOnCanvas(e){e.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(e)}shouldCache(){return this.needsItsOwnCache()}_renderFill(e){let t=this._element;if(!t)return;let i=this._filterScalingX,n=this._filterScalingY,r=this.width,a=this.height,o=Math.max(this.cropX,0),l=Math.max(this.cropY,0),c=t.naturalWidth||t.width,h=t.naturalHeight||t.height,d=o*i,u=l*n,p=Math.min(r*i,c-d),m=Math.min(a*n,h-u),v=-r/2,g=-a/2,f=Math.min(r,c/i-o),A=Math.min(a,h/n-l);t&&e.drawImage(t,d,u,p,m,v,g,f,A)}_needsResize(){let e=this.getTotalObjectScaling();return e.x!==this._lastScaleX||e.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight({width:e,height:t}={}){let i=this.getOriginalSize();this.width=e||i.width,this.height=t||i.height}parsePreserveAspectRatioAttribute(){let e=zP(this.preserveAspectRatio||""),t=this.width,i=this.height,n={width:t,height:i},r,a=this._element.width,o=this._element.height,l=1,c=1,h=0,d=0,u=0,p=0;return!e||e.alignX==="none"&&e.alignY==="none"?(l=t/a,c=i/o):(e.meetOrSlice==="meet"&&(l=c=RD(this._element,n),r=(t-a*l)/2,e.alignX==="Min"&&(h=-r),e.alignX==="Max"&&(h=r),r=(i-o*c)/2,e.alignY==="Min"&&(d=-r),e.alignY==="Max"&&(d=r)),e.meetOrSlice==="slice"&&(l=c=BD(this._element,n),r=a-t/l,e.alignX==="Mid"&&(u=r/2),e.alignX==="Max"&&(u=r),r=o-i/c,e.alignY==="Mid"&&(p=r/2),e.alignY==="Max"&&(p=r),a=t/l,o=i/c)),{width:a,height:o,scaleX:l,scaleY:c,offsetLeft:h,offsetTop:d,cropX:u,cropY:p}}static fromObject({filters:e,resizeFilter:t,src:i,crossOrigin:n,type:r,...a},o){return Promise.all([Fp(i,{...o,crossOrigin:n}),e&&md(e,o),t?md([t],o):[],Np(a,o)]).then(([l,c=[],[h],d={}])=>new this(l,{...a,src:i,filters:c,resizeFilter:h,...d}))}static fromURL(e,{crossOrigin:t=null,signal:i}={},n){return Fp(e,{crossOrigin:t,signal:i}).then(r=>new this(r,n))}static async fromElement(e,t={},i){let n=za(e,this.ATTRIBUTE_NAMES,i);return this.fromURL(n["xlink:href"]||n.href,t,n).catch(r=>(Fo("log","Unable to parse Image",r),null))}};ue(yc,"type","Image"),ue(yc,"cacheProperties",[...Fa,...fR]),ue(yc,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),ue(yc,"ATTRIBUTE_NAMES",[...Vo,"x","y","width","height","preserveAspectRatio","xlink:href","href","crossOrigin","image-rendering"]),ot.setClass(yc),ot.setSVGClass(yc),kv(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const Zv=s=>s.webgl!==void 0,nw="precision highp float",YK=`
|
||
${nw};
|
||
varying vec2 vTexCoord;
|
||
uniform sampler2D uTexture;
|
||
void main() {
|
||
gl_FragColor = texture2D(uTexture, vTexCoord);
|
||
}`,KK=new RegExp(nw,"g");var ji=class{get type(){return this.constructor.type}constructor({type:s,...e}={}){Object.assign(this,this.constructor.defaults,e)}getFragmentSource(){return YK}getVertexSource(){return`
|
||
attribute vec2 aPosition;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
vTexCoord = aPosition;
|
||
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
|
||
}`}createProgram(s,e=this.getFragmentSource(),t=this.getVertexSource()){let{WebGLProbe:{GLPrecision:i="highp"}}=Wr();i!=="highp"&&(e=e.replace(KK,nw.replace("highp",i)));let n=s.createShader(s.VERTEX_SHADER),r=s.createShader(s.FRAGMENT_SHADER),a=s.createProgram();if(!n||!r||!a)throw new Vr("Vertex, fragment shader or program creation error");if(s.shaderSource(n,t),s.compileShader(n),!s.getShaderParameter(n,s.COMPILE_STATUS))throw new Vr(`Vertex shader compile error for ${this.type}: ${s.getShaderInfoLog(n)}`);if(s.shaderSource(r,e),s.compileShader(r),!s.getShaderParameter(r,s.COMPILE_STATUS))throw new Vr(`Fragment shader compile error for ${this.type}: ${s.getShaderInfoLog(r)}`);if(s.attachShader(a,n),s.attachShader(a,r),s.linkProgram(a),!s.getProgramParameter(a,s.LINK_STATUS))throw new Vr(`Shader link error for "${this.type}" ${s.getProgramInfoLog(a)}`);let o=this.getUniformLocations(s,a)||{};return o.uStepW=s.getUniformLocation(a,"uStepW"),o.uStepH=s.getUniformLocation(a,"uStepH"),{program:a,attributeLocations:this.getAttributeLocations(s,a),uniformLocations:o}}getAttributeLocations(s,e){return{aPosition:s.getAttribLocation(e,"aPosition")}}getUniformLocations(s,e){let t=this.constructor.uniformLocations,i={};for(let n=0;n<t.length;n++)i[t[n]]=s.getUniformLocation(e,t[n]);return i}sendAttributeData(s,e,t){let i=e.aPosition,n=s.createBuffer();s.bindBuffer(s.ARRAY_BUFFER,n),s.enableVertexAttribArray(i),s.vertexAttribPointer(i,2,s.FLOAT,!1,0,0),s.bufferData(s.ARRAY_BUFFER,t,s.STATIC_DRAW)}_setupFrameBuffer(s){let e=s.context;if(s.passes>1){let t=s.destinationWidth,i=s.destinationHeight;s.sourceWidth===t&&s.sourceHeight===i||(e.deleteTexture(s.targetTexture),s.targetTexture=s.filterBackend.createTexture(e,t,i)),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,s.targetTexture,0)}else e.bindFramebuffer(e.FRAMEBUFFER,null),e.finish()}_swapTextures(s){s.passes--,s.pass++;let e=s.targetTexture;s.targetTexture=s.sourceTexture,s.sourceTexture=e}isNeutralState(s){return!1}applyTo(s){Zv(s)?(this._setupFrameBuffer(s),this.applyToWebGL(s),this._swapTextures(s)):this.applyTo2d(s)}applyTo2d(s){}getCacheKey(){return this.type}retrieveShader(s){let e=this.getCacheKey();return s.programCache[e]||(s.programCache[e]=this.createProgram(s.context)),s.programCache[e]}applyToWebGL(s){let e=s.context,t=this.retrieveShader(s);s.pass===0&&s.originalTexture?e.bindTexture(e.TEXTURE_2D,s.originalTexture):e.bindTexture(e.TEXTURE_2D,s.sourceTexture),e.useProgram(t.program),this.sendAttributeData(e,t.attributeLocations,s.aPosition),e.uniform1f(t.uniformLocations.uStepW,1/s.sourceWidth),e.uniform1f(t.uniformLocations.uStepH,1/s.sourceHeight),this.sendUniformData(e,t.uniformLocations),e.viewport(0,0,s.destinationWidth,s.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(s,e,t){s.activeTexture(t),s.bindTexture(s.TEXTURE_2D,e),s.activeTexture(s.TEXTURE0)}unbindAdditionalTexture(s,e){s.activeTexture(e),s.bindTexture(s.TEXTURE_2D,null),s.activeTexture(s.TEXTURE0)}sendUniformData(s,e){}createHelpLayer(s){if(!s.helpLayer){let{sourceWidth:e,sourceHeight:t}=s;s.helpLayer=_s({width:e,height:t})}}toObject(){let s=Object.keys(this.constructor.defaults||{});return{type:this.type,...s.reduce((e,t)=>(e[t]=this[t],e),{})}}toJSON(){return this.toObject()}static async fromObject({type:s,...e},t){return new this(e)}};ue(ji,"type","BaseFilter"),ue(ji,"uniformLocations",[]);const $K={multiply:`gl_FragColor.rgb *= uColor.rgb;
|
||
`,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
|
||
`,add:`gl_FragColor.rgb += uColor.rgb;
|
||
`,difference:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
|
||
`,subtract:`gl_FragColor.rgb -= uColor.rgb;
|
||
`,lighten:`gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);
|
||
`,darken:`gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);
|
||
`,exclusion:`gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);
|
||
`,overlay:`
|
||
if (uColor.r < 0.5) {
|
||
gl_FragColor.r *= 2.0 * uColor.r;
|
||
} else {
|
||
gl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);
|
||
}
|
||
if (uColor.g < 0.5) {
|
||
gl_FragColor.g *= 2.0 * uColor.g;
|
||
} else {
|
||
gl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);
|
||
}
|
||
if (uColor.b < 0.5) {
|
||
gl_FragColor.b *= 2.0 * uColor.b;
|
||
} else {
|
||
gl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);
|
||
}
|
||
`,tint:`
|
||
gl_FragColor.rgb *= (1.0 - uColor.a);
|
||
gl_FragColor.rgb += uColor.rgb;
|
||
`};var Yp=class extends ji{getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform vec4 uColor;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
vec4 color = texture2D(uTexture, vTexCoord);
|
||
gl_FragColor = color;
|
||
if (color.a > 0.0) {
|
||
${$K[this.mode]}
|
||
}
|
||
}
|
||
`}applyTo2d({imageData:{data:s}}){let e=new br(this.color).getSource(),t=this.alpha,i=e[0]*t,n=e[1]*t,r=e[2]*t,a=1-t;for(let o=0;o<s.length;o+=4){let l=s[o],c=s[o+1],h=s[o+2],d,u,p;switch(this.mode){case"multiply":d=l*i/255,u=c*n/255,p=h*r/255;break;case"screen":d=255-(255-l)*(255-i)/255,u=255-(255-c)*(255-n)/255,p=255-(255-h)*(255-r)/255;break;case"add":d=l+i,u=c+n,p=h+r;break;case"difference":d=Math.abs(l-i),u=Math.abs(c-n),p=Math.abs(h-r);break;case"subtract":d=l-i,u=c-n,p=h-r;break;case"darken":d=Math.min(l,i),u=Math.min(c,n),p=Math.min(h,r);break;case"lighten":d=Math.max(l,i),u=Math.max(c,n),p=Math.max(h,r);break;case"overlay":d=i<128?2*l*i/255:255-2*(255-l)*(255-i)/255,u=n<128?2*c*n/255:255-2*(255-c)*(255-n)/255,p=r<128?2*h*r/255:255-2*(255-h)*(255-r)/255;break;case"exclusion":d=i+l-2*i*l/255,u=n+c-2*n*c/255,p=r+h-2*r*h/255;break;case"tint":d=i+l*a,u=n+c*a,p=r+h*a}s[o]=d,s[o+1]=u,s[o+2]=p}}sendUniformData(s,e){let t=new br(this.color).getSource();t[0]=this.alpha*t[0]/255,t[1]=this.alpha*t[1]/255,t[2]=this.alpha*t[2]/255,t[3]=this.alpha,s.uniform4fv(e.uColor,t)}};ue(Yp,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),ue(Yp,"type","BlendColor"),ue(Yp,"uniformLocations",["uColor"]),ot.setClass(Yp);const ZK={multiply:`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform sampler2D uImage;
|
||
uniform vec4 uColor;
|
||
varying vec2 vTexCoord;
|
||
varying vec2 vTexCoord2;
|
||
void main() {
|
||
vec4 color = texture2D(uTexture, vTexCoord);
|
||
vec4 color2 = texture2D(uImage, vTexCoord2);
|
||
color.rgba *= color2.rgba;
|
||
gl_FragColor = color;
|
||
}
|
||
`,mask:`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform sampler2D uImage;
|
||
uniform vec4 uColor;
|
||
varying vec2 vTexCoord;
|
||
varying vec2 vTexCoord2;
|
||
void main() {
|
||
vec4 color = texture2D(uTexture, vTexCoord);
|
||
vec4 color2 = texture2D(uImage, vTexCoord2);
|
||
color.a = color2.a;
|
||
gl_FragColor = color;
|
||
}
|
||
`};var Kp=class extends ji{getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return ZK[this.mode]}getVertexSource(){return`
|
||
attribute vec2 aPosition;
|
||
varying vec2 vTexCoord;
|
||
varying vec2 vTexCoord2;
|
||
uniform mat3 uTransformMatrix;
|
||
void main() {
|
||
vTexCoord = aPosition;
|
||
vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
|
||
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
|
||
}
|
||
`}applyToWebGL(s){let e=s.context,t=this.createTexture(s.filterBackend,this.image);this.bindAdditionalTexture(e,t,e.TEXTURE1),super.applyToWebGL(s),this.unbindAdditionalTexture(e,e.TEXTURE1)}createTexture(s,e){return s.getCachedTexture(e.cacheKey,e.getElement())}calculateMatrix(){let s=this.image,{width:e,height:t}=s.getElement();return[1/s.scaleX,0,0,0,1/s.scaleY,0,-s.left/e,-s.top/t,1]}applyTo2d({imageData:{data:s,width:e,height:t},filterBackend:{resources:i}}){let n=this.image;i.blendImage||(i.blendImage=Qr());let r=i.blendImage,a=r.getContext("2d");r.width!==e||r.height!==t?(r.width=e,r.height=t):a.clearRect(0,0,e,t),a.setTransform(n.scaleX,0,0,n.scaleY,n.left,n.top),a.drawImage(n.getElement(),0,0,e,t);let o=a.getImageData(0,0,e,t).data;for(let l=0;l<s.length;l+=4){let c=s[l],h=s[l+1],d=s[l+2],u=s[l+3],p=o[l],m=o[l+1],v=o[l+2],g=o[l+3];switch(this.mode){case"multiply":s[l]=c*p/255,s[l+1]=h*m/255,s[l+2]=d*v/255,s[l+3]=u*g/255;break;case"mask":s[l+3]=g}}}sendUniformData(s,e){let t=this.calculateMatrix();s.uniform1i(e.uImage,1),s.uniformMatrix3fv(e.uTransformMatrix,!1,t)}toObject(){return{...super.toObject(),image:this.image&&this.image.toObject()}}static async fromObject({type:s,image:e,...t},i){return yc.fromObject(e,i).then(n=>new this({...t,image:n}))}};ue(Kp,"type","BlendImage"),ue(Kp,"defaults",{mode:"multiply",alpha:1}),ue(Kp,"uniformLocations",["uTransformMatrix","uImage"]),ot.setClass(Kp);var $p=class extends ji{getFragmentSource(){return`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform vec2 uDelta;
|
||
varying vec2 vTexCoord;
|
||
const float nSamples = 15.0;
|
||
vec3 v3offset = vec3(12.9898, 78.233, 151.7182);
|
||
float random(vec3 scale) {
|
||
/* use the fragment position for a different seed per-pixel */
|
||
return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);
|
||
}
|
||
void main() {
|
||
vec4 color = vec4(0.0);
|
||
float totalC = 0.0;
|
||
float totalA = 0.0;
|
||
float offset = random(v3offset);
|
||
for (float t = -nSamples; t <= nSamples; t++) {
|
||
float percent = (t + offset - 0.5) / nSamples;
|
||
vec4 sample = texture2D(uTexture, vTexCoord + uDelta * percent);
|
||
float weight = 1.0 - abs(percent);
|
||
float alpha = weight * sample.a;
|
||
color.rgb += sample.rgb * alpha;
|
||
color.a += alpha;
|
||
totalA += weight;
|
||
totalC += alpha;
|
||
}
|
||
gl_FragColor.rgb = color.rgb / totalC;
|
||
gl_FragColor.a = color.a / totalA;
|
||
}
|
||
`}applyTo(s){Zv(s)?(this.aspectRatio=s.sourceWidth/s.sourceHeight,s.passes++,this._setupFrameBuffer(s),this.horizontal=!0,this.applyToWebGL(s),this._swapTextures(s),this._setupFrameBuffer(s),this.horizontal=!1,this.applyToWebGL(s),this._swapTextures(s)):this.applyTo2d(s)}applyTo2d({imageData:{data:s,width:e,height:t}}){this.aspectRatio=e/t,this.horizontal=!0;let i=this.getBlurValue()*e,n=new Uint8ClampedArray(s),r=4*e;for(let a=0;a<s.length;a+=4){let o=0,l=0,c=0,h=0,d=0,u=a-a%r,p=u+r;for(let m=-14;m<15;m++){let v=m/15,g=4*Math.floor(i*v),f=1-Math.abs(v),A=a+g;A<u?A=u:A>p&&(A=p);let b=s[A+3]*f;o+=s[A]*b,l+=s[A+1]*b,c+=s[A+2]*b,h+=b,d+=f}n[a]=o/h,n[a+1]=l/h,n[a+2]=c/h,n[a+3]=h/d}this.horizontal=!1,i=this.getBlurValue()*t;for(let a=0;a<n.length;a+=4){let o=0,l=0,c=0,h=0,d=0,u=a%r,p=n.length-r+u;for(let m=-14;m<15;m++){let v=m/15,g=Math.floor(i*v)*r,f=1-Math.abs(v),A=a+g;A<u?A=u:A>p&&(A=p);let b=n[A+3]*f;o+=n[A]*b,l+=n[A+1]*b,c+=n[A+2]*b,h+=b,d+=f}s[a]=o/h,s[a+1]=l/h,s[a+2]=c/h,s[a+3]=h/d}}sendUniformData(s,e){let t=this.chooseRightDelta();s.uniform2fv(e.uDelta,t)}isNeutralState(){return this.blur===0}getBlurValue(){let s=1,{horizontal:e,aspectRatio:t}=this;return e?t>1&&(s=1/t):t<1&&(s=t),s*this.blur*.12}chooseRightDelta(){let s=this.getBlurValue();return this.horizontal?[s,0]:[0,s]}};ue($p,"type","Blur"),ue($p,"defaults",{blur:0}),ue($p,"uniformLocations",["uDelta"]),ot.setClass($p);var Zp=class extends ji{getFragmentSource(){return`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform float uBrightness;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
vec4 color = texture2D(uTexture, vTexCoord);
|
||
color.rgb += uBrightness;
|
||
gl_FragColor = color;
|
||
}
|
||
`}applyTo2d({imageData:{data:s}}){let e=Math.round(255*this.brightness);for(let t=0;t<s.length;t+=4)s[t]+=e,s[t+1]+=e,s[t+2]+=e}isNeutralState(){return this.brightness===0}sendUniformData(s,e){s.uniform1f(e.uBrightness,this.brightness)}};ue(Zp,"type","Brightness"),ue(Zp,"defaults",{brightness:0}),ue(Zp,"uniformLocations",["uBrightness"]),ot.setClass(Zp);const mR={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};var xc=class extends ji{getFragmentSource(){return`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
varying vec2 vTexCoord;
|
||
uniform mat4 uColorMatrix;
|
||
uniform vec4 uConstants;
|
||
void main() {
|
||
vec4 color = texture2D(uTexture, vTexCoord);
|
||
color *= uColorMatrix;
|
||
color += uConstants;
|
||
gl_FragColor = color;
|
||
}`}applyTo2d(s){let e=s.imageData.data,t=this.matrix,i=this.colorsOnly;for(let n=0;n<e.length;n+=4){let r=e[n],a=e[n+1],o=e[n+2];if(e[n]=r*t[0]+a*t[1]+o*t[2]+255*t[4],e[n+1]=r*t[5]+a*t[6]+o*t[7]+255*t[9],e[n+2]=r*t[10]+a*t[11]+o*t[12]+255*t[14],!i){let l=e[n+3];e[n]+=l*t[3],e[n+1]+=l*t[8],e[n+2]+=l*t[13],e[n+3]=r*t[15]+a*t[16]+o*t[17]+l*t[18]+255*t[19]}}}sendUniformData(s,e){let t=this.matrix,i=[t[0],t[1],t[2],t[3],t[5],t[6],t[7],t[8],t[10],t[11],t[12],t[13],t[15],t[16],t[17],t[18]],n=[t[4],t[9],t[14],t[19]];s.uniformMatrix4fv(e.uColorMatrix,!1,i),s.uniform4fv(e.uConstants,n)}toObject(){return{...super.toObject(),matrix:[...this.matrix]}}};function _c(s,e){var t;let i=(ue(t=class extends xc{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",s),ue(t,"defaults",{colorsOnly:!1,matrix:e}),t);return ot.setClass(i,s),i}ue(xc,"type","ColorMatrix"),ue(xc,"defaults",mR),ue(xc,"uniformLocations",["uColorMatrix","uConstants"]),ot.setClass(xc);const JK=_c("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]),e$=_c("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]),t$=_c("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]),i$=_c("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]),n$=_c("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]),s$=_c("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]),r$=_c("BlackWhite",[1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,0,0,0,1,0]);var sw=class extends ji{constructor(s={}){super(s),this.subFilters=s.subFilters||[]}applyTo(s){Zv(s)&&(s.passes+=this.subFilters.length-1),this.subFilters.forEach(e=>{e.applyTo(s)})}toObject(){return{type:this.type,subFilters:this.subFilters.map(s=>s.toObject())}}isNeutralState(){return!this.subFilters.some(s=>!s.isNeutralState())}static fromObject(s,e){return Promise.all((s.subFilters||[]).map(t=>ot.getClass(t.type).fromObject(t,e))).then(t=>new this({subFilters:t}))}};ue(sw,"type","Composed"),ot.setClass(sw);var Jp=class extends ji{getFragmentSource(){return`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform float uContrast;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
vec4 color = texture2D(uTexture, vTexCoord);
|
||
float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));
|
||
color.rgb = contrastF * (color.rgb - 0.5) + 0.5;
|
||
gl_FragColor = color;
|
||
}`}isNeutralState(){return this.contrast===0}applyTo2d({imageData:{data:s}}){let e=Math.floor(255*this.contrast),t=259*(e+255)/(255*(259-e));for(let i=0;i<s.length;i+=4)s[i]=t*(s[i]-128)+128,s[i+1]=t*(s[i+1]-128)+128,s[i+2]=t*(s[i+2]-128)+128}sendUniformData(s,e){s.uniform1f(e.uContrast,this.contrast)}};ue(Jp,"type","Contrast"),ue(Jp,"defaults",{contrast:0}),ue(Jp,"uniformLocations",["uContrast"]),ot.setClass(Jp);const a$={Convolute_3_1:`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform float uMatrix[9];
|
||
uniform float uStepW;
|
||
uniform float uStepH;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
vec4 color = vec4(0, 0, 0, 0);
|
||
for (float h = 0.0; h < 3.0; h+=1.0) {
|
||
for (float w = 0.0; w < 3.0; w+=1.0) {
|
||
vec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));
|
||
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];
|
||
}
|
||
}
|
||
gl_FragColor = color;
|
||
}
|
||
`,Convolute_3_0:`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform float uMatrix[9];
|
||
uniform float uStepW;
|
||
uniform float uStepH;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
vec4 color = vec4(0, 0, 0, 1);
|
||
for (float h = 0.0; h < 3.0; h+=1.0) {
|
||
for (float w = 0.0; w < 3.0; w+=1.0) {
|
||
vec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));
|
||
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];
|
||
}
|
||
}
|
||
float alpha = texture2D(uTexture, vTexCoord).a;
|
||
gl_FragColor = color;
|
||
gl_FragColor.a = alpha;
|
||
}
|
||
`,Convolute_5_1:`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform float uMatrix[25];
|
||
uniform float uStepW;
|
||
uniform float uStepH;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
vec4 color = vec4(0, 0, 0, 0);
|
||
for (float h = 0.0; h < 5.0; h+=1.0) {
|
||
for (float w = 0.0; w < 5.0; w+=1.0) {
|
||
vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
|
||
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];
|
||
}
|
||
}
|
||
gl_FragColor = color;
|
||
}
|
||
`,Convolute_5_0:`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform float uMatrix[25];
|
||
uniform float uStepW;
|
||
uniform float uStepH;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
vec4 color = vec4(0, 0, 0, 1);
|
||
for (float h = 0.0; h < 5.0; h+=1.0) {
|
||
for (float w = 0.0; w < 5.0; w+=1.0) {
|
||
vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
|
||
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];
|
||
}
|
||
}
|
||
float alpha = texture2D(uTexture, vTexCoord).a;
|
||
gl_FragColor = color;
|
||
gl_FragColor.a = alpha;
|
||
}
|
||
`,Convolute_7_1:`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform float uMatrix[49];
|
||
uniform float uStepW;
|
||
uniform float uStepH;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
vec4 color = vec4(0, 0, 0, 0);
|
||
for (float h = 0.0; h < 7.0; h+=1.0) {
|
||
for (float w = 0.0; w < 7.0; w+=1.0) {
|
||
vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
|
||
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];
|
||
}
|
||
}
|
||
gl_FragColor = color;
|
||
}
|
||
`,Convolute_7_0:`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform float uMatrix[49];
|
||
uniform float uStepW;
|
||
uniform float uStepH;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
vec4 color = vec4(0, 0, 0, 1);
|
||
for (float h = 0.0; h < 7.0; h+=1.0) {
|
||
for (float w = 0.0; w < 7.0; w+=1.0) {
|
||
vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
|
||
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];
|
||
}
|
||
}
|
||
float alpha = texture2D(uTexture, vTexCoord).a;
|
||
gl_FragColor = color;
|
||
gl_FragColor.a = alpha;
|
||
}
|
||
`,Convolute_9_1:`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform float uMatrix[81];
|
||
uniform float uStepW;
|
||
uniform float uStepH;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
vec4 color = vec4(0, 0, 0, 0);
|
||
for (float h = 0.0; h < 9.0; h+=1.0) {
|
||
for (float w = 0.0; w < 9.0; w+=1.0) {
|
||
vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
|
||
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];
|
||
}
|
||
}
|
||
gl_FragColor = color;
|
||
}
|
||
`,Convolute_9_0:`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform float uMatrix[81];
|
||
uniform float uStepW;
|
||
uniform float uStepH;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
vec4 color = vec4(0, 0, 0, 1);
|
||
for (float h = 0.0; h < 9.0; h+=1.0) {
|
||
for (float w = 0.0; w < 9.0; w+=1.0) {
|
||
vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
|
||
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];
|
||
}
|
||
}
|
||
float alpha = texture2D(uTexture, vTexCoord).a;
|
||
gl_FragColor = color;
|
||
gl_FragColor.a = alpha;
|
||
}
|
||
`};var ef=class extends ji{getCacheKey(){return`${this.type}_${Math.sqrt(this.matrix.length)}_${this.opaque?1:0}`}getFragmentSource(){return a$[this.getCacheKey()]}applyTo2d(s){let e=s.imageData,t=e.data,i=this.matrix,n=Math.round(Math.sqrt(i.length)),r=Math.floor(n/2),a=e.width,o=e.height,l=s.ctx.createImageData(a,o),c=l.data,h=this.opaque?1:0,d,u,p,m,v,g,f,A,b,y,x,_,M;for(x=0;x<o;x++)for(y=0;y<a;y++){for(v=4*(x*a+y),d=0,u=0,p=0,m=0,M=0;M<n;M++)for(_=0;_<n;_++)f=x+M-r,g=y+_-r,f<0||f>=o||g<0||g>=a||(A=4*(f*a+g),b=i[M*n+_],d+=t[A]*b,u+=t[A+1]*b,p+=t[A+2]*b,h||(m+=t[A+3]*b));c[v]=d,c[v+1]=u,c[v+2]=p,c[v+3]=h?t[v+3]:m}s.imageData=l}sendUniformData(s,e){s.uniform1fv(e.uMatrix,this.matrix)}toObject(){return{...super.toObject(),opaque:this.opaque,matrix:[...this.matrix]}}};ue(ef,"type","Convolute"),ue(ef,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),ue(ef,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),ot.setClass(ef);const gR="Gamma";var tf=class extends ji{getFragmentSource(){return`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform vec3 uGamma;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
vec4 color = texture2D(uTexture, vTexCoord);
|
||
vec3 correction = (1.0 / uGamma);
|
||
color.r = pow(color.r, correction.r);
|
||
color.g = pow(color.g, correction.g);
|
||
color.b = pow(color.b, correction.b);
|
||
gl_FragColor = color;
|
||
gl_FragColor.rgb *= color.a;
|
||
}
|
||
`}constructor(s={}){super(s),this.gamma=s.gamma||this.constructor.defaults.gamma.concat()}applyTo2d({imageData:{data:s}}){let e=this.gamma,t=1/e[0],i=1/e[1],n=1/e[2];this.rgbValues||(this.rgbValues={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)});let r=this.rgbValues;for(let a=0;a<256;a++)r.r[a]=255*(a/255)**t,r.g[a]=255*(a/255)**i,r.b[a]=255*(a/255)**n;for(let a=0;a<s.length;a+=4)s[a]=r.r[s[a]],s[a+1]=r.g[s[a+1]],s[a+2]=r.b[s[a+2]]}sendUniformData(s,e){s.uniform3fv(e.uGamma,this.gamma)}isNeutralState(){let{gamma:s}=this;return s[0]===1&&s[1]===1&&s[2]===1}toObject(){return{type:gR,gamma:this.gamma.concat()}}};ue(tf,"type",gR),ue(tf,"defaults",{gamma:[1,1,1]}),ue(tf,"uniformLocations",["uGamma"]),ot.setClass(tf);const o$={average:`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
vec4 color = texture2D(uTexture, vTexCoord);
|
||
float average = (color.r + color.b + color.g) / 3.0;
|
||
gl_FragColor = vec4(average, average, average, color.a);
|
||
}
|
||
`,lightness:`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform int uMode;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
vec4 col = texture2D(uTexture, vTexCoord);
|
||
float average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;
|
||
gl_FragColor = vec4(average, average, average, col.a);
|
||
}
|
||
`,luminosity:`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform int uMode;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
vec4 col = texture2D(uTexture, vTexCoord);
|
||
float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
|
||
gl_FragColor = vec4(average, average, average, col.a);
|
||
}
|
||
`};var nf=class extends ji{applyTo2d({imageData:{data:s}}){for(let e,t=0;t<s.length;t+=4){let i=s[t],n=s[t+1],r=s[t+2];switch(this.mode){case"average":e=(i+n+r)/3;break;case"lightness":e=(Math.min(i,n,r)+Math.max(i,n,r))/2;break;case"luminosity":e=.21*i+.72*n+.07*r}s[t+2]=s[t+1]=s[t]=e}}getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return o$[this.mode]}sendUniformData(s,e){s.uniform1i(e.uMode,1)}isNeutralState(){return!1}};ue(nf,"type","Grayscale"),ue(nf,"defaults",{mode:"average"}),ue(nf,"uniformLocations",["uMode"]),ot.setClass(nf);const l$={...mR,rotation:0};var Jv=class extends xc{calculateMatrix(){let s=this.rotation*Math.PI,e=mr(s),t=gr(s),i=1/3,n=Math.sqrt(i)*t,r=1-e;this.matrix=[e+r/3,i*r-n,i*r+n,0,0,i*r+n,e+i*r,i*r-n,0,0,i*r-n,i*r+n,e+i*r,0,0,0,0,0,1,0]}isNeutralState(){return this.rotation===0}applyTo(s){this.calculateMatrix(),super.applyTo(s)}toObject(){return{type:this.type,rotation:this.rotation}}};ue(Jv,"type","HueRotation"),ue(Jv,"defaults",l$),ot.setClass(Jv);var sf=class extends ji{applyTo2d({imageData:{data:s}}){for(let e=0;e<s.length;e+=4)s[e]=255-s[e],s[e+1]=255-s[e+1],s[e+2]=255-s[e+2],this.alpha&&(s[e+3]=255-s[e+3])}getFragmentSource(){return`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform int uInvert;
|
||
uniform int uAlpha;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
vec4 color = texture2D(uTexture, vTexCoord);
|
||
if (uInvert == 1) {
|
||
if (uAlpha == 1) {
|
||
gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,1.0 -color.a);
|
||
} else {
|
||
gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);
|
||
}
|
||
} else {
|
||
gl_FragColor = color;
|
||
}
|
||
}
|
||
`}isNeutralState(){return!this.invert}sendUniformData(s,e){s.uniform1i(e.uInvert,Number(this.invert)),s.uniform1i(e.uAlpha,Number(this.alpha))}};ue(sf,"type","Invert"),ue(sf,"defaults",{alpha:!1,invert:!0}),ue(sf,"uniformLocations",["uInvert","uAlpha"]),ot.setClass(sf);var rf=class extends ji{getFragmentSource(){return`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform float uStepH;
|
||
uniform float uNoise;
|
||
uniform float uSeed;
|
||
varying vec2 vTexCoord;
|
||
float rand(vec2 co, float seed, float vScale) {
|
||
return fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);
|
||
}
|
||
void main() {
|
||
vec4 color = texture2D(uTexture, vTexCoord);
|
||
color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;
|
||
gl_FragColor = color;
|
||
}
|
||
`}applyTo2d({imageData:{data:s}}){let e=this.noise;for(let t=0;t<s.length;t+=4){let i=(.5-Math.random())*e;s[t]+=i,s[t+1]+=i,s[t+2]+=i}}sendUniformData(s,e){s.uniform1f(e.uNoise,this.noise/255),s.uniform1f(e.uSeed,Math.random())}isNeutralState(){return this.noise===0}};ue(rf,"type","Noise"),ue(rf,"defaults",{noise:0}),ue(rf,"uniformLocations",["uNoise","uSeed"]),ot.setClass(rf);var af=class extends ji{applyTo2d({imageData:{data:s,width:e,height:t}}){for(let i=0;i<t;i+=this.blocksize)for(let n=0;n<e;n+=this.blocksize){let r=4*i*e+4*n,a=s[r],o=s[r+1],l=s[r+2],c=s[r+3];for(let h=i;h<Math.min(i+this.blocksize,t);h++)for(let d=n;d<Math.min(n+this.blocksize,e);d++){let u=4*h*e+4*d;s[u]=a,s[u+1]=o,s[u+2]=l,s[u+3]=c}}}isNeutralState(){return this.blocksize===1}getFragmentSource(){return`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform float uBlocksize;
|
||
uniform float uStepW;
|
||
uniform float uStepH;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
float blockW = uBlocksize * uStepW;
|
||
float blockH = uBlocksize * uStepH;
|
||
int posX = int(vTexCoord.x / blockW);
|
||
int posY = int(vTexCoord.y / blockH);
|
||
float fposX = float(posX);
|
||
float fposY = float(posY);
|
||
vec2 squareCoords = vec2(fposX * blockW, fposY * blockH);
|
||
vec4 color = texture2D(uTexture, squareCoords);
|
||
gl_FragColor = color;
|
||
}
|
||
`}sendUniformData(s,e){s.uniform1f(e.uBlocksize,this.blocksize)}};ue(af,"type","Pixelate"),ue(af,"defaults",{blocksize:4}),ue(af,"uniformLocations",["uBlocksize"]),ot.setClass(af);var of=class extends ji{getFragmentSource(){return`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform vec4 uLow;
|
||
uniform vec4 uHigh;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
gl_FragColor = texture2D(uTexture, vTexCoord);
|
||
if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {
|
||
gl_FragColor.a = 0.0;
|
||
}
|
||
}
|
||
`}applyTo2d({imageData:{data:s}}){let e=255*this.distance,t=new br(this.color).getSource(),i=[t[0]-e,t[1]-e,t[2]-e],n=[t[0]+e,t[1]+e,t[2]+e];for(let r=0;r<s.length;r+=4){let a=s[r],o=s[r+1],l=s[r+2];a>i[0]&&o>i[1]&&l>i[2]&&a<n[0]&&o<n[1]&&l<n[2]&&(s[r+3]=0)}}sendUniformData(s,e){let t=new br(this.color).getSource(),i=this.distance,n=[0+t[0]/255-i,0+t[1]/255-i,0+t[2]/255-i,1],r=[t[0]/255+i,t[1]/255+i,t[2]/255+i,1];s.uniform4fv(e.uLow,n),s.uniform4fv(e.uHigh,r)}};ue(of,"type","RemoveColor"),ue(of,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),ue(of,"uniformLocations",["uLow","uHigh"]),ot.setClass(of);var lf=class extends ji{sendUniformData(s,e){s.uniform2fv(e.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),s.uniform1fv(e.uTaps,this.taps)}getFilterWindow(){let s=this.tempScale;return Math.ceil(this.lanczosLobes/s)}getCacheKey(){let s=this.getFilterWindow();return`${this.type}_${s}`}getFragmentSource(){let s=this.getFilterWindow();return this.generateShader(s)}getTaps(){let s=this.lanczosCreate(this.lanczosLobes),e=this.tempScale,t=this.getFilterWindow(),i=Array(t);for(let n=1;n<=t;n++)i[n-1]=s(n*e);return i}generateShader(s){let e=Array(s);for(let t=1;t<=s;t++)e[t-1]=`${t}.0 * uDelta`;return`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform vec2 uDelta;
|
||
varying vec2 vTexCoord;
|
||
uniform float uTaps[${s}];
|
||
void main() {
|
||
vec4 color = texture2D(uTexture, vTexCoord);
|
||
float sum = 1.0;
|
||
${e.map((t,i)=>`
|
||
color += texture2D(uTexture, vTexCoord + ${t}) * uTaps[${i}] + texture2D(uTexture, vTexCoord - ${t}) * uTaps[${i}];
|
||
sum += 2.0 * uTaps[${i}];
|
||
`).join(`
|
||
`)}
|
||
gl_FragColor = color / sum;
|
||
}
|
||
`}applyToForWebgl(s){s.passes++,this.width=s.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=s.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),s.destinationWidth=this.dW,super.applyTo(s),s.sourceWidth=s.destinationWidth,this.height=s.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),s.destinationHeight=this.dH,super.applyTo(s),s.sourceHeight=s.destinationHeight}applyTo(s){Zv(s)?this.applyToForWebgl(s):this.applyTo2d(s)}isNeutralState(){return this.scaleX===1&&this.scaleY===1}lanczosCreate(s){return e=>{if(e>=s||e<=-s)return 0;if(e<11920929e-14&&e>-11920929e-14)return 1;let t=(e*=Math.PI)/s;return Math.sin(e)/e*Math.sin(t)/t}}applyTo2d(s){let e=s.imageData,t=this.scaleX,i=this.scaleY;this.rcpScaleX=1/t,this.rcpScaleY=1/i;let n=e.width,r=e.height,a=Math.round(n*t),o=Math.round(r*i),l;l=this.resizeType==="sliceHack"?this.sliceByTwo(s,n,r,a,o):this.resizeType==="hermite"?this.hermiteFastResize(s,n,r,a,o):this.resizeType==="bilinear"?this.bilinearFiltering(s,n,r,a,o):this.resizeType==="lanczos"?this.lanczosResize(s,n,r,a,o):new ImageData(a,o),s.imageData=l}sliceByTwo(s,e,t,i,n){let r=s.imageData,a=.5,o=!1,l=!1,c=e*a,h=t*a,d=s.filterBackend.resources,u=0,p=0,m=e,v=0;d.sliceByTwo||(d.sliceByTwo=Qr());let g=d.sliceByTwo;(g.width<1.5*e||g.height<t)&&(g.width=1.5*e,g.height=t);let f=g.getContext("2d");for(f.clearRect(0,0,1.5*e,t),f.putImageData(r,0,0),i=Math.floor(i),n=Math.floor(n);!o||!l;)e=c,t=h,i<Math.floor(c*a)?c=Math.floor(c*a):(c=i,o=!0),n<Math.floor(h*a)?h=Math.floor(h*a):(h=n,l=!0),f.drawImage(g,u,p,e,t,m,v,c,h),u=m,p=v,v+=h;return f.getImageData(u,p,i,n)}lanczosResize(s,e,t,i,n){let r=s.imageData.data,a=s.ctx.createImageData(i,n),o=a.data,l=this.lanczosCreate(this.lanczosLobes),c=this.rcpScaleX,h=this.rcpScaleY,d=2/this.rcpScaleX,u=2/this.rcpScaleY,p=Math.ceil(c*this.lanczosLobes/2),m=Math.ceil(h*this.lanczosLobes/2),v={},g={x:0,y:0},f={x:0,y:0};return(function A(b){let y,x,_,M,E,w,T,R,D,L,I;for(g.x=(b+.5)*c,f.x=Math.floor(g.x),y=0;y<n;y++){for(g.y=(y+.5)*h,f.y=Math.floor(g.y),E=0,w=0,T=0,R=0,D=0,x=f.x-p;x<=f.x+p;x++)if(!(x<0||x>=e)){L=Math.floor(1e3*Math.abs(x-g.x)),v[L]||(v[L]={});for(let O=f.y-m;O<=f.y+m;O++)O<0||O>=t||(I=Math.floor(1e3*Math.abs(O-g.y)),v[L][I]||(v[L][I]=l(Math.sqrt((L*d)**2+(I*u)**2)/1e3)),_=v[L][I],_>0&&(M=4*(O*e+x),E+=_,w+=_*r[M],T+=_*r[M+1],R+=_*r[M+2],D+=_*r[M+3]))}M=4*(y*i+b),o[M]=w/E,o[M+1]=T/E,o[M+2]=R/E,o[M+3]=D/E}return++b<i?A(b):a})(0)}bilinearFiltering(s,e,t,i,n){let r,a,o,l,c,h,d,u,p,m,v,g,f,A=0,b=this.rcpScaleX,y=this.rcpScaleY,x=4*(e-1),_=s.imageData.data,M=s.ctx.createImageData(i,n),E=M.data;for(d=0;d<n;d++)for(u=0;u<i;u++)for(c=Math.floor(b*u),h=Math.floor(y*d),p=b*u-c,m=y*d-h,f=4*(h*e+c),v=0;v<4;v++)r=_[f+v],a=_[f+4+v],o=_[f+x+v],l=_[f+x+4+v],g=r*(1-p)*(1-m)+a*p*(1-m)+o*m*(1-p)+l*p*m,E[A++]=g;return M}hermiteFastResize(s,e,t,i,n){let r=this.rcpScaleX,a=this.rcpScaleY,o=Math.ceil(r/2),l=Math.ceil(a/2),c=s.imageData.data,h=s.ctx.createImageData(i,n),d=h.data;for(let u=0;u<n;u++)for(let p=0;p<i;p++){let m=4*(p+u*i),v=0,g=0,f=0,A=0,b=0,y=0,x=0,_=(u+.5)*a;for(let M=Math.floor(u*a);M<(u+1)*a;M++){let E=Math.abs(_-(M+.5))/l,w=(p+.5)*r,T=E*E;for(let R=Math.floor(p*r);R<(p+1)*r;R++){let D=Math.abs(w-(R+.5))/o,L=Math.sqrt(T+D*D);L>1&&L<-1||(v=2*L*L*L-3*L*L+1,v>0&&(D=4*(R+M*e),x+=v*c[D+3],f+=v,c[D+3]<255&&(v=v*c[D+3]/250),A+=v*c[D],b+=v*c[D+1],y+=v*c[D+2],g+=v))}}d[m]=A/g,d[m+1]=b/g,d[m+2]=y/g,d[m+3]=x/f}return h}};ue(lf,"type","Resize"),ue(lf,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),ue(lf,"uniformLocations",["uDelta","uTaps"]),ot.setClass(lf);var cf=class extends ji{getFragmentSource(){return`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform float uSaturation;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
vec4 color = texture2D(uTexture, vTexCoord);
|
||
float rgMax = max(color.r, color.g);
|
||
float rgbMax = max(rgMax, color.b);
|
||
color.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;
|
||
color.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;
|
||
color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;
|
||
gl_FragColor = color;
|
||
}
|
||
`}applyTo2d({imageData:{data:s}}){let e=-this.saturation;for(let t=0;t<s.length;t+=4){let i=s[t],n=s[t+1],r=s[t+2],a=Math.max(i,n,r);s[t]+=a===i?0:(a-i)*e,s[t+1]+=a===n?0:(a-n)*e,s[t+2]+=a===r?0:(a-r)*e}}sendUniformData(s,e){s.uniform1f(e.uSaturation,-this.saturation)}isNeutralState(){return this.saturation===0}};ue(cf,"type","Saturation"),ue(cf,"defaults",{saturation:0}),ue(cf,"uniformLocations",["uSaturation"]),ot.setClass(cf);var hf=class extends ji{getFragmentSource(){return`
|
||
precision highp float;
|
||
uniform sampler2D uTexture;
|
||
uniform float uVibrance;
|
||
varying vec2 vTexCoord;
|
||
void main() {
|
||
vec4 color = texture2D(uTexture, vTexCoord);
|
||
float max = max(color.r, max(color.g, color.b));
|
||
float avg = (color.r + color.g + color.b) / 3.0;
|
||
float amt = (abs(max - avg) * 2.0) * uVibrance;
|
||
color.r += max != color.r ? (max - color.r) * amt : 0.00;
|
||
color.g += max != color.g ? (max - color.g) * amt : 0.00;
|
||
color.b += max != color.b ? (max - color.b) * amt : 0.00;
|
||
gl_FragColor = color;
|
||
}
|
||
`}applyTo2d({imageData:{data:s}}){let e=-this.vibrance;for(let t=0;t<s.length;t+=4){let i=s[t],n=s[t+1],r=s[t+2],a=Math.max(i,n,r),o=(i+n+r)/3,l=2*Math.abs(a-o)/255*e;s[t]+=a===i?0:(a-i)*l,s[t+1]+=a===n?0:(a-n)*l,s[t+2]+=a===r?0:(a-r)*l}}sendUniformData(s,e){s.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}};ue(hf,"type","Vibrance"),ue(hf,"defaults",{vibrance:0}),ue(hf,"uniformLocations",["uVibrance"]),ot.setClass(hf),Dp({BaseFilter:()=>ji,BlackWhite:()=>r$,BlendColor:()=>Yp,BlendImage:()=>Kp,Blur:()=>$p,Brightness:()=>Zp,Brownie:()=>JK,ColorMatrix:()=>xc,Composed:()=>sw,Contrast:()=>Jp,Convolute:()=>ef,Gamma:()=>tf,Grayscale:()=>nf,HueRotation:()=>Jv,Invert:()=>sf,Kodachrome:()=>t$,Noise:()=>rf,Pixelate:()=>af,Polaroid:()=>n$,RemoveColor:()=>of,Resize:()=>lf,Saturation:()=>cf,Sepia:()=>s$,Technicolor:()=>i$,Vibrance:()=>hf,Vintage:()=>e$});function c$(s,e,t="bim-snapshot.png"){const i=s?.renderer,n=i?.domElement;if(!i||!n||!e)return null;const r=n.width||n.clientWidth,a=n.height||n.clientHeight;if(r<=0||a<=0)return null;let o=h$(n,r,a);if(!d$(o)){const u=u$(s,r,a);u&&(o=u)}const l=document.createElement("canvas");l.width=r,l.height=a;const c=l.getContext("2d");if(!c)return null;c.drawImage(o,0,0,r,a),c.drawImage(e,0,0,r,a);const h=l.toDataURL("image/png"),d=document.createElement("a");return d.href=h,d.download=t.toLowerCase().endsWith(".png")?t:`${t}.png`,d.click(),h}function h$(s,e,t){const i=document.createElement("canvas");i.width=e,i.height=t;const n=i.getContext("2d");return n&&n.drawImage(s,0,0,e,t),i}function d$(s){const e=s.getContext("2d");if(!e||s.width<=0||s.height<=0)return!1;const t=Math.min(32,s.width),i=Math.min(32,s.height),n=Math.max(1,Math.floor(s.width/t)),r=Math.max(1,Math.floor(s.height/i));for(let a=0;a<s.height;a+=r)for(let o=0;o<s.width;o+=n){const l=e.getImageData(o,a,1,1).data;if(l[0]!==0||l[1]!==0||l[2]!==0||l[3]!==0)return!0}return!1}function u$(s,e,t){const i=s?.renderer,n=s?.scene,r=s?.camera;if(!i||!n||!r)return null;const a=new ki(e,t,{minFilter:wt,magFilter:wt,format:_i,depthBuffer:!0,stencilBuffer:!0}),o=i.getRenderTarget(),l=i.autoClear,c=i.xr?.enabled??!1;try{i.xr&&(i.xr.enabled=!1),i.autoClear=!0,i.setRenderTarget(a),i.clear(!0,!0,!0),i.render(n,r);const h=new Uint8Array(e*t*4);return i.readRenderTargetPixels(a,0,0,e,t,h),p$(h,e,t)}catch{return null}finally{i.setRenderTarget(o),i.autoClear=l,i.xr&&(i.xr.enabled=c),a.dispose()}}function p$(s,e,t){const i=document.createElement("canvas");i.width=e,i.height=t;const n=i.getContext("2d");if(!n)return i;const r=n.createImageData(e,t),a=e*4;for(let o=0;o<t;o++){const l=(t-1-o)*a,c=o*a;for(let h=0;h<a;h++)r.data[c+h]=s[l+h]}return n.putImageData(r,0,0),i}const f$={none:new URL("/assets/icon/%E9%80%89%E6%8B%A9.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pt&&pt.tagName.toUpperCase()==="SCRIPT"&&pt.src||new URL("iflow-engine.umd.js",document.baseURI).href).href,line:new URL("/assets/icon/%E7%BA%BF.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pt&&pt.tagName.toUpperCase()==="SCRIPT"&&pt.src||new URL("iflow-engine.umd.js",document.baseURI).href).href,arrow:new URL("/assets/icon/%E7%AE%AD%E5%A4%B4.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pt&&pt.tagName.toUpperCase()==="SCRIPT"&&pt.src||new URL("iflow-engine.umd.js",document.baseURI).href).href,rect:new URL("/assets/icon/%E7%9F%A9%E5%BD%A2.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pt&&pt.tagName.toUpperCase()==="SCRIPT"&&pt.src||new URL("iflow-engine.umd.js",document.baseURI).href).href,circle:new URL("/assets/icon/%E5%9C%86%E5%BD%A2.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pt&&pt.tagName.toUpperCase()==="SCRIPT"&&pt.src||new URL("iflow-engine.umd.js",document.baseURI).href).href,text:new URL("/assets/icon/%E6%96%87%E5%AD%97.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pt&&pt.tagName.toUpperCase()==="SCRIPT"&&pt.src||new URL("iflow-engine.umd.js",document.baseURI).href).href,cloudline:new URL("/assets/icon/%E4%BA%91%E7%BA%BF.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pt&&pt.tagName.toUpperCase()==="SCRIPT"&&pt.src||new URL("iflow-engine.umd.js",document.baseURI).href).href},m$=new URL("/assets/icon/%E6%B5%8B%E8%B7%9D.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pt&&pt.tagName.toUpperCase()==="SCRIPT"&&pt.src||new URL("iflow-engine.umd.js",document.baseURI).href).href,g$=new URL("/assets/icon/%E6%88%AA%E5%9B%BE.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pt&&pt.tagName.toUpperCase()==="SCRIPT"&&pt.src||new URL("iflow-engine.umd.js",document.baseURI).href).href,v$=new URL("/assets/icon/%E7%BA%BF%E5%AE%BD.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pt&&pt.tagName.toUpperCase()==="SCRIPT"&&pt.src||new URL("iflow-engine.umd.js",document.baseURI).href).href,A$=new URL("/assets/icon/%E5%AD%97%E5%8F%B7.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pt&&pt.tagName.toUpperCase()==="SCRIPT"&&pt.src||new URL("iflow-engine.umd.js",document.baseURI).href).href,b$=[{type:"distance",label:"距离"},{type:"clearDistance",label:"垂距"},{type:"clearHeight",label:"净高"},{type:"elevation",label:"标高"},{type:"point",label:"坐标"},{type:"angle",label:"角度"},{type:"area",label:"面积"},{type:"slope",label:"坡度"}],y$={distance:new URL("/assets/icon/%E8%B7%9D%E7%A6%BB.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pt&&pt.tagName.toUpperCase()==="SCRIPT"&&pt.src||new URL("iflow-engine.umd.js",document.baseURI).href).href,clearDistance:new URL("/assets/icon/%E5%87%80%E8%B7%9D.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pt&&pt.tagName.toUpperCase()==="SCRIPT"&&pt.src||new URL("iflow-engine.umd.js",document.baseURI).href).href,clearHeight:new URL("/assets/icon/%E5%87%80%E9%AB%98.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pt&&pt.tagName.toUpperCase()==="SCRIPT"&&pt.src||new URL("iflow-engine.umd.js",document.baseURI).href).href,elevation:new URL("/assets/icon/%E6%A0%87%E9%AB%98.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pt&&pt.tagName.toUpperCase()==="SCRIPT"&&pt.src||new URL("iflow-engine.umd.js",document.baseURI).href).href,point:new URL("/assets/icon/%E5%9D%90%E6%A0%87.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pt&&pt.tagName.toUpperCase()==="SCRIPT"&&pt.src||new URL("iflow-engine.umd.js",document.baseURI).href).href,angle:new URL("/assets/icon/%E8%A7%92%E5%BA%A6.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pt&&pt.tagName.toUpperCase()==="SCRIPT"&&pt.src||new URL("iflow-engine.umd.js",document.baseURI).href).href,area:new URL("/assets/icon/%E9%9D%A2%E7%A7%AF.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pt&&pt.tagName.toUpperCase()==="SCRIPT"&&pt.src||new URL("iflow-engine.umd.js",document.baseURI).href).href,slope:new URL("/assets/icon/%E5%9D%A1%E5%BA%A6.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:pt&&pt.tagName.toUpperCase()==="SCRIPT"&&pt.src||new URL("iflow-engine.umd.js",document.baseURI).href).href};class x${constructor(e,t){this.handlers=e,this.root=document.createElement("div"),this.root.style.position="absolute",this.root.style.top="8px",this.root.style.left="50%",this.root.style.transform="translateX(-50%)",this.root.style.display="none",this.root.style.padding="6px",this.root.style.background="#ffffff",this.root.style.border="1px solid #d9d9d9",this.root.style.borderRadius="8px",this.root.style.pointerEvents="auto",this.root.style.userSelect="none",this.root.style.boxShadow="0 4px 14px rgba(0, 0, 0, 0.12)",this.root.style.zIndex="1300",this.root.style.overflow="hidden",this.editPanel=document.createElement("div"),this.editPanel.style.display="flex",this.editPanel.style.flexDirection="column",this.editPanel.style.gap="6px",this.viewPanel=document.createElement("div"),this.viewPanel.style.display="none",this.viewPanel.style.alignItems="center",this.viewPanel.style.gap="6px";const i=document.createElement("div");i.style.display="flex",i.style.alignItems="center",i.style.gap="6px",i.style.flexWrap="wrap",[{type:"none",label:"选择"},{type:"line",label:"线"},{type:"arrow",label:"箭头"},{type:"rect",label:"矩形"},{type:"circle",label:"圆形"},{type:"text",label:"文字"},{type:"cloudline",label:"云线"}].forEach(l=>{const c=this.createIconButton(l.label,f$[l.type]);c.onclick=()=>this.handlers.onDrawTypeChange(l.type),this.drawButtons[l.type]=c,i.appendChild(c)}),this.colorInput=document.createElement("input"),this.colorInput.type="color",this.colorInput.value=t.stroke,this.colorInput.style.width="32px",this.colorInput.style.height="24px",this.colorInput.style.padding="0",this.colorInput.style.border="1px solid #d9d9d9",this.colorInput.style.borderRadius="4px",this.colorInput.style.background="#ffffff",this.colorInput.oninput=()=>this.handlers.onColorChange(this.colorInput.value),i.appendChild(this.createField("",this.colorInput)),this.strokeWidthInput=document.createElement("input"),this.strokeWidthInput.type="number",this.strokeWidthInput.min="1",this.strokeWidthInput.max="20",this.strokeWidthInput.step="1",this.strokeWidthInput.value=String(t.strokeWidth),this.strokeWidthInput.style.width="46px",this.strokeWidthInput.oninput=()=>this.handlers.onStrokeWidthChange(this.strokeWidthInput.value),i.appendChild(this.createField("",this.strokeWidthInput,v$,"线宽")),this.fontSizeInput=document.createElement("input"),this.fontSizeInput.type="number",this.fontSizeInput.min="10",this.fontSizeInput.max="96",this.fontSizeInput.step="1",this.fontSizeInput.value=String(t.fontSize),this.fontSizeInput.style.width="46px",this.fontSizeInput.oninput=()=>this.handlers.onFontSizeChange(this.fontSizeInput.value),i.appendChild(this.createField("",this.fontSizeInput,A$,"字号")),this.distanceButton=this.createIconButton("测量",m$),this.distanceButton.onclick=()=>this.handlers.onMeasureToggle(),i.appendChild(this.distanceButton);const n=this.createIconButton("截图",g$);n.onclick=()=>this.handlers.onScreenshot(),i.appendChild(n);const r=this.createTextButton("×","取消");r.onclick=()=>this.handlers.onCancel(),r.style.background="#ff4d4f",r.style.borderColor="#ff4d4f",r.style.color="#ffffff",i.appendChild(r);const a=this.createTextButton("✔","确定");a.onclick=()=>this.handlers.onConfirm(),a.style.background="#52c41a",a.style.borderColor="#52c41a",a.style.color="#ffffff",i.appendChild(a),this.measureSubPanel=document.createElement("div"),this.measureSubPanel.style.display="none",this.measureSubPanel.style.alignItems="center",this.measureSubPanel.style.gap="6px",this.measureSubPanel.style.flexWrap="wrap",this.measureSubPanel.style.paddingTop="2px",b$.forEach(l=>{const c=this.createSmallIconButton(l.label,y$[l.type]);c.onclick=()=>this.handlers.onMeasureTypeChange(l.type),this.measureTypeButtons[l.type]=c,this.measureSubPanel.appendChild(c)}),this.editPanel.appendChild(i),this.editPanel.appendChild(this.measureSubPanel);const o=this.createTextButton("关闭","关闭");o.onclick=()=>this.handlers.onClose(),this.viewPanel.appendChild(o),this.root.appendChild(this.editPanel),this.root.appendChild(this.viewPanel),this.disabledMask=document.createElement("div"),this.disabledMask.style.position="absolute",this.disabledMask.style.inset="0",this.disabledMask.style.display="none",this.disabledMask.style.background="rgba(255, 255, 255, 0.55)",this.disabledMask.style.backdropFilter="blur(1px)",this.disabledMask.style.cursor="not-allowed",this.disabledMask.style.pointerEvents="auto",this.disabledMask.style.zIndex="10",this.root.appendChild(this.disabledMask),this.setMode("edit")}root;disabledMask;drawButtons={};measureTypeButtons={};distanceButton;colorInput;strokeWidthInput;fontSizeInput;editPanel;viewPanel;measureSubPanel;mode="edit";isEditPanelMasked=!1;mount(e){e.appendChild(this.root)}show(){this.root.style.display="block"}hide(){this.root.style.display="none"}setMode(e){this.mode=e,this.editPanel.style.display=e==="edit"?"flex":"none",this.viewPanel.style.display=e==="view"?"flex":"none",e==="view"&&this.setMeasurePanelVisible(!1),this.applyEditPanelMaskState()}setEditPanelMasked(e){this.isEditPanelMasked=e,this.applyEditPanelMaskState()}setDrawType(e){for(const t in this.drawButtons){const i=this.drawButtons[t];if(!i)continue;const n=t===e;i.style.background=n?"#eaf2ff":"#ffffff",i.style.borderColor=n?"#2f80ed":"#d9d9d9"}}setMeasurePanelVisible(e){if(this.mode!=="edit"){this.measureSubPanel.style.display="none";return}this.measureSubPanel.style.display=e?"flex":"none"}setMeasureState(e,t){this.distanceButton.style.background=e?"#eaf2ff":"#ffffff",this.distanceButton.style.borderColor=e?"#2f80ed":"#d9d9d9";for(const i in this.measureTypeButtons){const n=this.measureTypeButtons[i];if(!n)continue;const r=e&&t===i;n.style.background=r?"#eaf2ff":"#ffffff",n.style.borderColor=r?"#2f80ed":"#d9d9d9"}}setStyleValues(e){e.stroke&&(this.colorInput.value=e.stroke),typeof e.strokeWidth=="number"&&(this.strokeWidthInput.value=String(e.strokeWidth)),typeof e.fontSize=="number"&&(this.fontSizeInput.value=String(e.fontSize))}dispose(){this.colorInput.oninput=null,this.strokeWidthInput.oninput=null,this.fontSizeInput.oninput=null,this.root.remove()}applyEditPanelMaskState(){const e=this.mode==="edit"&&this.isEditPanelMasked;this.disabledMask.style.display=e?"block":"none",this.editPanel.querySelectorAll("button, input").forEach(t=>{const i=t;i.disabled=e})}createField(e,t,i,n=""){const r=document.createElement("div");if(r.style.display="flex",r.style.alignItems="center",r.style.gap="4px",r.style.padding="0 2px",r.style.color="#333333",r.style.fontSize="12px",e){const a=document.createElement("span");a.textContent=e,r.appendChild(a)}if(i){const a=document.createElement("img");a.src=i,a.alt=n,a.style.width="14px",a.style.height="14px",a.style.display="block",r.appendChild(a)}return t.style.height="24px",t.style.border="1px solid #d9d9d9",t.style.borderRadius="4px",t.style.background="#ffffff",t.style.color="#333333",t.style.outline="none",t.style.padding="0 4px",r.appendChild(t),r}createIconButton(e,t){const i=document.createElement("button");i.type="button",i.style.width="28px",i.style.height="28px",i.style.padding="0",i.style.display="flex",i.style.alignItems="center",i.style.justifyContent="center",i.style.border="1px solid #d9d9d9",i.style.borderRadius="4px",i.style.background="#ffffff",i.style.cursor="pointer";const n=document.createElement("img");return n.src=t,n.alt=e,n.style.width="16px",n.style.height="16px",n.style.display="block",i.appendChild(n),i}createSmallIconButton(e,t){const i=document.createElement("button");i.type="button",i.style.width="26px",i.style.height="26px",i.style.padding="0",i.style.display="flex",i.style.alignItems="center",i.style.justifyContent="center",i.style.border="1px solid #d9d9d9",i.style.borderRadius="4px",i.style.background="#ffffff",i.style.cursor="pointer";const n=document.createElement("img");return n.src=t,n.alt=e,n.style.width="14px",n.style.height="14px",n.style.display="block",i.appendChild(n),i}createTextButton(e,t){const i=document.createElement("button");return i.type="button",i.title=t,i.textContent=e,i.style.width="28px",i.style.height="28px",i.style.padding="0 10px",i.style.border="1px solid #d9d9d9",i.style.borderRadius="4px",i.style.background="#ffffff",i.style.color="#333333",i.style.fontSize="13px",i.style.lineHeight="1",i.style.cursor="pointer",i}}class _${engine;wrapper;canvasEl;canvas;toolbar;isActive=!1;isVisible=!0;isViewLocked=!0;isDistanceMeasureMode=!1;isMeasurePanelExpanded=!1;drawType="none";mode="edit";currentMeasureType=null;sessionSnapshot=null;actionHandlers={};drawStyle={stroke:"#ff4d4f",strokeWidth:2,fill:"rgba(255, 77, 79, 0.08)",fontSize:16,text:"文本",cloudRadius:10};startPoint=null;tempObject=null;cloudPoints=[];onMouseDown=e=>this.handleMouseDown(e);onMouseMove=e=>this.handleMouseMove(e);onMouseUp=e=>this.handleMouseUp(e);onMouseDblClick=e=>this.handleMouseDblClick(e);onSelectionChanged=()=>this.syncStyleFromSelection();onKeyDown=e=>this.handleKeyDown(e);constructor(e){this.engine=e;const t=this.engine.container;if(!t)throw new Error("FabricDraw: engine container not found.");this.wrapper=document.createElement("div"),this.wrapper.className="fabric-draw-layer",this.wrapper.style.position="absolute",this.wrapper.style.left="0",this.wrapper.style.top="0",this.wrapper.style.right="0",this.wrapper.style.bottom="0",this.wrapper.style.zIndex="1200",this.wrapper.style.pointerEvents="none",this.canvasEl=document.createElement("canvas"),this.canvasEl.style.width="100%",this.canvasEl.style.height="100%",this.wrapper.appendChild(this.canvasEl),this.toolbar=new x$({onDrawTypeChange:i=>this.setDrawType(i),onMeasureToggle:()=>this.toggleMeasurePanel(),onMeasureTypeChange:i=>this.activateDistanceMeasure(i),onScreenshot:()=>{this.saveScreenshot(this.createScreenshotFileName())},onColorChange:i=>this.handleColorInputChange(i),onStrokeWidthChange:i=>this.handleStrokeWidthInputChange(i),onFontSizeChange:i=>this.handleFontSizeInputChange(i),onCancel:()=>{this.handleCancelClick()},onConfirm:()=>this.handleConfirmClick(),onClose:()=>{this.handleCloseClick()}},{stroke:this.drawStyle.stroke,strokeWidth:this.drawStyle.strokeWidth,fontSize:this.drawStyle.fontSize}),this.toolbar.mount(this.wrapper),t.appendChild(this.wrapper),this.canvas=new K_(this.canvasEl,{selection:!0,preserveObjectStacking:!0}),this.resize(),this.canvas.on("mouse:down",this.onMouseDown),this.canvas.on("mouse:move",this.onMouseMove),this.canvas.on("mouse:up",this.onMouseUp),this.canvas.on("mouse:dblclick",this.onMouseDblClick),this.canvas.on("selection:created",this.onSelectionChanged),this.canvas.on("selection:updated",this.onSelectionChanged),this.canvas.on("selection:cleared",this.onSelectionChanged),window.addEventListener("keydown",this.onKeyDown),this.refreshToolbarState()}active(e="edit"){this.isActive=!0,this.mode=e,this.isViewLocked=!0,this.drawType="none",this.isMeasurePanelExpanded=!1,this.currentMeasureType=null,this.canvas.defaultCursor="default",this.sessionSnapshot=e==="edit"?this.cloneJson(this.getAllShapes()):null,this.toolbar.setMode(e),this.applyCanvasInteractive(e==="edit"),this.isVisible&&this.toolbar.show(),this.updateOverlayPointerEvents(),this.refreshToolbarState()}disActive(){this.isActive=!1,this.isViewLocked=!0,this.startPoint=null,this.cloudPoints=[],this.tempObject=null,this.drawType="none",this.mode="edit",this.isMeasurePanelExpanded=!1,this.currentMeasureType=null,this.sessionSnapshot=null,this.stopDistanceMeasureMode(),this.canvas.defaultCursor="default",this.canvas.discardActiveObject(),this.applyCanvasInteractive(!0),this.canvas.requestRenderAll(),this.toolbar.setMode("edit"),this.toolbar.hide(),this.updateOverlayPointerEvents(),this.refreshToolbarState()}close(){this.disActive()}hide(){this.isVisible=!1,this.wrapper.style.display="none",this.toolbar.hide()}show(){this.isVisible=!0,this.wrapper.style.display="block",this.isActive&&this.toolbar.show(),this.resize()}isShown(){return this.isVisible}setDrawType(e,t){this.mode!=="view"&&(this.stopDistanceMeasureMode(),this.isMeasurePanelExpanded=!1,this.currentMeasureType=null,this.drawType=e,t&&(this.drawStyle={...this.drawStyle,...t}),this.canvas.defaultCursor=e==="none"?"default":"crosshair",this.updateOverlayPointerEvents(),this.refreshToolbarState())}getDrawType(){return this.drawType}setActionHandlers(e){this.actionHandlers={...e}}drawLine(e,t,i){const n=this.mergeStyle(i),r=this.createLineObject(e,t,n,!0);return this.canvas.add(r),this.canvas.requestRenderAll(),r}drawArrow(e,t,i){const n=this.mergeStyle(i),r=this.createArrowObject(e,t,n,!0);return this.canvas.add(r),this.canvas.requestRenderAll(),r}drawRect(e,t,i){const n=this.mergeStyle(i),r=this.createRectObject(e,t,n,!0);return this.canvas.add(r),this.canvas.requestRenderAll(),r}drawCircle(e,t,i){const n=this.mergeStyle(i),r=this.createCircleObject(e,t,n,!0);return this.canvas.add(r),this.canvas.requestRenderAll(),r}drawText(e,t,i){const n=this.mergeStyle(i),r=new bc(t??n.text,{left:e.x,top:e.y,fontSize:n.fontSize,fill:n.stroke,selectable:!0,evented:!0,objectCaching:!1});return r.annotationType="text",this.canvas.add(r),this.canvas.requestRenderAll(),r}drawCloudLine(e,t){if(e.length<2)return null;const i=this.mergeStyle(t),n=this.createCloudObject(e,i,!0);return n?(this.canvas.add(n),this.canvas.requestRenderAll(),n):null}getAllShapes(){return this.canvas.toObject(["annotationType"])}clearAllShapes(){this.canvas.clear(),this.canvas.requestRenderAll()}async restoreAllShapes(e){await this.canvas.loadFromJSON(e),this.canvas.requestRenderAll()}saveScreenshot(e="bim-snapshot.png"){const t=this.canvas.lowerCanvasEl;return t?c$(this.engine,t,e):null}resize(e,t){const i=this.engine.container;if(!i)return;const n=e??i.clientWidth??1,r=t??i.clientHeight??1;this.canvas.setDimensions({width:n,height:r}),this.canvas.requestRenderAll()}dispose(){this.stopDistanceMeasureMode(),window.removeEventListener("keydown",this.onKeyDown),this.canvas.off("mouse:down",this.onMouseDown),this.canvas.off("mouse:move",this.onMouseMove),this.canvas.off("mouse:up",this.onMouseUp),this.canvas.off("mouse:dblclick",this.onMouseDblClick),this.canvas.off("selection:created",this.onSelectionChanged),this.canvas.off("selection:updated",this.onSelectionChanged),this.canvas.off("selection:cleared",this.onSelectionChanged),this.toolbar.dispose(),this.canvas.dispose(),this.wrapper.remove()}handleMouseDown(e){if(!this.isActive||this.mode==="view"||!this.isViewLocked||this.drawType==="none"||e?.target)return;const t=this.getPointFromEvent(e);if(this.drawType==="text"){const n=this.drawText(t);this.canvas.setActiveObject(n),this.canvas.requestRenderAll(),setTimeout(()=>{n.enterEditing(),n.hiddenTextarea?.focus(),n.selectAll()},0);return}this.startPoint=t,this.cloudPoints=[t],this.canvas.selection=!1,this.canvas.discardActiveObject();const i=this.createDraftObject(t,t);i&&(this.tempObject=i,this.canvas.add(i),this.canvas.requestRenderAll())}handleMouseMove(e){if(!this.isActive||this.mode==="view"||!this.isViewLocked||!this.startPoint||!this.tempObject)return;const t=this.getPointFromEvent(e),i=this.drawStyle;if(this.drawType==="cloudline"){if(this.shouldAppendCloudPoint(t)){this.cloudPoints.push(t),this.canvas.remove(this.tempObject);const n=this.createCloudObject(this.cloudPoints,i,!1);if(!n)return;this.tempObject=n,this.canvas.add(n),this.canvas.requestRenderAll()}return}if(this.drawType==="arrow"){this.canvas.remove(this.tempObject),this.tempObject=this.createArrowObject(this.startPoint,t,i,!1),this.canvas.add(this.tempObject),this.canvas.requestRenderAll();return}this.updateDraftObject(this.startPoint,t),this.canvas.requestRenderAll()}handleMouseUp(e){if(!this.isActive||this.mode==="view"||!this.isViewLocked||!this.startPoint)return;const t=this.getPointFromEvent(e);this.drawType==="cloudline"&&this.cloudPoints.length===1&&(this.cloudPoints.push(t),this.canvas.remove(this.tempObject),this.tempObject=this.createCloudObject(this.cloudPoints,this.drawStyle,!0),this.tempObject&&this.canvas.add(this.tempObject)),this.tempObject&&(this.tempObject.set({selectable:!0,evented:!0}),this.tempObject.setCoords?.(),this.canvas.requestRenderAll()),this.startPoint=null,this.tempObject=null,this.cloudPoints=[],this.canvas.selection=!0}handleMouseDblClick(e){const t=e?.target;this.isTextObject(t)&&(t.enterEditing(),t.hiddenTextarea?.focus(),t.selectAll?.())}handleKeyDown(e){if(!this.isActive)return;const t=this.canvas.getActiveObject();if(!(this.isTextObject(t)&&t?.isEditing||this.isInputElement(e.target))){if(e.key==="Control"&&!e.repeat){this.toggleViewLock();return}if(e.key==="Escape"){e.preventDefault(),this.mode==="view"?this.handleCloseClick():this.handleCancelClick();return}if(e.key==="Enter"){this.mode==="edit"&&(e.preventDefault(),this.handleConfirmClick());return}e.key!=="Delete"&&e.key!=="Backspace"||!t||(e.preventDefault(),this.canvas.getActiveObjects().forEach(i=>this.canvas.remove(i)),this.canvas.discardActiveObject(),this.canvas.requestRenderAll())}}getPointFromEvent(e){if(e?.e){const i=this.canvas.getScenePoint(e.e);return{x:i.x,y:i.y}}const t=e?.scenePoint??e?.pointer??e?.absolutePointer;return t?{x:t.x,y:t.y}:{x:0,y:0}}shouldAppendCloudPoint(e){if(this.cloudPoints.length===0)return!0;const t=this.cloudPoints[this.cloudPoints.length-1],i=e.x-t.x,n=e.y-t.y;return Math.sqrt(i*i+n*n)>=6}createDraftObject(e,t){const i=this.drawStyle;switch(this.drawType){case"line":return this.createLineObject(e,t,i,!1);case"arrow":return this.createArrowObject(e,t,i,!1);case"rect":return this.createRectObject(e,t,i,!1);case"circle":return this.createCircleObject(e,t,i,!1);case"cloudline":return this.createCloudObject([e,t],i,!1);default:return null}}updateDraftObject(e,t){if(this.tempObject){if(this.drawType==="line"){this.tempObject.set({x2:t.x,y2:t.y});return}if(this.drawType==="rect"){const i=this.getBoxFromPoints(e,t);this.tempObject.set({left:i.left,top:i.top,width:i.width,height:i.height});return}if(this.drawType==="circle"){const i=this.getCircleFromPoints(e,t);this.tempObject.set({left:i.left,top:i.top,radius:i.radius})}}}mergeStyle(e){return{...this.drawStyle,...e??{}}}createObjectBase(e,t){return{stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,selectable:t,evented:t,objectCaching:!1}}createLineObject(e,t,i,n){const r=new Xo([e.x,e.y,t.x,t.y],{...this.createObjectBase(i,n),fill:"",strokeLineCap:"round"});return r.annotationType="line",r}createRectObject(e,t,i,n){const r=this.getBoxFromPoints(e,t),a=new Wo({...this.createObjectBase(i,n),left:r.left,top:r.top,width:r.width,height:r.height,originX:"left",originY:"top"});return a.annotationType="rect",a}createCircleObject(e,t,i,n){const r=this.getCircleFromPoints(e,t),a=new Ac({...this.createObjectBase(i,n),left:r.left,top:r.top,radius:r.radius,originX:"left",originY:"top"});return a.annotationType="circle",a}createArrowObject(e,t,i,n){const r=t.x-e.x,a=t.y-e.y,o=Math.sqrt(r*r+a*a);if(o<1e-6){const E=new Xo([e.x,e.y,t.x,t.y],{stroke:i.stroke,strokeWidth:i.strokeWidth,fill:"",selectable:n,evented:n}),w=new Qo([E],{selectable:n,evented:n,objectCaching:!1});return w.annotationType="arrow",w}const l=r/o,c=a/o,h=-c,d=l,u=Math.max(10,i.strokeWidth*6),p=u*.72,m=t.x-l*u,v=t.y-c*u,g=m+h*(p*.5),f=v+d*(p*.5),A=m-h*(p*.5),b=v-d*(p*.5),y=new Xo([e.x,e.y,t.x,t.y],{stroke:i.stroke,strokeWidth:i.strokeWidth,fill:"",strokeLineCap:"round",selectable:!1,evented:!1}),x=`M ${t.x} ${t.y} L ${g} ${f} L ${A} ${b} Z`,_=new vc(x,{fill:i.stroke,stroke:i.stroke,strokeWidth:1,selectable:!1,evented:!1,objectCaching:!1}),M=new Qo([y,_],{selectable:n,evented:n,objectCaching:!1});return M.annotationType="arrow",M}createCloudObject(e,t,i){const n=this.buildCloudPath(e,t.cloudRadius);if(!n)return null;const r=new vc(n,{stroke:t.stroke,strokeWidth:t.strokeWidth,fill:"",strokeLineCap:"round",strokeLineJoin:"round",selectable:i,evented:i});return r.annotationType="cloudline",r}getBoxFromPoints(e,t){return{left:Math.min(e.x,t.x),top:Math.min(e.y,t.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}getCircleFromPoints(e,t){const i=t.x-e.x,n=t.y-e.y,r=Math.max(Math.abs(i),Math.abs(n)),a=i>=0?e.x:e.x-r,o=n>=0?e.y:e.y-r;return{left:a,top:o,radius:Math.max(r/2,1)}}buildCloudPath(e,t){if(e.length<2)return"";const i=Math.max(2,t),n=i*1.4;let r=`M ${e[0].x} ${e[0].y}`,a=1;for(let o=1;o<e.length;o++){const l=e[o-1],c=e[o],h=c.x-l.x,d=c.y-l.y,u=Math.sqrt(h*h+d*d);if(u<.1)continue;const p=-d/u,m=h/u,v=Math.max(1,Math.round(u/n));for(let g=1;g<=v;g++){const f=g/v,A=l.x+h*f,b=l.y+d*f,y=a%2===0?-1:1,x=A+p*i*y,_=b+m*i*y;r+=` Q ${x} ${_} ${A} ${b}`,a++}}return r}handleColorInputChange(e){this.drawStyle.stroke=e||this.drawStyle.stroke,this.drawStyle.fill=this.colorToAlpha(this.drawStyle.stroke,.08),this.applyCurrentStyleToSelection(),this.refreshToolbarStyleValues()}handleStrokeWidthInputChange(e){const t=this.parseNumber(e,this.drawStyle.strokeWidth,1,20);this.drawStyle.strokeWidth=t,this.applyCurrentStyleToSelection(),this.refreshToolbarStyleValues()}handleFontSizeInputChange(e){const t=this.parseNumber(e,this.drawStyle.fontSize,10,96);this.drawStyle.fontSize=t,this.applyCurrentStyleToSelection(),this.refreshToolbarStyleValues()}applyCurrentStyleToSelection(){const e=this.canvas.getActiveObjects();e.length!==0&&(e.forEach(t=>this.applyStyleToObject(t)),this.canvas.requestRenderAll())}applyStyleToObject(e){if(!e)return;if(e.annotationType==="arrow"&&Array.isArray(e._objects)){e._objects.forEach(i=>{if(i?.type==="triangle"||i?.type==="path"){i.set({fill:this.drawStyle.stroke,stroke:this.drawStyle.stroke,strokeWidth:1});return}i?.set({stroke:this.drawStyle.stroke,strokeWidth:this.drawStyle.strokeWidth,strokeLineCap:"round"})}),e.set({dirty:!0}),e.setCoords?.();return}if(this.isTextObject(e)){e.set({fill:this.drawStyle.stroke,fontSize:this.drawStyle.fontSize}),e.setCoords?.();return}const t={stroke:this.drawStyle.stroke,strokeWidth:this.drawStyle.strokeWidth};e?.type==="line"||e?.type==="path"?t.fill="":t.fill=this.drawStyle.fill,e.set(t),e.setCoords?.()}syncStyleFromSelection(){const e=this.canvas.getActiveObject();if(!e)return;const t=this.readStyleFromObject(e);t.stroke&&(this.drawStyle.stroke=t.stroke,this.drawStyle.fill=this.colorToAlpha(t.stroke,.08)),typeof t.strokeWidth=="number"&&(this.drawStyle.strokeWidth=t.strokeWidth),typeof t.fontSize=="number"&&(this.drawStyle.fontSize=t.fontSize),this.refreshToolbarStyleValues()}readStyleFromObject(e){if(!e)return{};if(e.annotationType==="arrow"&&Array.isArray(e._objects)){const t=e._objects.find(i=>i?.type==="line")??e._objects[0];return{stroke:t?.stroke,strokeWidth:t?.strokeWidth}}return this.isTextObject(e)?{stroke:e.fill??this.drawStyle.stroke,fontSize:e.fontSize??this.drawStyle.fontSize}:{stroke:e.stroke??this.drawStyle.stroke,strokeWidth:e.strokeWidth??this.drawStyle.strokeWidth}}isTextObject(e){return e?e.type==="i-text"||e.type==="textbox"||e.annotationType==="text":!1}isInputElement(e){const t=e;if(!t||!t.tagName)return!1;const i=t.tagName.toLowerCase();return i==="input"||i==="textarea"||!!t.isContentEditable}applyCanvasInteractive(e){this.canvas.selection=e,this.canvas.getObjects().forEach(t=>{t.set({selectable:e,evented:e}),t.setCoords?.()}),this.canvas.discardActiveObject(),this.canvas.requestRenderAll()}parseNumber(e,t,i,n){const r=Number(e);return Number.isFinite(r)?Math.min(n,Math.max(i,r)):t}colorToAlpha(e,t){const i=e.trim(),n=/^#([0-9a-fA-F]{3})$/.exec(i);if(n){const a=n[1],o=parseInt(a[0]+a[0],16),l=parseInt(a[1]+a[1],16),c=parseInt(a[2]+a[2],16);return`rgba(${o}, ${l}, ${c}, ${t})`}const r=/^#([0-9a-fA-F]{6})$/.exec(i);if(r){const a=r[1],o=parseInt(a.slice(0,2),16),l=parseInt(a.slice(2,4),16),c=parseInt(a.slice(4,6),16);return`rgba(${o}, ${l}, ${c}, ${t})`}return this.drawStyle.fill}toggleMeasurePanel(){!this.isActive||this.mode!=="edit"||(this.isMeasurePanelExpanded=!this.isMeasurePanelExpanded,this.refreshToolbarState())}activateDistanceMeasure(e){if(!this.isActive||this.mode!=="edit")return;this.drawType="none",this.canvas.defaultCursor="default",this.isDistanceMeasureMode=!0,this.isMeasurePanelExpanded=!0,this.currentMeasureType=e,this.canvas.discardActiveObject(),this.canvas.requestRenderAll();const t=this.engine.measure;t?.active?.(),this.disActiveMeasureTools(t),this.activeMeasureTool(t,e),this.updateOverlayPointerEvents(),this.refreshToolbarState()}stopDistanceMeasureMode(){if(!this.isDistanceMeasureMode)return;const e=this.engine.measure;this.disActiveMeasureTools(e),this.isDistanceMeasureMode=!1,this.currentMeasureType=null,this.updateOverlayPointerEvents(),this.refreshToolbarState()}disActiveMeasureTools(e){e?.distanceMeasure?.disActive?.(),e?.clearDistanceMeasure?.disActive?.(),e?.clearHeightMeasure?.disActive?.(),e?.elevationMeasure?.disActive?.(),e?.pointMeasure?.disActive?.(),e?.angleMeasure?.disActive?.(),e?.areaMeasure?.disActive?.(),e?.slopeMeasure?.disActive?.()}activeMeasureTool(e,t){const i={distance:"distanceMeasure",clearDistance:"clearDistanceMeasure",clearHeight:"clearHeightMeasure",elevation:"elevationMeasure",point:"pointMeasure",angle:"angleMeasure",area:"areaMeasure",slope:"slopeMeasure"}[t];i&&e?.[i]?.active?.()}updateOverlayPointerEvents(){if(!this.isActive){this.wrapper.style.pointerEvents="none",this.canvasEl.style.pointerEvents="none";return}if(this.mode==="view"||this.isDistanceMeasureMode||!this.isViewLocked){this.wrapper.style.pointerEvents="none",this.canvasEl.style.pointerEvents="none",this.toolbar.root.style.pointerEvents="auto";return}this.wrapper.style.pointerEvents="auto",this.canvasEl.style.pointerEvents="auto",this.toolbar.root.style.pointerEvents="auto"}toggleViewLock(){!this.isActive||this.mode!=="edit"||this.isDistanceMeasureMode||(this.isViewLocked=!this.isViewLocked,this.isViewLocked?this.canvas.selection=!0:(this.startPoint=null,this.tempObject=null,this.cloudPoints=[],this.canvas.discardActiveObject(),this.canvas.selection=!1),this.canvas.requestRenderAll(),this.updateOverlayPointerEvents(),this.refreshToolbarState())}async handleCancelClick(){this.sessionSnapshot&&await this.restoreAllShapes(this.cloneJson(this.sessionSnapshot)),this.actionHandlers.onCancel?.(),this.disActive()}async handleCloseClick(){this.disActive()}handleConfirmClick(){const e=this.cloneJson(this.getAllShapes());this.actionHandlers.onConfirm?.(e),this.disActive()}refreshToolbarStyleValues(){this.toolbar.setStyleValues({stroke:this.drawStyle.stroke,strokeWidth:this.drawStyle.strokeWidth,fontSize:this.drawStyle.fontSize})}refreshToolbarState(){this.toolbar.setDrawType(this.drawType),this.toolbar.setMode(this.mode),this.toolbar.setMeasurePanelVisible(this.isMeasurePanelExpanded),this.toolbar.setMeasureState(this.isDistanceMeasureMode,this.currentMeasureType),this.toolbar.setEditPanelMasked(!this.isViewLocked),this.refreshToolbarStyleValues()}createScreenshotFileName(){const e=new Date,t=e.getFullYear(),i=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0"),r=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0"),o=String(e.getSeconds()).padStart(2,"0");return`bim-snapshot-${t}${i}${n}-${r}${a}${o}.png`}cloneJson(e){return JSON.parse(JSON.stringify(e))}}class w${engine;constructor(e){this.engine=e}get(){return{cameraPose:this.engine.cameraModule?.getCameraPose?.()??null,clipping:this.captureClippingState(),measureData:this.captureMeasureData(),annotationData:this.captureAnnotationData()}}async restore(e,t="view"){e&&(e.cameraPose&&this.engine.cameraModule?.restoreCameraPose?.(e.cameraPose),this.restoreClippingState(e.clipping),this.restoreMeasureData(e.measureData),await this.restoreAnnotationData(e.annotationData),this.applyAnnotationMode(t))}create(e){const t=this.engine.fabricDraw;if(!t){e?.(this.get());return}t.setActionHandlers({onConfirm:i=>{const n=this.get();n.annotationData=this.serializeSnapshotValue(i),e?.(n),this.clearAnnotation()},onCancel:()=>{this.clearAnnotation()}}),t.show?.(),t.active?.("edit"),t.setDrawType?.("none")}clearAnnotation(){this.engine.fabricDraw?.clearAllShapes?.(),this.engine.measure.disActive?.()}captureClippingState(){const e=this.engine.clipping,t=e?.sectionFace,i=e?.currentClippingMode??"",n={mode:i,fillCutFace:e?.getFillCutFace?.()??!0};if(i==="box"&&e?.sectionBox?.getboxXyz&&(n.box=e.sectionBox.getboxXyz()),i==="x"||i==="y"||i==="z"||i==="face"){const r=t?.normal;r&&(n.face={normal:{x:Number(r.x)||0,y:Number(r.y)||0,z:Number(r.z)||1},distance:Number(t?.distance)||0,direction:Number(t?.direction)===-1?-1:1})}return n}restoreClippingState(e){const t=this.engine.clipping;if(!t)return;typeof e?.fillCutFace=="boolean"&&t.setFillCutFace?.(e.fillCutFace);const i=e?.mode??"";if(!i){t.disActive?.();return}if(i==="box"){t.active?.("box"),e.box&&t.sectionBox?.setboxXyz?.(e.box);return}if(i==="x"||i==="y"||i==="z"){t.active?.(i),this.applyFaceState(e.face);return}if(i==="face"){this.restoreFaceMode(e.face);return}t.active?.(i)}restoreFaceMode(e){const t=this.engine.clipping,i=t?.sectionFace;!t||!i||(t.sectionBox?.disActive?.(),i.disActive?.(),i.active?.(),t.currentClippingMode="face",this.applyFaceState(e))}applyFaceState(e){if(!e)return;const t=this.engine.clipping?.sectionFace;if(!t)return;const i=new P(e.normal.x,e.normal.y,e.normal.z).normalize();t.direction=e.direction===-1?-1:1,t.setFaceNormal?.(i,e.distance??0)}captureMeasureData(){const e=this.engine.measure?.annotationData;return e?this.serializeSnapshotValue(e):null}restoreMeasureData(e){const t=this.engine.measure;if(!t)return;try{t.clearAll?.()}catch{}if(!e)return;const i=this.deserializeSnapshotValue(e);(!t.annotationData||typeof t.annotationData!="object")&&(t.annotationData={}),Object.keys(t.annotationData).forEach(n=>{t.annotationData[n]=[]}),Object.keys(i).forEach(n=>{t.annotationData[n]=Array.isArray(i[n])?i[n]:[]}),t.tools?.drawNormalAnnotation?.()}captureAnnotationData(){const e=this.engine.fabricDraw;return e?.getAllShapes?this.serializeSnapshotValue(e.getAllShapes()):null}async restoreAnnotationData(e){const t=this.engine.fabricDraw;if(!t)return;if(!e){t.clearAllShapes?.();return}const i=this.deserializeSnapshotValue(e);await t.restoreAllShapes?.(i)}applyAnnotationMode(e){const t=this.engine.fabricDraw;t&&(t.setActionHandlers?.({}),t.show?.(),t.active?.(e),t.setDrawType?.("none"))}serializeSnapshotValue(e){if(e==null)return e;if(e instanceof P)return{__type:"Vector3",x:e.x,y:e.y,z:e.z};if(Array.isArray(e))return e.map(t=>this.serializeSnapshotValue(t));if(typeof e=="object"){if(e instanceof HTMLElement||e instanceof SVGElement)return;const t={};return Object.keys(e).forEach(i=>{if(i==="container")return;const n=this.serializeSnapshotValue(e[i]);n!==void 0&&(t[i]=n)}),t}if(typeof e!="function")return e}deserializeSnapshotValue(e){if(e==null)return e;if(Array.isArray(e))return e.map(t=>this.deserializeSnapshotValue(t));if(typeof e=="object"){if(e.__type==="Vector3")return new P(e.x,e.y,e.z);const t={};return Object.keys(e).forEach(i=>{t[i]=this.deserializeSnapshotValue(e[i])}),t}return e}}class E${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;fabricDraw;drawingPin;models=[];reactBoundingClientRect={left:0,top:0};version="3.7.6";versionEl=null;container;constructor(e){if(window.THREE=XF,this.options=e,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);if(this.engineModelModule=new uQ(this),this.engineModelModule.init(),this.ai=new fq(this),this.deviceModule=new YF(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new Br(this),this.sceneModule=new qF(this),this.scene=this.sceneModule.scene,this.renderModule=new aH(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.renderer){const r=this.renderer;r.interactionCullingEnabled=!0,r.interactionActive=!1,r.interactionRenderScene=this.scene,r.interactionFrameBudgetMs=this.options.interactionFrameBudgetMs??6,r.interactionSkipShadows=this.options.interactionSkipShadows??!0}this.controlModule=new IH(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.clipping=new lq(this),this.clipping.init(),this.composerModule=new GH(this),this.composerModule.init(),this.events=new iQ,this.engineStatus=new tQ(this),this.engineStatus.init(),this.loaderModule=new eQ(this),this.lightModule=new aQ(this),this.lightModule.init(),this.viewCube=new QQ(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=jQ(this),this.rangeScale=new XQ(this),this.rangeScale.init(),this.setting=new rj(this),this.engineModelModule.init(),this.handelBehaved=kx(this),this.modelMapperBatch=new uq(this),this.measure=new fj(this),this.modelToolModule=new lQ(this),this.modelProperties=new dq(this),this.interactionModule=new oQ(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new F0(this),this.modelEdge=new nj(this),this.modelTree=new cq(this),this.viewTree=new wq(this),this.merge2d=new Dq(this),this.engineInfo=new hq(this),this.pathRoaming=new mq(this),this.pathRoaming.init(),this.oneClickEncoding=new _q(this),this.minMap=new gq(this),this.linkElement2d3d=new bq(this),this.linkView2d3d=new yq(this),this.grid=new KQ(this),this.level=new ij(this),this.issueReport=new vq(this),this.fabricDraw=new _$(this),this.drawingPin=new w$(this),this.text=new Aq(this),this.hdr=new JQ(this),this.ground=new A1(this),this.ground.init(),this.skyManager=new sj(this),this.setting.init(),this.worldToScreen=new Kt(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new gQ,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(To.EngineBusy),n.container&&(n.container.style.cursor="none")}),this.controls.addEventListener("end",()=>{n.renderer&&(n.renderer.interactionActive=!1),n.events.trigger(To.EngineFree),n.container&&(n.container.style.cursor="default")}),this.controls.addEventListener("change",()=>{const r=new P;n.camera.getWorldDirection(r);const a=Math.atan2(r.x,-r.z);let o=new CustomEvent("D3ViewUpdate",{detail:{position:n.camera.position,rotation:a,type:n.camera.type}});window.dispatchEvent(o)}),this.events.on(To.LoadingCompleted,r=>{n.modelEdge.active()}),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 r=performance.now();if(r-this._fpsLastCheck>=this._fpsCheckInterval){const a=r-this._fpsLastCheck,o=this._fpsFrameCount/a*1e3;this._fpsFrameCount=0,this._fpsLastCheck=r,o<this._fpsThreshold?(this._lowFpsCount++,this._highFpsCount=0,this._lowFpsCount>=this._lowFpsRequired&&r-this._fpsLastSwitch>this._fpsSwitchCooldown&&(this._adaptiveRenderingDowngrade(),this._fpsLastSwitch=r,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.lightModule.updateShadowCameraRange(this.camera))}},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 P;e.getWorldDirection(i);const n=100,r=new P().copy(i).multiplyScalar(-n),a=new P(0,1,0),o=new P().crossVectors(i,a).normalize();r.addScaledVector(a,n*.5),r.addScaledVector(o,n*.3),t.position.copy(e.position).add(r);const l=new P().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,r=this.cameraModule.getOrthographicVisibleHeight(n);this.cameraModule.setOrthographicVisibleHeight(r,n),n.updateProjectionMatrix()}if(this.catchSvg){const n=this.container.clientWidth,r=this.container.clientHeight;this.catchSvg.setAttribute("viewBox",`0 0 ${n} ${r}`)}this.fabricDraw&&this.fabricDraw.resize(e,t),this.events&&this.events.trigger(To.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.fabricDraw&&this.fabricDraw.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 We&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(t=>this.disposeMaterial(t)):this.disposeMaterial(e.material))),e instanceof Ci&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof Xm&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof hi&&(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 gu&&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 Ai&&i.dispose()}),e.dispose())}}const M$=`
|
||
varying vec2 vWorldPos;
|
||
|
||
void main() {
|
||
vec4 worldPosition = modelMatrix * vec4(position, 1.0);
|
||
vWorldPos = worldPosition.xy;
|
||
gl_Position = projectionMatrix * viewMatrix * worldPosition;
|
||
}
|
||
`,S$=`
|
||
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 C${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 qe(this.smallGridColor)},majorColor:{value:new qe(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 Si,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 Ds(1,1,1,1),this.gridMaterial=new mi({uniforms:this.gridUniforms,vertexShader:M$,fragmentShader:S$,transparent:!0,depthWrite:!1,depthTest:!1,side:qt,toneMapped:!1}),this.gridMesh=new We(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),r=[1,2,5,10];for(const a of r){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,r=this.camera.right-this.camera.left,a=this.camera.top-this.camera.bottom,o=Math.max(this.minSpacing,r/n),l=Math.max(this.minSpacing,a/n),c=this.camera.position.x,h=this.camera.position.y,d=o/t,u=l/i,p=d*this.desiredMinorPixelSize,m=this.normalizeSpacing(p),v=this.lastState;if(!e){const A=Math.abs(n-v.zoom)/Math.max(1e-4,v.zoom||1)>.02,b=Math.abs(m-v.minorSpacing)>v.minorSpacing*.05,y=Math.abs(c-v.centerX)>Math.max(m*.5,.01),x=Math.abs(h-v.centerY)>Math.max(m*.5,.01),_=Math.abs(o-v.viewWidth)>v.viewWidth*.01,M=Math.abs(l-v.viewHeight)>v.viewHeight*.01,E=t!==v.containerWidth||i!==v.containerHeight;if(!(A||b||y||x||_||M||E))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=m,this.gridUniforms.worldPerPixel.value.set(d,u),this.lastState={zoom:n,centerX:c,centerY:h,viewWidth:o,viewHeight:l,containerWidth:t,containerHeight:i,minorSpacing:m}}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 T${engine;scene;options;adaptiveGrid;axesHelper;constructor(e,t){this.engine=e,this.options=t,this.scene=this.createScene(),this.initHelpers()}createScene(){const e=new ll,t=this.options.backgroundColor??1710618;return e.background=new qe(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 C$(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 oS(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 qe(e),this.updateGridColorsByBackground(e)}updateGridColorsByBackground(e){if(!this.adaptiveGrid)return;const t=new qe(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 We&&(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 We?e++:n instanceof Ci?t++:n instanceof Si&&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 I${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 P${engine;orthographicCamera;container;frustumSize=1e3;near=.1;far=1e4;initialZoom=1;defaultPosition=new P(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 Zi(-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 r=new P(e.min[0],e.min[1]),a=new P(e.max[0],e.max[1]);if(!(r.distanceTo(a)>.001)){console.warn("[CameraModule2d] Invalid extents, using default view"),this.resetView();return}const o=new P;o.addVectors(r,a).multiplyScalar(.5);const l=new P;l.subVectors(a,r);const c=Math.max(l.x,l.y)*t,h=this.container.clientWidth/this.container.clientHeight,d=c/2,u=d*h,p=-u,m=u,v=d,g=-d,f=o.x,A=o.y,b=1;if(!i){this.orthographicCamera.left=p,this.orthographicCamera.right=m,this.orthographicCamera.top=v,this.orthographicCamera.bottom=g,this.orthographicCamera.position.set(f,A,this.defaultPosition.z),this.orthographicCamera.zoom=b,this.orthographicCamera.updateProjectionMatrix(),this.engine.controlModule2d?.panControls&&(this.engine.controlModule2d.panControls.setPosition(f,A),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:p,right:m,top:v,bottom:g,x:f,y:A,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),r=this.easeOutCubic(n),a=this.animationStartState,o=this.animationTargetState;this.orthographicCamera.left=this.lerp(a.left,o.left,r),this.orthographicCamera.right=this.lerp(a.right,o.right,r),this.orthographicCamera.top=this.lerp(a.top,o.top,r),this.orthographicCamera.bottom=this.lerp(a.bottom,o.bottom,r),this.orthographicCamera.position.x=this.lerp(a.x,o.x,r),this.orthographicCamera.position.y=this.lerp(a.y,o.y,r),this.orthographicCamera.zoom=this.lerp(a.zoom,o.zoom,r),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:r}),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,r=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+r,width:n-i,height:r-a}}screenToWorld(e,t){const i=new P(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 P(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 D${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 Uu({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 qe(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 R$ extends Ys{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 P;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,r=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*r*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,r=(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*r*(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,r=1/this.object.zoom,a=this.object.top-this.object.bottom,o=this.object.right-this.object.left,l=i/this.domElement.clientWidth*o*r,c=n/this.domElement.clientHeight*a*r;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 B${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 R$(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 L${engine;pickBoxElementIds=[];worldToScreen;constructor(e){this.engine=e,this.pickBoxElementIds=[],this.worldToScreen=new Kt(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 r=[];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 Oi){let u=new xt(c.min,c.max),p=e.ray.intersectsBox(u);if(p!=null&&p!=!1){var h=this.engine.modelGroup.children[c.indexes[0]].clonePoints.slice(c.indexes[1],c.indexes[2]);let m=[],v=[];for(let f=0;f<h.length/3;f++)m.push(new P(h[f*3],h[f*3+1],h[f*3+2]));for(let f=0;f<m.length/2;f++)v.push([m[f*2],m[f*2+1]]);v=v.filter(f=>f[0].distanceTo(f[1])>.001);let g=[];m.forEach(f=>{let A=this.worldToScreen.worldToScreen(f);g.push(A)});for(let f=0;f<g.length/2;f++)v.push([g[f*2],g[f*2+1]]);v=v.filter(f=>f[0].distanceTo(f[1])>1),v=v.filter(f=>o(n,f[0],f[1])<10),v.length>0&&v.forEach(f=>{r.push({distance:o(n,f[0],f[1]),linkId:l})})}}else{let u=d.geometrys[c.indexes[1]];const p=new Wt;let m=new We(u,p);m.linkId=l,i.push(m)}}})});const a=e.intersectObjects(i,!0);if(a.length>0)return a[0].object.linkId;if(r.length>0)return r[0].linkId;return null;function o(l,c,h){const d=new be().subVectors(h,c),u=d.lengthSq();if(u<1e-10)return l.distanceTo(c);const p=new be().subVectors(l,c),m=Bt.clamp(p.dot(d)/u,0,1),v=new be().copy(d).multiplyScalar(m).add(c);return l.distanceTo(v)}}RecurrentIteration(e,t){if(t==null)return;let i=new P(t.min.X,t.min.Y,0),n=new P(t.max.X,t.max.Y,0),r=new P(Math.min(i.x,n.x),Math.min(i.y,n.y),Math.min(i.z,n.z)),a=new P(Math.max(n.x,i.x),Math.max(n.y,i.y),Math.max(n.z,i.z)),o=new xt(r,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 k${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 Kt(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 r=n-this.rotationStartAngle;this.widgetRotation=this.widgetRotationStart+r,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,r=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(r)*n,l=-Math.cos(r)*n,c=Math.sin(r)*n,h=-Math.cos(r)*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 P(e.position.x,e.position.y,e.position.z),this.currentWordPosition=new P(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 P(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 r={source:"LinkView2d3d",mode:e};if(t.position2d&&this.lastCameraWorldPosition){const a=this.lastCameraWorldPosition.y,o=-t.position2d.y;r.position={x:t.position2d.x,y:a,z:o},this.lastCameraWorldPosition=new P(t.position2d.x,a,o)}n&&(r.rotation=t.rotation),window.dispatchEvent(new CustomEvent("D2ViewControl",{detail:r}))}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 O${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 F${engine;highlightMaterial;hideMaterial;translucentMaterial;constructor(e){this.engine=e,this.highlightMaterial=new Wt({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:qt}),this.hideMaterial=new Wt({color:0,transparent:!0,opacity:0,side:qt}),this.translucentMaterial=new Wt({color:16777215,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:qt}),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 hi)return;let t=e.materialClone.clone(),i=Ea(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 Oi){var r=this.engine.modelGroup.children[n.indexes[0]].clonePoints.slice(n.indexes[1],n.indexes[2]);this.highLightRenderLineHover(r)}else{let a=new We(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 Oi){var r=this.engine.modelGroup.children[n.indexes[0]].clonePoints.slice(n.indexes[1],n.indexes[2]);this.highLightRenderLine(r)}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 Oi||(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 Oi){let r=this.engine.modelGroup.children[n.indexes[0]].geometry.attributes.position.array;for(let a=n.indexes[1];a<n.indexes[2];a++)r[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 Oi){let r=this.engine.modelGroup.children[n.indexes[0]].geometry.attributes.position.array;for(let a=n.indexes[1];a<n.indexes[2];a++)r[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 dt;t.setAttribute("position",new it(e,3));const i=new bi({color:43775,depthTest:!1,depthWrite:!1}),n=new Oi(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 dt;t.setAttribute("position",new it(e,3));const i=new bi({color:16777215,depthTest:!1,depthWrite:!1}),n=new Oi(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 N$(s){const e={self:null,options:null,mouseDownTime:0,mouseDownPosition:null,lastClickTime:0};e.init=function(v,g){e.self!=null&&e.self.disActive!=null&&e.self.type!=v.type&&e.self.disActive(),e.self=v,g==null&&(g={showCatch:!1}),e.options=g},e.render=function(){e.self&&e.self.render!=null&&e.self.render()},e.active=function(){s.renderer.domElement.addEventListener("mousedown",o),s.renderer.domElement.addEventListener("mouseup",c),s.renderer.domElement.addEventListener("mousemove",l),s.renderer.domElement.addEventListener("touchstart",d,{passive:!1}),s.renderer.domElement.addEventListener("touchend",p,{passive:!1}),s.renderer.domElement.addEventListener("touchmove",u,{passive:!1}),window.addEventListener("keydown",t),window.addEventListener("keyup",i)},e.disActive=function(){s.renderer.domElement.removeEventListener("mousedown",o),s.renderer.domElement.removeEventListener("mouseup",c),s.renderer.domElement.removeEventListener("mousemove",l),s.renderer.domElement.removeEventListener("touchstart",d),s.renderer.domElement.removeEventListener("touchend",p),s.renderer.domElement.removeEventListener("touchmove",u),window.removeEventListener("keydown",t),window.removeEventListener("keyup",i)};function t(v){(v.keyCode===8||v.keyCode===46)&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),v.keyCode===27&&e.self&&e.self.handelKeyEscDown!=null&&e.self.handelKeyEscDown(),v.keyCode===13&&e.self&&e.self.handelKeyEnterDown!=null&&e.self.handelKeyEnterDown(),v.keyCode===32&&e.self&&e.self.handelKeySpaceDown!=null&&e.self.handelKeySpaceDown(),v.key==="Control"&&e.self&&e.self.handelKeyCtrlDown!=null&&e.self.handelKeyCtrlDown(),v.key==="Delete"&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),v.key==="Shift"&&e.self&&e.self.handelKeyShiftDown!=null&&e.self.handelKeyShiftDown(),v.key==="Meta"&&e.self&&e.self.handelKeyMetaDown!=null&&e.self.handelKeyMetaDown()}function i(v){v.key==="Alt"&&e.self&&e.self.handelKeyAltUp!=null&&e.self.handelKeyAltUp(),v.key==="Tab"&&e.self&&e.self.handelKeyTabUp!=null&&e.self.handelKeyTabUp(),v.key==="Control"&&e.self&&e.self.handelKeyCtrlUp!=null&&e.self.handelKeyCtrlUp(),v.key==="Shift"&&e.self&&e.self.handelKeyShiftUp!=null&&e.self.handelKeyShiftUp(),v.key==="Meta"&&e.self&&e.self.handelKeyMetaUp!=null&&e.self.handelKeyMetaUp(),v.key==="Command"&&e.self&&e.self.handelKeyCommandUp!=null&&e.self.handelKeyCommandUp(),v.key==="Windows"&&e.self&&e.self.handelKeyWindowsUp!=null&&e.self.handelKeyWindowsUp()}function n(v){const g=new be,f=s.renderer.domElement.clientWidth,A=s.renderer.domElement.clientHeight;return g.x=v.offsetX/f*2-1,g.y=-(v.offsetY/A)*2+1,g}function r(v){const g=new fs,f=n(v);return g.setFromCamera(f,s.camera),g}function a(v,g=!1){const f=r(v);if(v.raycaster=f,g){const A=m(f,v);v.catch=A}}function o(v){v.button===0&&(e.mouseDownTime=Date.now(),e.mouseDownPosition=new P(v.offsetX,v.offsetY,0),e.self&&e.self.handleMouseDown!=null&&(s.engineStatus.isFree=!0,a(v,!0),v.catch!=null&&s.controlModule.orbitControls.origin.set(v.catch.point.x,v.catch.point.y,v.catch.point.z),e.self.handleMouseDown(v)))}function l(v){a(v,!0),e.self&&e.self.handleMouseMove!=null&&e.self.handleMouseMove(v)}function c(v){if(v.button!==0)return;const g=Date.now(),f=g-e.mouseDownTime,A=new P(v.offsetX,v.offsetY,0);e.self&&e.self.handleMouseUp!=null&&(a(v,!1),e.self.handleMouseUp(v));const b=A.distanceTo(e.mouseDownPosition);(f<100||b==0)&&e.self&&e.self.handleMouseClick!=null&&(a(v,!0),g-e.lastClickTime<200?e.self.handleMouseDoubleClick!=null&&e.self.handleMouseDoubleClick(v):e.self.handleMouseClick!=null&&e.self.handleMouseClick(v),e.lastClickTime=Date.now())}function h(v){const g=v.touches[0]||v.changedTouches[0];if(!g)return null;const f=s.renderer.domElement.getBoundingClientRect(),A=g.clientX-f.left,b=g.clientY-f.top;return{offsetX:A,offsetY:b,button:0,clientX:g.clientX,clientY:g.clientY,preventDefault:()=>v.preventDefault(),stopPropagation:()=>v.stopPropagation(),originalEvent:v}}function d(v){if(v.preventDefault(),v.touches.length!==1)return;const g=h(v);g&&o(g)}function u(v){if(v.preventDefault(),v.touches.length!==1)return;const g=h(v);g&&l(g)}function p(v){v.preventDefault();const g=h(v);g&&c(g)}function m(v,g){var f=s.octreeBox2d.pick2d(v,g);return f==null?null:{point:null,id:f}}return e}class U${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 vR=(s=>(s.ModelLoadStart="model-load-start",s.ModelLoadProgress="model-load-progress",s.ModelLoaded="model-loaded",s.ModelError="model-error",s.SelectionChanged="selection-changed",s.HoverChanged="hover-changed",s.Click="click",s.MouseMove="mouse-move",s.CameraChanged="camera-changed",s.CameraIdle="camera-idle",s.EngineFree="engine-free",s.EngineBusy="engine-busy",s.MeasureChanged="measure-changed",s.MeasureClick="measure-click",s.SectionMove="section-move",s))(vR||{});class z${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 U$(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(vR.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 H${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 G$=[{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 V${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",G$.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 r=this.menu.offsetWidth,a=this.menu.offsetHeight,o=this.container.clientWidth,l=this.container.clientHeight;i+r>o&&(i=o-r-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 W${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 r=document.createElement("div");r.style.cssText=`
|
||
font-size:13px; color:var(--e2d-text2,#ccc);
|
||
text-align:center; white-space:nowrap;
|
||
`,r.textContent="正在加载...",this.textEl=r;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(r),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 Q$=`<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>`,j$=`<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>`,X$={房间:"#4fc3f7",门:"#81c784",窗:"#aed581",柱:"#ff8a65",梁:"#ffb74d",楼梯:"#ce93d8",电梯:"#80deea",设备间:"#f48fb1",轴线:"#90a4ae",墙体:"#bcaaa4",室外:"#a5d6a7"};class q${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">${Q$}</span>
|
||
<input
|
||
class="engine-2d-search__input"
|
||
type="text"
|
||
placeholder="搜索元素、图层、类型…"
|
||
autocomplete="off"
|
||
spellcheck="false"
|
||
/>
|
||
<button class="engine-2d-search__clear" title="清除">${j$}</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,r)=>{const a=document.createElement("li");a.className="engine-2d-search__item",a.setAttribute("role","option"),a.dataset.index=String(r);const o=X$[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=r;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 Y$=[{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 K${engine;searchUI=null;constructor(e){this.engine=e;const t=document.getElementById(e?.options?.containerId??"")??e?.container??null;t&&(this.searchUI=new q$(t,this))}search(e){const t=e.trim().toLowerCase();return t?Y$.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 AR={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 $${container;current;constructor(e,t="dark"){this.container=e,this.current=t,this._apply(t)}_apply(e){const t=AR[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(AR[this.current]))this.container.style.removeProperty(e);this.container.removeAttribute("data-e2d-theme")}}class Z${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=N$(this),this.interactionModule2d=new z$(this),this.interactionModule2d.init(),this.interactionModule2d.active()}initialize(){this.events=new Eq(!1),this.sceneModule2d=new T$(this,this.options),this.scene=this.sceneModule2d.scene,this.cameraModule2d=new P$(this,this.container),this.camera=this.cameraModule2d.orthographicCamera,this.renderModule2d=new D$(this,this.container,this.options),this.renderer=this.renderModule2d.renderer,this.controlModule2d=new B$(this),this.loaderModule2d=new $I(this),this.themeManager=new $$(this.container),this.layerManager=new KI(this),this.searchManager=new K$(this),this.octreeBox2d=new L$(this),this.modelToolModule2d=new F$(this),this.engineStatus2d=new I$(this),this.linkView2d3d=new k$(this),this.linkElement2d3d=new O$(this),this.sceneModule2d.initGrid(),this.cadCursorUI=new H$(this.container,this.renderer.domElement),this.loadingUI=new W$(this.container),this.events.on(xs.ModelLoadStart,()=>this.loadingUI.show("正在加载...",0)),this.events.on(xs.ModelLoadProgress,e=>this.loadingUI.update(e.text,e.progress)),this.events.on(xs.ModelLoaded,()=>this.loadingUI.hide()),this.events.on(xs.ModelLoadError,()=>this.loadingUI.hide()),this.contextMenuUI=new V$(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(xs.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,r=`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 u=t.toDataURL(r,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 p={dataURL:u};if(e?.download){const m=e.filename||`capture-${Date.now()}.${i}`,v=document.createElement("a");v.href=u,v.download=m,v.style.display="none",document.body.appendChild(v),v.click(),v.remove(),console.log(`[EngineKernel2d] Image captured and downloaded: ${m}`)}else console.log("[EngineKernel2d] Image captured");return p}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,r=`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 u=t.toDataURL(r,n),p=await new Promise(v=>{t.toBlob(g=>{g&&v(g)},r,n)}),m=URL.createObjectURL(p);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 v=e.filename||`capture-${Date.now()}.${i}`,g=document.createElement("a");g.href=m,g.download=v,g.style.display="none",document.body.appendChild(g),g.click(),g.remove(),console.log(`[EngineKernel2d] Image captured and downloaded: ${v}`)}else console.log("[EngineKernel2d] Image captured with Blob URL:",m);return{dataURL:u,blobURL:m,blob:p}}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 J${scene;panoramaSphere=null;sphereRadius;constructor(e=500){this.sphereRadius=e,this.scene=new ll,this.init()}init(){this.panoramaSphere=this.createPanoramaSphere(this.sphereRadius),this.scene.add(this.panoramaSphere)}createPanoramaSphere(e=500,t=64){const i=new ao(e,t,t/2);i.scale(-1,1,1);const n=new Wt({map:null,side:Yn,transparent:!0}),r=new We(i,n);return r.name="panorama-sphere",r}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 eZ{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 wi(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 Yi(t,e,0,"YXZ"),n=new Lt;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 tZ{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 Uu({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 iZ{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:r}=this.getRotationFactors();this.thetaDelta+=t*n*this.rotateSpeed*.06,this.phiDelta+=i*r*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:r}=this.getRotationFactors();this.thetaDelta-=t*n*this.rotateSpeed,this.phiDelta-=i*r*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=Bt.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=Bt.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 nZ{controls;domElement;cameraModule;constructor(e,t){this.cameraModule=e,this.domElement=t,this.controls=new iZ(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 sZ{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 lo().load(e,r=>{r.colorSpace=ci,r.minFilter=wt,r.magFilter=wt,this.cache.set(e,r),this.loadingPromises.delete(e),i(r)},void 0,r=>{this.loadingPromises.delete(e),n(r)})});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 rZ{textureCache;currentUrl=null;loadProgress=0;onProgressCallback;constructor(){this.textureCache=new sZ}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 lo().load(e,n=>{n.colorSpace=ci,n.minFilter=wt,n.magFilter=wt,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 bR{static sphericalToCartesian(e){const t=e.radius||500,{theta:i,phi:n}=e,r=t*Math.cos(n)*Math.cos(i),a=t*Math.sin(n),o=t*Math.cos(n)*Math.sin(i);return{x:r,y:a,z:o}}static cartesianToSpherical(e,t,i){const n=Math.sqrt(e*e+t*t+i*i),r=Math.asin(t/n);let a=Math.atan2(i,e);return a<0&&(a+=2*Math.PI),{theta:a,phi:r,radius:n}}static normalizeAngle(e,t=-Math.PI,i=Math.PI){const n=i-t;let r=e;for(;r<t;)r+=n;for(;r>i;)r-=n;return r}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 r=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:r,phi:a,radius:c}}}var df=(s=>(s.ICON="icon",s.TEXT="text",s.LINK="link",s))(df||{});class aZ{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 Kt(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),r={id:t,config:e,element:n,worldPosition:i,screenPosition:{x:0,y:0},visible:!1};return this.annotationContainer.appendChild(n),this.annotations.set(t,r),this.updateAnnotationPosition(r),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 df.ICON:this.createIconAnnotation(i,e);break;case df.TEXT:this.createTextAnnotation(i,e);break;case df.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 r=document.createElement("img");r.src=t.iconUrl,r.style.cssText=`
|
||
width: 16px;
|
||
height: 16px;
|
||
display: block;
|
||
`,e.appendChild(r)}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 bR.sphericalToCartesian({...e,radius:t})}updateAnnotationPosition(e){const t=new P(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),r=this.isPositionInView(i);e.visible=n&&r,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 P;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===df.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 oZ{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 r=n.indexOf(t);r!==-1&&n.splice(r,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 r=[...n];for(const a of r)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 qr=(s=>(s.PanoramaLoadStart="panorama-load-start",s.PanoramaLoadProgress="panorama-load-progress",s.PanoramaLoaded="panorama-loaded",s.PanoramaLoadError="panorama-load-error",s.AnnotationClick="annotation-click",s.AnnotationHover="annotation-hover",s.AnnotationAdd="annotation-add",s.AnnotationRemove="annotation-remove",s.ViewAngleChanged="view-angle-changed",s))(qr||{});class lZ{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 oZ,this.sceneModule=new J$(t.sphereRadius),this.cameraModule=new eZ(i,t.fov,t.minFov,t.maxFov),this.renderModule=new tZ(i,!0),this.controlModule=new nZ(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((r,a)=>{this.eventModule.trigger(qr.ViewAngleChanged,{theta:r,phi:a})}),this.panoramaLoader=new rZ,this.worldToScreen=new Kt(this.cameraModule.getCamera(),this.renderModule.getRenderer(),this.sceneModule.getScene()),this.annotationManager=new aZ(i,this.cameraModule.getCamera(),this.renderModule.getRenderer(),t.sphereRadius),this.annotationManager.setOnClickAnnotation(r=>{this.eventModule.trigger(qr.AnnotationClick,{id:r.id,config:r.config,metadata:r.config.metadata})}),this.annotationManager.setOnHoverAnnotation(r=>{this.eventModule.trigger(qr.AnnotationHover,{annotation:r?{id:r.id,config:r.config,metadata:r.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(qr.PanoramaLoadStart,{url:e});try{this.panoramaLoader.setOnProgress(i=>{this.eventModule.trigger(qr.PanoramaLoadProgress,{url:e,progress:i})});const t=await this.panoramaLoader.loadTexture(e);this.sceneModule.updatePanoramaTexture(t),this.eventModule.trigger(qr.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(qr.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(qr.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(qr.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,r=i.clientHeight;if(n===0||r===0)return null;const a=new be(e/n*2-1,-(t/r*2-1)),o=this.cameraModule.getCamera(),l=new P(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=bR.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 cZ(s){return new E$(s)}function hZ(s){return new Z$(s)}function dZ(s){return new lZ(s)}class uZ{engine=null;registry;container;containerId;options;_isInitialized=!1;_isDestroyed=!1;unsubscribeTheme=null;currentMeasureType=null;isMeasureActive=!1;currentSectionMode=null;selectedComponent=null;viewDropdownTrigger=null;viewDropdownMenu=null;infoButton=null;helpPanel=null;unsubscribeLocale=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=cZ(e),!this.engine)throw new Error("Failed to create engine instance");this._isInitialized=!0,this.resize(this.container.clientWidth,this.container.clientHeight),this.unsubscribeTheme=ct.subscribe(i=>{this.setTheme(i)}),this.setTheme(ct.getTheme()),this.engine?.events?.on?(this.engine.events.on("click",i=>{const n=this.registry;console.log("[Engine] 底层 click 事件触发:",i),i&&Array.isArray(i)&&i.length>0&&i[0].url?(this.selectedComponent={url:i[0].url,id:i[0].ids?.[0]},console.log("[Engine] 触发 component:selected:",this.selectedComponent),n.emit("component:selected",this.selectedComponent)):(this.selectedComponent=null,console.log("[Engine] 触发 component:deselected"),n.emit("component:deselected",{}))}),this.engine.events.on("loading_completed",()=>{console.log("[Engine] 底层 LoadingCompleted 事件触发"),this.registry.emit("engine:model-loading-completed",{}),this.helpPanel?.shouldAutoShow()&&this.helpPanel.show()})):console.warn("[Engine] 底层引擎不支持 events.on 方法,无法监听点击事件");const t=this.engine.oneClickEncoding;t?.on&&(t.on("encoding-start",i=>{console.log("[Engine] 底层 encoding-start 事件触发:",i),this.registry.emit("encoding:start",i)}),t.on("encoding-complete",i=>{console.log("[Engine] 底层 encoding-complete 事件触发:",i),this.registry.emit("encoding:complete",i)}),t.on("encoding-error",i=>{console.log("[Engine] 底层 encoding-error 事件触发:",i),this.registry.emit("encoding:error",i)})),this.createViewDropdown(),this.initHelpPanel(),this.createInfoButton(),this.unsubscribeLocale=Ft.subscribe(()=>{this.updateViewDropdownText()})}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()}switchToPerspectiveCamera(){if(!this._isInitialized||!this.engine?.cameraModule){console.warn("[Engine] Cannot switch to perspective camera: engine not initialized.");return}this.engine.cameraModule.switchToPerspectiveCamera()}saveMainView(){if(!this._isInitialized||!this.engine?.viewCube)return console.warn("[Engine] Cannot save main view: engine not initialized."),null;const e=this.engine.viewCube.saveMainViewPort();return this.registry.emit("view:main-view-saved",{viewData:e}),e}restoreMainView(){if(!this._isInitialized||!this.engine?.viewCube){console.warn("[Engine] Cannot reset main view: engine not initialized.");return}this.engine.viewCube.resetMainViewPort(),this.registry.emit("view:main-view-restored",{})}setMainViewPort(e){if(!this._isInitialized||!this.engine?.viewCube){console.warn("[Engine] Cannot set main view: engine not initialized.");return}this.engine.viewCube.setMainViewPort(e)}captureScreenshot(){if(!this._isInitialized||!this.engine?.viewCube){console.warn("[Engine] Cannot capture screenshot: engine not initialized.");return}this.engine.viewCube.screenshot()}createViewDropdown(){const e=document.createElement("div");e.className="engine-view-dropdown-trigger",e.innerHTML=gt("doubleArrowDown"),e.title=Ft.t("viewDropdown.triggerTitle"),e.addEventListener("click",t=>{t.stopPropagation(),this.toggleViewDropdown()}),this.container.appendChild(e),this.viewDropdownTrigger=e}initHelpPanel(){this.helpPanel=new Af,this.helpPanel.init(),this.container.appendChild(this.helpPanel.element)}createInfoButton(){const e=document.createElement("div");e.className="engine-info-button",e.innerHTML=gt("default"),e.title="信息",e.addEventListener("click",t=>{t.stopPropagation(),this.helpPanel?.show()}),this.container.appendChild(e),this.infoButton=e}toggleViewDropdown(){if(this.viewDropdownMenu){this.closeViewDropdown();return}const e=document.createElement("div");e.className="engine-view-dropdown-menu",[{key:"switchOrthographic",action:()=>this.switchToOrthographicCamera()},{key:"switchPerspective",action:()=>this.switchToPerspectiveCamera()},{key:"saveMainView",action:()=>this.saveMainView()},{key:"restoreMainView",action:()=>this.restoreMainView()},{key:"captureScreenshot",action:()=>this.captureScreenshot()}].forEach(r=>{const a=document.createElement("div");a.className="engine-view-dropdown-item",a.dataset.key=r.key,a.textContent=Ft.t(`viewDropdown.${r.key}`),a.addEventListener("click",o=>{o.stopPropagation(),r.action(),this.closeViewDropdown()}),e.appendChild(a)});const i=this.viewDropdownTrigger.getBoundingClientRect();e.style.position="fixed",e.style.top=`${i.bottom+4}px`,e.style.right=`${window.innerWidth-i.right}px`,e.style.zIndex="10000",document.body.appendChild(e),this.viewDropdownMenu=e;const n=r=>{e.contains(r.target)||(this.closeViewDropdown(),document.removeEventListener("mousedown",n))};document.addEventListener("mousedown",n)}closeViewDropdown(){this.viewDropdownMenu&&(this.viewDropdownMenu.remove(),this.viewDropdownMenu=null)}updateViewDropdownText(){if(!this.viewDropdownTrigger||(this.viewDropdownTrigger.title=Ft.t("viewDropdown.triggerTitle"),!this.viewDropdownMenu))return;const e=this.viewDropdownMenu.querySelectorAll(".engine-view-dropdown-item"),t=["switchOrthographic","switchPerspective","saveMainView","restoreMainView","captureScreenshot"];e.forEach((i,n)=>{t[n]&&(i.textContent=Ft.t(`viewDropdown.${t[n]}`))})}onRawEvent(e,t){this.engine?.events?.on(e,t)}offRawEvent(e,t){this.engine?.events?.off(e,t)}onOneClickEncodingEvent(e,t){this.engine?.oneClickEncoding?.on(e,t)}offOneClickEncodingEvent(e,t){this.engine?.oneClickEncoding?.off(e,t)}startOneClickEncoding(){if(!this._isInitialized||!this.engine?.oneClickEncoding){console.warn("[Engine] oneClickEncoding not available.");return}this.engine.oneClickEncoding.start()}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()}createDrawingPin(e){if(console.log("[Engine] createDrawingPin called"),!this._isInitialized||!this.engine?.drawingPin){console.warn("[Engine] drawingPin.create not available. initialized:",this._isInitialized,"drawingPin:",!!this.engine?.drawingPin);return}console.log("[Engine] calling this.engine.drawingPin.create"),this.engine.drawingPin.create(e)}async restoreDrawingPin(e){if(!this._isInitialized||!this.engine?.drawingPin){console.warn("[Engine] drawingPin.restore not available.");return}return this.engine.drawingPin.restore(e,"edit")}setPinRecords(e){console.log("[Engine] setPinRecords called, records count:",e.length),this.registry.emit("drawingPin:list-updated",{records:e})}setPinList(e){this.setPinRecords(e)}dispose(){if(!this._isInitialized||!this.engine){console.warn("[Engine] Engine not initialized.");return}this.closeViewDropdown(),this.viewDropdownTrigger&&(this.viewDropdownTrigger.remove(),this.viewDropdownTrigger=null),this.infoButton&&(this.infoButton.remove(),this.infoButton=null),this.helpPanel&&(this.helpPanel.destroy(),this.helpPanel=null),this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),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)}resetMeasureState(){this.currentMeasureType=null,this.isMeasureActive=!1}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()}setFillCutFace(e){if(!this._isInitialized||!this.engine?.clipping){console.error("[Engine] Cannot set fill cut face: engine not initialized.");return}console.log("[Engine] Setting fill cut face:",e),this.engine.clipping.setFillCutFace(e)}getFillCutFace(){return!this._isInitialized||!this.engine?.clipping?!1:this.engine.clipping.getFillCutFace?.()??!1}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,r=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:r,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}switchToOrthographicCamera(){if(!this._isInitialized)return 0;this.engine.cameraModule.switchToOrthographicCamera()}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.isWalkModeActive=!0}deactivateFirstPersonMode(){!this._isInitialized||!this.engine?.controlModule||this.isWalkModeActive&&(this.engine.controlModule.switchDefaultMode(),console.log("[Engine] Deactivating first person mode"),this.isWalkModeActive=!1)}getWalkSpeed(){if(!this._isInitialized)return console.error("[Engine] Cannot get walk speed: engine not initialized."),1;const e=this.engine.controlModule.getMoveSpeed();return console.log("[Engine] getWalkSpeed from controlModule:",e),e}setWalkSpeed(e){if(!this._isInitialized||!this.engine?.controlModule){console.error("[Engine] Cannot set walk speed: engine not initialized.");return}this.engine.controlModule.setMoveSpeed(e)}getWalkGravity(){if(!this._isInitialized)return console.error("[Engine] Cannot get walk gravity: engine not initialized."),!1;const e=this.engine.controlModule.getApplyGravity();return console.log("[Engine] getWalkGravity from controlModule:",e),e}setWalkGravity(e){if(!this._isInitialized){console.error("[Engine] Cannot set walk gravity: engine not initialized.");return}this.engine.controlModule.setApplyGravity(e)}getWalkCollision(){if(!this._isInitialized)return console.error("[Engine] Cannot get walk collision: engine not initialized."),!1;const e=this.engine.controlModule.getApplyCollision();return console.log("[Engine] getWalkCollision from controlModule:",e),e}setWalkCollision(e){if(!this._isInitialized||!this.engine?.controlModule){console.error("[Engine] Cannot set walk collision: engine not initialized.");return}this.engine.controlModule.setApplyCollision(e)}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()}getAllViewTreeData(){return!this._isInitialized||!this.engine?.viewTree?[]:this.engine.viewTree.getAllViewTreeData()}openView(e,t){if(!this._isInitialized||!this.engine?.viewTree){console.warn("[Engine] Cannot open view: engine not initialized or viewTree not available.");return}try{this.engine.viewTree.openView(e,t)}catch(i){console.warn("[Engine] openView failed:",i)}}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 r=[];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 u=o.nodesMap.get(d);!u||!Array.isArray(u.indexes)||u.indexes.length===0||l.add(d)}const c=Array.from(l);c.length&&r.push({url:a.url,ids:c})}return r}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)}readModelCodeFormStoge(){if(!this._isInitialized||!this.engine){console.warn("[Engine] Cannot read model code form stoge: engine not initialized.");return}let e=0;this.engine.models.forEach(t=>{this.engine.oneClickEncoding.readModelCodeFormStoge(t.url),e++}),console.log("readModelCodeFormStoge-success:",e)}hasModelCode(){if(!this._isInitialized||!this.engine)return console.warn("[Engine] Cannot check model code: engine not initialized."),!1;const e=this.engine.models;if(!Array.isArray(e)||e.length===0)return!1;const t=this.engine.oneClickEncoding;return!t||typeof t.exitModelCode!="function"?(console.warn("[Engine] oneClickEncoding.exitModelCode is not available."),!1):e.every(i=>!i||typeof i.url!="string"?!1:t.exitModelCode(i.url)===!0)}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 pZ{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,r=window.innerHeight;let a=e,o=t;e+i.width>n&&(a=e-i.width),t+i.height>r&&(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 rw{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=Ft.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ct.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 r=[];if(t){r=t.filter(a=>i.has(a));for(const a of i.keys())r.includes(a)||r.push(a)}else r=Array.from(i.keys());r.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 r=document.createElement("div");r.className="bim-menu-item-label",r.textContent=de(e.label),t.appendChild(r);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 r=t.getBoundingClientRect();n.style.top=`${r.top}px`,n.style.left=`${r.right}px`,n.addEventListener("mousedown",l=>l.stopPropagation());const a=new rw({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=`${r.left-o.width}px`)}closeSubMenu(){this.activeSubMenu&&(this.activeSubMenu.menu.destroy(),this.activeSubMenu.container.remove(),this.activeSubMenu=null)}}class aw extends Cs{container;rightKeyPanel;contextHandlers=[];constructor(e,t){super(t),this.container=e,this.rightKeyPanel=new pZ({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 r=new rw({items:i,groupOrder:n});r.init(),this.rightKeyPanel.mount(r),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 yR extends Cs{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 uZ({container:this.container,...e},this.registry),this.engineInstance.init(),this.rightKey=new aw(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 r=this.engineInstance?.getHighlightModels();r&&this.engineInstance?.hideModels(r),this.rightKey?.hide()}}),n.push({id:"transparentSelected",label:"menu.transparentSelected",group:"component",order:3,onClick:()=>{const r=this.engineInstance?.getHighlightModels();r&&this.engineInstance?.translucentModels(r),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 r=this.engineInstance?.getHighlightModels();r&&this.engineInstance?.isolateModels(r),this.rightKey?.hide()}},{id:"transparentOthers",label:"menu.transparentOthers",onClick:()=>{const r=this.engineInstance?.getHighlightModels();r&&this.engineInstance?.translucentOtherModels(r),this.rightKey?.hide()}}]}),n.push({id:"quickSelect",label:"menu.quickSelect",group:"component",order:6,children:[{id:"selectSameType",label:"menu.selectSameType",onClick:()=>{const r=this.engineInstance?.getHighlightModels();r&&this.engineInstance?.batchSelectSameTypeModel(r),this.rightKey?.hide()}},{id:"selectSameLevel",label:"menu.selectSameLevel",onClick:()=>{const r=this.engineInstance?.getHighlightModels();r&&this.engineInstance?.batchSelectSameLevelModel(r),this.rightKey?.hide()}},{id:"selectSameLevelType",label:"menu.selectSameLevelType",onClick:()=>{const r=this.engineInstance?.getHighlightModels();r&&this.engineInstance?.batchSelectSameLevelTypeModel(r),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)}setMainViewPort(e){if(!this.engineInstance){console.warn("[EngineManager] 3D Engine not initialized.");return}this.engineInstance.setMainViewPort(e)}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)}setPinRecords(e){if(console.log("[EngineManager] setPinRecords called, records count:",e.length),!this.engineInstance){console.warn("[EngineManager] 3D Engine not initialized.");return}this.engineInstance.setPinRecords(e)}setPinList(e){this.setPinRecords(e)}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()}}class fZ{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;MAIN_BUTTON_SIZE=60;SUB_BUTTON_SIZE=46;BASE_RADIUS=80;RING_GAP=60;FAN_START_DEG=170;FAN_END_DEG=280;CANVAS_PADDING=28;FIXED_RING_CAPACITIES=[4,6,8];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.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(ct.getTheme()),this.updateLocales(),this.unsubscribeTheme=ct.subscribe(t=>{this.setTheme(t)}),this.unsubscribeLocale=Ft.subscribe(()=>{this.updateLocales()})}createDefaultItems(){return[{id:"zoom",label:"toolbar.zoomBox",icon:gt("框选放大")},{id:"measure",label:"toolbar.measure",icon:gt("测量")},{id:"section",label:"toolbar.section",icon:gt("剖切")},{id:"walk",label:"toolbar.walk",icon:gt("漫游")},{id:"setting",label:"toolbar.setting",icon:gt("设置")}]}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??gt("主视角"),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",r=>{if(r.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}getRingCapacities(e){const t=[];let i=e;for(const n of this.FIXED_RING_CAPACITIES){if(i<=0)break;const r=Math.min(n,i);t.push(r),i-=r}return i>0&&t.push(i),t}updateItemPositions(){const e=this.itemElements.length;if(e===0)return;const t=this.FAN_END_DEG-this.FAN_START_DEG,i=this.getRingCapacities(e);let n=0;i.forEach((r,a)=>{const o=this.BASE_RADIUS+a*this.RING_GAP;for(let l=0;l<r;l++){const c=this.itemElements[n],h=r<=1?0:l/(r-1),u=(this.FAN_START_DEG+t*h)*Math.PI/180,p=Math.cos(u)*o,m=Math.sin(u)*o,v=(l+a*.5)*.045,g=(r-1-l+a*.4)*.032;c.style.setProperty("--rt-x",`${p.toFixed(2)}px`),c.style.setProperty("--rt-y",`${m.toFixed(2)}px`),c.style.setProperty("--rt-open-delay",`${v.toFixed(3)}s`),c.style.setProperty("--rt-close-delay",`${g.toFixed(3)}s`),n++}})}updateLayoutMetrics(){const e=this.items.length,i=this.getRingCapacities(e).length,n=this.BASE_RADIUS+(i-1)*this.RING_GAP,r=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=`${r}px`,this.wrapper.style.height=`${r}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`)}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,r=this.pointerY-i,a=Math.hypot(n,r);if(a<=this.MAIN_BUTTON_SIZE/2)return!0;if(a>this.maxInteractiveRadius)return!1;let o=Math.atan2(r,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=de(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 r=n.title??de(n.label);if(t.title=r,t.setAttribute("aria-label",r),this.applyItemActiveClass(t,n),!n.icon){const a=t.querySelector(".radial-sub-btn-icon");a&&(a.textContent=this.getFallbackLabel(n.title??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=de(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(r=>r.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)}addItem(e){this.items.push(e),this.renderItems(),this.updateLayoutMetrics()}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 mZ=s=>({id:"measure",label:"toolbar.measure",icon:gt("测量"),isToggle:!0,isActive:s.bottomDock?.isOpen("measure")??!1,onToggle:e=>{const t=s.bottomDock;if(!t){console.warn("[RadialToolbar] bottom dock not initialized: measure");return}e?t.open("measure"):t.close("measure"),console.log(`[RadialToolbar] 测量${e?"已打开":"已关闭"}`)}}),gZ=s=>({id:"section",label:"toolbar.section",icon:gt("剖切"),isToggle:!0,isActive:s.bottomDock?.isOpen("section")??!1,onToggle:e=>{const t=s.bottomDock;if(!t){console.warn("[RadialToolbar] bottom dock not initialized: section");return}e?t.open("section"):t.close("section"),console.log(`[RadialToolbar] 剖切${e?"已打开":"已关闭"}`)}}),vZ=s=>({id:"setting",label:"toolbar.setting",icon:gt("设置"),onClick:()=>{s.setting?.toggle(),console.log(`[RadialToolbar] 设置${s.setting?.isOpen()?"已打开":"已关闭"}`)}}),AZ=s=>({id:"walk",label:"toolbar.walk",icon:gt("漫游"),isToggle:!0,isActive:s.bottomDock?.isOpen("walk")??!1,onToggle:e=>{const t=s.bottomDock;if(!t){console.warn("[RadialToolbar] bottom dock not initialized: walk");return}e?t.open("walk"):t.close("walk"),console.log(`[RadialToolbar] 漫游${e?"已打开":"已关闭"}`)}});class xR extends Cs{toolbar=null;unsubscribeDockState=null;constructor(e,t,i){super(t),this.toolbar=new fZ({container:e,items:i?.items??this.createDefaultItems(),mainButtonIcon:gt("主视角"),mainButtonLabel:"toolbar.home",onMainButtonClick:()=>{console.log("[RadialToolbar] main: home"),this.registry.engine3d?.getEngineComponent()?.CameraGoHome()}}),this.toolbar.setTheme(ct.getTheme()),this.unsubscribeDockState=this.registry.bottomDock?.onStateChange(({id:n,open:r})=>{this.toolbar?.setItemActive(n,r)})??null,this.syncInitialToggleStates()}createDefaultItems(){return[vZ(this.registry),mZ(this.registry),gZ(this.registry),AZ(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")))}addItem(e){this.toolbar?.addItem(e)}destroy(){this.unsubscribeDockState&&(this.unsubscribeDockState(),this.unsubscribeDockState=null),this.toolbar?.destroy(),this.toolbar=null,super.destroy()}}class bZ{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 r=document.createElement("div");r.className="bottom-dock-panel-body",r.appendChild(e.content),i.appendChild(r),this.root.appendChild(i),this.panelOrder.push(e.id),this.panelMap.set(e.id,{id:e.id,element:i,bodyElement:r,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(r=>{const a=this.panelMap.get(r);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 _R extends Cs{stack;definitions=new Map;openStates=new Map;listeners=new Set;unsubscribeTheme=null;constructor(e,t){super(t),this.stack=new bZ(e),this.stack.setTheme(ct.getTheme()),this.unsubscribeTheme=ct.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 Yo={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>'},Ed={distance:{key:"distance",callBackType:"distance",icon:Yo.distance,order:0},clearHeight:{key:"clearHeight",callBackType:"clear-height",icon:Yo.clearHeight,order:1},clearDistance:{key:"clearDistance",callBackType:"clear-distance",icon:Yo.clearDistance,order:2},elevation:{key:"elevation",callBackType:"elevation",icon:Yo.elevation,order:3},point:{key:"point",callBackType:"point",icon:Yo.point,order:4},angle:{key:"angle",callBackType:"angle",icon:Yo.angle,order:5},area:{key:"area",callBackType:"area",icon:Yo.area,order:6},slope:{key:"slope",callBackType:"slope",icon:Yo.slope,order:7}},wR=Object.values(Ed).sort((s,e)=>s.order-e.order).map(s=>s.key);function ER(s){switch(s){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 MR(s){return Object.values(Ed).find(e=>e.callBackType===s)?.key}const yZ=["distance","clearHeight","clearDistance","elevation"],xZ=["point","angle","area","slope"],SR="bim-engine:measure:config",_Z={unit:"mm",precision:2};class wZ{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()??{..._Z};const{root:t,clearBtn:i,expandBtn:n,settingsBtn:r,secondaryRow:a,clearHeightOptions:o,clearHeightDirectionLabel:l,clearHeightSelectTypeLabel:c,mainView:h,settingsView:d,settingsUnitLabel:u,settingsPrecisionLabel:p,settingsUnitSelect:m,settingsPrecisionSelect:v,settingsSaveBtn:g,settingsBackBtn:f}=this.createDom();this.element=t,this.clearBtn=i,this.expandBtn=n,this.settingsBtn=r,this.secondaryRow=a,this.clearHeightOptions=o,this.clearHeightDirectionLabel=l,this.clearHeightSelectTypeLabel=c,this.mainView=h,this.settingsView=d,this.settingsUnitLabel=u,this.settingsPrecisionLabel=p,this.settingsUnitSelect=m,this.settingsPrecisionSelect=v,this.settingsSaveBtn=g,this.settingsBackBtn=f}init(){this.setLocales(),this.syncSettingsFormFromConfig(),this.applyExpandedState(),this.applyClearHeightOptionsState(),this.applyViewState(),this.syncActiveMode(this.activeMode??"distance")}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,r]of this.modeButtons.entries()){const a=de(`measure.modes.${n}`);r.dataset.tooltip=a,r.setAttribute("aria-label",a)}const e=de("measure.actions.clearAll");this.clearBtn.dataset.tooltip=e,this.clearBtn.setAttribute("aria-label",e);const t=this.isExpanded?de("measure.actions.collapse"):de("measure.actions.expand");delete this.expandBtn.dataset.tooltip,this.expandBtn.setAttribute("aria-label",t);const i=de("measure.actions.settings");this.settingsBtn.dataset.tooltip=i,this.settingsBtn.setAttribute("aria-label",i),this.clearHeightDirectionLabel.textContent=de("measure.clearHeight.direction"),this.clearHeightSelectTypeLabel.textContent=de("measure.clearHeight.selectType"),this.directionButtons.get(0).textContent=de("measure.clearHeight.directionDown"),this.directionButtons.get(1).textContent=de("measure.clearHeight.directionUp"),this.selectTypeButtons.get("point").textContent=de("measure.clearHeight.selectPoint"),this.selectTypeButtons.get("element").textContent=de("measure.clearHeight.selectElement"),this.settingsUnitLabel.textContent=de("measure.settings.unit"),this.settingsPrecisionLabel.textContent=de("measure.settings.precision"),this.settingsSaveBtn.textContent=de("measure.settings.save"),this.settingsBackBtn.textContent=de("measure.settings.cancel")}switchMode(e,t=!0){this.activeMode!==e&&(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 r=document.createElement("span");r.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(r),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 u=this.createClearHeightOptionButton(()=>{this.setClearHeightSelectType("point")}),p=this.createClearHeightOptionButton(()=>{this.setClearHeightSelectType("element")});this.selectTypeButtons.set("point",u),this.selectTypeButtons.set("element",p),d.appendChild(u),d.appendChild(p),c.appendChild(h),c.appendChild(d),i.appendChild(n),i.appendChild(c);const m=document.createElement("div");m.className="measure-dock-panel-top";const v=document.createElement("div");v.className="measure-dock-panel-mode-zone";const g=document.createElement("div");g.className="measure-dock-panel-mode-row",yZ.forEach(L=>{g.appendChild(this.createModeButton(L))});const f=document.createElement("div");f.className="measure-dock-panel-mode-row measure-dock-panel-mode-row-secondary",xZ.forEach(L=>{f.appendChild(this.createModeButton(L))});const A=this.createIconButton("measure-dock-panel-action-clear",gt("delete"));A.addEventListener("click",()=>{this.options.onClearAll?.()});const b=this.createIconButton("measure-dock-panel-action-settings",gt("settings"));b.addEventListener("click",()=>{this.openSettingsView(),this.options.onSettings?.()}),g.appendChild(A),f.appendChild(b),v.appendChild(g),v.appendChild(f);const y=document.createElement("div");y.className="measure-dock-panel-actions";const x=this.createIconButton("measure-dock-panel-action-expand",gt("expand"));x.addEventListener("click",()=>{this.isExpanded=!this.isExpanded,this.applyExpandedState(),this.setLocales()}),y.appendChild(x),m.appendChild(v),m.appendChild(y),t.appendChild(i),t.appendChild(m);const{settingsView:_,settingsUnitLabel:M,settingsPrecisionLabel:E,settingsUnitSelect:w,settingsPrecisionSelect:T,settingsSaveBtn:R,settingsBackBtn:D}=this.createSettingsView();return e.appendChild(t),e.appendChild(_),{root:e,clearBtn:A,expandBtn:x,settingsBtn:b,secondaryRow:f,clearHeightOptions:i,clearHeightDirectionLabel:r,clearHeightSelectTypeLabel:h,mainView:t,settingsView:_,settingsUnitLabel:M,settingsPrecisionLabel:E,settingsUnitSelect:w,settingsPrecisionSelect:T,settingsSaveBtn:R,settingsBackBtn:D}}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 u=document.createElement("option");u.value=d,u.textContent=d,n.appendChild(u)}),t.appendChild(i),t.appendChild(n);const r=document.createElement("div");r.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 u=document.createElement("option");u.value=String(d),u.textContent=d===0?"0":`0.${"0".repeat(d)}`,o.appendChild(u)}),r.appendChild(a),r.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(r),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">${Ed[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(SR);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(SR,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)}clearActiveMode(){for(const e of this.modeButtons.values())e.classList.remove("is-active");this.activeMode=null}}class CR extends Cs{panel=null;unsubscribeTheme=null;unsubscribeLocale=null;unsubscribeDockState=null;unsubscribeMeasureEvents=null;constructor(e){super(e)}init(){this.unsubscribeTheme||(this.unsubscribeTheme=ct.subscribe(()=>{this.applyPresentation()})),this.unsubscribeLocale||(this.unsubscribeLocale=Ft.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"),this.engineComponent?.activateMeasure("distance");else{this.panel=new wZ({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?.activateMeasure("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=r=>{this.handleMeasureCallback("measure-changed",r)},i=r=>{this.handleMeasureCallback("measure-click",r)},n=()=>{console.log("[MeasureDockManager] quit_measure_draw received"),this.panel?.clearActiveMode(),this.engineComponent?.resetMeasureState()};e.onRawEvent("measure-changed",t),e.onRawEvent("measure-click",i),e.onRawEvent("quit_measure_draw",n),this.unsubscribeMeasureEvents=()=>{e.offRawEvent("measure-changed",t),e.offRawEvent("measure-click",i),e.offRawEvent("quit_measure_draw",n)},console.log("[MeasureDockManager] raw event callbacks bound")}applyPresentation(){this.panel&&(this.panel.setTheme(ct.getTheme()),this.panel.setLocales())}handleMeasureCallback(e,t){const i=this.registry.bottomDock?.isOpen("measure")??!1,n=MR(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 EZ{element;options;typeButtons=new Map;axisButtons=new Map;toolContainer;axisPanel;divider;activeType;activeAxis;isHidden;isFilled;constructor(e={}){this.options=e,this.activeType=e.defaultType??null,this.activeAxis=e.defaultAxis??"x",this.isHidden=e.defaultHidden??!1,this.isFilled=e.defaultFill??!1;const{root:t,toolContainer:i,axisPanel:n,divider:r}=this.createDom();this.element=t,this.toolContainer=i,this.axisPanel=n,this.divider=r}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=de("toolbar.sectionPlane"),this.typeButtons.get("axis").dataset.tooltip=de("toolbar.sectionAxis"),this.typeButtons.get("box").dataset.tooltip=de("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}setFillState(e){this.isFilled=e,this.renderTools()}getFillState(){return this.isFilled}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 r=this.createTypeButton("face",gt("拾曲面剖切")),a=this.createTypeButton("axis",gt("轴向剖切")),o=this.createTypeButton("box",gt("剖切盒"));n.appendChild(r),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=gt(e.iconName),t.appendChild(i);const n=de(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:"fill",iconName:"填充",textKey:e==="box"?"sectionBox.actions.fill":e==="axis"?"sectionAxis.actions.fill":"sectionPlane.actions.fill",isActive:this.isFilled,onClick:()=>{this.isFilled=!this.isFilled,this.options.onFillToggle?.(this.isFilled),this.renderTools()}},i={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()}},n={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,n,{key:"reset",iconName:"重置",textKey:"sectionAxis.actions.reset",onClick:()=>{this.isHidden=!1,this.options.onReset?.(e,this.activeAxis),this.renderTools()}}]:e==="box"?[t,i,{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,n,{key:"reset",iconName:"重置",textKey:"sectionPlane.actions.reset",onClick:()=>{this.isHidden=!1,this.options.onReset?.(e,this.activeAxis),this.renderTools()}}]}}class TR extends Cs{panel=null;unsubscribeTheme=null;unsubscribeLocale=null;unsubscribeDockState=null;constructor(e){super(e)}init(){this.unsubscribeTheme||(this.unsubscribeTheme=ct.subscribe(()=>{this.applyPresentation()})),this.unsubscribeLocale||(this.unsubscribeLocale=Ft.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 EZ({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()},defaultFill:this.engineComponent?.getFillCutFace()??!1,onFillToggle:e=>{this.engineComponent?.setFillCutFace(e)}}),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(ct.getTheme()),this.panel.setLocales())}}class MZ{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}init(){this.element=this.createPanel(),this.updateSettingsView(),this.unsubscribeLocale=Ft.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ct.subscribe(e=>this.setTheme(e)),this.setLocales(),this.setTheme(ct.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}}setSpeed(e){this.state.speed=Math.max(1,Math.min(10,e)),this.updateSpeedDisplay()}setGravity(e){this.state.gravity=e,this.gravityCheckbox&&(this.gravityCheckbox.checked=e)}setCollision(e){this.state.collision=e,this.collisionCheckbox&&(this.collisionCheckbox.checked=e)}createPanel(){const e=document.createElement("div");e.className="walk-dock-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 r=this.createExitButton();return e.appendChild(t),e.appendChild(i),e.appendChild(this.settingsContainer),e.appendChild(n),e.appendChild(r),e}createLeftButtons(){const e=document.createElement("div");return e.className="walk-dock-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}createSettingsContainer(){const e=document.createElement("div");e.className="walk-dock-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 r=document.createElement("div");return r.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)}),r.appendChild(this.walkModeLabel),r.appendChild(this.walkModeSelect),e.appendChild(this.speedControl),e.appendChild(n),e.appendChild(r),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=de("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,r=this.walkModeSelect.parentElement;this.state.mode==="walk"?(e.style.display="none",t.style.display="flex",i.style.display="flex",n.style.display="flex",r.style.display="flex"):(e.style.display="flex",t.style.display="flex",i.style.display="flex",n.style.display="none",r.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":gt("地图"),path:gt("路径漫游"),walk:gt("第一人称漫游")}[e]||""}setLocales(){const e=this.speedControl.querySelector(".walk-speed-label");e&&(e.textContent=de("walkControl.speed")),this.gravityLabel.textContent=de("walkControl.gravity"),this.collisionLabel.textContent=de("walkControl.collision"),this.characterModelLabel.textContent=de("walkControl.characterModel.label"),this.characterModelSelect.innerHTML="";const t=document.createElement("option");t.value="construction-worker",t.textContent=de("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=de("walkControl.characterModel.officeMale"),i.selected=this.state.characterModel==="office-male",this.characterModelSelect.appendChild(i),this.walkModeLabel.textContent=de("walkControl.walkMode.label"),this.walkModeSelect.innerHTML="";const n=document.createElement("option");n.value="walk",n.textContent=de("walkControl.walkMode.walk"),n.selected=this.state.walkMode==="walk",this.walkModeSelect.appendChild(n);const r=document.createElement("option");r.value="run",r.textContent=de("walkControl.walkMode.run"),r.selected=this.state.walkMode==="run",this.walkModeSelect.appendChild(r),this.exitBtn.textContent=de("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 wc extends Cs{dialog=null;isVisible=!1;constructor(e){super(e)}get dialogWidth(){return 300}get dialogHeight(){return"auto"}get dialogOptions(){return{draggable:!0,resizable:!1}}get dialogHeader(){}get dialogHideCloseButton(){return!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,r=typeof this.dialogHeight=="number"?this.dialogHeight:300;return{x:t-n-20,y:(i-r)/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,header:this.dialogHeader,hideCloseButton:this.dialogHideCloseButton,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 SZ{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=Ft.subscribe(()=>this.render()),this.unsubscribeTheme=ct.subscribe(e=>this.setTheme(e)),this.loadPointsFromEngine(),this.render(),this.setTheme(ct.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=de("walkControl.path.duration");const n=document.createElement("div");n.className="walk-path-input-wrapper";const r=document.createElement("input");r.type="number",r.className="walk-path-input",r.value=String(this.duration/1e3),r.min="1",r.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=de("walkControl.path.durationUnit"),n.appendChild(r),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=de("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=`+ ${de("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=de("walkControl.path.deleteAll"),n.onclick=()=>this.deleteAllPoints(),t.appendChild(i),t.appendChild(n),e.appendChild(t);const r=document.createElement("div");if(r.className="walk-path-points-list",this.points.length===0){const a=document.createElement("div");a.className="walk-path-empty",a.textContent=de("walkControl.path.noPoints"),r.appendChild(a)}else this.points.forEach((a,o)=>{const l=this.createPointItem(o);r.appendChild(l)});return e.appendChild(r),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=`${de("walkControl.path.point")}${e}`;const n=document.createElement("div");n.className="walk-path-point-actions";const r=document.createElement("button");r.className="walk-path-btn-icon",r.innerHTML="▶",r.title=de("walkControl.path.play"),r.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(r),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=`▶ ${de("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=`■ ${de("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 CZ extends wc{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 SZ(this.registry),this.panel.init(),this.panel.element}onDialogClose(){this.registry.walkDock?.setPathModeActive(!1)}onBeforeDestroy(){this.panel&&(this.panel.destroy(),this.panel=null)}}class IR extends Cs{panel=null;pathManager=null;unsubscribeDockState=null;constructor(e){super(e)}init(){this.pathManager=new CZ(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 MZ({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=>{this.engineComponent?.setWalkSpeed(e),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}setPlanViewActive(e){this.panel?.setPlanViewActive(e)}setPathModeActive(e){this.panel?.setPathModeActive(e)}onOpen(){this.engineComponent?.activateFirstPersonMode(),this.syncMapState(),this.engineComponent?.setWalkSpeed(5);const e=this.engineComponent?.getWalkSpeed()??1,t=this.engineComponent?.getWalkGravity()??!1,i=this.engineComponent?.getWalkCollision()??!1;console.log("[WalkDock] 初始状态 - speed:",e,"gravity:",t,"collision:",i),this.panel?.setSpeed(e),this.panel?.setGravity(t),this.panel?.setCollision(i)}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 PR{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(ct.getTheme()),this.unsubscribeLocale=Ft.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ct.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 r=n.dataset.id===e;n.classList.toggle("is-active",r),n.setAttribute("aria-selected",`${r}`)}),this.panelMap.forEach((n,r)=>{const a=r===e;a||this.savePanelTreeScrollTop(r,n),n.classList.toggle("is-active",a),n.style.display=a?"":"none",a&&this.restorePanelTreeScrollTop(r,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 r=t.querySelector(".bim-tab__title");r&&(r.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 de(e)||e}catch{return e}}}var gi=(s=>(s[s.Unchecked=0]="Unchecked",s[s.Checked=1]="Checked",s[s.Indeterminate=2]="Indeterminate",s))(gi||{});class TZ{config;element;children=[];parent=null;checkState=gi.Unchecked;contentEl;switcherEl;checkboxEl=null;titleEl;actionsEl;childrenContainer;onExpandChange;onCheckChange;onNodeClick;renderActions;renderActionsContent(){if(!this.renderActions)return;const e=this.renderActions(this.config);this.actionsEl.innerHTML="",typeof e=="string"?this.actionsEl.innerHTML=e:e instanceof HTMLElement&&this.actionsEl.appendChild(e)}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?gi.Checked:gi.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",r=>{r.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",r=>{r.stopPropagation(),!this.config.disabled&&this.toggleCheck()}),this.contentEl.appendChild(this.checkboxEl)),this.config.icon){const r=document.createElement("span");r.className="bim-tree-icon",r.innerHTML=this.config.icon.includes("<svg")?this.config.icon:`<img src="${this.config.icon}" />`,this.contentEl.appendChild(r)}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",r=>{r.stopPropagation()}),this.renderActionsContent(),this.contentEl.appendChild(this.actionsEl),this.contentEl.addEventListener("click",r=>{if(r.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){e?this.contentEl.classList.add("is-selected"):this.contentEl.classList.remove("is-selected")}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!==gi.Checked;this.setChecked(e?gi.Checked:gi.Unchecked,!0)}setChecked(e,t=!1,i=!1){!i&&this.checkState===e||(this.checkState=e,this.config.checked=e===gi.Checked,this.updateCheckboxUI(),t&&this.onCheckChange(this))}updateCheckboxUI(){this.checkboxEl&&(this.checkboxEl.classList.remove("is-checked","is-indeterminate"),this.checkState===gi.Checked?this.checkboxEl.classList.add("is-checked"):this.checkState===gi.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 eA{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=de(this.options.searchPlaceholder||"搜索..."),this.searchInput.addEventListener("input",n=>{const r=n.target.value;this.handleSearch(r)}),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=Ft.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ct.subscribe(e=>this.setTheme(e)),this.setTheme(ct.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 r=n.config.label;r.toLowerCase().includes(i)&&t.push({node:n,label:r,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=de("tree.noResults"),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 r=document.createElement("span");r.className="bim-tree-search-item-path",r.textContent=t.path,i.appendChild(n),t.path&&i.appendChild(r),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 r=n.top-i.top+t.scrollTop,a=Math.max(0,r-(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=de(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 TZ(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===gi.Checked;if(this.onNodeCheck&&this.onNodeCheck(e),this.options.checkStrictly===!1)return;const i=(r,a)=>{r.children.forEach(o=>{o.config.disabled||(o.setChecked(a,!1),i(o,a))})};t?i(e,gi.Checked):i(e,gi.Unchecked);let n=e.parent;for(;n;){if(n.config.disabled){n=n.parent;continue}const r=n.children,a=r.every(l=>l.checkState===gi.Checked),o=r.every(l=>l.checkState===gi.Unchecked);a?n.setChecked(gi.Checked,!1):o?n.setChecked(gi.Unchecked,!1):n.setChecked(gi.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?gi.Checked:gi.Unchecked,!0)}expandAll(e){this.nodeMap.forEach(t=>t.toggleExpand(e))}checkAllNodes(e){const t=e?gi.Checked:gi.Unchecked;this.nodeMap.forEach(i=>i.setChecked(t,!1,!0))}getCheckedNodes(e=!1){const t=[];return this.nodeMap.forEach(i=>{(i.checkState===gi.Checked||e&&i.checkState===gi.Indeterminate)&&t.push(i.config)}),t}}function DR(s,e){let t=e>>>0;for(let i=0;i<s.length;i++){const n=s.charCodeAt(i);t^=n&255,t=Math.imul(t,16777619),t^=n>>>8&255,t=Math.imul(t,16777619)}return t>>>0}async function IZ(s){const e=JSON.stringify(s),t=DR(e,2166136261),i=DR(e,522970236);return`${t.toString(16).padStart(8,"0")}${i.toString(16).padStart(8,"0")}`}function RR(s){const e=new Map,t=n=>{const r=n.config.data,a=r?._modelUrl;if(a&&r?.ids?.length){let o=e.get(a);o||(o=new Set,e.set(a,o));for(const l of r.ids){const c=Number(l);Number.isFinite(c)&&o.add(c)}}for(const o of n.children||[])t(o)};t(s);const i=[];for(const[n,r]of e)r.size>0&&i.push({url:n,ids:Array.from(r)});return i}let PZ=0;async function DZ(s){if(!s||s.length===0)return[];const e=async(t,i)=>{const n=t.children&&t.children.length>0;let r;return t.ids?.length?r=await IZ(t.ids):t.id?r=t.id:r=`node_${++PZ}`,{id:r,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(s.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(r=>e(r,n))):void 0,data:{_modelUrl:n}}}))}class RZ{element;registry;mountElement;unsubscribeLocale=null;unsubscribeTheme=null;unsubscribeShowAll=null;activeTab=null;levelTree=null;typeTree=null;majorTree=null;refreshToken=0;isRendering=!1;pendingRefresh=!1;constructor(e){this.registry=e,this.element=document.createElement("section"),this.element.className="component-tree-drawer-construct-tree",this.element.dataset.tab="construct-tree",this.mountElement=document.createElement("div"),this.mountElement.className="component-tree-drawer-construct-tree-mount",this.element.appendChild(this.mountElement)}init(){this.setTheme(ct.getTheme()),this.unsubscribeLocale=Ft.subscribe(()=>{this.setLocales(),this.refresh()}),this.unsubscribeTheme=ct.subscribe(e=>this.setTheme(e))}getElement(){return this.element}onShow(){this.refresh()}setTheme(e){const t=this.element.style;t.setProperty("--bim-component-tree-page-title",e.textPrimary),t.setProperty("--bim-component-tree-page-description",e.textSecondary),t.setProperty("--bim-component-tree-content-bg",e.bgElevated)}setLocales(){}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.unsubscribeShowAll&&(this.unsubscribeShowAll(),this.unsubscribeShowAll=null),this.destroyCurrentContent(),this.element.remove()}async refresh(){if(!this.registry||!this.registry.engine3d)return;if(this.isRendering){this.pendingRefresh=!0;return}this.isRendering=!0;const e=++this.refreshToken;try{const t=this.registry.engine3d.getEngineComponent?.(),i=t?.getLevelTreeData()??[],n=t?.getTypeTreeData()??[],r=t?.getMajorTreeData()??[],[a,o,l]=await Promise.all([this.createTree(i),this.createTree(n),this.createTree(r)]);if(e!==this.refreshToken){a.destroy(),o.destroy(),l.destroy();return}this.destroyCurrentContent(),this.levelTree=a,this.typeTree=o,this.majorTree=l;const c=document.createElement("div");c.className="component-tree-drawer-construct-tree-panel",c.appendChild(a.element);const h=document.createElement("div");h.className="component-tree-drawer-construct-tree-panel",h.appendChild(o.element);const d=document.createElement("div");d.className="component-tree-drawer-construct-tree-panel",d.appendChild(l.element);const u=document.createElement("div");u.className="component-tree-drawer-construct-tree-tab-container";const p=new PR({container:u,tabs:[{id:"component",title:"tab.component",content:c},{id:"type",title:"tab.type",content:h},{id:"major",title:"tab.major",content:d}],activeId:"component"});p.init(),this.activeTab=p,this.mountElement.appendChild(u),this.resetAllTrees(),this.unsubscribeShowAll=this.registry.on("menu:show-all",()=>{this.resetAllTrees()})}finally{this.isRendering=!1,this.pendingRefresh&&(this.pendingRefresh=!1,this.refresh())}}async createTree(e){const t=await DZ(e),i=new eA({data:t,checkable:!0,indent:0,enableSearch:!0,checkStrictly:!0,defaultExpandAll:!0,onNodeCheck:n=>{const r=RR(n);r.length&&(n.checkState===gi.Checked?this.registry?.engine3d?.getEngineComponent?.()?.showModel(r):this.registry?.engine3d?.getEngineComponent?.()?.hideModels(r))},onNodeSelect:n=>{const r=RR(n);if(!r.length)return;const a=this.registry?.engine3d?.getEngineComponent?.();a?.unhighlightAllModels(),a?.highlightModel(r),a?.viewScaleToModel(r)},onNodeDeselect:()=>{this.registry?.engine3d?.getEngineComponent?.()?.unhighlightAllModels()}});return i.init(),i}resetAllTrees(){this.registry?.engine3d?.getEngineComponent?.()?.showAllModels(),this.levelTree?.checkAllNodes(!0),this.typeTree?.checkAllNodes(!0),this.majorTree?.checkAllNodes(!0)}destroyCurrentContent(){this.unsubscribeShowAll&&(this.unsubscribeShowAll(),this.unsubscribeShowAll=null),this.activeTab?.destroy(),this.activeTab=null,this.levelTree?.destroy(),this.levelTree=null,this.typeTree?.destroy(),this.typeTree=null,this.majorTree?.destroy(),this.majorTree=null,this.mountElement.innerHTML=""}}class BZ{element;registry;toolbarElement;addPinBtn;addFolderBtn;emptyElement;listContainer;tree=null;records=[];nodes=[];editingId=null;deleteDialog=null;unsubscribeLocale=null;unsubscribeTheme=null;unsubscribeListUpdated=null;constructor(e){this.registry=e,this.element=document.createElement("section"),this.element.className="component-tree-drawer-page component-tree-drawer-pin-page",this.element.dataset.tab="pin",this.toolbarElement=document.createElement("div"),this.toolbarElement.className="component-tree-drawer-pin-toolbar";const t=document.createElement("div");t.className="component-tree-drawer-pin-btn-group",this.addPinBtn=document.createElement("button"),this.addPinBtn.type="button",this.addPinBtn.className="component-tree-drawer-add-pin-btn",this.addPinBtn.addEventListener("click",()=>this.handleAddPin()),this.addFolderBtn=document.createElement("button"),this.addFolderBtn.type="button",this.addFolderBtn.className="component-tree-drawer-add-folder-btn",this.addFolderBtn.addEventListener("click",()=>this.handleAddFolder()),t.appendChild(this.addPinBtn),t.appendChild(this.addFolderBtn),this.toolbarElement.appendChild(t),this.emptyElement=document.createElement("div"),this.emptyElement.className="component-tree-drawer-pin-empty";const i=document.createElement("div");i.className="component-tree-drawer-pin-empty-icon",i.innerHTML=gt("pin");const n=document.createElement("div");n.className="component-tree-drawer-pin-empty-title";const r=document.createElement("div");r.className="component-tree-drawer-pin-empty-desc",this.emptyElement.appendChild(i),this.emptyElement.appendChild(n),this.emptyElement.appendChild(r),this.listContainer=document.createElement("div"),this.listContainer.className="component-tree-drawer-pin-tree-container",this.element.appendChild(this.toolbarElement),this.element.appendChild(this.emptyElement),this.element.appendChild(this.listContainer)}init(){this.setLocales(),this.setTheme(ct.getTheme()),this.unsubscribeLocale=Ft.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ct.subscribe(e=>this.setTheme(e)),this.unsubscribeListUpdated=this.registry?.on("drawingPin:list-updated",e=>{this.records=this.normalizeRecords(e.records),this.nodes=this.buildTree(this.records),this.renderTree()})??null}getElement(){return this.element}setTheme(e){const t=this.element.style;t.setProperty("--bim-component-tree-page-title",e.textPrimary),t.setProperty("--bim-component-tree-page-description",e.textSecondary),t.setProperty("--bim-pin-primary",e.primary),t.setProperty("--bim-pin-primary-hover",e.primaryHover),t.setProperty("--bim-pin-bg",e.bgElevated),t.setProperty("--bim-pin-card-bg",e.componentBg),t.setProperty("--bim-pin-card-hover",e.componentBgHover),t.setProperty("--bim-pin-border",e.borderSubtle),t.setProperty("--bim-pin-text",e.textPrimary),t.setProperty("--bim-pin-muted",e.textSecondary),t.setProperty("--bim-pin-shadow",e.shadowSm),t.setProperty("--bim-pin-shadow-hover",e.shadowMd),t.setProperty("--bim-pin-soft",e.primarySubtle)}setLocales(){this.addPinBtn.innerHTML=`${gt("plus")} <span>${de("componentTreeDrawer.actions.addPin")}</span>`,this.addFolderBtn.innerHTML=`${gt("folder")} <span>${de("componentTreeDrawer.actions.addFolder")}</span>`;const e=this.emptyElement.querySelector(".component-tree-drawer-pin-empty-title"),t=this.emptyElement.querySelector(".component-tree-drawer-pin-empty-desc");e&&(e.textContent=de("componentTreeDrawer.empty.pinTitle")),t&&(t.textContent=de("componentTreeDrawer.empty.pinDesc"))}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.unsubscribeListUpdated&&(this.unsubscribeListUpdated(),this.unsubscribeListUpdated=null),this.closeDeleteDialog(),this.tree?.destroy(),this.tree=null,this.element.remove()}normalizeRecords(e){return[...e].map(t=>({...t,parentId:t.parentId??null}))}buildTree(e){const t=new Map,i=[];e.forEach(r=>{t.set(r.id,{...r,children:[]})}),e.forEach(r=>{const a=t.get(r.id);if(!a)return;const o=r.parentId??null;if(o&&t.has(o)){t.get(o)?.children?.push(a);return}i.push(a)});const n=r=>{r.sort((a,o)=>a.seq-o.seq||a.name.localeCompare(o.name)),r.forEach(a=>{a.children?.length?n(a.children):delete a.children})};return n(i),i}handleAddPin(e=null){const t=this.registry?.engine3d?.getEngineComponent?.();if(!t){console.warn("[PinTab] Engine component not available.");return}t.createDrawingPin(i=>{const n=this.getSiblingCount(e,"pin"),r={id:`pin_${Date.now()}`,parentId:e,name:`图钉${n+1}`,type:"pin",seq:this.getNextSeq(e),data:i};this.registry?.emit("drawingPin:create",{record:r})})}handleAddFolder(e=null){const t=this.getSiblingCount(e,"folder"),i={id:`folder_${Date.now()}`,parentId:e,name:`文件夹${t+1}`,type:"folder",seq:this.getNextSeq(e)};this.registry?.emit("drawingPin:create",{record:i})}getNextSeq(e){return this.records.filter(t=>(t.parentId??null)===e).length}getSiblingCount(e,t){return this.records.filter(i=>i.type===t&&(i.parentId??null)===e).length}findNodeById(e,t=this.nodes){for(const i of t){if(i.id===e)return i;if(i.children?.length){const n=this.findNodeById(e,i.children);if(n)return n}}return null}renderTree(){if(this.tree?.destroy(),this.tree=null,this.nodes.length===0){this.emptyElement.style.display="flex",this.listContainer.style.display="none";return}this.emptyElement.style.display="none",this.listContainer.style.display="block",this.tree=new eA({data:this.toTreeConfig(this.nodes),checkable:!1,checkStrictly:!1,defaultExpandAll:!0,enableSearch:!0,searchPlaceholder:"tree.searchPlaceholder",renderActions:e=>this.renderNodeActions(e.data),onNodeSelect:e=>{const t=e.config.data;if(t.type!=="pin"||!t.data)return;const i=this.registry?.engine3d?.getEngineComponent?.();i&&i.restoreDrawingPin(t.data)}}),this.tree.init(),this.listContainer.innerHTML="",this.listContainer.appendChild(this.tree.element)}toTreeConfig(e){return e.map(t=>({id:t.id,label:t.name,icon:t.type==="folder"?gt("folder"):gt("pin"),expanded:!0,data:t,children:t.children?.length?this.toTreeConfig(t.children):void 0,clickAction:t.type==="folder"?"expand":"select"}))}renderNodeActions(e){const t=document.createElement("div");if(t.className="pin-node-actions",e.type==="folder"){const r=document.createElement("button");r.type="button",r.className="pin-node-action-btn",r.title=de("componentTreeDrawer.actions.edit"),r.setAttribute("aria-label",de("componentTreeDrawer.actions.edit")),r.innerHTML=gt("edit"),r.addEventListener("click",l=>{l.stopPropagation(),this.startEdit(e.id)}),t.appendChild(r);const a=document.createElement("button");a.type="button",a.className="pin-node-action-btn",a.title=de("componentTreeDrawer.actions.addPin"),a.setAttribute("aria-label",de("componentTreeDrawer.actions.addPin")),a.innerHTML=gt("plus"),a.addEventListener("click",l=>{l.stopPropagation(),this.handleAddPin(e.id)}),t.appendChild(a);const o=document.createElement("button");return o.type="button",o.className="pin-node-action-btn",o.title=de("componentTreeDrawer.actions.delete"),o.setAttribute("aria-label",de("componentTreeDrawer.actions.delete")),o.innerHTML=gt("delete"),o.addEventListener("click",l=>{l.stopPropagation(),this.openDeleteFolderDialog(e)}),t.appendChild(o),t}const i=document.createElement("button");i.type="button",i.className="pin-node-action-btn",i.title=de("componentTreeDrawer.actions.edit"),i.setAttribute("aria-label",de("componentTreeDrawer.actions.edit")),i.innerHTML=gt("edit"),i.addEventListener("click",r=>{r.stopPropagation(),this.startEdit(e.id)}),t.appendChild(i);const n=document.createElement("button");return n.type="button",n.className="pin-node-action-btn",n.title=de("componentTreeDrawer.actions.delete"),n.setAttribute("aria-label",de("componentTreeDrawer.actions.delete")),n.innerHTML=gt("delete"),n.addEventListener("click",r=>{r.stopPropagation(),this.registry?.emit("drawingPin:delete",{id:e.id})}),t.appendChild(n),t}startEdit(e){if(this.editingId===e)return;this.editingId=e;const t=this.findNodeById(e);if(!t)return;const i=this.tree?.getNode(e);if(!i)return;const n=i.element.querySelector(".bim-tree-node-content");if(!n)return;const r=n.querySelector(".bim-tree-title"),a=n.querySelector(".bim-tree-node-actions");if(!r||!a)return;r.style.display="none",a.style.display="none";const o=document.createElement("div");o.className="pin-node-edit-wrapper";const l=document.createElement("input");l.type="text",l.className="pin-node-edit-input",l.value=t.name,l.maxLength=12;const c=document.createElement("div");c.className="pin-node-edit-actions";const h=document.createElement("button");h.type="button",h.className="pin-node-edit-btn pin-node-edit-save",h.innerHTML=gt("check"),h.title=de("componentTreeDrawer.actions.save"),h.setAttribute("aria-label",de("componentTreeDrawer.actions.save")),h.addEventListener("click",p=>{p.stopPropagation(),this.saveEdit(e,l.value)});const d=document.createElement("button");d.type="button",d.className="pin-node-edit-btn pin-node-edit-cancel",d.innerHTML=gt("close"),d.title=de("componentTreeDrawer.actions.cancel"),d.setAttribute("aria-label",de("componentTreeDrawer.actions.cancel")),d.addEventListener("click",p=>{p.stopPropagation(),this.cancelEdit()}),c.appendChild(h),c.appendChild(d),o.appendChild(l),o.appendChild(c),n.appendChild(o),requestAnimationFrame(()=>{l.focus(),l.select()});const u=p=>{p.key==="Enter"?(p.preventDefault(),this.saveEdit(e,l.value)):p.key==="Escape"&&(p.preventDefault(),this.cancelEdit())};l.addEventListener("keydown",u),n._editWrapper=o,n._keydownHandler=u}saveEdit(e,t){const i=this.findNodeById(e);if(!i)return;const r=(t.trim()||i.name).slice(0,12);if(r===i.name){this.cancelEdit();return}this.registry?.emit("drawingPin:update",{id:e,patch:{name:r}}),this.editingId=null}cancelEdit(){this.editingId=null,this.renderTree()}countPins(e){let t=0;return e.forEach(i=>{i.type==="pin"&&(t+=1),i.children?.length&&(t+=this.countPins(i.children))}),t}openDeleteFolderDialog(e){this.closeDeleteDialog();const t=document.createElement("div");t.className="pin-delete-dialog";const i=document.createElement("div");i.className="pin-delete-dialog-symbol",i.textContent="!";const n=document.createElement("div");n.className="pin-delete-dialog-text",n.textContent=`${de("componentTreeDrawer.dialogs.deleteFolderMessagePrefix")}${e.name}${de("componentTreeDrawer.dialogs.deleteFolderMessageSuffix")}`;const r=document.createElement("div");r.className="pin-delete-dialog-actions";const a=document.createElement("button");a.type="button",a.className="pin-delete-dialog-btn is-secondary",a.textContent=de("componentTreeDrawer.actions.cancel");const o=document.createElement("button");o.type="button",o.className="pin-delete-dialog-btn is-danger",o.textContent=de("componentTreeDrawer.dialogs.confirm"),a.addEventListener("click",()=>this.closeDeleteDialog()),o.addEventListener("click",()=>{this.registry?.emit("drawingPin:delete",{id:e.id}),this.closeDeleteDialog()}),r.appendChild(a),r.appendChild(o),t.appendChild(i),t.appendChild(n),t.appendChild(r),this.deleteDialog=this.registry?.dialog?.create({title:"componentTreeDrawer.dialogs.noticeTitle",content:t,width:360,height:"auto",position:"center",draggable:!1,resizable:!1})??null}closeDeleteDialog(){this.deleteDialog&&(this.deleteDialog.close(),this.deleteDialog=null)}}const LZ={ceilingPlans:"viewTab.category.ceilingPlans",elevations:"viewTab.category.elevations",floorPlans:"viewTab.category.floorPlans",sections:"viewTab.category.sections"};function kZ(s){return!s||s.length===0?[]:s.map(e=>{const t=[];return Object.keys(e.views).forEach(i=>{const n=e.views[i];!n||n.length===0||t.push({id:`${e.url}::${i}`,label:de(LZ[i]),clickAction:"expand",children:n.map(r=>({id:`${e.url}::${i}::${r.id}`,label:r.name,data:{url:r.url,viewId:r.id}}))})}),{id:e.url,label:e.name||e.url,expanded:!0,clickAction:"expand",children:t}})}class OZ{element;registry;mountElement;unsubscribeLocale=null;unsubscribeTheme=null;tree=null;refreshToken=0;isRendering=!1;pendingRefresh=!1;constructor(e){this.registry=e,this.element=document.createElement("section"),this.element.className="component-tree-drawer-view",this.element.dataset.tab="view",this.mountElement=document.createElement("div"),this.mountElement.className="component-tree-drawer-view-mount",this.element.appendChild(this.mountElement)}init(){this.setTheme(ct.getTheme()),this.unsubscribeLocale=Ft.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ct.subscribe(e=>this.setTheme(e))}getElement(){return this.element}onShow(){this.refresh()}setTheme(e){const t=this.element.style;t.setProperty("--bim-view-tab-text",e.textPrimary),t.setProperty("--bim-view-tab-muted",e.textSecondary),t.setProperty("--bim-view-tab-bg",e.bgElevated)}setLocales(){this.refresh()}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.destroyCurrentContent(),this.element.remove()}async refresh(){if(!this.registry||!this.registry.engine3d)return;if(this.isRendering){this.pendingRefresh=!0;return}this.isRendering=!0;const e=++this.refreshToken;try{const t=this.registry.engine3d.getEngineComponent?.()?.getAllViewTreeData()??[],i=kZ(t);if(e!==this.refreshToken)return;if(this.destroyCurrentContent(),i.length===0){this.renderEmptyState();return}const n=new eA({data:i,checkable:!1,indent:0,enableSearch:!0,defaultExpandAll:!1,onNodeSelect:r=>{const a=r.config.data;a?.url&&a?.viewId&&this.registry?.engine3d?.getEngineComponent?.()?.openView(a.url,a.viewId)}});n.init(),this.tree=n,this.mountElement.appendChild(n.element)}finally{this.isRendering=!1,this.pendingRefresh&&(this.pendingRefresh=!1,this.refresh())}}renderEmptyState(){const e=document.createElement("div");e.className="component-tree-drawer-view-empty",e.textContent=de("viewTab.empty"),this.mountElement.appendChild(e)}destroyCurrentContent(){this.tree?.destroy(),this.tree=null,this.mountElement.innerHTML=""}}const tA=["view","pin","construct-tree"];class FZ{element;options;headerElement;tabsElement;closeButton;bodyElement;tabButtons=new Map;panelElements=new Map;tabInstances;unsubscribeLocale=null;unsubscribeTheme=null;activeTab;open=!1;constructor(e={}){this.options=e,this.activeTab=e.defaultTab??"view";const t=e.registry;this.tabInstances={view:new OZ(t??null),pin:new BZ(t??null),"construct-tree":new RZ(t??null)},this.element=document.createElement("aside"),this.element.className="component-tree-drawer",this.element.setAttribute("aria-hidden","true"),this.headerElement=document.createElement("div"),this.headerElement.className="component-tree-drawer-header",this.tabsElement=document.createElement("div"),this.tabsElement.className="component-tree-drawer-tabs",this.closeButton=document.createElement("button"),this.closeButton.type="button",this.closeButton.className="component-tree-drawer-close",this.closeButton.innerHTML=gt("close"),this.closeButton.addEventListener("click",()=>this.close()),this.bodyElement=document.createElement("div"),this.bodyElement.className="component-tree-drawer-body",this.headerElement.appendChild(this.tabsElement),this.headerElement.appendChild(this.closeButton),this.element.appendChild(this.headerElement),this.element.appendChild(this.bodyElement),this.renderTabs(),this.renderPanels()}init(){const e=this.options.container??document.body;this.element.parentElement||e.appendChild(this.element),Object.values(this.tabInstances).forEach(t=>t.init()),this.setLocales(),this.setTheme(ct.getTheme()),this.applyActiveTab(),this.applyOpenState(),this.unsubscribeLocale=Ft.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ct.subscribe(t=>this.setTheme(t))}setTheme(e){const t=this.element.style;t.setProperty("--bim-component-tree-bg",e.bgGlass||e.bgElevated),t.setProperty("--bim-component-tree-blur",e.bgGlassBlur||"18px"),t.setProperty("--bim-component-tree-border",e.borderDefault),t.setProperty("--bim-component-tree-shadow",e.shadowLg),t.setProperty("--bim-component-tree-text",e.textPrimary),t.setProperty("--bim-component-tree-muted",e.textSecondary),t.setProperty("--bim-component-tree-tab-bg",e.componentBg),t.setProperty("--bim-component-tree-tab-hover",e.componentBgHover),t.setProperty("--bim-component-tree-tab-active",e.primarySubtle),t.setProperty("--bim-component-tree-tab-active-border",e.primary),t.setProperty("--bim-component-tree-tab-active-text",e.primary),t.setProperty("--bim-component-tree-close-bg",e.componentBg),t.setProperty("--bim-component-tree-close-hover",e.componentBgHover),t.setProperty("--bim-component-tree-surface",e.bgElevated),t.setProperty("--bim-component-tree-surface-border",e.borderSubtle),t.setProperty("--bim-component-tree-subtab-nav-bg",e.tabBg),t.setProperty("--bim-component-tree-subtab-nav-border",e.borderDefault),t.setProperty("--bim-component-tree-subtab-text",e.textSecondary),t.setProperty("--bim-component-tree-subtab-hover-bg",e.tabItemBgHover),t.setProperty("--bim-component-tree-subtab-hover-text",e.textPrimary),t.setProperty("--bim-component-tree-subtab-active-bg",e.tabItemBgActive),t.setProperty("--bim-component-tree-subtab-active-text",e.tabItemTextActive),t.setProperty("--bim-component-tree-subtab-active-border",e.primarySubtle),t.setProperty("--bim-component-tree-subtab-active-shadow",e.shadowSm),t.setProperty("--bim-component-tree-tree-bg",e.bgElevated),t.setProperty("--bim-component-tree-tree-border",e.borderDefault)}setLocales(){for(const t of tA){const i=this.tabButtons.get(t);i&&(i.textContent=this.getTabTitle(t))}const e=de("componentTreeDrawer.actions.close");this.closeButton.setAttribute("aria-label",e),this.closeButton.setAttribute("title",e)}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),Object.values(this.tabInstances).forEach(e=>e.destroy()),this.tabButtons.clear(),this.panelElements.clear(),this.element.remove()}openDrawer(e){e&&(this.activeTab=e,this.applyActiveTab()),this.open=!0,this.applyOpenState(),this.tabInstances[this.activeTab].onShow?.()}close(){this.open&&(this.open=!1,this.applyOpenState(),this.options.onClose?.())}toggle(e){if(this.open){this.close();return}this.openDrawer(e)}isOpen(){return this.open}getActiveTab(){return this.activeTab}switchTab(e){this.activeTab!==e&&(this.activeTab=e,this.applyActiveTab(),this.tabInstances[e].onShow?.(),this.options.onTabChange?.(e))}getViewTabApi(){return this.tabInstances.view}getPinTabApi(){return this.tabInstances.pin}getConstructTreeTabApi(){return this.tabInstances["construct-tree"]}renderTabs(){this.tabsElement.innerHTML="";for(const e of tA){const t=document.createElement("button");t.type="button",t.className="component-tree-drawer-tab",t.dataset.tab=e,t.addEventListener("click",()=>this.switchTab(e)),this.tabButtons.set(e,t),this.tabsElement.appendChild(t)}}renderPanels(){this.bodyElement.innerHTML="";for(const e of tA){const t=document.createElement("div");t.className="component-tree-drawer-panel",t.dataset.tab=e,t.appendChild(this.tabInstances[e].getElement()),this.panelElements.set(e,t),this.bodyElement.appendChild(t)}}applyActiveTab(){for(const e of tA){const t=e===this.activeTab;this.tabButtons.get(e)?.classList.toggle("is-active",t),this.panelElements.get(e)?.classList.toggle("is-active",t)}}applyOpenState(){this.element.classList.toggle("is-open",this.open),this.element.setAttribute("aria-hidden",`${!this.open}`)}getTabTitle(e){return de({view:"componentTreeDrawer.tabs.view",pin:"componentTreeDrawer.tabs.pin","construct-tree":"componentTreeDrawer.tabs.constructTree"}[e])}}class NZ extends Cs{drawer=null;constructor(e){super(e),this.init()}init(){this.drawer||!this.registry.wrapper||(this.drawer=new FZ({container:this.registry.wrapper,registry:this.registry}),this.drawer.init())}open(e){this.drawer?.openDrawer(e)}close(){this.drawer?.close()}toggle(e){this.drawer?.toggle(e)}switchTab(e){this.drawer?.switchTab(e)}isOpen(){return this.drawer?.isOpen()??!1}getActiveTab(){return this.drawer?.getActiveTab()??"construct-tree"}getViewTabApi(){return this.drawer?.getViewTabApi()??null}getPinTabApi(){return this.drawer?.getPinTabApi()??null}getConstructTreeTabApi(){return this.drawer?.getConstructTreeTabApi()??null}destroy(){this.drawer?.destroy(),this.drawer=null,super.destroy()}}class uf{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()??{...uf.DEFAULT_CONFIG},this.element=this.createDom()}init(){this.unsubscribeLocale=Ft.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ct.subscribe(e=>{this.setTheme(e)}),this.setLocales(),this.setTheme(ct.getTheme()),this.applyExpandedState(),this.applyActiveModeState(),this.applyClearHeightOptionsState(),this.applyViewState(),this.renderResult(),this.options.onModeChange&&this.activeMode&&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=de(this.getModeI18nKey(t)),i.setAttribute("aria-label",i.title);this.toggleBtn.title=this.isExpanded?de("measure.actions.collapse"):de("measure.actions.expand"),this.toggleBtn.setAttribute("aria-label",this.toggleBtn.title),this.toggleTextEl&&(this.toggleTextEl.textContent=this.toggleBtn.title),this.clearBtn.textContent=de("measure.actions.clearAll"),this.settingsBtn.title=de("measure.actions.settings"),this.settingsBtn.setAttribute("aria-label",this.settingsBtn.title),this.activeMode&&(this.mainValueLabelEl.textContent=de(this.getModeValueLabelI18nKey(this.activeMode))),this.element.querySelectorAll("[data-i18n-key]").forEach(t=>{const i=t.dataset.i18nKey;i&&(t.textContent=de(i))}),this.saveSettingsBtn.textContent=de("measure.settings.save"),this.cancelSettingsBtn.textContent=de("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=de(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 m=0;m<wR.length;m++){const v=wR[m],g=Ed[v],f=document.createElement("button");f.type="button",f.className="bim-measure-tool-btn",f.dataset.mode=v;const A=document.createElement("span");A.className="bim-measure-tool-icon",A.innerHTML=g.icon||n,f.appendChild(A),f.addEventListener("click",()=>{this.setActiveMode(v)}),this.toolButtons.set(v,f),i.appendChild(f)}t.appendChild(i);const r=document.createElement("div");r.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)}),r.appendChild(this.toggleBtn),t.appendChild(r),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 u=(m,v,g)=>{const f=document.createElement("div");f.className="bim-measure-row";const A=document.createElement("span");A.className="label",A.dataset.i18nKey=m;const b=document.createElement("span");return b.className=`value ${v}`,g(b),f.appendChild(A),f.appendChild(b),f};d.appendChild(u("measure.labels.x","bim-measure-xyz-x",m=>this.xyzXEl=m)),d.appendChild(u("measure.labels.y","bim-measure-xyz-y",m=>this.xyzYEl=m)),d.appendChild(u("measure.labels.z","bim-measure-xyz-z",m=>this.xyzZEl=m)),o.appendChild(d),this.mainViewEl.appendChild(o);const p=document.createElement("div");return p.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()}),p.appendChild(this.clearBtn),p.appendChild(this.settingsBtn),this.mainViewEl.appendChild(p),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 r=document.createElement("div");r.className="bim-measure-settings-hint",r.dataset.i18nKey="measure.settings.hint",e.appendChild(r);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 r=this.createRadioItem("measure.clearHeight.directionDown",()=>{this.setClearHeightDirection(0)}),a=this.createRadioItem("measure.clearHeight.directionUp",()=>{this.setClearHeightDirection(1)});this.directionBtns.set(0,r),this.directionBtns.set(1,a),n.appendChild(r),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=de(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(uf.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(uf.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")}clearActiveMode(){for(const e of this.toolButtons.values())e.classList.remove("is-active");this.activeMode=null}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}if(this.mainValueRowEl.style.display="",!this.activeMode){this.mainNumberEl.textContent="--",this.mainUnitEl.textContent="",this.xyzBoxEl.style.display="none";return}this.mainValueLabelEl.textContent=de(this.getModeValueLabelI18nKey(this.activeMode));const t=this.result?this.result[Ed[this.activeMode].callBackType]:void 0;if(this.activeMode==="slope"||this.activeMode==="angle")this.mainNumberEl.textContent=t??"--",this.mainUnitEl.textContent="";else{const i=ER(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 r;switch(e){case"length":switch(i){case"mm":r=t*1e3;break;case"cm":r=t*100;break;case"km":r=t/1e3;break;default:r=t}break;case"area":switch(i){case"mm":r=t*1e3*1e3;break;case"cm":r=t*100*100;break;case"km":r=t/1e3/1e3;break;default:r=t}break;default:r=t}return r.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 BR extends wc{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 uf({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.engineComponent?.activateMeasure("distance"),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=n=>{console.log("[MeasureDialogManager] 测量值回调:",n),n&&this.panel&&this.handleMeasureChanged(n)},i=()=>{console.log("[MeasureDialogManager] quit_measure_draw received"),this.panel?.clearActiveMode(),this.engineComponent?.resetMeasureState()};e.onRawEvent("measure-changed",t),e.onRawEvent("measure-click",t),e.onRawEvent("quit_measure_draw",i),this.unsubscribeMeasureChanged=()=>{e.offRawEvent("measure-changed",t),e.offRawEvent("measure-click",t),e.offRawEvent("quit_measure_draw",i)}}}handleMeasureChanged(e){if(!this.panel)return;const t=MR(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=Ed[t],n={};return ER(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 UZ{element;options;isHidden=!1;isFilled=!1;hideBtn;reverseBtn;resetBtn;fillBtn;hideLabelEl;reverseLabelEl;resetLabelEl;fillLabelEl;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.isHidden=e.defaultHidden??!1,this.isFilled=e.defaultFill??!1,this.element=this.createDom()}setHiddenState(e){this.isHidden=e,this.updateButtonStates()}getHiddenState(){return this.isHidden}setFillState(e){this.isFilled=e,this.updateButtonStates()}getFillState(){return this.isFilled}updateButtonStates(){this.hideBtn?.classList.toggle("active",this.isHidden),this.fillBtn?.classList.toggle("active",this.isFilled)}init(){this.unsubscribeLocale=Ft.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ct.subscribe(e=>{this.setTheme(e)}),this.setLocales(),this.setTheme(ct.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=de("sectionPlane.actions.hide"),this.reverseLabelEl.textContent=de("sectionPlane.actions.reverse"),this.resetLabelEl.textContent=de("sectionPlane.actions.reset"),this.fillLabelEl.textContent=de("sectionPlane.actions.fill"),this.hideBtn.title=de("sectionPlane.actions.hide"),this.reverseBtn.title=de("sectionPlane.actions.reverse"),this.resetBtn.title=de("sectionPlane.actions.reset"),this.fillBtn.title=de("sectionPlane.actions.fill")}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.fillBtn=this.createButton("fill",gt("填充"),()=>{this.isFilled=!this.isFilled,this.updateButtonStates(),this.options.onFillToggle?.(this.isFilled)}),this.hideBtn=this.createButton("hide",gt("隐藏"),()=>{this.isHidden=!this.isHidden,this.updateButtonStates(),this.options.onHideToggle?.(this.isHidden)}),this.reverseBtn=this.createButton("reverse",gt("反向"),()=>{this.options.onReverse&&this.options.onReverse()}),this.resetBtn=this.createButton("reset",gt("重置"),()=>{this.options.onReset&&this.options.onReset()}),e.appendChild(this.fillBtn),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 r=document.createElement("div");r.className="section-plane-btn-icon",r.innerHTML=t,n.appendChild(r);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:e==="fill"?this.fillLabelEl=a:this.resetLabelEl=a,n.addEventListener("click",i),n}}class LR extends wc{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,r=e.clientHeight;return{x:n-this.dialogWidth-t,y:r-this.dialogHeight-i}}createContent(){return this.panel=new UZ({defaultHidden:!1,defaultFill:this.engineComponent?.getFillCutFace()??!1,onHideToggle:e=>{console.log("[SectionPlaneDialogManager] 隐藏切换:",e),e?this.engineComponent?.hideSection():this.engineComponent?.recoverSection()},onFillToggle:e=>{this.engineComponent?.setFillCutFace(e)},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 zZ{element;options;isHidden=!1;isFilled=!1;activeAxis="x";hideBtn;reverseBtn;fillBtn;hideLabelEl;reverseLabelEl;fillLabelEl;axisXBtn;axisYBtn;axisZBtn;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.isHidden=e.defaultHidden??!1,this.isFilled=e.defaultFill??!1,this.activeAxis=e.defaultAxis??"x",this.element=this.createDom()}init(){this.unsubscribeLocale=Ft.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ct.subscribe(e=>{this.setTheme(e)}),this.setLocales(),this.setTheme(ct.getTheme()),this.updateButtonStates(),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=de("sectionAxis.actions.hide"),this.reverseLabelEl.textContent=de("sectionAxis.actions.reverse"),this.fillLabelEl.textContent=de("sectionAxis.actions.fill"),this.hideBtn.title=de("sectionAxis.actions.hide"),this.reverseBtn.title=de("sectionAxis.actions.reverse"),this.fillBtn.title=de("sectionAxis.actions.fill"),this.axisXBtn.title=de("sectionAxis.actions.axisX"),this.axisYBtn.title=de("sectionAxis.actions.axisY"),this.axisZBtn.title=de("sectionAxis.actions.axisZ")}setHiddenState(e){this.isHidden=e,this.updateButtonStates()}getHiddenState(){return this.isHidden}setFillState(e){this.isFilled=e,this.updateButtonStates()}getFillState(){return this.isFilled}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.fillBtn=this.createButton("fill",gt("填充"),()=>this.handleFillToggle()),this.hideBtn=this.createButton("hide",gt("隐藏"),()=>this.handleHideToggle()),this.reverseBtn=this.createButton("reverse",gt("反向"),()=>this.handleReverse()),t.appendChild(this.fillBtn),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 r=document.createElement("div");r.className="section-axis-btn-icon",r.innerHTML=t,n.appendChild(r);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:e==="fill"&&(this.fillLabelEl=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 r=document.createElement("div");return r.className="section-axis-btn-label",r.textContent=t,n.appendChild(r),n.addEventListener("click",i),n}handleHideToggle(){this.isHidden=!this.isHidden,this.updateButtonStates(),this.options.onHideToggle&&this.options.onHideToggle(this.isHidden)}handleFillToggle(){this.isFilled=!this.isFilled,this.updateButtonStates(),this.options.onFillToggle&&this.options.onFillToggle(this.isFilled)}handleReverse(){this.options.onReverse&&this.options.onReverse()}handleAxisChange(e){this.activeAxis!==e&&(this.activeAxis=e,this.updateAxisButtonsState(),this.options.onAxisChange&&this.options.onAxisChange(e))}updateButtonStates(){this.hideBtn.classList.toggle("active",this.isHidden),this.fillBtn.classList.toggle("active",this.isFilled)}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 kR extends wc{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 zZ({defaultAxis:"x",defaultHidden:!1,defaultFill:this.engineComponent?.getFillCutFace()??!1,onHideToggle:e=>{console.log("[SectionAxisDialogManager] 隐藏切换:",e),e?this.engineComponent?.hideSection():this.engineComponent?.recoverSection()},onFillToggle:e=>{this.engineComponent?.setFillCutFace(e)},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 OR={x:{min:0,max:100},y:{min:0,max:100},z:{min:0,max:100}};class HZ{element;options;isHidden=!1;isReversed=!1;isFilled=!1;range;hideBtn;fitBtn;resetBtn;fillBtn;hideLabelEl;fitLabelEl;resetLabelEl;fillLabelEl;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.isFilled=e.defaultFill??!1,this.range=JSON.parse(JSON.stringify(e.defaultRange??OR))}init(){this.element=this.createPanel(),this.unsubscribeLocale=Ft.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ct.subscribe(e=>this.setTheme(e)),this.setLocales(),this.setTheme(ct.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}setFillState(e){this.isFilled=e,this.updateButtonStates()}getFillState(){return this.isFilled}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??OR)),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.fillBtn=this.createButton("fill",de("sectionBox.actions.fill"),()=>{this.isFilled=!this.isFilled,this.updateButtonStates(),this.options.onFillToggle?.(this.isFilled)},"fill"),this.hideBtn=this.createButton("hide",de("sectionBox.actions.hide"),()=>{this.isHidden=!this.isHidden,this.updateButtonStates(),this.options.onHideToggle?.(this.isHidden)},"hide"),this.fitBtn=this.createButton("fit",de("sectionBox.actions.fitToModel"),()=>{this.options.onFitToModel?.()},"fit"),this.resetBtn=this.createButton("reset",de("sectionBox.actions.reset"),()=>this.reset(),"reset"),[this.fillBtn,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",de("sectionBox.axes.x")),this.ySlider=this.createSlider("y",de("sectionBox.axes.y")),this.zSlider=this.createSlider("z",de("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 r=document.createElement("button");r.className="section-box-btn",r.title=t;const a={hide:"隐藏",reverse:"反向",fit:"适应到模型",reset:"重置",fill:"填充"},o=document.createElement("div");o.className="section-box-btn-icon",o.innerHTML=gt(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:n==="fill"&&(this.fillLabelEl=l),r.appendChild(o),r.appendChild(l),r.addEventListener("click",i),r}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 r=document.createElement("div");r.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"),r.append(a,o,l),i.append(n,r),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.fillLabelEl.textContent=de("sectionBox.actions.fill"),this.hideLabelEl.textContent=de("sectionBox.actions.hide"),this.fitLabelEl.textContent=de("sectionBox.actions.fitToModel"),this.resetLabelEl.textContent=de("sectionBox.actions.reset"),this.xLabelEl.textContent=de("sectionBox.axes.x"),this.yLabelEl.textContent=de("sectionBox.axes.y"),this.zLabelEl.textContent=de("sectionBox.axes.z"),this.fillBtn.title=de("sectionBox.actions.fill"),this.hideBtn.title=de("sectionBox.actions.hide"),this.fitBtn.title=de("sectionBox.actions.fitToModel"),this.resetBtn.title=de("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 FR extends wc{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 HZ({defaultHidden:!1,defaultReversed:!1,defaultFill:this.engineComponent?.getFillCutFace()??!1,onHideToggle:e=>{console.log("[SectionBoxDialogManager] 隐藏切换:",e),e?this.engineComponent?.hideSection():this.engineComponent?.recoverSection()},onFillToggle:e=>{this.engineComponent?.setFillCutFace(e)},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 NR extends wc{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,r)=>{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(r),a.appendChild(o),a.appendChild(l),a};return t.appendChild(i(de("info.meshCount"),e?.meshCount??"-")),t.appendChild(i(de("info.totalTriangles"),e?.totalTriangles??"-")),t.appendChild(i(de("info.totalVertices"),e?.totalVertices??"-")),t}}const ow="font-size: 15px; font-weight: 600; color: var(--bim-text-primary, #0f172a); margin-bottom: 4px;",GZ="height: 1px; background: var(--bim-divider, #e2e8f0); margin: 8px 0;",lw="display: flex; align-items: center; justify-content: space-between; gap: 12px;",cw="display: flex; flex-direction: column; gap: 6px;",VZ="font-size: 12px; color: var(--bim-text-secondary, #475569); min-width: 32px; text-align: right;",Ss="var(--bim-border-default, #e2e8f0)",hw="var(--bim-bg-inset, #f1f5f9)",Ec="var(--bim-primary, #3b82f6)",Mc="var(--bim-text-primary, #0f172a)",Md="var(--bim-text-inverse, #ffffff)",WZ="var(--bim-component-bg-hover, rgba(0,0,0,0.04))",UR={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}},QZ={ground:[],hdr:[],sky:[]};class Ha extends wc{get dialogId(){return"setting-dialog"}get dialogTitle(){return"setting.dialogTitle"}get dialogWidth(){return 420}settings=structuredClone(UR);presetList=[];selectedPresetId=null;presetLists=structuredClone(QZ);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=Ft.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!==Ha.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===Ha.INTERNAL_DEFAULT_PRESET_ID);e<0||(this.presetList[e]={...this.presetList[e],presetName:de("setting.defaultPresetLabel")},this.ensurePresetListWithInternalDefault())}createInternalDefaultPreset(e=!0){return{id:Ha.INTERNAL_DEFAULT_PRESET_ID,presetName:de("setting.defaultPresetLabel"),isDefault:e,settings:structuredClone(UR),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(de("setting.lightIntensity"),this.settings.render.lightIntensity,0,100,n=>this.updateSettings({render:{lightIntensity:n}}))),this.settings.render.mode==="advanced"&&(t.appendChild(this.createSliderSection(de("setting.contrast"),this.settings.render.contrast,0,100,n=>this.updateSettings({render:{contrast:n}}))),t.appendChild(this.createSliderSection(de("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 ${Ss};
|
||
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 r=n.id.trim();r!==Ha.INTERNAL_DEFAULT_PRESET_ID&&(!r||t.has(r)||(t.add(r),i.push({id:r,presetName:n.presetName?.trim()||r,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=GZ,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=de("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(),r=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()),r&&n)i.appendChild(this.createDeleteIconButton());else{const a=document.createElement("div");a.style.cssText="width: 40px; height: 36px;",i.appendChild(a)}if(r)i.appendChild(this.createFooterActionButton(de("setting.savePreset"),{background:Ec,color:Md,border:"none",onClick:()=>this.handleSaveCurrentPreset(),compact:!0}));else{const a=document.createElement("div");i.appendChild(a)}return i.appendChild(this.createFooterActionButton(de("setting.saveAsNewPreset"),{background:Ec,color:Md,border:"none",onClick:()=>this.openSaveAsPresetModal(),compact:!0})),e.appendChild(i),e}createDeleteIconButton(){const e=document.createElement("button");return e.type="button",e.title=de("setting.deletePreset"),e.setAttribute("aria-label",de("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===Ha.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:de("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=cw;const t=document.createElement("div");t.style.cssText=ow,t.textContent=de("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 ${Ss};
|
||
`;const n=[{key:"simple",labelKey:"setting.modes.simple"},{key:"balance",labelKey:"setting.modes.balance"},{key:"advanced",labelKey:"setting.modes.advanced"}];for(let r=0;r<n.length;r++){const a=n[r],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?Ec:"transparent"};
|
||
color: ${o?Md:Mc};
|
||
border: none;
|
||
${r<n.length-1?`border-right: 1px solid ${Ss};`:""}
|
||
`,l.textContent=de(a.labelKey),l.addEventListener("mouseenter",()=>{o||(l.style.background=WZ)}),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=cw;const t=document.createElement("div");if(t.style.cssText=ow,t.textContent=de("setting.displaySection"),e.appendChild(t),e.appendChild(this.createToggleRow(de("setting.edgeLine"),this.settings.display.showEdge,i=>{this.updateSettings({display:{showEdge:i}},!0)})),this.settings.display.showEdge&&e.appendChild(this.createSliderSection(de("setting.edgeOpacity"),this.settings.display.edgeOpacity,0,100,i=>this.updateSettings({display:{edgeOpacity:i}}))),e.appendChild(this.createToggleRow(de("setting.showGrid"),this.settings.display.showGrid,i=>{this.updateSettings({display:{showGrid:i}})})),e.appendChild(this.createToggleRow(de("setting.showLevel"),this.settings.display.showLevel,i=>{this.updateSettings({display:{showLevel:i}})})),e.appendChild(this.createToggleRow(de("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=`${lw} margin-top: 10px;`;const r=document.createElement("span");r.style.cssText="font-size: 13px; color: var(--bim-text-secondary, #475569);",r.textContent=de("setting.groundElevation"),n.appendChild(r);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 ${Ss};
|
||
background: ${hw};
|
||
color: ${Mc};
|
||
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=de("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=cw;const t=document.createElement("div");t.style.cssText=ow,t.textContent=de("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 ${Ss};
|
||
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 r=0;r<n.length;r++){const a=n[r],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?Ec:"transparent"};
|
||
color: ${o?Md:Mc};
|
||
border: none;
|
||
${r<n.length-1?`border-right: 1px solid ${Ss};`:""}
|
||
`,l.textContent=de(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 r=this.presetLists.hdr.map(a=>({value:a.id,label:this.getLocalizedPresetName(a.names,a.id)}));e.appendChild(this.createSelect(r,this.settings.environment.hdrId,a=>{this.updateSettings({environment:{type:"hdr",hdrId:a}})}))}if(this.settings.environment.type==="sky"){const r=this.presetLists.sky.map(a=>({value:a.id,label:this.getLocalizedPresetName(a.names,a.id)}));e.appendChild(this.createSelect(r,this.settings.environment.skyPreset,a=>{this.updateSettings({environment:{type:"sky",skyPreset:a}})}))}return e}createSliderSection(e,t,i,n,r){const a=document.createElement("div");a.style.cssText="margin-bottom: 4px;";const o=document.createElement("div");o.style.cssText=`${lw} 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=VZ,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),r(d)}),a.appendChild(h),a}createToggleRow(e,t,i){const n=document.createElement("div");n.style.cssText=lw;const r=document.createElement("span");r.style.cssText="font-size: 13px; color: var(--bim-text-secondary, #475569);",r.textContent=e,n.appendChild(r);const a="var(--bim-border-strong, #cbd5e1)",o=Ec;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 ${Ss};
|
||
background: ${hw};
|
||
color: ${Mc};
|
||
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 r of e){const a=document.createElement("option");a.value=r.value,a.textContent=r.label,r.value===t&&(a.selected=!0),n.appendChild(a)}return n.addEventListener("change",()=>i(n.value)),n.addEventListener("focus",()=>{n.style.borderColor=Ec}),n.addEventListener("blur",()=>{n.style.borderColor=Ss}),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=Ft.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(de("setting.selectPresetFirst"));return}const e=this.presetList.findIndex(r=>r.id===this.selectedPresetId);if(e<0){window.alert(de("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((r,a)=>({...a===e?n:r,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(de("setting.presetNameRequired")),!1;if(this.presetList.some(o=>o.presetName.toLowerCase()===t.toLowerCase()))return window.alert(de("setting.presetNameDuplicate")),!1;const n=this.engineComponent?.getSettings()??structuredClone(this.settings),r={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!==Ha.INTERNAL_DEFAULT_PRESET_ID);return this.presetList=[...a.map(o=>({...o,isDefault:!1})),r],this.ensurePresetListWithInternalDefault(),this.selectedPresetId=r.id,this.settings=structuredClone(n),this.isDirty=!1,this.updateUndoRestoreVisibility(),this.emit("setting:preset-saved",{preset:structuredClone(r),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 ${Ss};
|
||
padding: 12px;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 10px;
|
||
`;const n=document.createElement("div");n.textContent=de("setting.deleteDialogTitle"),n.style.cssText="font-size: 14px; font-weight: 600; color: var(--bim-text-primary, #0f172a);";const r=document.createElement("div");r.textContent=de("setting.deleteDialogMessage"),r.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=de("setting.cancel"),o.style.cssText=`
|
||
height: 32px; padding: 0 12px;
|
||
border-radius: 6px; border: 1px solid ${Ss};
|
||
background: var(--bim-bg-elevated, #fff); color: ${Mc}; cursor: pointer;
|
||
`,o.addEventListener("click",()=>this.closeDeletePresetConfirmModal());const l=document.createElement("button");l.type="button",l.textContent=de("setting.confirm"),l.style.cssText=`
|
||
height: 32px; padding: 0 12px;
|
||
border-radius: 6px; border: none;
|
||
background: #ef4444; color: ${Md}; cursor: pointer;
|
||
`,l.addEventListener("click",()=>{this.deleteSelectedPreset(),this.closeDeletePresetConfirmModal()}),a.appendChild(o),a.appendChild(l),i.appendChild(n),i.appendChild(r),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 ${Ss};
|
||
padding: 12px;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 10px;
|
||
`;const r=document.createElement("div");r.textContent=de("setting.saveAsDialogTitle"),r.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??`${de("setting.presetDefaultName")} ${this.presetList.length+1}`,a.placeholder=de("setting.presetNamePlaceholder"),a.style.cssText=`
|
||
width: 100%; height: 34px; padding: 0 10px;
|
||
border-radius: 6px; border: 1px solid ${Ss};
|
||
background: ${hw}; color: ${Mc}; 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=de("setting.cancel"),l.style.cssText=`
|
||
height: 32px; padding: 0 12px;
|
||
border-radius: 6px; border: 1px solid ${Ss};
|
||
background: var(--bim-bg-elevated, #fff); color: ${Mc}; cursor: pointer;
|
||
`,l.addEventListener("click",()=>this.closeSaveAsPresetModal());const c=document.createElement("button");c.type="button",c.textContent=de("setting.confirm"),c.style.cssText=`
|
||
height: 32px; padding: 0 12px;
|
||
border-radius: 6px; border: none;
|
||
background: ${Ec}; color: ${Md}; 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(r),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 jZ{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=de(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=de(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 XZ{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 jZ(e,this);this.items.set(e.id,t),this.element.appendChild(t.element),this.activeIds.has(e.id)&&t.setActive(!0)}),this.unsubscribeLocale=Ft.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ct.subscribe(e=>{this.setTheme(e)}),this.setTheme(ct.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 zR extends Cs{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=de("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 XZ({container:e,accordion:!1,ghost:!0,activeIds:n.length>0?[n[0].id]:[],items:n});const r=document.createElement("style");return r.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(r),e}createCategoryContent(e){const t=document.createElement("div");return e.forEach((i,n)=>{const r=document.createElement("div");r.style.cssText=`
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 12px;
|
||
border-bottom: 1px solid var(--bim-border-default, rgba(255,255,255,0.15));
|
||
`,n===e.length-1&&(r.style.borderBottom="none");const a=document.createElement("div");a.style.cssText=`
|
||
width: 120px;
|
||
flex-shrink: 0;
|
||
padding: 8px 12px;
|
||
`;const o=document.createElement("div");o.style.cssText=`
|
||
color: var(--bim-text-secondary, #999);
|
||
font-size: 13px;
|
||
font-weight: 600;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
`,o.textContent=i.name||"-",a.appendChild(o);const l=document.createElement("div");l.style.cssText=`
|
||
flex: 1;
|
||
min-width: 0;
|
||
padding: 8px 12px;
|
||
`;const c=document.createElement("div");c.style.cssText=`
|
||
color: var(--bim-text-primary, #fff);
|
||
font-size: 13px;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
`;const h=String(i.value??"-");c.textContent=h,l.appendChild(c),r.appendChild(a),r.appendChild(l),t.appendChild(r)}),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 qZ{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=ct.subscribe(e=>{this.setTheme(e)}),this.unsubscribeLocale=Ft.subscribe(()=>{this.setLocales()}),this.setTheme(ct.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=de(this.options.title));const t=this.element.querySelector(".bim-ai-textarea");t&&this.options.placeholder&&(t.placeholder=de(this.options.placeholder));const i=this.element.querySelector(".bim-ai-helper-left");i&&(i.textContent=de("aiChat.helper.newline"));const n=this.element.querySelector(".bim-ai-helper-right");n&&(n.textContent=de("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="${de("aiChat.action.new")}">
|
||
${gt("plus")}
|
||
</button>
|
||
<button class="bim-ai-chat-action-btn" data-action="history" title="${de("aiChat.action.history")}">
|
||
${gt("history")}
|
||
</button>
|
||
<button class="bim-ai-chat-action-btn" data-action="settings" title="${de("aiChat.action.settings")}">
|
||
${gt("settings")}
|
||
</button>
|
||
<button class="bim-ai-chat-action-btn" data-action="close" title="${de("aiChat.action.close")}">
|
||
${gt("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">
|
||
${gt("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,r=0,a=0,o=0,l=0,c=0;const h=p=>{p.target.closest(".bim-ai-chat-action-btn")||(p.preventDefault(),p.stopPropagation(),t=p.clientX,i=p.clientY,n=this.element.offsetLeft,r=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",u,{capture:!0}))},d=p=>{p.preventDefault(),p.stopPropagation(),!this.rafId&&(this.rafId=requestAnimationFrame(()=>{const m=p.clientX-t,v=p.clientY-i;let g=n+m,f=r+v;const A=a-l,b=o-c;g=Math.max(0,Math.min(g,A)),f=Math.max(0,Math.min(f,b)),this.element.style.left=`${g}px`,this.element.style.top=`${f}px`,this.rafId=null}))},u=()=>{this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null),document.removeEventListener("mousemove",d,{capture:!0}),document.removeEventListener("mouseup",u,{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}">
|
||
${de(n.label)}
|
||
</button>
|
||
`).join(""),i.querySelectorAll(".bim-ai-quick-prompt").forEach(n=>{n.addEventListener("click",r=>{const a=r.currentTarget.dataset.promptId,o=this.options.quickPrompts?.find(l=>l.id===a);o&&this.textarea&&(this.textarea.value=de(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">${gt({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">${gt("loader")}</span>
|
||
<span class="bim-ai-thinking-text">${de("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?de("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="${de("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">${gt("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>${de("aiChat.submit")}</span>
|
||
${gt("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,r=i.dataset.optionId;if(n&&r){const a=this.messages.find(o=>o.id===n);a&&!a.answered&&(a.selectedOptionId=r,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 r=this.messages.find(a=>a.id===n);r&&(r.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 r=this.messages.find(a=>a.id===n);r&&r.selectedOptionId&&(r.answered=!0,this.renderMessages(),this.options.onQuestionSubmit?.(n,r.selectedOptionId,r.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 HR{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 qZ({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 YZ{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 r=i;this.customColors.has(r)||(this.options[r]=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=Ft.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ct.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(r=>r.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 r={...e,children:e.children||[]};if(i){const a=this.findButton(n.buttons,i);a&&(a.children||(a.children=[]),a.children.push(r))}else n.buttons.push(r)}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(r=>{if(this.isVisible(r.id)){const a=this.renderButton(r);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=de(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=de(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 r of n)r&&r.id!==e.id&&r.parentId===e.parentId&&r.groupId===e.groupId&&this.activeBtnIds.has(r.id)&&(this.setBtnActive(r.id,!1),r.onClick&&r.onClick(r));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 r=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=ct.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-r.top+8+"px",i.style.left=r.left+(r.width-l.width)/2+"px"):a==="down"?(i.style.top=r.bottom+8+"px",i.style.left=r.left+(r.width-l.width)/2+"px"):a==="right"?(i.style.top=r.top+(r.height-l.height)/2+"px",i.style.left=r.right+8+"px"):a==="left"&&(i.style.top=r.top+(r.height-l.height)/2+"px",i.style.right=window.innerWidth-r.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,r=e.minWidth;r&&(t.style.minWidth=`${r}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=de(e.label),t.appendChild(o)}else e.label&&(t.title=de(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 r=this.findButtonById(e);r&&(r.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=de(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()}}function GR(s,e){let t=e>>>0;for(let i=0;i<s.length;i++){const n=s.charCodeAt(i);t^=n&255,t=Math.imul(t,16777619),t^=n>>>8&255,t=Math.imul(t,16777619)}return t>>>0}async function KZ(s){const e=JSON.stringify(s),t=GR(e,2166136261),i=GR(e,522970236);return`${t.toString(16).padStart(8,"0")}${i.toString(16).padStart(8,"0")}`}function VR(s){const e=new Map,t=n=>{const r=n.config.data,a=r?._modelUrl;if(a&&r?.ids?.length){let o=e.get(a);o||(o=new Set,e.set(a,o));for(const l of r.ids){const c=Number(l);Number.isFinite(c)&&o.add(c)}}for(const o of n.children||[])t(o)};t(s);const i=[];for(const[n,r]of e)r.size>0&&i.push({url:n,ids:Array.from(r)});return i}let $Z=0;async function ZZ(s){if(!s||s.length===0)return[];const e=async(t,i)=>{const n=t.children&&t.children.length>0;let r;return t.ids?.length?r=await KZ(t.ids):t.id?r=t.id:r=`node_${++$Z}`,{id:r,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(s.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(r=>e(r,n))):void 0,data:{_modelUrl:n}}}))}class JZ extends Cs{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 YZ({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:gt("目录树"),onClick:()=>{if(this.registry.componentTreeDrawer){this.registry.componentTreeDrawer.toggle();return}this.openConstructTreeDialog()}}),this.toolbar.render()}async openConstructTreeDialog(){if(this.registry.componentTreeDrawer){this.registry.componentTreeDrawer.open();return}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(v,g)=>{const f=await ZZ(v);console.log(`[ConstructTree] 转换后数据 (${g}):`,f);const A=new eA({data:f,checkable:!0,indent:0,enableSearch:!0,checkStrictly:!0,defaultExpandAll:!0,onNodeCheck:b=>{const y=VR(b);y.length&&(b.checkState===gi.Checked?this.engineComponent?.showModel(y):this.engineComponent?.hideModels(y))},onNodeSelect:b=>{const y=VR(b);y.length&&(this.engineComponent?.unhighlightAllModels(),this.engineComponent?.highlightModel(y),this.engineComponent?.viewScaleToModel(y))},onNodeDeselect:()=>{this.engineComponent?.unhighlightAllModels()},onNodeExpand:()=>{this.dialog?.fitWidth()}});return A.init(),A},r=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(r.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 u=()=>{this.engineComponent?.showAllModels(),r.checkAllNodes(!0),a.checkAllNodes(!0),o.checkAllNodes(!0)},p=new PR({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()}});p.init(),u();const m=this.registry.on("menu:show-all",()=>{u()});this.dialog=this.registry.dialog.create({title:"constructTree.title",minWidth:320,height:600,content:d,position:{x:20,y:20},resizable:!1,onClose:()=>{m(),p.destroy(),r.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 eJ{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(r){console.error(`[EventEmitter] Error in listener for event "${e}":`,r)}})}clear(){this.events.clear()}}class iA{eventEmitter=new eJ;container=null;wrapper=null;toolbar=null;dialog=null;engine3d=null;buttonGroup=null;rightKey=null;constructTree=null;measure=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;componentTreeDrawer=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.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,this.componentTreeDrawer=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 tJ{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;componentTreeDrawer=null;measure=null;sectionPlane=null;sectionAxis=null;sectionBox=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 iA,t?.locale&&Ft.setLocale(t.locale),t?.theme&&(t.theme==="custom"?console.warn("Custom theme should be set via setCustomTheme()."):ct.setTheme(t.theme)),this.init()}emit(e,t){this.registry.emit(e,t)}on(e,t){return this.registry.on(e,t)}setLocale(e){Ft.setLocale(e)}getLocale(){return Ft.getLocale()}setTheme(e){ct.setTheme(e)}setCustomTheme(e){ct.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="v3.7.0",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 yR(this.wrapper,this.registry),this.dialog=new Ew(this.wrapper,this.registry),this.rightKey=new aw(this.wrapper,this.registry),this.bottomDock=new _R(this.wrapper,this.registry),this.registry.bottomDock=this.bottomDock,this.measureDock=new CR(this.registry),this.registry.measureDock=this.measureDock,this.measureDock.init(),this.sectionDock=new TR(this.registry),this.registry.sectionDock=this.sectionDock,this.sectionDock.init(),this.walkDock=new IR(this.registry),this.registry.walkDock=this.walkDock,this.walkDock.init(),this.componentTreeDrawer=new NZ(this.registry),this.registry.componentTreeDrawer=this.componentTreeDrawer,this.radialToolbar=new xR(this.wrapper,this.registry),this.measure=new BR(this.registry),this.sectionPlane=new LR(this.registry),this.sectionAxis=new kR(this.registry),this.sectionBox=new FR(this.registry),this.engineInfo=new NR(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.engineInfo=this.engineInfo,this.componentDetail=new zR(this.registry),this.registry.componentDetail=this.componentDetail,this.componentDetail.init(),this.aiChat=new HR(this.registry),this.registry.aiChat=this.aiChat,this.aiChat.init(),this.constructTreeBtn=new JZ(this.wrapper,this.registry),this.registry.constructTree=this.constructTreeBtn,this.setting=new Ha(this.registry),this.registry.setting=this.setting,this.setting.init(),this.updateTheme(ct.getTheme()),ct.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.componentTreeDrawer?.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.constructTreeBtn?.destroy(),this.aiChat?.destroy(),this.setting?.destroy(),this.sizeEl=null,this.lastSyncedWidth=-1,this.lastSyncedHeight=-1,this.container.innerHTML="",this.registry.reset()}}class iJ{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;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 iA,t?.locale&&Ft.setLocale(t.locale),t?.theme&&(t.theme==="custom"?console.warn("Custom theme should be set via setCustomTheme()."):ct.setTheme(t.theme)),this.init()}emit(e,t){this.registry.emit(e,t)}on(e,t){return this.registry.on(e,t)}setLocale(e){Ft.setLocale(e)}getLocale(){return Ft.getLocale()}setTheme(e){ct.setTheme(e)}setCustomTheme(e){ct.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="v3.7.0",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 yR(this.wrapper,this.registry),this.dialog=new Ew(this.wrapper,this.registry),this.rightKey=new aw(this.wrapper,this.registry),this.bottomDock=new _R(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 CR(this.registry),this.registry.measureDock=this.measureDock,this.measureDock.init(),this.sectionDock=new TR(this.registry),this.registry.sectionDock=this.sectionDock,this.sectionDock.init(),this.walkDock=new IR(this.registry),this.registry.walkDock=this.walkDock,this.walkDock.init(),this.radialToolbar=new xR(this.wrapper,this.registry),this.measure=new BR(this.registry),this.sectionPlane=new LR(this.registry),this.sectionAxis=new kR(this.registry),this.sectionBox=new FR(this.registry),this.engineInfo=new NR(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.engineInfo=this.engineInfo,this.componentDetail=new zR(this.registry),this.registry.componentDetail=this.componentDetail,this.componentDetail.init(),this.aiChat=new HR(this.registry),this.registry.aiChat=this.aiChat,this.aiChat.init(),this.setting=new Ha(this.registry),this.registry.setting=this.setting,this.setting.init(),this.updateTheme(ct.getTheme()),this.unsubscribeTheme=ct.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.aiChat?.destroy(),this.setting?.destroy(),this.sizeEl=null,this.lastSyncedWidth=-1,this.lastSyncedHeight=-1,this.container.innerHTML="",this.registry.reset()}}class nJ{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=hZ(e),!this.engine)throw new Error("Failed to create 2D engine instance");this._isInitialized=!0,this.unsubscribeTheme=ct.subscribe(t=>{this.setTheme(t)}),this.setTheme(ct.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 sJ{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 iA,t?.locale&&Ft.setLocale(t.locale),t?.theme&&t.theme!=="custom"&&ct.setTheme(t.theme),this.engineComponent=new nJ({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){ct.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 rJ{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=dZ(e),!this.engine)throw new Error("Failed to create 720 engine instance");this._isInitialized=!0,this.unsubscribeTheme=ct.subscribe(t=>{this.setTheme(t)}),this.setTheme(ct.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 aJ{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 iA,t?.locale&&Ft.setLocale(t.locale),t?.theme&&t.theme!=="custom"&&ct.setTheme(t.theme),this.engineComponent=new rJ({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){ct.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 oJ=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"})),lJ=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"})),cJ=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"}));_r.BimEngine=tJ,_r.BimEngine2d=sJ,_r.BimEngine720=aJ,_r.CusBimEngine=iJ,Object.defineProperty(_r,Symbol.toStringTag,{value:"Module"})}));
|
||
//# sourceMappingURL=iflow-engine.umd.js.map
|