Files
bim_engine/demo/lib/iflow-engine.umd.js
yuding 507112fcf9 feat: add camera switch, fix click event/dialog resize/map state sync
- fix(engine): adapt click handler to base engine array format data[0].url/ids
- feat(toolbar): add perspective/orthographic camera switch button with dynamic icon
- fix(dialog): clamp resize to container bounds to prevent overflow
- feat(demo): add auto-combine feature with robust URL parsing and validation
- fix(walk): close minimap on walk exit and sync map state between toolbar and walk panel
- fix(engine): correct MiniMap getstate() casing to match base engine API
- build: rebuild demo libs
2026-03-05 17:43:50 +08:00

7175 lines
1.4 MiB
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(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-btn-group-root{display:flex;gap:8px;z-index:1000;position:absolute;pointer-events:auto;background:transparent}.bim-btn-group-root.static{position:relative;inset:auto;transform:none}.bim-btn-group-root.dir-row{flex-direction:row;align-items:center}.bim-btn-group-root.dir-column{flex-direction:column;align-items:stretch}.bim-btn-group-section{display:flex;gap:4px;background-color:var(--bim-btn-group-section-bg, rgba(17, 17, 17, .88));border-radius:6px;padding:4px;box-shadow:0 2px 8px #0000004d,0 1px 3px #0003}.bim-btn-group-root.dir-row .bim-btn-group-section{flex-direction:row;align-items:center}.bim-btn-group-root.dir-column .bim-btn-group-section{flex-direction:column}.opt-btn-wrapper{position:relative}.opt-btn{display:flex;cursor:pointer;border-radius:4px;transition:background-color .2s,color .2s,border-color .2s;color:var(--bim-btn-text-color, #ccc);background-color:var(--bim-btn-bg, transparent);padding:6px;align-items:center;position:relative;justify-content:center;border:1px solid transparent;outline:none}.opt-btn:hover{background-color:var(--bim-btn-hover-bg, #444)}.opt-btn.active{background-color:var(--bim-btn-active-bg, rgba(255, 255, 255, .15));color:var(--bim-btn-text-active-color, #fff)}.opt-btn.disabled{opacity:.5;cursor:not-allowed}.opt-btn-icon{width:var(--bim-icon-size, 24px);height:var(--bim-icon-size, 24px);display:flex;align-items:center;justify-content:center;color:var(--bim-icon-color, #ccc);flex-shrink:0}.opt-btn-icon svg{width:100%;height:100%;fill:currentColor}.opt-btn-arrow{font-size:10px;opacity:.6;transition:transform .2s;display:inline-block;margin-left:4px}.opt-btn-arrow.rotated{transform:rotate(180deg)}.opt-btn-text-wrapper{display:flex;align-items:center;justify-content:center;pointer-events:none}.opt-btn-label{display:inline}.opt-btn.no-label .opt-btn-label{display:none}.opt-btn.align-vertical:not(.no-label){flex-direction:column;text-align:center}.opt-btn.align-vertical:not(.no-label) .opt-btn-text-wrapper{margin-top:4px}.opt-btn.align-vertical:not(.no-label) .opt-btn-label{font-size:12px;line-height:1.2}.opt-btn.align-horizontal:not(.no-label){flex-direction:row}.opt-btn.align-horizontal:not(.no-label) .opt-btn-text-wrapper{margin-left:8px}.opt-btn.align-horizontal:not(.no-label) .opt-btn-label{font-size:14px}.opt-btn.no-label .opt-btn-text-wrapper{width:0;height:0;margin:0;padding:0;overflow:visible;position:absolute;top:0;right:0}.opt-btn.no-label .opt-btn-arrow{position:absolute;top:2px;right:2px;margin:0;font-size:8px}.opt-btn-dropdown{position:absolute;background-color:var(--bim-toolbar-bg, rgba(17, 17, 17, .95));border-radius:4px;padding:4px;box-shadow:0 4px 12px #0003;z-index:1001;display:flex;flex-direction:column;border:1px solid rgba(255,255,255,.1);opacity:0;visibility:hidden;transform:translateY(-10px);transition:opacity .2s ease,transform .2s cubic-bezier(.2,0,.2,1),visibility .2s}@keyframes dropdown-fade-in{0%{opacity:0;transform:translateY(-8px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}.opt-btn-dropdown{animation:dropdown-fade-in .2s cubic-bezier(.2,0,.2,1) forwards;opacity:1;visibility:visible;transform:none}.opt-btn-dropdown-item{display:flex;align-items:center;padding:8px 12px;cursor:pointer;border-radius:4px;color:var(--bim-btn-text-color, #ccc);transition:background .2s,border-color .2s,color .2s;box-sizing:border-box;border:1px solid transparent;outline:none}.opt-btn-dropdown-item .opt-btn-icon{color:var(--bim-icon-color, #ccc)}.opt-btn-dropdown-item:hover{background-color:var(--bim-btn-hover-bg, #444)}.opt-btn-dropdown-item.active{background-color:var(--bim-btn-active-bg, rgba(255, 255, 255, .15));color:var(--bim-btn-text-active-color, #fff)}.opt-btn-dropdown-item.align-horizontal{flex-direction:row}.opt-btn-dropdown-item.align-horizontal .opt-btn-icon{width:18px;height:18px;margin-right:8px}.opt-btn-dropdown-item.align-vertical{flex-direction:column;text-align:center}.opt-btn-dropdown-item.align-vertical .opt-btn-icon{width:24px;height:24px;margin-bottom:4px}.opt-btn-dropdown-item.align-vertical .opt-btn-dropdown-label{font-size:12px}.bim-btn-group-root.is-bottom-toolbar .opt-btn-icon{width:32px;height:32px}.bim-btn-group-root.is-bottom-toolbar .opt-btn{padding:8px}.bim-btn-group-root.is-bottom-toolbar.dir-row{max-width:calc(100% - 40px);overflow-x:auto;overflow-y:visible;scrollbar-width:thin;scrollbar-color:rgba(255,255,255,.2) transparent}.bim-btn-group-root.is-bottom-toolbar.dir-row .bim-btn-group-section{flex-shrink:0}.bim-btn-group-root.is-bottom-toolbar.dir-row::-webkit-scrollbar{height:4px}.bim-btn-group-root.is-bottom-toolbar.dir-row::-webkit-scrollbar-track{background:transparent}.bim-btn-group-root.is-bottom-toolbar.dir-row::-webkit-scrollbar-thumb{background:#fff3;border-radius:2px}.bim-btn-group-root.is-bottom-toolbar.dir-row::-webkit-scrollbar-thumb:hover{background:#fff6}.bim-btn-group-root.type-glass-pill .bim-btn-group-section{background:var(--bim-floating-bg);backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px);border:1px solid var(--bim-floating-border);border-radius:9999px;box-shadow:none;padding:8px;gap:10px}.bim-btn-group-root.type-glass-pill .opt-btn{width:48px;height:48px;min-width:48px;border-radius:9999px;background:var(--bim-floating-btn-bg);border:1px solid var(--bim-floating-btn-border);box-shadow:var(--bim-floating-btn-shadow);color:var(--bim-text-primary);padding:0;transition:all .2s ease-out}.bim-btn-group-root.type-glass-pill .opt-btn:hover{background:var(--bim-floating-btn-bg-hover);transform:scale(1.05);box-shadow:var(--bim-floating-btn-shadow-hover)}.bim-btn-group-root.type-glass-pill .opt-btn:active{transform:scale(.98)}.bim-btn-group-root.type-glass-pill .opt-btn.active{background:var(--bim-primary);border:1px solid var(--bim-primary-active);color:var(--bim-text-inverse);box-shadow:var(--bim-shadow-glow)}.bim-btn-group-root.type-glass-pill .opt-btn.active:hover{background:var(--bim-primary-hover);transform:scale(1.05)}.bim-btn-group-root.type-glass-pill .opt-btn.active:active{transform:scale(.98)}.bim-btn-group-root.type-glass-pill .opt-btn.active .opt-btn-icon{color:var(--bim-icon-inverse)}.bim-btn-group-root.type-glass-pill .opt-btn.disabled{opacity:.3;cursor:not-allowed;transform:none;box-shadow:none}.bim-btn-group-root.type-glass-pill .opt-btn-icon{width:18px;height:18px;color:var(--bim-floating-icon-color);transition:color .2s ease-out}.bim-btn-group-root.type-glass-pill .opt-btn-icon svg{width:18px;height:18px}.bim-btn-group-root.type-glass-pill .opt-btn:hover .opt-btn-icon{color:var(--bim-floating-icon-color-hover)}.bim-btn-group-root.type-glass-pill .opt-btn-label{display:none!important}.bim-btn-group-root.type-glass-pill .opt-btn-text-wrapper{position:absolute;top:2px;right:2px;width:0;height:0;margin:0;padding:0}.bim-btn-group-root.type-glass-pill .opt-btn-arrow{font-size:8px;position:absolute;top:0;right:0;color:var(--bim-text-tertiary)}.opt-btn-dropdown.type-glass-pill{background:#fffffff2;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border:1px solid rgba(226,232,240,.6);border-radius:12px;box-shadow:0 8px 24px #0000001f;padding:6px}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item{display:flex;flex-direction:row;align-items:center;gap:10px;border-radius:8px;color:#334155;padding:8px 12px;font-size:13px;font-weight:400;transition:all .1s ease-out}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item:hover{background:#f1f5f9}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item:active{background:#e2e8f0}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item.active{background:#3b82f6;color:#fff}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item.active .opt-btn-icon,.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item.active .opt-btn-dropdown-label{color:#fff}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item .opt-btn-icon{width:18px;height:18px;color:#334155;flex-shrink:0}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item .opt-btn-icon svg{width:18px;height:18px}.opt-btn-dropdown.type-glass-pill .opt-btn-dropdown-item .opt-btn-dropdown-label{white-space:nowrap;color:#334155}.opt-btn-dropdown.type-glass-pill.theme-dark{background:var(--bim-bg-overlay);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border:1px solid var(--bim-border-default);box-shadow:var(--bim-shadow-lg)}.opt-btn-dropdown.type-glass-pill.theme-dark .opt-btn-dropdown-item{color:var(--bim-text-primary)}.opt-btn-dropdown.type-glass-pill.theme-dark .opt-btn-dropdown-item:hover{background:var(--bim-floating-btn-bg)}.opt-btn-dropdown.type-glass-pill.theme-dark .opt-btn-dropdown-item:active{background:var(--bim-floating-btn-bg-hover)}.opt-btn-dropdown.type-glass-pill.theme-dark .opt-btn-dropdown-item.active{background:var(--bim-primary);color:var(--bim-text-inverse)}.opt-btn-dropdown.type-glass-pill.theme-dark .opt-btn-dropdown-item .opt-btn-icon{color:var(--bim-floating-icon-color)}.opt-btn-dropdown.type-glass-pill.theme-dark .opt-btn-dropdown-item .opt-btn-dropdown-label{color:var(--bim-text-primary)}.bim-dialog{position:absolute;background-color:var(--bim-bg-elevated);border:1px solid var(--bim-border-default);border-radius:var(--bim-panel-radius, 12px);box-shadow:var(--bim-shadow-lg);display:flex;flex-direction:column;z-index:10001;color:var(--bim-dialog-title-color, var(--bim-text-primary));overflow:hidden;min-width:200px;min-height:100px;pointer-events:auto}.bim-dialog-header{height:40px;background-color:var(--bim-bg-inset);display:flex;align-items:center;justify-content:space-between;padding:0 12px;cursor:default;-webkit-user-select:none;user-select:none;border-bottom:1px solid var(--bim-border-default);flex-shrink:0}.bim-dialog-header.draggable{cursor:move}.bim-dialog-title{font-size:14px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--bim-dialog-title-color)}.bim-dialog-close{cursor:pointer;font-size:18px;color:var(--bim-text-tertiary);line-height:1;margin-left:8px}.bim-dialog-close:hover{color:var(--bim-text-primary)}.bim-dialog-content{flex:1;overflow:auto;font-size:14px;color:var(--bim-dialog-text-color, var(--bim-text-secondary))}.bim-dialog-resize-handle{position:absolute;width:10px;height:10px;bottom:0;right:0;cursor:se-resize;z-index:10}.bim-dialog-resize-handle:after{content:"";position:absolute;bottom:3px;right:3px;width:6px;height:6px;border-right:2px solid var(--bim-text-tertiary);border-bottom:2px solid var(--bim-text-tertiary)}.bim-dialog-resize-handle:hover:after{border-color:var(--bim-text-primary)}.originRotate{width:10px;height:10px;background-color:red}.versionText{position:absolute;right:10px;color:#86d9ff;z-index:1000;bottom:0;font-size:10px;background:transparent;pointer-events:none}.originDiv{position:absolute;top:100px;left:100px;width:30px;height:30px;border-radius:50%;z-index:1000;pointer-events:none}.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}.measureBack{cursor:pointer;pointer-events:auto;fill:orange;top:-50px;rx:5;ry:5}.measureLabel{position:absolute;fill:#fff;font-size:14px;font-family:Arial,sans-serif;pointer-events:none}.measurePointer{fill:orange}.Hight{stroke:#fff;stroke-width:2}.allow-select{pointer-events:auto}.disallow-select{pointer-events:none}.angle-annotation{position:absolute;pointer-events:auto}.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}.bim-tree{width:100%;height:100%;display:flex;flex-direction:column;overflow:hidden;font-size:14px;color:var(--bim-text-primary);-webkit-user-select:none;user-select:none;position:relative;background:transparent}.bim-tree-search{padding:6px;background-color:transparent;flex-shrink:0;position:relative}.bim-tree-search-wrapper{position:relative;width:100%;display:flex;align-items:center}.bim-tree-search-icon{position:absolute;left:8px;width:16px;height:16px;color:var(--bim-text-secondary);pointer-events:none;display:flex;align-items:center;justify-content:center}.bim-tree-search-icon svg{width:100%;height:100%}.bim-tree-search-input{width:100%;height:30px;padding:4px 8px 4px 30px;border:1px solid var(--bim-border-default);border-radius:4px;outline:none;font-size:13px;color:inherit;background-color:var(--bim-bg-elevated);transition:all .2s;box-sizing:border-box}.bim-tree-search-input:focus{border-color:var(--bim-primary);box-shadow:var(--bim-focus-ring)}.bim-tree-search-results{position:absolute;top:100%;left:8px;right:8px;background-color:var(--bim-bg-elevated);border:1px solid var(--bim-border-default);box-shadow:var(--bim-shadow-md);border-radius:4px;max-height:200px;overflow-y:auto;z-index:10;display:none}.bim-tree-search-results.is-visible{display:block}.bim-tree-search-item{padding:8px 12px;cursor:pointer;border-bottom:1px solid rgba(0,0,0,.03)}.bim-tree-search-item:last-child{border-bottom:none}.bim-tree-search-item:hover{background-color:var(--bim-component-bg-hover)}.bim-tree-search-item-title{font-weight:500;display:block}.bim-tree-search-item-path{font-size:12px;color:var(--bim-text-secondary);margin-top:2px;display:block}.bim-tree-node-content:hover{background-color:var(--bim-component-bg-hover)}.bim-tree-switcher{width:24px;height:32px;display:flex;align-items:center;justify-content:center;cursor:pointer;color:var(--bim-text-secondary);transition:transform .2s;flex-shrink:0}.bim-tree-switcher svg{width:12px;height:12px;fill:currentColor;transition:transform .2s}.bim-tree-switcher.is-expanded svg{transform:rotate(90deg)}.bim-tree-switcher.is-hidden{visibility:hidden}.bim-tree-checkbox{width:16px;height:16px;border:1px solid var(--bim-border-default);border-radius:2px;margin-right:8px;background-color:var(--bim-bg-elevated);position:relative;cursor:pointer;flex-shrink:0;transition:all .2s}.bim-tree-checkbox:hover{border-color:var(--bim-primary)}.bim-tree-checkbox.is-checked{background-color:var(--bim-primary);border-color:var(--bim-primary)}.bim-tree-checkbox.is-checked:after{content:"";position:absolute;top:1px;left:4px;width:5px;height:9px;border:2px solid var(--bim-text-inverse);border-top:0;border-left:0;transform:rotate(45deg)}.bim-tree-checkbox.is-indeterminate{background-color:var(--bim-bg-elevated);border-color:var(--bim-primary)}.bim-tree-checkbox.is-indeterminate:after{content:"";position:absolute;top:6px;left:3px;width:8px;height:2px;background-color:var(--bim-primary)}.bim-tree-node.is-disabled .bim-tree-checkbox{background-color:var(--bim-component-bg-disabled);border-color:var(--bim-border-disabled);cursor:not-allowed}.bim-tree-node.is-disabled .bim-tree-checkbox.is-checked{background-color:var(--bim-text-disabled)}.bim-tree-node.is-disabled .bim-tree-node-content{color:var(--bim-text-disabled);cursor:not-allowed}.bim-tree-icon{width:16px;height:16px;margin-right:6px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.bim-tree-icon img,.bim-tree-icon svg{width:100%;height:100%}.bim-tree-title{flex:1;white-space:nowrap}.bim-tree-children{display:none;overflow:visible}.bim-tree-children.is-visible{display:block}.bim-tree-node-content.is-selected{background-color:var(--bim-component-bg-selected);color:var(--bim-primary)}.bim-tree-node-actions{display:none;align-items:center;margin-left:8px;flex-shrink:0}.bim-tree-node-content.is-selected .bim-tree-node-actions{display:flex}.bim-tree-content{flex:1;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;scroll-behavior:auto;padding:2px 0;min-height:0}.bim-tree-node{display:flex;flex-direction:column;width:100%}.bim-tree-node-content{display:flex;align-items:center;height:32px;cursor:pointer;transition:background-color .2s;border-radius:4px;padding-right:8px;width:100%;box-sizing:border-box}.bim-tab{display:flex;flex-direction:column;width:100%;height:100%;background:transparent;color:var(--bim-text-secondary)}.bim-tab__nav{display:flex;align-items:center;gap:4px;padding:4px;margin:8px 12px;background:var(--bim-bg-inset);border-radius:8px;border:1px solid var(--bim-border-subtle)}.bim-tab__item{flex:1;display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:8px 12px;border:none;border-radius:6px;background:transparent;color:var(--bim-text-secondary);cursor:pointer;transition:all .2s ease;font-size:13px;font-weight:500}.bim-tab__item:hover{color:var(--bim-text-primary);background-color:var(--bim-component-bg-hover)}.bim-tab__item.is-active{color:var(--bim-primary);background-color:var(--bim-bg-elevated);box-shadow:0 1px 3px #0000001a}.bim-tab__item.is-disabled{opacity:.5;cursor:not-allowed}.bim-tab__icon{width:16px;height:16px;display:inline-flex;align-items:center;justify-content:center;color:var(--bim-tab-icon, currentColor)}.bim-tab__icon svg{width:100%;height:100%;fill:currentColor}.bim-tab__title{white-space:nowrap}.bim-tab__content{flex:1;display:flex;position:relative;min-height:0;overflow:hidden}.bim-tab__panel{display:none;width:100%;height:100%;flex:1}.bim-tab__panel.is-active{display:flex;flex-direction:column;height:100%}.construct-tab__container{height:100%;display:flex;flex-direction:column}.construct-tab__panel-content{flex:1;display:flex;flex-direction:column;min-height:0;overflow:hidden}.construct-tab__panel-content .bim-tree{flex:1}.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)}.walk-control-panel{display:flex;align-items:center;gap:20px;padding:12px 20px;background-color:var(--bim-bg-base, #152232);border:1px solid var(--bim-border-strong, #475569);border-radius:12px;box-shadow:var(--bim-shadow-xl, 0 20px 40px rgba(0, 0, 0, .3));-webkit-user-select:none;user-select:none}.walk-divider{width:1px;height:40px;background:var(--bim-divider);flex-shrink:0}.walk-control-left{display:flex;gap:8px}.walk-icon-btn{width:48px;height:48px;display:flex;align-items:center;justify-content:center;background:var(--bim-bg-inset);border:1px solid var(--bim-border-default);border-radius:8px;cursor:pointer;transition:all .2s ease;color:var(--bim-icon-default);padding:8px}.walk-icon-btn:hover{background:var(--bim-component-bg-hover);border-color:var(--bim-border-strong)}.walk-icon-btn.active{background:var(--bim-primary-subtle);border-color:var(--bim-primary);color:var(--bim-primary)}.walk-icon-btn.active svg{fill:var(--bim-primary)}.walk-icon-btn svg{width:32px;height:32px}.walk-control-settings{display:flex;align-items:center;gap:16px;flex:1}.walk-speed-control{display:flex;align-items:center;gap:12px}.walk-speed-label{color:var(--bim-text-primary);font-size:14px;white-space:nowrap}.walk-speed-group{display:flex;align-items:center;gap:8px;background:var(--bim-bg-inset);border:1px solid var(--bim-border-subtle);border-radius:6px;padding:4px}.walk-speed-btn{width:32px;height:32px;background:var(--bim-bg-elevated);border:1px solid var(--bim-border-subtle);border-radius:4px;color:var(--bim-text-primary);font-size:18px;cursor:pointer;transition:all .2s ease}.walk-speed-btn:hover{background:var(--bim-component-bg-hover);border-color:var(--bim-border-strong)}.walk-speed-btn:disabled{opacity:.5;cursor:not-allowed}.walk-speed-display{min-width:40px;text-align:center;color:var(--bim-text-primary);font-size:14px;font-weight:700}.walk-checkbox-wrapper{display:flex;align-items:center;gap:8px;cursor:pointer}.walk-checkbox{width:18px;height:18px;cursor:pointer}.walk-checkbox:disabled{opacity:.5;cursor:not-allowed}.walk-checkbox-label{color:var(--bim-text-primary);font-size:14px;white-space:nowrap}.walk-checkbox-wrapper input:disabled+.walk-checkbox-label{opacity:.5}.walk-select-wrapper{display:flex;align-items:center;gap:8px}.walk-select-label{color:var(--bim-text-primary);font-size:14px;white-space:nowrap}.walk-select{padding:6px 12px;background:var(--bim-bg-inset);border:1px solid var(--bim-border-default);border-radius:6px;color:var(--bim-text-primary);font-size:14px;cursor:pointer;min-width:120px}.walk-select option{background:var(--bim-bg-elevated);color:var(--bim-text-primary)}.walk-exit-btn{padding:10px 24px;background:var(--bim-primary);border:none;border-radius:8px;color:var(--bim-text-inverse);font-size:14px;font-weight:600;cursor:pointer;transition:all .2s ease;white-space:nowrap}.walk-exit-btn:hover{background:var(--bim-primary-hover);transform:scale(1.02)}.walk-path-panel{padding:16px;box-sizing:border-box}.walk-path-btn{border:none;border-radius:6px;cursor:pointer;font-size:14px;transition:all .2s;box-sizing:border-box}.walk-path-btn-group{display:flex;gap:8px;margin-top:16px}.walk-path-btn-play{flex:1;height:32px;padding:0 16px;background:var(--bim-primary, #3b82f6);color:#fff}.walk-path-btn-play:hover:not(:disabled){opacity:.9}.walk-path-btn-play:disabled{opacity:.5;cursor:not-allowed}.walk-path-btn-stop{flex:1;height:32px;padding:0 16px;background:#ef4444;color:#fff}.walk-path-btn-stop:hover:not(:disabled){opacity:.9}.walk-path-btn-stop:disabled{opacity:.5;cursor:not-allowed}.walk-path-btn-small{height:28px;padding:0 12px;font-size:12px;background:var(--bim-bg-elevated, #1f2d3e);color:var(--bim-text-primary, #fff);border:1px solid var(--bim-border-default, #334155)}.walk-path-btn-small:hover{background:var(--bim-border-default, #334155)}.walk-path-btn-danger{color:#ef4444}.walk-path-settings{display:flex;flex-direction:column;gap:12px;margin-bottom:16px}.walk-path-form-group{display:flex;flex-direction:column;gap:6px}.walk-path-form-group label{font-size:12px;color:var(--bim-text-secondary, #94a3b8)}.walk-path-form-group-inline{flex-direction:row;align-items:center}.walk-path-input{padding:8px 12px;border:1px solid var(--bim-border-default, #334155);border-radius:4px;background:var(--bim-bg-elevated, #1f2d3e);color:var(--bim-text-primary, #fff);font-size:14px;width:100%;box-sizing:border-box}.walk-path-input:focus{outline:none;border-color:var(--bim-primary, #3b82f6)}.walk-path-input-wrapper{display:flex;align-items:center;gap:8px}.walk-path-input-wrapper .walk-path-input{flex:1}.walk-path-unit{color:var(--bim-text-secondary, #94a3b8);font-size:14px}.walk-path-checkbox{width:16px;height:16px;margin-right:8px}.walk-path-points-section{margin-bottom:16px}.walk-path-points-toolbar{display:flex;gap:8px;margin-bottom:12px}.walk-path-points-list{height:200px;overflow-y:auto;display:flex;flex-direction:column;gap:8px}.walk-path-empty{text-align:center;padding:32px 16px;color:var(--bim-text-secondary, #94a3b8);font-size:14px}.walk-path-point-item{display:flex;justify-content:space-between;align-items:center;padding:6px 12px;background:var(--bim-bg-elevated, #1f2d3e);border-radius:4px;transition:all .2s}.walk-path-point-item:hover{background:var(--bim-border-default, #334155)}.walk-path-point-item:hover .walk-path-point-actions{opacity:1}.walk-path-point-item-active{background:var(--bim-primary, #3b82f6)}.walk-path-point-item-active .walk-path-point-name{color:#fff}.walk-path-point-item-active .walk-path-point-actions{opacity:1}.walk-path-point-name{font-size:14px;color:var(--bim-text-primary, #fff)}.walk-path-point-actions{display:flex;gap:8px;opacity:0;transition:opacity .2s}.walk-path-btn-icon{width:28px;height:28px;border:none;border-radius:4px;background:transparent;color:var(--bim-text-primary, #fff);cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:14px}.walk-path-btn-icon:hover{background:#ffffff1a}.walk-path-btn-icon-danger:hover{background:#ef444433;color:#ef4444}.bim-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)}')),document.head.appendChild(e)}}catch(i){console.error("vite-plugin-css-injected-by-js",i)}})();
(function(js,Zr){typeof exports=="object"&&typeof module<"u"?Zr(exports):typeof define=="function"&&define.amd?define(["exports"],Zr):(js=typeof globalThis<"u"?globalThis:js||self,Zr(js.IflowEngine={}))})(this,(function(js){"use strict";const Zr={common:{title:"BimEngine",description:"这是一个使用 BIM-ENGINE。",openTestDialog:"打开测试弹窗",openInfoDialog:"打开信息弹窗 (封装版)"},toolbar:{home:"首页",measure:"测量",zoomBox:"选框放大",info:"信息",location:"定位",setting:"设置",walk:"漫游",map:"地图",property:"构件详情",fullscreen:"全屏",walkMenu:"漫游菜单",walkPerson:"第一人称",walkBird:"第三人称",tree:"模型树",section:"剖切",sectionPlane:"拾取面剖切",sectionAxis:"轴向剖切",sectionBox:"剖切盒",cameraSwitch:"相机切换"},dialog:{testTitle:"测试弹窗",testContent:'<div style="padding: 10px;">这是一个 <b>可拖拽</b> 且 <b>可缩放</b> 的弹窗。<br><br>你可以尝试拖动标题栏,或者拖动右下角改变大小。</div>'},menu:{info:"信息",home:"首页",componentDetail:"构件详情",hideSelected:"隐藏选中构件",transparentSelected:"半透明选中构件",cancelTranslucent:"取消半透明",isolateSelected:"隔离选中构件",hideOthers:"其他构件隐藏",transparentOthers:"其他构件半透明",fitSectionBox:"剖切盒适应",showAll:"显示全部",quickSelect:"快速选择",selectSameType:"选择同类模型",selectSameLevel:"选择同层模型",selectSameLevelType:"选择同层同类模型"},tree:{searchPlaceholder:"请输入要搜索的内容"},constructTree:{title:"目录树"},tab:{component:"构件",system:"系统",space:"空间",type:"类型",major:"专业"},panel:{property:{title:"构件详情",base:"基本属性",material:"材质信息",advanced:"高级设置",tab:{props:"属性",material:"材质"}},componentDetail:{title:"构件详情",noSelection:"请先选中构件"}},measure:{btnName:"测量",dialogTitle:"测量",modes:{clearHeight:"净高",clearDistance:"净距",distance:"距离",elevation:"标高",point:"坐标",angle:"角度",area:"面积",slope:"坡度"},actions:{expand:"展开",collapse:"收起",clearAll:"删除全部",settings:"设置"},labels:{currentMode:"当前测量方式:",x:"X",y:"Y",z:"Z",value:{clearHeight:"净高:",clearDistance:"净距:",distance:"距离:",elevation:"标高:",point:"坐标:",angle:"角度:",area:"面积:",slope:"坡度:"}},settings:{title:"设置",unit:"单位:",precision:"精度:",hint:"距离、净距、净高和标高默认使用该单位;角度和面积有各自默认单位。",save:"保存设置",cancel:"取消"},clearHeight:{direction:"朝向:",directionDown:"朝下",directionUp:"朝上",selectType:"选择对象:",selectPoint:"选择点",selectElement:"选择构件"}},sectionPlane:{dialogTitle:"拾取面剖切",actions:{hide:"隐藏",reverse:"反向",reset:"重置"}},sectionAxis:{dialogTitle:"轴向剖切",actions:{hide:"隐藏",reverse:"反向",axisX:"X",axisY:"Y",axisZ:"Z"}},sectionBox:{dialogTitle:"剖切盒",actions:{hide:"隐藏",reverse:"反向",fitToModel:"适应",reset:"重置"},axes:{x:"X",y:"Y",z:"Z"}},walkControl:{speed:"移动速度:",gravity:"重力",collision:"碰撞",characterModel:{label:"建筑工人",constructionWorker:"建筑工人",officeMale:"办公室男性"},walkMode:{label:"行走模式",walk:"行走模式",run:"奔跑模式"},exit:"退出",path:{dialogTitle:"路径漫游",duration:"漫游时间",durationUnit:"秒",loop:"循环播放",addPoint:"添加漫游点",deleteAll:"删除全部",point:"漫游点",play:"播放漫游",stop:"停止漫游",noPoints:"暂无漫游点,请添加"}},info:{dialogTitle:"基本信息",meshCount:"构件数量",totalTriangles:"三角面数量",totalVertices:"顶点数量"},aiChat:{title:"AI 助手",placeholder:"输入你的问题...",quickPrompt:{summarize:"总结这个模型",explain:"解释选中的构件",generate:"生成报告"},action:{new:"新建对话",history:"历史记录",settings:"设置",close:"关闭"},helper:{newline:"Shift + Enter 换行",send:"Enter 发送"},thinking:"正在思考...",other:"其他",otherPlaceholder:"请输入自定义答案",submit:"提交"},setting:{dialogTitle:"设置",renderMode:"渲染模式",modes:{simple:"性能模式",balance:"平衡模式",advanced:"效果模式"},edgeLine:"边线",contrast:"对比度",saturation:"饱和度",lightIntensity:"光照强度",environment:"环境背景",backgroundVisible:"显示背景",ground:"显示地面",groundElevation:"地面高度",groundElevationUnit:"m"}},xg={common:{title:"BimEngine",description:"This is a BIM-ENGINE demo.",openTestDialog:"Open Test Dialog",openInfoDialog:"Open Info Dialog (Wrapped)"},toolbar:{home:"Home",measure:"Measure",zoomBox:"Zoom Box",info:"Info",location:"Location",setting:"Settings",walk:"Walk",map:"Map",property:"Property",fullscreen:"Fullscreen",walkPerson:"Person",walkBird:"Bird Eye",walkMenu:"Menu",tree:"Tree",section:"Section",sectionPlane:"Plane Section",sectionAxis:"Axis Section",sectionBox:"Section Box",cameraSwitch:"Camera"},dialog:{testTitle:"Test Dialog",testContent:'<div style="padding: 10px;">This is a <b>draggable</b> and <b>resizable</b> dialog.<br><br>Try dragging the title bar or resizing from the bottom-right corner.</div>'},menu:{info:"Info",home:"Home",componentDetail:"Component Detail",hideSelected:"Hide Selected",transparentSelected:"Transparent Selected",cancelTranslucent:"Cancel Translucent",isolateSelected:"Isolate Selected",hideOthers:"Hide Others",transparentOthers:"Transparent Others",fitSectionBox:"Fit Section Box",showAll:"Show All",quickSelect:"Quick Select",selectSameType:"Select Same Type",selectSameLevel:"Select Same Level",selectSameLevelType:"Select Same Level & Type"},tree:{searchPlaceholder:"Please enter content to search"},constructTree:{title:"Construct Tree"},tab:{component:"Component",system:"System",space:"Space",type:"Type",major:"Major"},panel:{property:{title:"Component Details",base:"Basic Info",material:"Material",advanced:"Advanced",tab:{props:"Properties",material:"Material"}},componentDetail:{title:"Component Detail",noSelection:"Please select a component first"}},measure:{btnName:"Measure",dialogTitle:"Measure",modes:{clearHeight:"Clear Height",clearDistance:"Clear Distance",distance:"Distance",elevation:"Elevation",point:"Point",angle:"Angle",area:"Area",slope:"Slope"},actions:{expand:"Expand",collapse:"Collapse",clearAll:"Clear All",settings:"Settings"},labels:{currentMode:"Mode:",x:"X:",y:"Y:",z:"Z:",value:{clearHeight:"Clear Height:",clearDistance:"Clear Distance:",distance:"Distance:",elevation:"Elevation:",point:"Point:",angle:"Angle:",area:"Area:",slope:"Slope:"}},settings:{title:"Settings",unit:"Unit:",precision:"Precision:",hint:"Distance, clear distance, clear height and elevation use this unit by default; angle and area use their own units.",save:"Save",cancel:"Cancel"},clearHeight:{direction:"Direction:",directionDown:"Down",directionUp:"Up",selectType:"Select:",selectPoint:"Point",selectElement:"Element"}},sectionPlane:{dialogTitle:"Plane Section",actions:{hide:"Hide",reverse:"Reverse",reset:"Reset"}},sectionAxis:{dialogTitle:"Axis Section",actions:{hide:"Hide",reverse:"Reverse",axisX:"X",axisY:"Y",axisZ:"Z"}},sectionBox:{dialogTitle:"Section Box",actions:{hide:"Hide",reverse:"Reverse",fitToModel:"Fit",reset:"Reset"},axes:{x:"X",y:"Y",z:"Z"}},walkControl:{speed:"Speed:",gravity:"Gravity",collision:"Collision",characterModel:{label:"Construction Worker",constructionWorker:"Construction Worker",officeMale:"Office Male"},walkMode:{label:"Walk Mode",walk:"Walk",run:"Run"},exit:"Exit",path:{dialogTitle:"Path Roaming",duration:"Duration",durationUnit:"s",loop:"Loop",addPoint:"Add Point",deleteAll:"Delete All",point:"Point",play:"Play",stop:"Stop",noPoints:"No points yet"}},info:{dialogTitle:"Basic Info",meshCount:"Mesh Count",totalTriangles:"Total Triangles",totalVertices:"Total Vertices"},aiChat:{title:"AI Assistant",placeholder:"Ask a question...",quickPrompt:{summarize:"Summarize this model",explain:"Explain selected component",generate:"Generate report"},action:{new:"New Chat",history:"History",settings:"Settings",close:"Close"},helper:{newline:"Shift + Enter for new line",send:"Enter to send"},thinking:"Thinking...",other:"Other",otherPlaceholder:"Enter custom answer",submit:"Submit"},setting:{dialogTitle:"Settings",renderMode:"Render Mode",modes:{simple:"Performance",balance:"Balanced",advanced:"Quality"},edgeLine:"Edge Lines",contrast:"Contrast",saturation:"Saturation",lightIntensity:"Light Intensity",environment:"Environment",backgroundVisible:"Show Background",ground:"Ground",groundElevation:"Ground Elevation",groundElevationUnit:"m"}};class vg{currentLocale="zh-CN";messages={"zh-CN":Zr,"en-US":xg};listeners=[];constructor(){}getLocale(){return this.currentLocale}setLocale(e){this.currentLocale!==e&&(this.currentLocale=e,this.notifyListeners())}t(e){if(!e)return"";const t=e.split(".");let n=this.messages[this.currentLocale];for(const i of t)if(n&&typeof n=="object"&&i in n)n=n[i];else return e;return n}subscribe(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}notifyListeners(){this.listeners.forEach(e=>e(this.currentLocale))}}const Qt=new vg,xe=s=>Qt.t(s),Mu={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"}}},bg={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 yg{currentTheme=Mu;listeners=[];constructor(){}getTheme(){return this.currentTheme}setTheme(e){e==="light"?this.applyTheme(Mu):this.applyTheme(bg)}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 ot=new yg;class tc{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(i=>{e[i]&&this.customColors.add(i)}),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=i=>{i.stopPropagation()};["click","dblclick","contextmenu","wheel","mousedown","mouseup","mousemove","touchstart","touchend","touchmove","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointerover","pointerout"].forEach(i=>{e.addEventListener(i,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 n="20px";switch(e){case"top-left":t.top=n,t.left=n;break;case"top-center":t.top=n,t.left="50%",t.transform="translateX(-50%)";break;case"top-right":t.top=n,t.right=n;break;case"bottom-left":t.bottom=n,t.left=n;break;case"bottom-center":t.bottom=n,t.left="50%",t.transform="translateX(-50%)";break;case"bottom-right":t.bottom=n,t.right=n;break;case"left-center":t.left=n,t.top="50%",t.transform="translateY(-50%)";break;case"right-center":t.right=n,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(n=>{const i=n.style;this.options.iconColor&&i.setProperty("--bim-icon-color",this.options.iconColor),this.options.iconActiveColor&&i.setProperty("--bim-icon-active-color",this.options.iconActiveColor),this.options.textColor&&i.setProperty("--bim-btn-text-color",this.options.textColor),this.options.textActiveColor&&i.setProperty("--bim-btn-text-active-color",this.options.textActiveColor),this.options.btnBackgroundColor&&i.setProperty("--bim-btn-bg",this.options.btnBackgroundColor),this.options.btnHoverColor&&i.setProperty("--bim-btn-hover-bg",this.options.btnHoverColor),this.options.btnActiveColor&&i.setProperty("--bim-btn-active-bg",this.options.btnActiveColor)})}setPrimaryColor(e){this.container.style.setProperty("--bim-primary-color",e),document.querySelectorAll(".opt-btn-dropdown").forEach(n=>{n.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(([n,i])=>{const r=n;this.customColors.has(r)||(this.options[r]=i)}),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(n=>{const i=n.style;i.setProperty("--bim-primary",e.primary),i.setProperty("--bim-bg-overlay",e.bgOverlay),i.setProperty("--bim-border-default",e.borderDefault),i.setProperty("--bim-text-primary",e.textPrimary),i.setProperty("--bim-text-inverse",e.textInverse),i.setProperty("--bim-shadow-lg",e.shadowLg),i.setProperty("--bim-floating-btn-bg",e.floatingBtnBg),i.setProperty("--bim-floating-btn-bg-hover",e.floatingBtnBgHover),i.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=Qt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ot.subscribe(e=>{this.setTheme(e)})}setLocales(){this.render()}addGroup(e,t){if(this.groups.some(i=>i.id===e))return;const n={id:e,buttons:[]};if(t){const i=this.groups.findIndex(r=>r.id===t);i!==-1?this.groups.splice(i,0,n):this.groups.push(n)}else this.groups.push(n)}addButton(e){const{groupId:t,parentId:n}=e,i=this.groups.find(a=>a.id===t);if(!i)return;const r={...e,children:e.children||[]};if(n){const a=this.findButton(i.buttons,n);a&&(a.children||(a.children=[]),a.children.push(r))}else i.buttons.push(r)}findButton(e,t){for(const n of e){if(n.id===t)return n;if(n.children){const i=this.findButton(n.children,t);if(i)return i}}}render(){this.container.innerHTML="",this.btnRefs.clear(),this.groups.forEach((e,t)=>{const n=this.renderGroup(e,t,this.groups.length);this.container.appendChild(n)})}renderGroup(e,t,n){const i=document.createElement("div");return i.className="bim-btn-group-section",t<n-1&&i.classList.add("has-divider"),e.buttons.forEach(r=>{if(this.isVisible(r.id)){const a=this.renderButton(r);i.appendChild(a)}}),i}renderButton(e){const t=document.createElement("div");t.className="opt-btn-wrapper";const n=document.createElement("div");n.className="opt-btn",e.isActive&&this.activeBtnIds.add(e.id),(e.align||this.options.align||"vertical")==="horizontal"?n.classList.add("align-horizontal"):n.classList.add("align-vertical"),this.activeBtnIds.has(e.id)&&n.classList.add("active"),e.disabled&&n.classList.add("disabled"),this.options.showLabel&&e.label||(n.classList.add("no-label"),e.label&&(n.title=xe(e.label)));const a=e.iconSize||32,o=e.minWidth||50;n.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),n.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=xe(e.label),c.appendChild(h)}return c.hasChildNodes()&&n.appendChild(c),n.addEventListener("click",()=>this.handleClick(e)),n.addEventListener("mouseenter",()=>this.handleMouseEnter(e,n)),n.addEventListener("mouseleave",()=>this.handleMouseLeave()),this.btnRefs.set(e.id,n),t.appendChild(n),t}setBtnActive(e,t){const n=this.findButtonById(e);if(!n)return;const i=t!==void 0?t:!this.activeBtnIds.has(e);i?this.activeBtnIds.add(e):this.activeBtnIds.delete(e),n.isActive=i,this.updateButtonState(e)}handleClick(e){if(!e.disabled&&(!e.children||e.children.length===0)){if(e.keepActive){const n=!this.activeBtnIds.has(e.id);this.setBtnActive(e.id,n),n&&e.exclusive&&e.groupId&&this.deactivateExclusiveSiblings(e)}this.closeDropdown(),e.onClick&&e.onClick(e)}}deactivateExclusiveSiblings(e){const t=this.groups.find(n=>n.id===e.groupId);if(t){if(e.parentId){const i=this.findButton(t.buttons,e.parentId)?.children||[];for(const r of i)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 n of t.buttons)n.id!==e.id&&n.groupId===e.groupId&&(n.parentId||this.activeBtnIds.has(n.id)&&(this.setBtnActive(n.id,!1),n.onClick&&n.onClick(n)))}}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 n=document.createElement("div");n.className="opt-btn-dropdown",this.options.backgroundColor&&n.style.setProperty("--bim-toolbar-bg",this.options.backgroundColor);const i=n.style;this.options.iconColor&&i.setProperty("--bim-icon-color",this.options.iconColor),this.options.iconActiveColor&&i.setProperty("--bim-icon-active-color",this.options.iconActiveColor),this.options.textColor&&i.setProperty("--bim-btn-text-color",this.options.textColor),this.options.textActiveColor&&i.setProperty("--bim-btn-text-active-color",this.options.textActiveColor),this.options.btnBackgroundColor&&i.setProperty("--bim-btn-bg",this.options.btnBackgroundColor),this.options.btnHoverColor&&i.setProperty("--bim-btn-hover-bg",this.options.btnHoverColor),this.options.btnActiveColor&&i.setProperty("--bim-btn-active-bg",this.options.btnActiveColor);const r=t.getBoundingClientRect(),a=this.options.expand||"down";this.options.direction==="row"?n.style.flexDirection="column":n.style.flexDirection="row",this.options.type&&this.options.type!=="default"&&n.classList.add(`type-${this.options.type}`);const o=ot.getTheme();n.classList.add(`theme-${o.name}`),i.setProperty("--bim-primary",o.primary),i.setProperty("--bim-bg-overlay",o.bgOverlay),i.setProperty("--bim-border-default",o.borderDefault),i.setProperty("--bim-text-primary",o.textPrimary),i.setProperty("--bim-text-inverse",o.textInverse),i.setProperty("--bim-shadow-lg",o.shadowLg),i.setProperty("--bim-floating-btn-bg",o.floatingBtnBg),i.setProperty("--bim-floating-btn-bg-hover",o.floatingBtnBgHover),i.setProperty("--bim-floating-icon-color",o.floatingIconColor),document.body.appendChild(n),this.setupEventInterception(n),e.children.forEach(c=>{if(this.isVisible(c.id)){const h=this.renderDropdownItem(c);n.appendChild(h)}});const l=n.getBoundingClientRect();a==="up"?(n.style.bottom=window.innerHeight-r.top+8+"px",n.style.left=r.left+(r.width-l.width)/2+"px"):a==="down"?(n.style.top=r.bottom+8+"px",n.style.left=r.left+(r.width-l.width)/2+"px"):a==="right"?(n.style.top=r.top+(r.height-l.height)/2+"px",n.style.left=r.right+8+"px"):a==="left"&&(n.style.top=r.top+(r.height-l.height)/2+"px",n.style.right=window.innerWidth-r.left+8+"px"),n.addEventListener("mouseenter",()=>{this.hoverTimeout&&clearTimeout(this.hoverTimeout)}),n.addEventListener("mouseleave",()=>this.handleMouseLeave()),this.dropdownElement=n}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 i=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=`${i}px`,a.style.height=`${i}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=xe(e.label),t.appendChild(o)}else e.label&&(t.title=xe(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 n=this.btnRefs.get(e);if(!n)return;const i=n.querySelector(".opt-btn-icon");i&&(i.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 n=this.findButtonById(t);if(!n)return;this.options.showLabel&&n.label?(e.classList.remove("no-label"),e.removeAttribute("title")):(e.classList.add("no-label"),n.label&&(e.title=xe(n.label)))})}findButtonById(e){for(const t of this.groups){const n=this.findButton(t.buttons,e);if(n)return n}}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()}}class _g extends tc{async init(){await super.init();const e=this.options.registry,{createHomeButton:t}=await Promise.resolve().then(()=>$C),{createZoomBoxButton:n}=await Promise.resolve().then(()=>KC),{createWalkMenuButton:i}=await Promise.resolve().then(()=>JC),{createMapButton:r}=await Promise.resolve().then(()=>QC),{createPropertyButton:a}=await Promise.resolve().then(()=>eT),{createSettingButton:o}=await Promise.resolve().then(()=>tT),{createInfoButton:l}=await Promise.resolve().then(()=>nT),{createFullscreenButton:c}=await Promise.resolve().then(()=>iT),{createMeasureButton:h}=await Promise.resolve().then(()=>sT),{createSectionMenuButton:d}=await Promise.resolve().then(()=>rT),{createSectionPlaneButton:p}=await Promise.resolve().then(()=>aT),{createSectionAxisButton:u}=await Promise.resolve().then(()=>oT),{createSectionBoxButton:g}=await Promise.resolve().then(()=>lT),{createAiChatButton:f}=await Promise.resolve().then(()=>cT),{createCameraSwitchButton:x}=await Promise.resolve().then(()=>hT);this.addGroup("group-1"),this.addButton(t(e)),this.addButton(x(e)),this.addButton(n(e)),this.addButton(h(e)),this.addButton(d(e)),this.addButton(p(e)),this.addButton(u(e)),this.addButton(g(e)),this.addButton(i(e)),this.addButton(r(e)),this.addButton(a(e)),this.addGroup("group-2"),this.addButton(f(e)),this.addButton(o(e)),this.addButton(l(e)),this.addButton(c(e)),this.render()}}class xi{registry;subscriptions=[];constructor(e){this.registry=e}get engineComponent(){return this.registry.engine3d?.getEngineComponent?.()??null}subscribe(e,t){const n=this.registry.on(e,t);this.subscriptions.push(n)}emit(e,t){this.registry.emit(e,t)}destroy(){this.subscriptions.forEach(e=>e()),this.subscriptions=[]}}class Mg extends xi{toolbar=null;toolbarContainer=null;container;constructor(e,t){super(t),this.container=e,this.init()}init(){this.toolbarContainer=document.createElement("div"),this.toolbarContainer.id="opt-btn-groups",this.toolbarContainer.className="bim-engine-opt-btn-container is-bottom-toolbar",this.container.appendChild(this.toolbarContainer),this.toolbar=new _g({container:this.toolbarContainer,type:"glass-pill",showLabel:!0,direction:"row",position:"bottom-right",align:"vertical",expand:"up",registry:this.registry}),this.toolbar.init()}updateTheme(e){this.toolbar?.setTheme(e)}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)}setBtnActive(e,t){this.toolbar?.setBtnActive(e,t)}updateButtonIcon(e,t){this.toolbar?.updateButtonIcon(e,t)}setVisible(e){this.toolbarContainer&&(this.toolbarContainer.style.visibility=e?"visible":"hidden")}setBackgroundColor(e){this.toolbar?.setBackgroundColor(e)}setColors(e){this.toolbar?.setColors(e)}hide(){this.toolbarContainer&&(this.toolbarContainer.style.display="none")}show(){this.toolbarContainer&&(this.toolbarContainer.style.display="")}getContainer(){return this.toolbarContainer}setType(e){this.toolbar?.setType(e)}getType(){return this.toolbar?.getType()||"default"}}class wg extends xi{groups=new Map;container;constructor(e,t){super(t),this.container=e}create(e,t){const n=new tc({container:this.container,registry:this.registry,...t});return n.init(),this.groups.set(e,n),n}get(e){return this.groups.get(e)}updateTheme(e){this.groups.forEach(t=>t.setTheme(e))}destroy(){this.groups.forEach(e=>e.destroy()),this.groups.clear(),super.destroy()}}class Sg{element;options;container;header;contentArea;_isDestroyed=!1;_isInitialized=!1;unsubscribeTheme=null;unsubscribeLocale=null;rafId=null;constructor(e){this.options={title:"Dialog",width:300,height:"auto",position:"center",draggable:!0,resizable:!1,minWidth:200,minHeight:100,...e},this.container=e.container,this.element=this.createDom(),this.header=this.element.querySelector(".bim-dialog-header"),this.contentArea=this.element.querySelector(".bim-dialog-content"),this.init()}setTheme(e){const t=this.element.style;this.options.backgroundColor||t.setProperty("--bim-dialog-bg",e.bgElevated),this.options.headerBackgroundColor||t.setProperty("--bim-dialog-header-bg",e.bgInset),this.options.titleColor||t.setProperty("--bim-dialog-title-color",e.textPrimary),this.options.textColor||t.setProperty("--bim-dialog-text-color",e.textSecondary),this.options.borderColor||t.setProperty("--bim-dialog-border-color",e.borderDefault),t.setProperty("--bim-bg-elevated",e.bgElevated),t.setProperty("--bim-bg-inset",e.bgInset),t.setProperty("--bim-text-primary",e.textPrimary),t.setProperty("--bim-text-secondary",e.textSecondary),t.setProperty("--bim-text-tertiary",e.textTertiary),t.setProperty("--bim-border-default",e.borderDefault),t.setProperty("--bim-shadow-lg",e.shadowLg)}init(){this._isInitialized||(this.container.appendChild(this.element),this.initPosition(),this.options.draggable&&this.initDrag(),this.options.resizable&&this.initResize(),this._isInitialized=!0,this.options.onOpen&&this.options.onOpen(),this.unsubscribeTheme=ot.subscribe(e=>{this.setTheme(e)}),this.unsubscribeLocale=Qt.subscribe(()=>{this.setLocales()}))}setLocales(){if(this.options.title){const e=this.header.querySelector(".bim-dialog-title");e&&(e.textContent=xe(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 n=document.createElement("div");n.className="bim-dialog-header",this.options.draggable&&n.classList.add("draggable");const i=document.createElement("span");i.className="bim-dialog-title",i.textContent=this.options.title?xe(this.options.title):"";const r=document.createElement("span");r.className="bim-dialog-close",r.innerHTML="&times;",r.onclick=()=>{this.close()},n.appendChild(i),n.appendChild(r);const a=document.createElement("div");if(a.className="bim-dialog-content",typeof this.options.content=="string"?a.innerHTML=this.options.content:this.options.content instanceof HTMLElement&&a.appendChild(this.options.content),e.appendChild(n),e.appendChild(a),this.options.resizable){const c=document.createElement("div");c.className="bim-dialog-resize-handle",e.appendChild(c)}const o=c=>{c.stopPropagation()};return["click","dblclick","contextmenu","wheel","mousedown","mouseup","mousemove","touchstart","touchend","touchmove","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointerover","pointerout"].forEach(c=>{e.addEventListener(c,o,{passive:!1})}),e}setSize(e,t,n){t!==void 0&&(t==="auto"||t==="fit-content"?e.style.width=t:e.style.width=typeof t=="number"?`${t}px`:t),n!==void 0&&(n==="auto"||n==="fit-content"?e.style.height=n:e.style.height=typeof n=="number"?`${n}px`:n)}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,n=this.options.minHeight??100,i=this.container.clientHeight||0;let r=Math.max(n,t);i>0&&(r=Math.min(r,i)),this.element.style.height=`${r}px`,e?this.initPosition():this.clampToContainer()}clampToContainer(){const e=this.container.clientWidth,t=this.container.clientHeight,n=this.element.offsetWidth,i=this.element.offsetHeight,r=this.options.bottomOffset??70,a=this.element.offsetLeft,o=this.element.offsetTop,l=Math.max(0,e-n),c=Math.max(0,t-i-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(),n=this.options.bottomOffset??70;let i=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)i=e.x,r=e.y;else switch(e){case"center":i=(a-l)/2,r=(o-c)/2;break;case"top-left":i=0,r=0;break;case"top-center":i=(a-l)/2,r=0;break;case"top-right":i=a-l,r=0;break;case"left-center":i=0,r=(o-c)/2;break;case"right-center":i=a-l,r=(o-c)/2;break;case"bottom-left":i=0,r=o-c-n;break;case"bottom-center":i=(a-l)/2,r=o-c-n;break;case"bottom-right":i=a-l,r=o-c-n;break;default:i=(a-l)/2,r=(o-c)/2}i=Math.max(0,Math.min(i,a-l)),r=Math.max(0,Math.min(r,o-c-n)),this.element.style.left=`${i}px`,this.element.style.top=`${r}px`}initDrag(){let e=0,t=0,n=0,i=0,r=0,a=0,o=0,l=0,c=0;const h=u=>{u.preventDefault(),u.stopPropagation(),e=u.clientX,t=u.clientY,n=this.element.offsetLeft,i=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",p,{capture:!0})},d=u=>{u.preventDefault(),u.stopPropagation(),!this.rafId&&(this.rafId=requestAnimationFrame(()=>{const g=u.clientX-e,f=u.clientY-t;let x=n+g,m=i+f;const b=r-o,v=a-l-c;x=Math.max(0,Math.min(x,b)),m=Math.max(0,Math.min(m,v)),this.element.style.left=`${x}px`,this.element.style.top=`${m}px`,this.rafId=null}))},p=()=>{this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null),document.removeEventListener("mousemove",d,{capture:!0}),document.removeEventListener("mouseup",p,{capture:!0})};this.header.addEventListener("mousedown",h)}initResize(){const e=this.element.querySelector(".bim-dialog-resize-handle");if(!e)return;let t=0,n=0,i=0,r=0,a=0,o=0,l=0,c=0;const h=u=>{u.preventDefault(),u.stopPropagation(),t=u.clientX,n=u.clientY,i=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",p,{capture:!0})},d=u=>{u.preventDefault(),u.stopPropagation(),!this.rafId&&(this.rafId=requestAnimationFrame(()=>{const g=u.clientX-t,f=u.clientY-n,x=a-l,m=o-c,b=Math.min(x,Math.max(this.options.minWidth||100,i+g)),v=Math.min(m,Math.max(this.options.minHeight||50,r+f));this.element.style.width=`${b}px`,this.element.style.height=`${v}px`,this.rafId=null}))},p=()=>{this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null),document.removeEventListener("mousemove",d,{capture:!0}),document.removeEventListener("mouseup",p,{capture:!0})};e.addEventListener("mousedown",h)}setContent(e){this.contentArea.innerHTML="",typeof e=="string"?this.contentArea.innerHTML=e:this.contentArea.appendChild(e)}close(){this._isDestroyed||(this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.element.remove(),this._isDestroyed=!0,this.options.onClose&&this.options.onClose())}destroy(){this.close()}}class Eg extends xi{container;activeDialogs=[];constructor(e,t){super(t),this.container=e}create(e){const t=new Sg({container:this.container,...e,onClose:()=>{this.activeDialogs=this.activeDialogs.filter(n=>n!==t),e.onClose&&e.onClose()}});return t.setTheme(ot.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 Yr="181",qs={ROTATE:0,DOLLY:1,PAN:2},Zs={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Cg=0,wu=1,Tg=2,Su=1,Eu=2,vi=3,kn=0,sn=1,yt=2,St=0,Ys=1,nc=2,Cu=3,Tu=4,ic=5,Cn=100,Ag=101,Pg=102,Rg=103,Lg=104,us=200,Ig=201,Dg=202,Ng=203,sc=204,rc=205,Za=206,Bg=207,Ya=208,kg=209,Ug=210,Og=211,zg=212,Fg=213,Hg=214,ac=0,oc=1,lc=2,$s=3,cc=4,hc=5,dc=6,uc=7,pc=0,Vg=1,Gg=2,Fi=0,Au=1,Pu=2,Ru=3,Lu=4,Iu=5,Du=6,Nu=7,Bu="attached",Wg="detached",ku=300,Ks=301,Js=302,$a=303,fc=304,Ka=306,Tn=1e3,Un=1001,Ja=1002,Xt=1003,Uu=1004,$r=1005,Pt=1006,Qa=1007,ai=1008,$n=1009,Ou=1010,zu=1011,Kr=1012,mc=1013,ps=1014,hn=1015,dn=1016,gc=1017,xc=1018,fs=1020,Fu=35902,Hu=35899,Vu=1021,Gu=1022,vn=1023,Jr=1026,ms=1027,eo=1028,vc=1029,bc=1030,yc=1031,_c=1033,to=33776,no=33777,io=33778,so=33779,Mc=35840,wc=35841,Sc=35842,Ec=35843,Cc=36196,Tc=37492,Ac=37496,Pc=37808,Rc=37809,Lc=37810,Ic=37811,Dc=37812,Nc=37813,Bc=37814,kc=37815,Uc=37816,Oc=37817,zc=37818,Fc=37819,Hc=37820,Vc=37821,Gc=36492,Wc=36494,Xc=36495,jc=36283,qc=36284,Zc=36285,Yc=36286,Qr=2300,ea=2301,$c=2302,Wu=2400,Xu=2401,ju=2402,Xg=2500,jg=0,qu=1,Kc=2,qg=3200,Zg=3201,ro=0,Yg=1,Hi="",Rt="srgb",en="srgb-linear",ao="linear",ct="srgb",Qs=7680,Zu=519,$g=512,Kg=513,Jg=514,Yu=515,Qg=516,ex=517,tx=518,nx=519,Jc=35044,$u="300 es",oi=2e3,oo=2001;function Ku(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}function ta(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function ix(){const s=ta("canvas");return s.style.display="block",s}const Ju={};function lo(...s){const e="THREE."+s.shift();console.log(e,...s)}function He(...s){const e="THREE."+s.shift();console.warn(e,...s)}function Qe(...s){const e="THREE."+s.shift();console.error(e,...s)}function na(...s){const e=s.join(" ");e in Ju||(Ju[e]=!0,He(...s))}function sx(s,e,t){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}class gs{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const i=n[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let r=0,a=i.length;r<a;r++)i[r].call(this,e);e.target=null}}}const rn=["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 Qu=1234567;const ia=Math.PI/180,er=180/Math.PI;function On(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(rn[s&255]+rn[s>>8&255]+rn[s>>16&255]+rn[s>>24&255]+"-"+rn[e&255]+rn[e>>8&255]+"-"+rn[e>>16&15|64]+rn[e>>24&255]+"-"+rn[t&63|128]+rn[t>>8&255]+"-"+rn[t>>16&255]+rn[t>>24&255]+rn[n&255]+rn[n>>8&255]+rn[n>>16&255]+rn[n>>24&255]).toLowerCase()}function qe(s,e,t){return Math.max(e,Math.min(t,s))}function Qc(s,e){return(s%e+e)%e}function rx(s,e,t,n,i){return n+(s-e)*(i-n)/(t-e)}function ax(s,e,t){return s!==e?(t-s)/(e-s):0}function sa(s,e,t){return(1-t)*s+t*e}function ox(s,e,t,n){return sa(s,e,1-Math.exp(-t*n))}function lx(s,e=1){return e-Math.abs(Qc(s,e*2)-e)}function cx(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function hx(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function dx(s,e){return s+Math.floor(Math.random()*(e-s+1))}function ux(s,e){return s+Math.random()*(e-s)}function px(s){return s*(.5-Math.random())}function fx(s){s!==void 0&&(Qu=s);let e=Qu+=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 mx(s){return s*ia}function gx(s){return s*er}function xx(s){return(s&s-1)===0&&s!==0}function vx(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function bx(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function yx(s,e,t,n,i){const r=Math.cos,a=Math.sin,o=r(t/2),l=a(t/2),c=r((e+n)/2),h=a((e+n)/2),d=r((e-n)/2),p=a((e-n)/2),u=r((n-e)/2),g=a((n-e)/2);switch(i){case"XYX":s.set(o*h,l*d,l*p,o*c);break;case"YZY":s.set(l*p,o*h,l*d,o*c);break;case"ZXZ":s.set(l*d,l*p,o*h,o*c);break;case"XZX":s.set(o*h,l*g,l*u,o*c);break;case"YXY":s.set(l*u,o*h,l*g,o*c);break;case"ZYZ":s.set(l*g,l*u,o*h,o*c);break;default:He("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Kn(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 ht(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 zt={DEG2RAD:ia,RAD2DEG:er,generateUUID:On,clamp:qe,euclideanModulo:Qc,mapLinear:rx,inverseLerp:ax,lerp:sa,damp:ox,pingpong:lx,smoothstep:cx,smootherstep:hx,randInt:dx,randFloat:ux,randFloatSpread:px,seededRandom:fx,degToRad:mx,radToDeg:gx,isPowerOfTwo:xx,ceilPowerOfTwo:vx,floorPowerOfTwo:bx,setQuaternionFromProperEuler:yx,normalize:ht,denormalize:Kn};class he{constructor(e=0,t=0){he.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[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=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(qe(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class zn{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,a,o){let l=n[i+0],c=n[i+1],h=n[i+2],d=n[i+3],p=r[a+0],u=r[a+1],g=r[a+2],f=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]=p,e[t+1]=u,e[t+2]=g,e[t+3]=f;return}if(d!==f||l!==p||c!==u||h!==g){let x=l*p+c*u+h*g+d*f;x<0&&(p=-p,u=-u,g=-g,f=-f,x=-x);let m=1-o;if(x<.9995){const b=Math.acos(x),v=Math.sin(b);m=Math.sin(m*b)/v,o=Math.sin(o*b)/v,l=l*m+p*o,c=c*m+u*o,h=h*m+g*o,d=d*m+f*o}else{l=l*m+p*o,c=c*m+u*o,h=h*m+g*o,d=d*m+f*o;const b=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=b,c*=b,h*=b,d*=b}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,i,r,a){const o=n[i],l=n[i+1],c=n[i+2],h=n[i+3],d=r[a],p=r[a+1],u=r[a+2],g=r[a+3];return e[t]=o*g+h*d+l*u-c*p,e[t+1]=l*g+h*p+c*d-o*u,e[t+2]=c*g+h*u+o*p-l*d,e[t+3]=h*g-o*d-l*p-c*u,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(i/2),d=o(r/2),p=l(n/2),u=l(i/2),g=l(r/2);switch(a){case"XYZ":this._x=p*h*d+c*u*g,this._y=c*u*d-p*h*g,this._z=c*h*g+p*u*d,this._w=c*h*d-p*u*g;break;case"YXZ":this._x=p*h*d+c*u*g,this._y=c*u*d-p*h*g,this._z=c*h*g-p*u*d,this._w=c*h*d+p*u*g;break;case"ZXY":this._x=p*h*d-c*u*g,this._y=c*u*d+p*h*g,this._z=c*h*g+p*u*d,this._w=c*h*d-p*u*g;break;case"ZYX":this._x=p*h*d-c*u*g,this._y=c*u*d+p*h*g,this._z=c*h*g-p*u*d,this._w=c*h*d+p*u*g;break;case"YZX":this._x=p*h*d+c*u*g,this._y=c*u*d+p*h*g,this._z=c*h*g-p*u*d,this._w=c*h*d-p*u*g;break;case"XZY":this._x=p*h*d-c*u*g,this._y=c*u*d-p*h*g,this._z=c*h*g+p*u*d,this._w=c*h*d+p*u*g;break;default:He("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],d=t[10],p=n+o+d;if(p>0){const u=.5/Math.sqrt(p+1);this._w=.25/u,this._x=(h-l)*u,this._y=(r-c)*u,this._z=(a-i)*u}else if(n>o&&n>d){const u=2*Math.sqrt(1+n-o-d);this._w=(h-l)/u,this._x=.25*u,this._y=(i+a)/u,this._z=(r+c)/u}else if(o>d){const u=2*Math.sqrt(1+o-n-d);this._w=(r-c)/u,this._x=(i+a)/u,this._y=.25*u,this._z=(l+h)/u}else{const u=2*Math.sqrt(1+d-n-o);this._w=(a-i)/u,this._x=(r+c)/u,this._y=(l+h)/u,this._z=.25*u}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(qe(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+a*o+i*c-r*l,this._y=i*h+a*l+r*o-n*c,this._z=r*h+a*c+n*l-i*o,this._w=a*h-n*o-i*l-r*c,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let n=e._x,i=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,i=-i,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+n*t,this._y=this._y*l+i*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+i*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*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,n=0){P.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(ep.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ep.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*i-o*n),h=2*(o*t-r*i),d=2*(r*n-a*t);return this.x=t+l*c+a*d-o*h,this.y=n+l*h+o*c-r*d,this.z=i+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,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,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=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this.z=qe(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this.z=qe(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=i*l-r*o,this.y=r*a-n*l,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return eh.copy(this).projectOnVector(e),this.sub(eh)}reflect(e){return this.sub(eh.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(qe(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const eh=new P,ep=new zn;class $e{constructor(e,t,n,i,r,a,o,l,c){$e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,a,o,l,c)}set(e,t,n,i,r,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=i,h[2]=o,h[3]=t,h[4]=r,h[5]=l,h[6]=n,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,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],d=n[7],p=n[2],u=n[5],g=n[8],f=i[0],x=i[3],m=i[6],b=i[1],v=i[4],y=i[7],_=i[2],M=i[5],T=i[8];return r[0]=a*f+o*b+l*_,r[3]=a*x+o*v+l*M,r[6]=a*m+o*y+l*T,r[1]=c*f+h*b+d*_,r[4]=c*x+h*v+d*M,r[7]=c*m+h*y+d*T,r[2]=p*f+u*b+g*_,r[5]=p*x+u*v+g*M,r[8]=p*m+u*y+g*T,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=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-n*r*h+n*o*l+i*r*c-i*a*l}invert(){const e=this.elements,t=e[0],n=e[1],i=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,p=o*l-h*r,u=c*r-a*l,g=t*d+n*p+i*u;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const f=1/g;return e[0]=d*f,e[1]=(i*c-h*n)*f,e[2]=(o*n-i*a)*f,e[3]=p*f,e[4]=(h*t-i*l)*f,e[5]=(i*r-o*t)*f,e[6]=u*f,e[7]=(n*l-c*t)*f,e[8]=(a*t-n*r)*f,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-i*c,i*l,-i*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(th.makeScale(e,t)),this}rotate(e){return this.premultiply(th.makeRotation(-e)),this}translate(e,t){return this.premultiply(th.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const th=new $e,tp=new $e().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),np=new $e().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function _x(){const s={enabled:!0,workingColorSpace:en,spaces:{},convert:function(i,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===ct&&(i.r=bi(i.r),i.g=bi(i.g),i.b=bi(i.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[r].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ct&&(i.r=tr(i.r),i.g=tr(i.g),i.b=tr(i.b))),i},workingToColorSpace:function(i,r){return this.convert(i,this.workingColorSpace,r)},colorSpaceToWorking:function(i,r){return this.convert(i,r,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Hi?ao:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,r=this.workingColorSpace){return i.fromArray(this.spaces[r].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,r,a){return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,r){return na("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(i,r)},toWorkingColorSpace:function(i,r){return na("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(i,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[en]:{primaries:e,whitePoint:n,transfer:ao,toXYZ:tp,fromXYZ:np,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Rt},outputColorSpaceConfig:{drawingBufferColorSpace:Rt}},[Rt]:{primaries:e,whitePoint:n,transfer:ct,toXYZ:tp,fromXYZ:np,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Rt}}}),s}const it=_x();function bi(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function tr(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let nr;class Mx{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{nr===void 0&&(nr=ta("canvas")),nr.width=e.width,nr.height=e.height;const i=nr.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=nr}return n.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=ta("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let a=0;a<r.length;a++)r[a]=bi(r[a]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(bi(t[n]/255)*255):t[n]=bi(t[n]);return{data:t,width:e.width,height:e.height}}else return He("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let wx=0;class nh{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:wx++}),this.uuid=On(),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 n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?r.push(ih(i[a].image)):r.push(ih(i[a]))}else r=ih(i);n.url=r}return t||(e.images[this.uuid]=n),n}}function ih(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?Mx.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(He("Texture: Unable to serialize Texture."),{})}let Sx=0;const sh=new P;class Ft extends gs{constructor(e=Ft.DEFAULT_IMAGE,t=Ft.DEFAULT_MAPPING,n=Un,i=Un,r=Pt,a=ai,o=vn,l=$n,c=Ft.DEFAULT_ANISOTROPY,h=Hi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Sx++}),this.uuid=On(),this.name="",this.source=new nh(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new he(0,0),this.repeat=new he(1,1),this.center=new he(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new $e,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(sh).x}get height(){return this.source.getSize(sh).y}get depth(){return this.source.getSize(sh).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){He(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){He(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ku)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Tn:e.x=e.x-Math.floor(e.x);break;case Un:e.x=e.x<0?0:1;break;case Ja: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 Tn:e.y=e.y-Math.floor(e.y);break;case Un:e.y=e.y<0?0:1;break;case Ja: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++}}Ft.DEFAULT_IMAGE=null,Ft.DEFAULT_MAPPING=ku,Ft.DEFAULT_ANISOTROPY=1;class tt{constructor(e=0,t=0,n=0,i=1){tt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+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,n,i,r;const l=e.elements,c=l[0],h=l[4],d=l[8],p=l[1],u=l[5],g=l[9],f=l[2],x=l[6],m=l[10];if(Math.abs(h-p)<.01&&Math.abs(d-f)<.01&&Math.abs(g-x)<.01){if(Math.abs(h+p)<.1&&Math.abs(d+f)<.1&&Math.abs(g+x)<.1&&Math.abs(c+u+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const v=(c+1)/2,y=(u+1)/2,_=(m+1)/2,M=(h+p)/4,T=(d+f)/4,R=(g+x)/4;return v>y&&v>_?v<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(v),i=M/n,r=T/n):y>_?y<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(y),n=M/i,r=R/i):_<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(_),n=T/r,i=R/r),this.set(n,i,r,t),this}let b=Math.sqrt((x-g)*(x-g)+(d-f)*(d-f)+(p-h)*(p-h));return Math.abs(b)<.001&&(b=1),this.x=(x-g)/b,this.y=(d-f)/b,this.z=(p-h)/b,this.w=Math.acos((c+u+m-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this.z=qe(this.z,e.z,t.z),this.w=qe(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this.z=qe(this.z,e,t),this.w=qe(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Ex extends gs{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Pt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new tt(0,0,e,t),this.scissorTest=!1,this.viewport=new tt(0,0,e,t);const i={width:e,height:t,depth:n.depth},r=new Ft(i);this.textures=[];const a=n.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(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){const t={minFilter:Pt,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const i=Object.assign({},e.textures[t].image);this.textures[t].source=new nh(i)}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 An extends Ex{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class ip extends Ft{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Xt,this.minFilter=Xt,this.wrapR=Un,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Cx extends Ft{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Xt,this.minFilter=Xt,this.wrapR=Un,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ut{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,n=e.length;t<n;t+=3)this.expandByPoint(Jn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Jn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Jn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const r=n.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,Jn):Jn.fromBufferAttribute(r,a),Jn.applyMatrix4(e.matrixWorld),this.expandByPoint(Jn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),co.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),co.copy(n.boundingBox)),co.applyMatrix4(e.matrixWorld),this.union(co)}const i=e.children;for(let r=0,a=i.length;r<a;r++)this.expandByObject(i[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,Jn),Jn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ra),ho.subVectors(this.max,ra),ir.subVectors(e.a,ra),sr.subVectors(e.b,ra),rr.subVectors(e.c,ra),Vi.subVectors(sr,ir),Gi.subVectors(rr,sr),xs.subVectors(ir,rr);let t=[0,-Vi.z,Vi.y,0,-Gi.z,Gi.y,0,-xs.z,xs.y,Vi.z,0,-Vi.x,Gi.z,0,-Gi.x,xs.z,0,-xs.x,-Vi.y,Vi.x,0,-Gi.y,Gi.x,0,-xs.y,xs.x,0];return!rh(t,ir,sr,rr,ho)||(t=[1,0,0,0,1,0,0,0,1],!rh(t,ir,sr,rr,ho))?!1:(uo.crossVectors(Vi,Gi),t=[uo.x,uo.y,uo.z],rh(t,ir,sr,rr,ho))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Jn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Jn).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:(yi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),yi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),yi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),yi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),yi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),yi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),yi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),yi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(yi),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 yi=[new P,new P,new P,new P,new P,new P,new P,new P],Jn=new P,co=new ut,ir=new P,sr=new P,rr=new P,Vi=new P,Gi=new P,xs=new P,ra=new P,ho=new P,uo=new P,vs=new P;function rh(s,e,t,n,i){for(let r=0,a=s.length-3;r<=a;r+=3){vs.fromArray(s,r);const o=i.x*Math.abs(vs.x)+i.y*Math.abs(vs.y)+i.z*Math.abs(vs.z),l=e.dot(vs),c=t.dot(vs),h=n.dot(vs);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const Tx=new ut,aa=new P,ah=new P;class li{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 n=this.center;t!==void 0?n.copy(t):Tx.setFromPoints(e).getCenter(n);let i=0;for(let r=0,a=e.length;r<a;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;aa.subVectors(e,this.center);const t=aa.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(aa,i/n),this.radius+=i}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):(ah.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(aa.copy(e.center).add(ah)),this.expandByPoint(aa.copy(e.center).sub(ah))),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 _i=new P,oh=new P,po=new P,Wi=new P,lh=new P,fo=new P,ch=new P;class Xi{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,_i)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=_i.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(_i.copy(this.origin).addScaledVector(this.direction,t),_i.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){oh.copy(e).add(t).multiplyScalar(.5),po.copy(t).sub(e).normalize(),Wi.copy(this.origin).sub(oh);const r=e.distanceTo(t)*.5,a=-this.direction.dot(po),o=Wi.dot(this.direction),l=-Wi.dot(po),c=Wi.lengthSq(),h=Math.abs(1-a*a);let d,p,u,g;if(h>0)if(d=a*l-o,p=a*o-l,g=r*h,d>=0)if(p>=-g)if(p<=g){const f=1/h;d*=f,p*=f,u=d*(d+a*p+2*o)+p*(a*d+p+2*l)+c}else p=r,d=Math.max(0,-(a*p+o)),u=-d*d+p*(p+2*l)+c;else p=-r,d=Math.max(0,-(a*p+o)),u=-d*d+p*(p+2*l)+c;else p<=-g?(d=Math.max(0,-(-a*r+o)),p=d>0?-r:Math.min(Math.max(-r,-l),r),u=-d*d+p*(p+2*l)+c):p<=g?(d=0,p=Math.min(Math.max(-r,-l),r),u=p*(p+2*l)+c):(d=Math.max(0,-(a*r+o)),p=d>0?r:Math.min(Math.max(-r,-l),r),u=-d*d+p*(p+2*l)+c);else p=a>0?-r:r,d=Math.max(0,-(a*p+o)),u=-d*d+p*(p+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),i&&i.copy(oh).addScaledVector(po,p),u}intersectSphere(e,t){_i.subVectors(e.center,this.origin);const n=_i.dot(this.direction),i=_i.dot(_i)-n*n,r=e.radius*e.radius;if(i>r)return null;const a=Math.sqrt(r-i),o=n-a,l=n+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 n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,p=this.origin;return c>=0?(n=(e.min.x-p.x)*c,i=(e.max.x-p.x)*c):(n=(e.max.x-p.x)*c,i=(e.min.x-p.x)*c),h>=0?(r=(e.min.y-p.y)*h,a=(e.max.y-p.y)*h):(r=(e.max.y-p.y)*h,a=(e.min.y-p.y)*h),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a<i||isNaN(i))&&(i=a),d>=0?(o=(e.min.z-p.z)*d,l=(e.max.z-p.z)*d):(o=(e.max.z-p.z)*d,l=(e.min.z-p.z)*d),n>l||o>i)||((o>n||n!==n)&&(n=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,_i)!==null}intersectTriangle(e,t,n,i,r){lh.subVectors(t,e),fo.subVectors(n,e),ch.crossVectors(lh,fo);let a=this.direction.dot(ch),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Wi.subVectors(this.origin,e);const l=o*this.direction.dot(fo.crossVectors(Wi,fo));if(l<0)return null;const c=o*this.direction.dot(lh.cross(Wi));if(c<0||l+c>a)return null;const h=-o*Wi.dot(ch);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 Ie{constructor(e,t,n,i,r,a,o,l,c,h,d,p,u,g,f,x){Ie.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,a,o,l,c,h,d,p,u,g,f,x)}set(e,t,n,i,r,a,o,l,c,h,d,p,u,g,f,x){const m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=i,m[1]=r,m[5]=a,m[9]=o,m[13]=l,m[2]=c,m[6]=h,m[10]=d,m[14]=p,m[3]=u,m[7]=g,m[11]=f,m[15]=x,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 Ie().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/ar.setFromMatrixColumn(e,0).length(),r=1/ar.setFromMatrixColumn(e,1).length(),a=1/ar.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(i),c=Math.sin(i),h=Math.cos(r),d=Math.sin(r);if(e.order==="XYZ"){const p=a*h,u=a*d,g=o*h,f=o*d;t[0]=l*h,t[4]=-l*d,t[8]=c,t[1]=u+g*c,t[5]=p-f*c,t[9]=-o*l,t[2]=f-p*c,t[6]=g+u*c,t[10]=a*l}else if(e.order==="YXZ"){const p=l*h,u=l*d,g=c*h,f=c*d;t[0]=p+f*o,t[4]=g*o-u,t[8]=a*c,t[1]=a*d,t[5]=a*h,t[9]=-o,t[2]=u*o-g,t[6]=f+p*o,t[10]=a*l}else if(e.order==="ZXY"){const p=l*h,u=l*d,g=c*h,f=c*d;t[0]=p-f*o,t[4]=-a*d,t[8]=g+u*o,t[1]=u+g*o,t[5]=a*h,t[9]=f-p*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const p=a*h,u=a*d,g=o*h,f=o*d;t[0]=l*h,t[4]=g*c-u,t[8]=p*c+f,t[1]=l*d,t[5]=f*c+p,t[9]=u*c-g,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const p=a*l,u=a*c,g=o*l,f=o*c;t[0]=l*h,t[4]=f-p*d,t[8]=g*d+u,t[1]=d,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=u*d+g,t[10]=p-f*d}else if(e.order==="XZY"){const p=a*l,u=a*c,g=o*l,f=o*c;t[0]=l*h,t[4]=-d,t[8]=c*h,t[1]=p*d+f,t[5]=a*h,t[9]=u*d-g,t[2]=g*d-u,t[6]=o*h,t[10]=f*d+p}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Ax,e,Px)}lookAt(e,t,n){const i=this.elements;return Pn.subVectors(e,t),Pn.lengthSq()===0&&(Pn.z=1),Pn.normalize(),ji.crossVectors(n,Pn),ji.lengthSq()===0&&(Math.abs(n.z)===1?Pn.x+=1e-4:Pn.z+=1e-4,Pn.normalize(),ji.crossVectors(n,Pn)),ji.normalize(),mo.crossVectors(Pn,ji),i[0]=ji.x,i[4]=mo.x,i[8]=Pn.x,i[1]=ji.y,i[5]=mo.y,i[9]=Pn.y,i[2]=ji.z,i[6]=mo.z,i[10]=Pn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],d=n[5],p=n[9],u=n[13],g=n[2],f=n[6],x=n[10],m=n[14],b=n[3],v=n[7],y=n[11],_=n[15],M=i[0],T=i[4],R=i[8],w=i[12],E=i[1],I=i[5],A=i[9],B=i[13],S=i[2],U=i[6],H=i[10],G=i[14],Z=i[3],j=i[7],ie=i[11],X=i[15];return r[0]=a*M+o*E+l*S+c*Z,r[4]=a*T+o*I+l*U+c*j,r[8]=a*R+o*A+l*H+c*ie,r[12]=a*w+o*B+l*G+c*X,r[1]=h*M+d*E+p*S+u*Z,r[5]=h*T+d*I+p*U+u*j,r[9]=h*R+d*A+p*H+u*ie,r[13]=h*w+d*B+p*G+u*X,r[2]=g*M+f*E+x*S+m*Z,r[6]=g*T+f*I+x*U+m*j,r[10]=g*R+f*A+x*H+m*ie,r[14]=g*w+f*B+x*G+m*X,r[3]=b*M+v*E+y*S+_*Z,r[7]=b*T+v*I+y*U+_*j,r[11]=b*R+v*A+y*H+_*ie,r[15]=b*w+v*B+y*G+_*X,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],d=e[6],p=e[10],u=e[14],g=e[3],f=e[7],x=e[11],m=e[15];return g*(+r*l*d-i*c*d-r*o*p+n*c*p+i*o*u-n*l*u)+f*(+t*l*u-t*c*p+r*a*p-i*a*u+i*c*h-r*l*h)+x*(+t*c*d-t*o*u-r*a*d+n*a*u+r*o*h-n*c*h)+m*(-i*o*h-t*l*d+t*o*p+i*a*d-n*a*p+n*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,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=e[9],p=e[10],u=e[11],g=e[12],f=e[13],x=e[14],m=e[15],b=d*x*c-f*p*c+f*l*u-o*x*u-d*l*m+o*p*m,v=g*p*c-h*x*c-g*l*u+a*x*u+h*l*m-a*p*m,y=h*f*c-g*d*c+g*o*u-a*f*u-h*o*m+a*d*m,_=g*d*l-h*f*l-g*o*p+a*f*p+h*o*x-a*d*x,M=t*b+n*v+i*y+r*_;if(M===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/M;return e[0]=b*T,e[1]=(f*p*r-d*x*r-f*i*u+n*x*u+d*i*m-n*p*m)*T,e[2]=(o*x*r-f*l*r+f*i*c-n*x*c-o*i*m+n*l*m)*T,e[3]=(d*l*r-o*p*r-d*i*c+n*p*c+o*i*u-n*l*u)*T,e[4]=v*T,e[5]=(h*x*r-g*p*r+g*i*u-t*x*u-h*i*m+t*p*m)*T,e[6]=(g*l*r-a*x*r-g*i*c+t*x*c+a*i*m-t*l*m)*T,e[7]=(a*p*r-h*l*r+h*i*c-t*p*c-a*i*u+t*l*u)*T,e[8]=y*T,e[9]=(g*d*r-h*f*r-g*n*u+t*f*u+h*n*m-t*d*m)*T,e[10]=(a*f*r-g*o*r+g*n*c-t*f*c-a*n*m+t*o*m)*T,e[11]=(h*o*r-a*d*r-h*n*c+t*d*c+a*n*u-t*o*u)*T,e[12]=_*T,e[13]=(h*f*i-g*d*i+g*n*p-t*f*p-h*n*x+t*d*x)*T,e[14]=(g*o*i-a*f*i-g*n*l+t*f*l+a*n*x-t*o*x)*T,e[15]=(a*d*i-h*o*i+h*n*l-t*d*l-a*n*p+t*o*p)*T,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,a=e.x,o=e.y,l=e.z,c=r*a,h=r*o;return this.set(c*a+n,c*o-i*l,c*l+i*o,0,c*o+i*l,h*o+n,h*l-i*a,0,c*l-i*o,h*l+i*a,r*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,a=t._y,o=t._z,l=t._w,c=r+r,h=a+a,d=o+o,p=r*c,u=r*h,g=r*d,f=a*h,x=a*d,m=o*d,b=l*c,v=l*h,y=l*d,_=n.x,M=n.y,T=n.z;return i[0]=(1-(f+m))*_,i[1]=(u+y)*_,i[2]=(g-v)*_,i[3]=0,i[4]=(u-y)*M,i[5]=(1-(p+m))*M,i[6]=(x+b)*M,i[7]=0,i[8]=(g+v)*T,i[9]=(x-b)*T,i[10]=(1-(p+f))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=ar.set(i[0],i[1],i[2]).length();const a=ar.set(i[4],i[5],i[6]).length(),o=ar.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],Qn.copy(this);const c=1/r,h=1/a,d=1/o;return Qn.elements[0]*=c,Qn.elements[1]*=c,Qn.elements[2]*=c,Qn.elements[4]*=h,Qn.elements[5]*=h,Qn.elements[6]*=h,Qn.elements[8]*=d,Qn.elements[9]*=d,Qn.elements[10]*=d,t.setFromRotationMatrix(Qn),n.x=r,n.y=a,n.z=o,this}makePerspective(e,t,n,i,r,a,o=oi,l=!1){const c=this.elements,h=2*r/(t-e),d=2*r/(n-i),p=(t+e)/(t-e),u=(n+i)/(n-i);let g,f;if(l)g=r/(a-r),f=a*r/(a-r);else if(o===oi)g=-(a+r)/(a-r),f=-2*a*r/(a-r);else if(o===oo)g=-a/(a-r),f=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=p,c[12]=0,c[1]=0,c[5]=d,c[9]=u,c[13]=0,c[2]=0,c[6]=0,c[10]=g,c[14]=f,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,a,o=oi,l=!1){const c=this.elements,h=2/(t-e),d=2/(n-i),p=-(t+e)/(t-e),u=-(n+i)/(n-i);let g,f;if(l)g=1/(a-r),f=a/(a-r);else if(o===oi)g=-2/(a-r),f=-(a+r)/(a-r);else if(o===oo)g=-1/(a-r),f=-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]=p,c[1]=0,c[5]=d,c[9]=0,c[13]=u,c[2]=0,c[6]=0,c[10]=g,c[14]=f,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const ar=new P,Qn=new Ie,Ax=new P(0,0,0),Px=new P(1,1,1),ji=new P,mo=new P,Pn=new P,sp=new Ie,rp=new zn;class Rn{constructor(e=0,t=0,n=0,i=Rn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],a=i[4],o=i[8],l=i[1],c=i[5],h=i[9],d=i[2],p=i[6],u=i[10];switch(t){case"XYZ":this._y=Math.asin(qe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,u),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(p,c),this._z=0);break;case"YXZ":this._x=Math.asin(-qe(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,u),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(qe(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-d,u),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-qe(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(p,u),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(qe(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,u));break;case"XZY":this._z=Math.asin(-qe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(p,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,u),this._y=0);break;default:He("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return sp.makeRotationFromQuaternion(e),this.setFromRotationMatrix(sp,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return rp.setFromEuler(this),this.setFromQuaternion(rp,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}}Rn.DEFAULT_ORDER="XYZ";class hh{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 Rx=0;const ap=new P,or=new zn,Mi=new Ie,go=new P,oa=new P,Lx=new P,Ix=new zn,op=new P(1,0,0),lp=new P(0,1,0),cp=new P(0,0,1),hp={type:"added"},Dx={type:"removed"},lr={type:"childadded",child:null},dh={type:"childremoved",child:null};class Et extends gs{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Rx++}),this.uuid=On(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Et.DEFAULT_UP.clone();const e=new P,t=new Rn,n=new zn,i=new P(1,1,1);function r(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ie},normalMatrix:{value:new $e}}),this.matrix=new Ie,this.matrixWorld=new Ie,this.matrixAutoUpdate=Et.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Et.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new hh,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 or.setFromAxisAngle(e,t),this.quaternion.multiply(or),this}rotateOnWorldAxis(e,t){return or.setFromAxisAngle(e,t),this.quaternion.premultiply(or),this}rotateX(e){return this.rotateOnAxis(op,e)}rotateY(e){return this.rotateOnAxis(lp,e)}rotateZ(e){return this.rotateOnAxis(cp,e)}translateOnAxis(e,t){return ap.copy(e).applyQuaternion(this.quaternion),this.position.add(ap.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(op,e)}translateY(e){return this.translateOnAxis(lp,e)}translateZ(e){return this.translateOnAxis(cp,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Mi.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?go.copy(e):go.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),oa.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Mi.lookAt(oa,go,this.up):Mi.lookAt(go,oa,this.up),this.quaternion.setFromRotationMatrix(Mi),i&&(Mi.extractRotation(i.matrixWorld),or.setFromRotationMatrix(Mi),this.quaternion.premultiply(or.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Qe("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(hp),lr.child=e,this.dispatchEvent(lr),lr.child=null):Qe("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Dx),dh.child=e,this.dispatchEvent(dh),dh.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),Mi.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Mi.multiply(e.parent.matrixWorld)),e.applyMatrix4(Mi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(hp),lr.child=e,this.dispatchEvent(lr),lr.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(oa,e,Lx),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(oa,Ix,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.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?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.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&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),i.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]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.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),p=a(e.skeletons),u=a(e.animations),g=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),p.length>0&&(n.skeletons=p),u.length>0&&(n.animations=u),g.length>0&&(n.nodes=g)}return n.object=i,n;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 n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}Et.DEFAULT_UP=new P(0,1,0),Et.DEFAULT_MATRIX_AUTO_UPDATE=!0,Et.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const ei=new P,wi=new P,uh=new P,Si=new P,cr=new P,hr=new P,dp=new P,ph=new P,fh=new P,mh=new P,gh=new tt,xh=new tt,vh=new tt;class vt{constructor(e=new P,t=new P,n=new P){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),ei.subVectors(e,t),i.cross(ei);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){ei.subVectors(i,t),wi.subVectors(n,t),uh.subVectors(e,t);const a=ei.dot(ei),o=ei.dot(wi),l=ei.dot(uh),c=wi.dot(wi),h=wi.dot(uh),d=a*c-o*o;if(d===0)return r.set(0,0,0),null;const p=1/d,u=(c*l-o*h)*p,g=(a*h-o*l)*p;return r.set(1-u-g,g,u)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Si)===null?!1:Si.x>=0&&Si.y>=0&&Si.x+Si.y<=1}static getInterpolation(e,t,n,i,r,a,o,l){return this.getBarycoord(e,t,n,i,Si)===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,Si.x),l.addScaledVector(a,Si.y),l.addScaledVector(o,Si.z),l)}static getInterpolatedAttribute(e,t,n,i,r,a){return gh.setScalar(0),xh.setScalar(0),vh.setScalar(0),gh.fromBufferAttribute(e,t),xh.fromBufferAttribute(e,n),vh.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(gh,r.x),a.addScaledVector(xh,r.y),a.addScaledVector(vh,r.z),a}static isFrontFacing(e,t,n,i){return ei.subVectors(n,t),wi.subVectors(e,t),ei.cross(wi).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),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 ei.subVectors(this.c,this.b),wi.subVectors(this.a,this.b),ei.cross(wi).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return vt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return vt.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return vt.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return vt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return vt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let a,o;cr.subVectors(i,n),hr.subVectors(r,n),ph.subVectors(e,n);const l=cr.dot(ph),c=hr.dot(ph);if(l<=0&&c<=0)return t.copy(n);fh.subVectors(e,i);const h=cr.dot(fh),d=hr.dot(fh);if(h>=0&&d<=h)return t.copy(i);const p=l*d-h*c;if(p<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(n).addScaledVector(cr,a);mh.subVectors(e,r);const u=cr.dot(mh),g=hr.dot(mh);if(g>=0&&u<=g)return t.copy(r);const f=u*c-l*g;if(f<=0&&c>=0&&g<=0)return o=c/(c-g),t.copy(n).addScaledVector(hr,o);const x=h*g-u*d;if(x<=0&&d-h>=0&&u-g>=0)return dp.subVectors(r,i),o=(d-h)/(d-h+(u-g)),t.copy(i).addScaledVector(dp,o);const m=1/(x+f+p);return a=f*m,o=p*m,t.copy(n).addScaledVector(cr,a).addScaledVector(hr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const up={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},qi={h:0,s:0,l:0},xo={h:0,s:0,l:0};function bh(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 Fe{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Rt){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,n,i=it.workingColorSpace){return this.r=e,this.g=t,this.b=n,it.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=it.workingColorSpace){if(e=Qc(e,1),t=qe(t,0,1),n=qe(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=bh(a,r,e+1/3),this.g=bh(a,r,e),this.b=bh(a,r,e-1/3)}return it.colorSpaceToWorking(this,i),this}setStyle(e,t=Rt){function n(r){r!==void 0&&parseFloat(r)<1&&He("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=i[1],o=i[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 n(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 n(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 n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:He("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=i[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);He("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Rt){const n=up[e.toLowerCase()];return n!==void 0?this.setHex(n,t):He("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=bi(e.r),this.g=bi(e.g),this.b=bi(e.b),this}copyLinearToSRGB(e){return this.r=tr(e.r),this.g=tr(e.g),this.b=tr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Rt){return it.workingToColorSpace(an.copy(this),e),Math.round(qe(an.r*255,0,255))*65536+Math.round(qe(an.g*255,0,255))*256+Math.round(qe(an.b*255,0,255))}getHexString(e=Rt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=it.workingColorSpace){it.workingToColorSpace(an.copy(this),t);const n=an.r,i=an.g,r=an.b,a=Math.max(n,i,r),o=Math.min(n,i,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 n:l=(i-r)/d+(i<r?6:0);break;case i:l=(r-n)/d+2;break;case r:l=(n-i)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=it.workingColorSpace){return it.workingToColorSpace(an.copy(this),t),e.r=an.r,e.g=an.g,e.b=an.b,e}getStyle(e=Rt){it.workingToColorSpace(an.copy(this),e);const t=an.r,n=an.g,i=an.b;return e!==Rt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(qi),this.setHSL(qi.h+e,qi.s+t,qi.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(qi),e.getHSL(xo);const n=sa(qi.h,xo.h,t),i=sa(qi.s,xo.s,t),r=sa(qi.l,xo.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,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 an=new Fe;Fe.NAMES=up;let Nx=0;class Ln extends gs{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Nx++}),this.uuid=On(),this.name="",this.type="Material",this.blending=Ys,this.side=kn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=sc,this.blendDst=rc,this.blendEquation=Cn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Fe(0,0,0),this.blendAlpha=0,this.depthFunc=$s,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Zu,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Qs,this.stencilZFail=Qs,this.stencilZPass=Qs,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){He(`Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){He(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Ys&&(n.blending=this.blending),this.side!==kn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==sc&&(n.blendSrc=this.blendSrc),this.blendDst!==rc&&(n.blendDst=this.blendDst),this.blendEquation!==Cn&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==$s&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Zu&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Qs&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Qs&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Qs&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=i(e.textures),a=i(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Ht extends Ln{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Fe(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 Rn,this.combine=pc,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 Ei=Bx();function Bx(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[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:n,shiftTable:i,mantissaTable:r,exponentTable:a,offsetTable:o}}function kx(s){Math.abs(s)>65504&&He("DataUtils.toHalfFloat(): Value out of range."),s=qe(s,-65504,65504),Ei.floatView[0]=s;const e=Ei.uint32View[0],t=e>>23&511;return Ei.baseTable[t]+((e&8388607)>>Ei.shiftTable[t])}function Ux(s){const e=s>>10;return Ei.uint32View[0]=Ei.mantissaTable[Ei.offsetTable[e]+(s&1023)]+Ei.exponentTable[e],Ei.floatView[0]}class vo{static toHalfFloat(e){return kx(e)}static fromHalfFloat(e){return Ux(e)}}const Vt=new P,bo=new he;let Ox=0;class bt{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Ox++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Jc,this.updateRanges=[],this.gpuType=hn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)bo.fromBufferAttribute(this,t),bo.applyMatrix3(e),this.setXY(t,bo.x,bo.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Vt.fromBufferAttribute(this,t),Vt.applyMatrix3(e),this.setXYZ(t,Vt.x,Vt.y,Vt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Vt.fromBufferAttribute(this,t),Vt.applyMatrix4(e),this.setXYZ(t,Vt.x,Vt.y,Vt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Vt.fromBufferAttribute(this,t),Vt.applyNormalMatrix(e),this.setXYZ(t,Vt.x,Vt.y,Vt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Vt.fromBufferAttribute(this,t),Vt.transformDirection(e),this.setXYZ(t,Vt.x,Vt.y,Vt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Kn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ht(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Kn(t,this.array)),t}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Kn(t,this.array)),t}setY(e,t){return this.normalized&&(t=ht(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=Kn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ht(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=Kn(t,this.array)),t}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,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!==Jc&&(e.usage=this.usage),e}}class pp extends bt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class fp extends bt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class jt extends bt{constructor(e,t,n){super(new Float32Array(e),t,n)}}let zx=0;const Fn=new Ie,yh=new Et,dr=new P,In=new ut,la=new ut,$t=new P;class pt extends gs{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:zx++}),this.uuid=On(),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(Ku(e)?fp:pp)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new $e().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Fn.makeRotationFromQuaternion(e),this.applyMatrix4(Fn),this}rotateX(e){return Fn.makeRotationX(e),this.applyMatrix4(Fn),this}rotateY(e){return Fn.makeRotationY(e),this.applyMatrix4(Fn),this}rotateZ(e){return Fn.makeRotationZ(e),this.applyMatrix4(Fn),this}translate(e,t,n){return Fn.makeTranslation(e,t,n),this.applyMatrix4(Fn),this}scale(e,t,n){return Fn.makeScale(e,t,n),this.applyMatrix4(Fn),this}lookAt(e){return yh.lookAt(e),yh.updateMatrix(),this.applyMatrix4(yh.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(dr).negate(),this.translate(dr.x,dr.y,dr.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let i=0,r=e.length;i<r;i++){const a=e[i];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new jt(n,3))}else{const n=Math.min(e.length,t.count);for(let i=0;i<n;i++){const r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}e.length>t.count&&He("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 ut);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Qe("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 n=0,i=t.length;n<i;n++){const r=t[n];In.setFromBufferAttribute(r),this.morphTargetsRelative?($t.addVectors(this.boundingBox.min,In.min),this.boundingBox.expandByPoint($t),$t.addVectors(this.boundingBox.max,In.max),this.boundingBox.expandByPoint($t)):(this.boundingBox.expandByPoint(In.min),this.boundingBox.expandByPoint(In.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Qe('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 li);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Qe("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new P,1/0);return}if(e){const n=this.boundingSphere.center;if(In.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];la.setFromBufferAttribute(o),this.morphTargetsRelative?($t.addVectors(In.min,la.min),In.expandByPoint($t),$t.addVectors(In.max,la.max),In.expandByPoint($t)):(In.expandByPoint(la.min),In.expandByPoint(la.max))}In.getCenter(n);let i=0;for(let r=0,a=e.count;r<a;r++)$t.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared($t));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++)$t.fromBufferAttribute(o,c),l&&(dr.fromBufferAttribute(e,c),$t.add(dr)),i=Math.max(i,n.distanceToSquared($t))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Qe('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){Qe("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,i=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new bt(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let R=0;R<n.count;R++)o[R]=new P,l[R]=new P;const c=new P,h=new P,d=new P,p=new he,u=new he,g=new he,f=new P,x=new P;function m(R,w,E){c.fromBufferAttribute(n,R),h.fromBufferAttribute(n,w),d.fromBufferAttribute(n,E),p.fromBufferAttribute(r,R),u.fromBufferAttribute(r,w),g.fromBufferAttribute(r,E),h.sub(c),d.sub(c),u.sub(p),g.sub(p);const I=1/(u.x*g.y-g.x*u.y);isFinite(I)&&(f.copy(h).multiplyScalar(g.y).addScaledVector(d,-u.y).multiplyScalar(I),x.copy(d).multiplyScalar(u.x).addScaledVector(h,-g.x).multiplyScalar(I),o[R].add(f),o[w].add(f),o[E].add(f),l[R].add(x),l[w].add(x),l[E].add(x))}let b=this.groups;b.length===0&&(b=[{start:0,count:e.count}]);for(let R=0,w=b.length;R<w;++R){const E=b[R],I=E.start,A=E.count;for(let B=I,S=I+A;B<S;B+=3)m(e.getX(B+0),e.getX(B+1),e.getX(B+2))}const v=new P,y=new P,_=new P,M=new P;function T(R){_.fromBufferAttribute(i,R),M.copy(_);const w=o[R];v.copy(w),v.sub(_.multiplyScalar(_.dot(w))).normalize(),y.crossVectors(M,w);const I=y.dot(l[R])<0?-1:1;a.setXYZW(R,v.x,v.y,v.z,I)}for(let R=0,w=b.length;R<w;++R){const E=b[R],I=E.start,A=E.count;for(let B=I,S=I+A;B<S;B+=3)T(e.getX(B+0)),T(e.getX(B+1)),T(e.getX(B+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new bt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let p=0,u=n.count;p<u;p++)n.setXYZ(p,0,0,0);const i=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 p=0,u=e.count;p<u;p+=3){const g=e.getX(p+0),f=e.getX(p+1),x=e.getX(p+2);i.fromBufferAttribute(t,g),r.fromBufferAttribute(t,f),a.fromBufferAttribute(t,x),h.subVectors(a,r),d.subVectors(i,r),h.cross(d),o.fromBufferAttribute(n,g),l.fromBufferAttribute(n,f),c.fromBufferAttribute(n,x),o.add(h),l.add(h),c.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(f,l.x,l.y,l.z),n.setXYZ(x,c.x,c.y,c.z)}else for(let p=0,u=t.count;p<u;p+=3)i.fromBufferAttribute(t,p+0),r.fromBufferAttribute(t,p+1),a.fromBufferAttribute(t,p+2),h.subVectors(a,r),d.subVectors(i,r),h.cross(d),n.setXYZ(p+0,h.x,h.y,h.z),n.setXYZ(p+1,h.x,h.y,h.z),n.setXYZ(p+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)$t.fromBufferAttribute(e,t),$t.normalize(),e.setXYZ(t,$t.x,$t.y,$t.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,d=o.normalized,p=new c.constructor(l.length*h);let u=0,g=0;for(let f=0,x=l.length;f<x;f++){o.isInterleavedBufferAttribute?u=l[f]*o.data.stride+o.offset:u=l[f]*h;for(let m=0;m<h;m++)p[g++]=c[u++]}return new bt(p,h,d)}if(this.index===null)return He("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new pt,n=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,n);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 p=c[h],u=e(p,n);l.push(u)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let d=0,p=c.length;d<p;d++){const u=c[d];h.push(u.toJSON(e.data))}h.length>0&&(i[l]=h,r=!0)}r&&(e.data.morphAttributes=i,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 n=e.index;n!==null&&this.setIndex(n.clone());const i=e.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(t))}const r=e.morphAttributes;for(const c in r){const h=[],d=r[c];for(let p=0,u=d.length;p<u;p++)h.push(d[p].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,h=a.length;c<h;c++){const d=a[c];this.addGroup(d.start,d.count,d.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const mp=new Ie,bs=new Xi,yo=new li,gp=new P,_o=new P,Mo=new P,wo=new P,_h=new P,So=new P,xp=new P,Eo=new P;class at extends Et{constructor(e=new pt,t=new Ht){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(r&&o){So.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const h=o[l],d=r[l];h!==0&&(_h.fromBufferAttribute(d,e),a?So.addScaledVector(_h,h):So.addScaledVector(_h.sub(t),h))}t.add(So)}return t}raycast(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),yo.copy(n.boundingSphere),yo.applyMatrix4(r),bs.copy(e.ray).recast(e.near),!(yo.containsPoint(bs.origin)===!1&&(bs.intersectSphere(yo,gp)===null||bs.origin.distanceToSquared(gp)>(e.far-e.near)**2))&&(mp.copy(r).invert(),bs.copy(e.ray).applyMatrix4(mp),!(n.boundingBox!==null&&bs.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,bs)))}_computeIntersections(e,t,n){let i;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,p=r.groups,u=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,f=p.length;g<f;g++){const x=p[g],m=a[x.materialIndex],b=Math.max(x.start,u.start),v=Math.min(o.count,Math.min(x.start+x.count,u.start+u.count));for(let y=b,_=v;y<_;y+=3){const M=o.getX(y),T=o.getX(y+1),R=o.getX(y+2);i=Co(this,m,e,n,c,h,d,M,T,R),i&&(i.faceIndex=Math.floor(y/3),i.face.materialIndex=x.materialIndex,t.push(i))}}else{const g=Math.max(0,u.start),f=Math.min(o.count,u.start+u.count);for(let x=g,m=f;x<m;x+=3){const b=o.getX(x),v=o.getX(x+1),y=o.getX(x+2);i=Co(this,a,e,n,c,h,d,b,v,y),i&&(i.faceIndex=Math.floor(x/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let g=0,f=p.length;g<f;g++){const x=p[g],m=a[x.materialIndex],b=Math.max(x.start,u.start),v=Math.min(l.count,Math.min(x.start+x.count,u.start+u.count));for(let y=b,_=v;y<_;y+=3){const M=y,T=y+1,R=y+2;i=Co(this,m,e,n,c,h,d,M,T,R),i&&(i.faceIndex=Math.floor(y/3),i.face.materialIndex=x.materialIndex,t.push(i))}}else{const g=Math.max(0,u.start),f=Math.min(l.count,u.start+u.count);for(let x=g,m=f;x<m;x+=3){const b=x,v=x+1,y=x+2;i=Co(this,a,e,n,c,h,d,b,v,y),i&&(i.faceIndex=Math.floor(x/3),t.push(i))}}}}function Fx(s,e,t,n,i,r,a,o){let l;if(e.side===sn?l=n.intersectTriangle(a,r,i,!0,o):l=n.intersectTriangle(i,r,a,e.side===kn,o),l===null)return null;Eo.copy(o),Eo.applyMatrix4(s.matrixWorld);const c=t.ray.origin.distanceTo(Eo);return c<t.near||c>t.far?null:{distance:c,point:Eo.clone(),object:s}}function Co(s,e,t,n,i,r,a,o,l,c){s.getVertexPosition(o,_o),s.getVertexPosition(l,Mo),s.getVertexPosition(c,wo);const h=Fx(s,e,t,n,_o,Mo,wo,xp);if(h){const d=new P;vt.getBarycoord(xp,_o,Mo,wo,d),i&&(h.uv=vt.getInterpolatedAttribute(i,o,l,c,d,new he)),r&&(h.uv1=vt.getInterpolatedAttribute(r,o,l,c,d,new he)),a&&(h.normal=vt.getInterpolatedAttribute(a,o,l,c,d,new P),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const p={a:o,b:l,c,normal:new P,materialIndex:0};vt.getNormal(_o,Mo,wo,p.normal),h.face=p,h.barycoord=d}return h}class Zi extends pt{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const o=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],h=[],d=[];let p=0,u=0;g("z","y","x",-1,-1,n,t,e,a,r,0),g("z","y","x",1,-1,n,t,-e,a,r,1),g("x","z","y",1,1,e,n,t,i,a,2),g("x","z","y",1,-1,e,n,-t,i,a,3),g("x","y","z",1,-1,e,t,n,i,r,4),g("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(l),this.setAttribute("position",new jt(c,3)),this.setAttribute("normal",new jt(h,3)),this.setAttribute("uv",new jt(d,2));function g(f,x,m,b,v,y,_,M,T,R,w){const E=y/T,I=_/R,A=y/2,B=_/2,S=M/2,U=T+1,H=R+1;let G=0,Z=0;const j=new P;for(let ie=0;ie<H;ie++){const X=ie*I-B;for(let $=0;$<U;$++){const ue=$*E-A;j[f]=ue*b,j[x]=X*v,j[m]=S,c.push(j.x,j.y,j.z),j[f]=0,j[x]=0,j[m]=M>0?1:-1,h.push(j.x,j.y,j.z),d.push($/T),d.push(1-ie/R),G+=1}}for(let ie=0;ie<R;ie++)for(let X=0;X<T;X++){const $=p+X+U*ie,ue=p+X+U*(ie+1),pe=p+(X+1)+U*(ie+1),fe=p+(X+1)+U*ie;l.push($,ue,fe),l.push(ue,pe,fe),Z+=6}o.addGroup(u,Z,w),u+=Z,p+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Zi(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function ur(s){const e={};for(const t in s){e[t]={};for(const n in s[t]){const i=s[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(He("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function un(s){const e={};for(let t=0;t<s.length;t++){const n=ur(s[t]);for(const i in n)e[i]=n[i]}return e}function Hx(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function vp(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:it.workingColorSpace}const Hn={clone:ur,merge:un};var Vx=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,Gx=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;class Lt extends Ln{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Vx,this.fragmentShader=Gx,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=ur(e.uniforms),this.uniformsGroups=Hx(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 i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?t.uniforms[i]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[i]={type:"m4",value:a.toArray()}:t.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class bp extends Et{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ie,this.projectionMatrix=new Ie,this.projectionMatrixInverse=new Ie,this.coordinateSystem=oi,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 Yi=new P,yp=new he,_p=new he;class on extends bp{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,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=er*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(ia*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return er*2*Math.atan(Math.tan(ia*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Yi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Yi.x,Yi.y).multiplyScalar(-e/Yi.z),Yi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Yi.x,Yi.y).multiplyScalar(-e/Yi.z)}getViewSize(e,t){return this.getViewBounds(e,yp,_p),t.subVectors(_p,yp)}setViewOffset(e,t,n,i,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=n,this.view.offsetY=i,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(ia*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*i/l,t-=a.offsetY*n/c,i*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const pr=-90,fr=1;class Wx extends Et{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new on(pr,fr,e,t);i.layers=this.layers,this.add(i);const r=new on(pr,fr,e,t);r.layers=this.layers,this.add(r);const a=new on(pr,fr,e,t);a.layers=this.layers,this.add(a);const o=new on(pr,fr,e,t);o.layers=this.layers,this.add(o);const l=new on(pr,fr,e,t);l.layers=this.layers,this.add(l);const c=new on(pr,fr,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===oi)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.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===oo)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.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:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,h]=this.children,d=e.getRenderTarget(),p=e.getActiveCubeFace(),u=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,r),e.setRenderTarget(n,1,i),e.render(t,a),e.setRenderTarget(n,2,i),e.render(t,o),e.setRenderTarget(n,3,i),e.render(t,l),e.setRenderTarget(n,4,i),e.render(t,c),n.texture.generateMipmaps=f,e.setRenderTarget(n,5,i),e.render(t,h),e.setRenderTarget(d,p,u),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class Mp extends Ft{constructor(e=[],t=Ks,n,i,r,a,o,l,c,h){super(e,t,n,i,r,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Xx extends An{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new Mp(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
varying vec3 vWorldDirection;
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}
`,fragmentShader:`
uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
vec3 direction = normalize( vWorldDirection );
vec2 sampleUV = equirectUv( direction );
gl_FragColor = texture2D( tEquirect, sampleUV );
}
`},i=new Zi(5,5,5),r=new Lt({name:"CubemapFromEquirect",uniforms:ur(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:sn,blending:St});r.uniforms.tEquirect.value=t;const a=new at(i,r),o=t.minFilter;return t.minFilter===ai&&(t.minFilter=Pt),new Wx(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(r)}}class ln extends Et{constructor(){super(),this.isGroup=!0,this.type="Group"}}const jx={type:"move"};class Mh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ln,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 ln,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 ln,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 n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=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 f of e.hand.values()){const x=t.getJointPose(f,n),m=this._getHandJoint(c,f);x!==null&&(m.matrix.fromArray(x.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=x.radius),m.visible=x!==null}const h=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],p=h.position.distanceTo(d.position),u=.02,g=.005;c.inputState.pinching&&p>u+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&p<=u-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),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&&(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(jx)))}return o!==null&&(o.visible=i!==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 n=new ln;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class wp extends Et{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 Rn,this.environmentIntensity=1,this.environmentRotation=new Rn,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}}class wh{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Jc,this.updateRanges=[],this.version=0,this.uuid=On()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];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=On()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=On()),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 pn=new P;class mr{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)pn.fromBufferAttribute(this,t),pn.applyMatrix4(e),this.setXYZ(t,pn.x,pn.y,pn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)pn.fromBufferAttribute(this,t),pn.applyNormalMatrix(e),this.setXYZ(t,pn.x,pn.y,pn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)pn.fromBufferAttribute(this,t),pn.transformDirection(e),this.setXYZ(t,pn.x,pn.y,pn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Kn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ht(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=ht(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=Kn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Kn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Kn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Kn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){lo("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new bt(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 mr(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){lo("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+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}}}class Sp extends Ln{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Fe(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 gr;const ca=new P,xr=new P,vr=new P,br=new he,ha=new he,Ep=new Ie,To=new P,da=new P,Ao=new P,Cp=new he,Sh=new he,Tp=new he;class Eh extends Et{constructor(e=new Sp){if(super(),this.isSprite=!0,this.type="Sprite",gr===void 0){gr=new pt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new wh(t,5);gr.setIndex([0,1,2,0,2,3]),gr.setAttribute("position",new mr(n,3,0,!1)),gr.setAttribute("uv",new mr(n,2,3,!1))}this.geometry=gr,this.material=e,this.center=new he(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Qe('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),xr.setFromMatrixScale(this.matrixWorld),Ep.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),vr.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&xr.multiplyScalar(-vr.z);const n=this.material.rotation;let i,r;n!==0&&(r=Math.cos(n),i=Math.sin(n));const a=this.center;Po(To.set(-.5,-.5,0),vr,a,xr,i,r),Po(da.set(.5,-.5,0),vr,a,xr,i,r),Po(Ao.set(.5,.5,0),vr,a,xr,i,r),Cp.set(0,0),Sh.set(1,0),Tp.set(1,1);let o=e.ray.intersectTriangle(To,da,Ao,!1,ca);if(o===null&&(Po(da.set(-.5,.5,0),vr,a,xr,i,r),Sh.set(0,1),o=e.ray.intersectTriangle(To,Ao,da,!1,ca),o===null))return;const l=e.ray.origin.distanceTo(ca);l<e.near||l>e.far||t.push({distance:l,point:ca.clone(),uv:vt.getInterpolation(ca,To,da,Ao,Cp,Sh,Tp,new he),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 Po(s,e,t,n,i,r){br.subVectors(s,t).addScalar(.5).multiply(n),i!==void 0?(ha.x=r*br.x-i*br.y,ha.y=i*br.x+r*br.y):ha.copy(br),s.copy(e),s.x+=ha.x,s.y+=ha.y,s.applyMatrix4(Ep)}const Ap=new P,Pp=new tt,Rp=new tt,qx=new P,Lp=new Ie,Ro=new P,Ch=new li,Ip=new Ie,Th=new Xi;class Zx extends at{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Bu,this.bindMatrix=new Ie,this.bindMatrixInverse=new Ie,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new ut),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ro),this.boundingBox.expandByPoint(Ro)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new li),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ro),this.boundingSphere.expandByPoint(Ro)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ch.copy(this.boundingSphere),Ch.applyMatrix4(i),e.ray.intersectsSphere(Ch)!==!1&&(Ip.copy(i).invert(),Th.copy(e.ray).applyMatrix4(Ip),!(this.boundingBox!==null&&Th.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Th)))}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 tt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Bu?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Wg?this.bindMatrixInverse.copy(this.bindMatrix).invert():He("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;Pp.fromBufferAttribute(i.attributes.skinIndex,e),Rp.fromBufferAttribute(i.attributes.skinWeight,e),Ap.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){const a=Rp.getComponent(r);if(a!==0){const o=Pp.getComponent(r);Lp.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(qx.copy(Ap).applyMatrix4(Lp),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Dp extends Et{constructor(){super(),this.isBone=!0,this.type="Bone"}}class ys extends Ft{constructor(e=null,t=1,n=1,i,r,a,o,l,c=Xt,h=Xt,d,p){super(null,a,o,l,c,h,i,r,d,p),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Np=new Ie,Yx=new Ie;class Ah{constructor(e=[],t=[]){this.uuid=On(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){He("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Ie)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Ie;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,a=e.length;r<a;r++){const o=e[r]?e[r].matrixWorld:Yx;Np.multiplyMatrices(o,t[r]),Np.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Ah(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new ys(t,e,e,vn,hn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const r=e.bones[n];let a=t[r];a===void 0&&(He("Skeleton: No bone found with UUID:",r),a=new Dp),this.bones.push(a),this.boneInverses.push(new Ie().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){const a=t[i];e.bones.push(a.uuid);const o=n[i];e.boneInverses.push(o.toArray())}return e}}class Lo extends bt{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}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 yr=new Ie,Bp=new Ie,Io=[],kp=new ut,$x=new Ie,ua=new at,pa=new li;class Ut extends at{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Lo(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,$x)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new ut),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,yr),kp.copy(e.boundingBox).applyMatrix4(yr),this.boundingBox.union(kp)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new li),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,yr),pa.copy(e.boundingSphere).applyMatrix4(yr),this.boundingSphere.union(pa)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,a=e*r+1;for(let o=0;o<n.length;o++)n[o]=i[a+o]}raycast(e,t){const n=this.matrixWorld,i=this.count;if(ua.geometry=this.geometry,ua.material=this.material,ua.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),pa.copy(this.boundingSphere),pa.applyMatrix4(n),e.ray.intersectsSphere(pa)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,yr),Bp.multiplyMatrices(n,yr),ua.matrixWorld=Bp,ua.raycast(e,Io);for(let a=0,o=Io.length;a<o;a++){const l=Io[a];l.instanceId=r,l.object=this,t.push(l)}Io.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Lo(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new ys(new Float32Array(i*this.count),i,this.count,eo,hn));const r=this.morphTexture.source.data.data;let a=0;for(let c=0;c<n.length;c++)a+=n[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=i*e;r[l]=o,r.set(n,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Ph=new P,Kx=new P,Jx=new $e;class It{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,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=Ph.subVectors(n,t).cross(Kx.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(Ph),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Jx.getNormalMatrix(e),i=this.coplanarPoint(Ph).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.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 _s=new li,Qx=new he(.5,.5),Do=new P;class Rh{constructor(e=new It,t=new It,n=new It,i=new It,r=new It,a=new It){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=oi,n=!1){const i=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],h=r[4],d=r[5],p=r[6],u=r[7],g=r[8],f=r[9],x=r[10],m=r[11],b=r[12],v=r[13],y=r[14],_=r[15];if(i[0].setComponents(c-a,u-h,m-g,_-b).normalize(),i[1].setComponents(c+a,u+h,m+g,_+b).normalize(),i[2].setComponents(c+o,u+d,m+f,_+v).normalize(),i[3].setComponents(c-o,u-d,m-f,_-v).normalize(),n)i[4].setComponents(l,p,x,y).normalize(),i[5].setComponents(c-l,u-p,m-x,_-y).normalize();else if(i[4].setComponents(c-l,u-p,m-x,_-y).normalize(),t===oi)i[5].setComponents(c+l,u+p,m+x,_+y).normalize();else if(t===oo)i[5].setComponents(l,p,x,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(),_s.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),_s.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(_s)}intersectsSprite(e){_s.center.set(0,0,0);const t=Qx.distanceTo(e.center);return _s.radius=.7071067811865476+t,_s.applyMatrix4(e.matrixWorld),this.intersectsSphere(_s)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(Do.x=i.normal.x>0?e.max.x:e.min.x,Do.y=i.normal.y>0?e.max.y:e.min.y,Do.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Do)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Ms extends Ln{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Fe(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 No=new P,Bo=new P,Up=new Ie,fa=new Xi,ko=new li,Lh=new P,Op=new P;class $i extends Et{constructor(e=new pt,t=new Ms){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)No.fromBufferAttribute(t,i-1),Bo.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=No.distanceTo(Bo);e.setAttribute("lineDistance",new jt(n,1))}else He("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),ko.copy(n.boundingSphere),ko.applyMatrix4(i),ko.radius+=r,e.ray.intersectsSphere(ko)===!1)return;Up.copy(i).invert(),fa.copy(e.ray).applyMatrix4(Up);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=n.index,p=n.attributes.position;if(h!==null){const u=Math.max(0,a.start),g=Math.min(h.count,a.start+a.count);for(let f=u,x=g-1;f<x;f+=c){const m=h.getX(f),b=h.getX(f+1),v=Uo(this,e,fa,l,m,b,f);v&&t.push(v)}if(this.isLineLoop){const f=h.getX(g-1),x=h.getX(u),m=Uo(this,e,fa,l,f,x,g-1);m&&t.push(m)}}else{const u=Math.max(0,a.start),g=Math.min(p.count,a.start+a.count);for(let f=u,x=g-1;f<x;f+=c){const m=Uo(this,e,fa,l,f,f+1,f);m&&t.push(m)}if(this.isLineLoop){const f=Uo(this,e,fa,l,g-1,u,g-1);f&&t.push(f)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Uo(s,e,t,n,i,r,a){const o=s.geometry.attributes.position;if(No.fromBufferAttribute(o,i),Bo.fromBufferAttribute(o,r),t.distanceSqToSegment(No,Bo,Lh,Op)>n)return;Lh.applyMatrix4(s.matrixWorld);const c=e.ray.origin.distanceTo(Lh);if(!(c<e.near||c>e.far))return{distance:c,point:Op.clone().applyMatrix4(s.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:s}}const zp=new P,Fp=new P;class Hp extends $i{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)zp.fromBufferAttribute(t,i),Fp.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+zp.distanceTo(Fp);e.setAttribute("lineDistance",new jt(n,1))}else He("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class e1 extends $i{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Vp extends Ln{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Fe(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 Gp=new Ie,Ih=new Xi,Oo=new li,zo=new P;class Wp extends Et{constructor(e=new pt,t=new Vp){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Oo.copy(n.boundingSphere),Oo.applyMatrix4(i),Oo.radius+=r,e.ray.intersectsSphere(Oo)===!1)return;Gp.copy(i).invert(),Ih.copy(e.ray).applyMatrix4(Gp);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,d=n.attributes.position;if(c!==null){const p=Math.max(0,a.start),u=Math.min(c.count,a.start+a.count);for(let g=p,f=u;g<f;g++){const x=c.getX(g);zo.fromBufferAttribute(d,x),Xp(zo,x,l,i,e,t,this)}}else{const p=Math.max(0,a.start),u=Math.min(d.count,a.start+a.count);for(let g=p,f=u;g<f;g++)zo.fromBufferAttribute(d,g),Xp(zo,g,l,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Xp(s,e,t,n,i,r,a){const o=Ih.distanceSqToPoint(s);if(o<t){const l=new P;Ih.closestPointToPoint(s,l),l.applyMatrix4(n);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;r.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class t1 extends Ft{constructor(e,t,n,i,r,a,o,l,c){super(e,t,n,i,r,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Fo extends Ft{constructor(e,t,n=ps,i,r,a,o=Xt,l=Xt,c,h=Jr,d=1){if(h!==Jr&&h!==ms)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const p={width:e,height:t,depth:d};super(p,i,r,a,o,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new nh(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 jp extends Ft{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class ci{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){He("Curve: .getPoint() not implemented.")}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const n=this.getLengths();let i=0;const r=n.length;let a;t?a=t:a=e*n[r-1];let o=0,l=r-1,c;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),c=n[i]-a,c<0)o=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===a)return i/(r-1);const h=n[i],p=n[i+1]-h,u=(a-h)/p;return(i+u)/(r-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);const a=this.getPoint(i),o=this.getPoint(r),l=t||(a.isVector2?new he:new P);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new P,i=[],r=[],a=[],o=new P,l=new Ie;for(let u=0;u<=e;u++){const g=u/e;i[u]=this.getTangentAt(g,new P)}r[0]=new P,a[0]=new P;let c=Number.MAX_VALUE;const h=Math.abs(i[0].x),d=Math.abs(i[0].y),p=Math.abs(i[0].z);h<=c&&(c=h,n.set(1,0,0)),d<=c&&(c=d,n.set(0,1,0)),p<=c&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],o),a[0].crossVectors(i[0],r[0]);for(let u=1;u<=e;u++){if(r[u]=r[u-1].clone(),a[u]=a[u-1].clone(),o.crossVectors(i[u-1],i[u]),o.length()>Number.EPSILON){o.normalize();const g=Math.acos(qe(i[u-1].dot(i[u]),-1,1));r[u].applyMatrix4(l.makeRotationAxis(o,g))}a[u].crossVectors(i[u],r[u])}if(t===!0){let u=Math.acos(qe(r[0].dot(r[e]),-1,1));u/=e,i[0].dot(o.crossVectors(r[0],r[e]))>0&&(u=-u);for(let g=1;g<=e;g++)r[g].applyMatrix4(l.makeRotationAxis(i[g],u*g)),a[g].crossVectors(i[g],r[g])}return{tangents:i,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 Dh extends ci{constructor(e=0,t=0,n=1,i=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=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new he){const n=t,i=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(a?r=0:r=i),this.aClockwise===!0&&!a&&(r===i?r=-i:r=r-i);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),p=l-this.aX,u=c-this.aY;l=p*h-u*d+this.aX,c=p*d+u*h+this.aY}return n.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 n1 extends Dh{constructor(e,t,n,i,r,a){super(e,t,n,n,i,r,a),this.isArcCurve=!0,this.type="ArcCurve"}}function Nh(){let s=0,e=0,t=0,n=0;function i(r,a,o,l){s=r,e=o,t=-3*r+3*a-2*o-l,n=2*r-2*a+o+l}return{initCatmullRom:function(r,a,o,l,c){i(a,o,c*(o-r),c*(l-a))},initNonuniformCatmullRom:function(r,a,o,l,c,h,d){let p=(a-r)/c-(o-r)/(c+h)+(o-a)/h,u=(o-a)/h-(l-a)/(h+d)+(l-o)/d;p*=h,u*=h,i(a,o,p,u)},calc:function(r){const a=r*r,o=a*r;return s+e*r+t*a+n*o}}}const Ho=new P,Bh=new Nh,kh=new Nh,Uh=new Nh;class i1 extends ci{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new P){const n=t,i=this.points,r=i.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=i[(o-1)%r]:(Ho.subVectors(i[0],i[1]).add(i[0]),c=Ho);const d=i[o%r],p=i[(o+1)%r];if(this.closed||o+2<r?h=i[(o+2)%r]:(Ho.subVectors(i[r-1],i[r-2]).add(i[r-1]),h=Ho),this.curveType==="centripetal"||this.curveType==="chordal"){const u=this.curveType==="chordal"?.5:.25;let g=Math.pow(c.distanceToSquared(d),u),f=Math.pow(d.distanceToSquared(p),u),x=Math.pow(p.distanceToSquared(h),u);f<1e-4&&(f=1),g<1e-4&&(g=f),x<1e-4&&(x=f),Bh.initNonuniformCatmullRom(c.x,d.x,p.x,h.x,g,f,x),kh.initNonuniformCatmullRom(c.y,d.y,p.y,h.y,g,f,x),Uh.initNonuniformCatmullRom(c.z,d.z,p.z,h.z,g,f,x)}else this.curveType==="catmullrom"&&(Bh.initCatmullRom(c.x,d.x,p.x,h.x,this.tension),kh.initCatmullRom(c.y,d.y,p.y,h.y,this.tension),Uh.initCatmullRom(c.z,d.z,p.z,h.z,this.tension));return n.set(Bh.calc(l),kh.calc(l),Uh.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new P().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function qp(s,e,t,n,i){const r=(n-e)*.5,a=(i-t)*.5,o=s*s,l=s*o;return(2*t-2*n+r+a)*l+(-3*t+3*n-2*r-a)*o+r*s+t}function s1(s,e){const t=1-s;return t*t*e}function r1(s,e){return 2*(1-s)*s*e}function a1(s,e){return s*s*e}function ma(s,e,t,n){return s1(s,e)+r1(s,t)+a1(s,n)}function o1(s,e){const t=1-s;return t*t*t*e}function l1(s,e){const t=1-s;return 3*t*t*s*e}function c1(s,e){return 3*(1-s)*s*s*e}function h1(s,e){return s*s*s*e}function ga(s,e,t,n,i){return o1(s,e)+l1(s,t)+c1(s,n)+h1(s,i)}class Zp extends ci{constructor(e=new he,t=new he,n=new he,i=new he){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new he){const n=t,i=this.v0,r=this.v1,a=this.v2,o=this.v3;return n.set(ga(e,i.x,r.x,a.x,o.x),ga(e,i.y,r.y,a.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class d1 extends ci{constructor(e=new P,t=new P,n=new P,i=new P){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new P){const n=t,i=this.v0,r=this.v1,a=this.v2,o=this.v3;return n.set(ga(e,i.x,r.x,a.x,o.x),ga(e,i.y,r.y,a.y,o.y),ga(e,i.z,r.z,a.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Yp extends ci{constructor(e=new he,t=new he){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new he){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new he){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 u1 extends ci{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 n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new 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 $p extends ci{constructor(e=new he,t=new he,n=new he){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new he){const n=t,i=this.v0,r=this.v1,a=this.v2;return n.set(ma(e,i.x,r.x,a.x),ma(e,i.y,r.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class p1 extends ci{constructor(e=new P,t=new P,n=new P){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new P){const n=t,i=this.v0,r=this.v1,a=this.v2;return n.set(ma(e,i.x,r.x,a.x),ma(e,i.y,r.y,a.y),ma(e,i.z,r.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Kp extends ci{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new he){const n=t,i=this.points,r=(i.length-1)*e,a=Math.floor(r),o=r-a,l=i[a===0?a:a-1],c=i[a],h=i[a>i.length-2?i.length-1:a+1],d=i[a>i.length-3?i.length-1:a+2];return n.set(qp(o,l.x,c.x,h.x,d.x),qp(o,l.y,c.y,h.y,d.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new he().fromArray(i))}return this}}var Oh=Object.freeze({__proto__:null,ArcCurve:n1,CatmullRomCurve3:i1,CubicBezierCurve:Zp,CubicBezierCurve3:d1,EllipseCurve:Dh,LineCurve:Yp,LineCurve3:u1,QuadraticBezierCurve:$p,QuadraticBezierCurve3:p1,SplineCurve:Kp});class f1 extends ci{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Oh[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let r=0;for(;r<i.length;){if(i[r]>=n){const a=i[r]-n,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 n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let i=0,r=this.curves;i<r.length;i++){const a=r[i],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];n&&n.equals(h)||(t.push(h),n=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,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(new Oh[i.type]().fromJSON(i))}return this}}class Jp extends f1{constructor(e){super(),this.type="Path",this.currentPoint=new he,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new Yp(this.currentPoint.clone(),new he(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const r=new $p(this.currentPoint.clone(),new he(e,t),new he(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,r,a){const o=new Zp(this.currentPoint.clone(),new he(e,t),new he(n,i),new he(r,a));return this.curves.push(o),this.currentPoint.set(r,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new Kp(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,r,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,n,i,r,a),this}absarc(e,t,n,i,r,a){return this.absellipse(e,t,n,n,i,r,a),this}ellipse(e,t,n,i,r,a,o,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+c,t+h,n,i,r,a,o,l),this}absellipse(e,t,n,i,r,a,o,l){const c=new Dh(e,t,n,i,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 Qp extends Jp{constructor(e){super(e),this.uuid=On(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(new Jp().fromJSON(i))}return this}}function m1(s,e,t=2){const n=e&&e.length,i=n?e[0]*t:s.length;let r=ef(s,0,i,t,!0);const a=[];if(!r||r.next===r.prev)return a;let o,l,c;if(n&&(r=y1(s,e,r,t)),s.length>80*t){o=s[0],l=s[1];let h=o,d=l;for(let p=t;p<i;p+=t){const u=s[p],g=s[p+1];u<o&&(o=u),g<l&&(l=g),u>h&&(h=u),g>d&&(d=g)}c=Math.max(h-o,d-l),c=c!==0?32767/c:0}return xa(r,a,t,o,l,c,0),a}function ef(s,e,t,n,i){let r;if(i===L1(s,e,t,n)>0)for(let a=e;a<t;a+=n)r=rf(a/n|0,s[a],s[a+1],r);else for(let a=t-n;a>=e;a-=n)r=rf(a/n|0,s[a],s[a+1],r);return r&&_r(r,r.next)&&(ya(r),r=r.next),r}function ws(s,e){if(!s)return s;e||(e=s);let t=s,n;do if(n=!1,!t.steiner&&(_r(t,t.next)||Ct(t.prev,t,t.next)===0)){if(ya(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function xa(s,e,t,n,i,r,a){if(!s)return;!a&&r&&E1(s,n,i,r);let o=s;for(;s.prev!==s.next;){const l=s.prev,c=s.next;if(r?x1(s,n,i,r):g1(s)){e.push(l.i,s.i,c.i),ya(s),s=c.next,o=c.next;continue}if(s=c,s===o){a?a===1?(s=v1(ws(s),e),xa(s,e,t,n,i,r,2)):a===2&&b1(s,e,t,n,i,r):xa(ws(s),e,t,n,i,r,1);break}}}function g1(s){const e=s.prev,t=s,n=s.next;if(Ct(e,t,n)>=0)return!1;const i=e.x,r=t.x,a=n.x,o=e.y,l=t.y,c=n.y,h=Math.min(i,r,a),d=Math.min(o,l,c),p=Math.max(i,r,a),u=Math.max(o,l,c);let g=n.next;for(;g!==e;){if(g.x>=h&&g.x<=p&&g.y>=d&&g.y<=u&&va(i,o,r,l,a,c,g.x,g.y)&&Ct(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function x1(s,e,t,n){const i=s.prev,r=s,a=s.next;if(Ct(i,r,a)>=0)return!1;const o=i.x,l=r.x,c=a.x,h=i.y,d=r.y,p=a.y,u=Math.min(o,l,c),g=Math.min(h,d,p),f=Math.max(o,l,c),x=Math.max(h,d,p),m=zh(u,g,e,t,n),b=zh(f,x,e,t,n);let v=s.prevZ,y=s.nextZ;for(;v&&v.z>=m&&y&&y.z<=b;){if(v.x>=u&&v.x<=f&&v.y>=g&&v.y<=x&&v!==i&&v!==a&&va(o,h,l,d,c,p,v.x,v.y)&&Ct(v.prev,v,v.next)>=0||(v=v.prevZ,y.x>=u&&y.x<=f&&y.y>=g&&y.y<=x&&y!==i&&y!==a&&va(o,h,l,d,c,p,y.x,y.y)&&Ct(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;v&&v.z>=m;){if(v.x>=u&&v.x<=f&&v.y>=g&&v.y<=x&&v!==i&&v!==a&&va(o,h,l,d,c,p,v.x,v.y)&&Ct(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;y&&y.z<=b;){if(y.x>=u&&y.x<=f&&y.y>=g&&y.y<=x&&y!==i&&y!==a&&va(o,h,l,d,c,p,y.x,y.y)&&Ct(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function v1(s,e){let t=s;do{const n=t.prev,i=t.next.next;!_r(n,i)&&nf(n,t,t.next,i)&&ba(n,i)&&ba(i,n)&&(e.push(n.i,t.i,i.i),ya(t),ya(t.next),t=s=i),t=t.next}while(t!==s);return ws(t)}function b1(s,e,t,n,i,r){let a=s;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&A1(a,o)){let l=sf(a,o);a=ws(a,a.next),l=ws(l,l.next),xa(a,e,t,n,i,r,0),xa(l,e,t,n,i,r,0);return}o=o.next}a=a.next}while(a!==s)}function y1(s,e,t,n){const i=[];for(let r=0,a=e.length;r<a;r++){const o=e[r]*n,l=r<a-1?e[r+1]*n:s.length,c=ef(s,o,l,n,!1);c===c.next&&(c.steiner=!0),i.push(T1(c))}i.sort(_1);for(let r=0;r<i.length;r++)t=M1(i[r],t);return t}function _1(s,e){let t=s.x-e.x;if(t===0&&(t=s.y-e.y,t===0)){const n=(s.next.y-s.y)/(s.next.x-s.x),i=(e.next.y-e.y)/(e.next.x-e.x);t=n-i}return t}function M1(s,e){const t=w1(s,e);if(!t)return e;const n=sf(t,s);return ws(n,n.next),ws(t,t.next)}function w1(s,e){let t=e;const n=s.x,i=s.y;let r=-1/0,a;if(_r(s,t))return t;do{if(_r(s,t.next))return t.next;if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){const d=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=n&&d>r&&(r=d,a=t.x<t.next.x?t:t.next,d===n))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(n>=t.x&&t.x>=l&&n!==t.x&&tf(i<c?n:r,i,l,c,i<c?r:n,i,t.x,t.y)){const d=Math.abs(i-t.y)/(n-t.x);ba(t,s)&&(d<h||d===h&&(t.x>a.x||t.x===a.x&&S1(a,t)))&&(a=t,h=d)}t=t.next}while(t!==o);return a}function S1(s,e){return Ct(s.prev,s,e.prev)<0&&Ct(e.next,s,s.next)<0}function E1(s,e,t,n){let i=s;do i.z===0&&(i.z=zh(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,C1(i)}function C1(s){let e,t=1;do{let n=s,i;s=null;let r=null;for(e=0;n;){e++;let a=n,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||n.z<=a.z)?(i=n,n=n.nextZ,o--):(i=a,a=a.nextZ,l--),r?r.nextZ=i:s=i,i.prevZ=r,r=i;n=a}r.nextZ=null,t*=2}while(e>1);return s}function zh(s,e,t,n,i){return s=(s-t)*i|0,e=(e-n)*i|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 T1(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 tf(s,e,t,n,i,r,a,o){return(i-a)*(e-o)>=(s-a)*(r-o)&&(s-a)*(n-o)>=(t-a)*(e-o)&&(t-a)*(r-o)>=(i-a)*(n-o)}function va(s,e,t,n,i,r,a,o){return!(s===a&&e===o)&&tf(s,e,t,n,i,r,a,o)}function A1(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!P1(s,e)&&(ba(s,e)&&ba(e,s)&&R1(s,e)&&(Ct(s.prev,s,e.prev)||Ct(s,e.prev,e))||_r(s,e)&&Ct(s.prev,s,s.next)>0&&Ct(e.prev,e,e.next)>0)}function Ct(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function _r(s,e){return s.x===e.x&&s.y===e.y}function nf(s,e,t,n){const i=Go(Ct(s,e,t)),r=Go(Ct(s,e,n)),a=Go(Ct(t,n,s)),o=Go(Ct(t,n,e));return!!(i!==r&&a!==o||i===0&&Vo(s,t,e)||r===0&&Vo(s,n,e)||a===0&&Vo(t,s,n)||o===0&&Vo(t,e,n))}function Vo(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 Go(s){return s>0?1:s<0?-1:0}function P1(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&&nf(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function ba(s,e){return Ct(s.prev,s,s.next)<0?Ct(s,e,s.next)>=0&&Ct(s,s.prev,e)>=0:Ct(s,e,s.prev)<0||Ct(s,s.next,e)<0}function R1(s,e){let t=s,n=!1;const i=(s.x+e.x)/2,r=(s.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&i<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==s);return n}function sf(s,e){const t=Fh(s.i,s.x,s.y),n=Fh(e.i,e.x,e.y),i=s.next,r=e.prev;return s.next=e,e.prev=s,t.next=i,i.prev=t,n.next=t,t.prev=n,r.next=n,n.prev=r,n}function rf(s,e,t,n){const i=Fh(s,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function ya(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 Fh(s,e,t){return{i:s,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function L1(s,e,t,n){let i=0;for(let r=e,a=t-n;r<t;r+=n)i+=(s[a]-s[r])*(s[r+1]+s[a+1]),a=r;return i}class I1{static triangulate(e,t,n=2){return m1(e,t,n)}}class Mr{static area(e){const t=e.length;let n=0;for(let i=t-1,r=0;r<t;i=r++)n+=e[i].x*e[r].y-e[r].x*e[i].y;return n*.5}static isClockWise(e){return Mr.area(e)<0}static triangulateShape(e,t){const n=[],i=[],r=[];af(e),of(n,e);let a=e.length;t.forEach(af);for(let l=0;l<t.length;l++)i.push(a),a+=t[l].length,of(n,t[l]);const o=I1.triangulate(n,i);for(let l=0;l<o.length;l+=3)r.push(o.slice(l,l+3));return r}}function af(s){const e=s.length;e>2&&s[e-1].equals(s[0])&&s.pop()}function of(s,e){for(let t=0;t<e.length;t++)s.push(e[t].x),s.push(e[t].y)}class Hh extends pt{constructor(e=new Qp([new he(.5,.5),new he(-.5,.5),new he(-.5,-.5),new he(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],r=[];for(let o=0,l=e.length;o<l;o++){const c=e[o];a(c)}this.setAttribute("position",new jt(i,3)),this.setAttribute("uv",new jt(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 p=t.bevelEnabled!==void 0?t.bevelEnabled:!0,u=t.bevelThickness!==void 0?t.bevelThickness:.2,g=t.bevelSize!==void 0?t.bevelSize:u-.1,f=t.bevelOffset!==void 0?t.bevelOffset:0,x=t.bevelSegments!==void 0?t.bevelSegments:3;const m=t.extrudePath,b=t.UVGenerator!==void 0?t.UVGenerator:D1;let v,y=!1,_,M,T,R;m&&(v=m.getSpacedPoints(h),y=!0,p=!1,_=m.computeFrenetFrames(h,!1),M=new P,T=new P,R=new P),p||(x=0,u=0,g=0,f=0);const w=o.extractPoints(c);let E=w.shape;const I=w.holes;if(!Mr.isClockWise(E)){E=E.reverse();for(let C=0,D=I.length;C<D;C++){const W=I[C];Mr.isClockWise(W)&&(I[C]=W.reverse())}}function B(C){const W=10000000000000001e-36;let O=C[0];for(let k=1;k<=C.length;k++){const F=k%C.length,ee=C[F],J=ee.x-O.x,q=ee.y-O.y,N=J*J+q*q,L=Math.max(Math.abs(ee.x),Math.abs(ee.y),Math.abs(O.x),Math.abs(O.y)),V=W*L*L;if(N<=V){C.splice(F,1),k--;continue}O=ee}}B(E),I.forEach(B);const S=I.length,U=E;for(let C=0;C<S;C++){const D=I[C];E=E.concat(D)}function H(C,D,W){return D||Qe("ExtrudeGeometry: vec does not exist"),C.clone().addScaledVector(D,W)}const G=E.length;function Z(C,D,W){let O,k,F;const ee=C.x-D.x,J=C.y-D.y,q=W.x-C.x,N=W.y-C.y,L=ee*ee+J*J,V=ee*N-J*q;if(Math.abs(V)>Number.EPSILON){const K=Math.sqrt(L),le=Math.sqrt(q*q+N*N),te=D.x-J/K,Te=D.y+ee/K,ye=W.x-N/le,Re=W.y+q/le,De=((ye-te)*N-(Re-Te)*q)/(ee*N-J*q);O=te+ee*De-C.x,k=Te+J*De-C.y;const de=O*O+k*k;if(de<=2)return new he(O,k);F=Math.sqrt(de/2)}else{let K=!1;ee>Number.EPSILON?q>Number.EPSILON&&(K=!0):ee<-Number.EPSILON?q<-Number.EPSILON&&(K=!0):Math.sign(J)===Math.sign(N)&&(K=!0),K?(O=-J,k=ee,F=Math.sqrt(L)):(O=ee,k=J,F=Math.sqrt(L/2))}return new he(O/F,k/F)}const j=[];for(let C=0,D=U.length,W=D-1,O=C+1;C<D;C++,W++,O++)W===D&&(W=0),O===D&&(O=0),j[C]=Z(U[C],U[W],U[O]);const ie=[];let X,$=j.concat();for(let C=0,D=S;C<D;C++){const W=I[C];X=[];for(let O=0,k=W.length,F=k-1,ee=O+1;O<k;O++,F++,ee++)F===k&&(F=0),ee===k&&(ee=0),X[O]=Z(W[O],W[F],W[ee]);ie.push(X),$=$.concat(X)}let ue;if(x===0)ue=Mr.triangulateShape(U,I);else{const C=[],D=[];for(let W=0;W<x;W++){const O=W/x,k=u*Math.cos(O*Math.PI/2),F=g*Math.sin(O*Math.PI/2)+f;for(let ee=0,J=U.length;ee<J;ee++){const q=H(U[ee],j[ee],F);be(q.x,q.y,-k),O===0&&C.push(q)}for(let ee=0,J=S;ee<J;ee++){const q=I[ee];X=ie[ee];const N=[];for(let L=0,V=q.length;L<V;L++){const K=H(q[L],X[L],F);be(K.x,K.y,-k),O===0&&N.push(K)}O===0&&D.push(N)}}ue=Mr.triangulateShape(C,D)}const pe=ue.length,fe=g+f;for(let C=0;C<G;C++){const D=p?H(E[C],$[C],fe):E[C];y?(T.copy(_.normals[0]).multiplyScalar(D.x),M.copy(_.binormals[0]).multiplyScalar(D.y),R.copy(v[0]).add(T).add(M),be(R.x,R.y,R.z)):be(D.x,D.y,0)}for(let C=1;C<=h;C++)for(let D=0;D<G;D++){const W=p?H(E[D],$[D],fe):E[D];y?(T.copy(_.normals[C]).multiplyScalar(W.x),M.copy(_.binormals[C]).multiplyScalar(W.y),R.copy(v[C]).add(T).add(M),be(R.x,R.y,R.z)):be(W.x,W.y,d/h*C)}for(let C=x-1;C>=0;C--){const D=C/x,W=u*Math.cos(D*Math.PI/2),O=g*Math.sin(D*Math.PI/2)+f;for(let k=0,F=U.length;k<F;k++){const ee=H(U[k],j[k],O);be(ee.x,ee.y,d+W)}for(let k=0,F=I.length;k<F;k++){const ee=I[k];X=ie[k];for(let J=0,q=ee.length;J<q;J++){const N=H(ee[J],X[J],O);y?be(N.x,N.y+v[h-1].y,v[h-1].x+W):be(N.x,N.y,d+W)}}}se(),ce();function se(){const C=i.length/3;if(p){let D=0,W=G*D;for(let O=0;O<pe;O++){const k=ue[O];Se(k[2]+W,k[1]+W,k[0]+W)}D=h+x*2,W=G*D;for(let O=0;O<pe;O++){const k=ue[O];Se(k[0]+W,k[1]+W,k[2]+W)}}else{for(let D=0;D<pe;D++){const W=ue[D];Se(W[2],W[1],W[0])}for(let D=0;D<pe;D++){const W=ue[D];Se(W[0]+G*h,W[1]+G*h,W[2]+G*h)}}n.addGroup(C,i.length/3-C,0)}function ce(){const C=i.length/3;let D=0;me(U,D),D+=U.length;for(let W=0,O=I.length;W<O;W++){const k=I[W];me(k,D),D+=k.length}n.addGroup(C,i.length/3-C,1)}function me(C,D){let W=C.length;for(;--W>=0;){const O=W;let k=W-1;k<0&&(k=C.length-1);for(let F=0,ee=h+x*2;F<ee;F++){const J=G*F,q=G*(F+1),N=D+O+J,L=D+k+J,V=D+k+q,K=D+O+q;Be(N,L,V,K)}}}function be(C,D,W){l.push(C),l.push(D),l.push(W)}function Se(C,D,W){Je(C),Je(D),Je(W);const O=i.length/3,k=b.generateTopUV(n,i,O-3,O-2,O-1);ke(k[0]),ke(k[1]),ke(k[2])}function Be(C,D,W,O){Je(C),Je(D),Je(O),Je(D),Je(W),Je(O);const k=i.length/3,F=b.generateSideWallUV(n,i,k-6,k-3,k-2,k-1);ke(F[0]),ke(F[1]),ke(F[3]),ke(F[1]),ke(F[2]),ke(F[3])}function Je(C){i.push(l[C*3+0]),i.push(l[C*3+1]),i.push(l[C*3+2])}function ke(C){r.push(C.x),r.push(C.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return N1(t,n,e)}static fromJSON(e,t){const n=[];for(let r=0,a=e.shapes.length;r<a;r++){const o=t[e.shapes[r]];n.push(o)}const i=e.options.extrudePath;return i!==void 0&&(e.options.extrudePath=new Oh[i.type]().fromJSON(i)),new Hh(n,e.options)}}const D1={generateTopUV:function(s,e,t,n,i){const r=e[t*3],a=e[t*3+1],o=e[n*3],l=e[n*3+1],c=e[i*3],h=e[i*3+1];return[new he(r,a),new he(o,l),new he(c,h)]},generateSideWallUV:function(s,e,t,n,i,r){const a=e[t*3],o=e[t*3+1],l=e[t*3+2],c=e[n*3],h=e[n*3+1],d=e[n*3+2],p=e[i*3],u=e[i*3+1],g=e[i*3+2],f=e[r*3],x=e[r*3+1],m=e[r*3+2];return Math.abs(o-h)<Math.abs(a-c)?[new he(a,1-l),new he(c,1-d),new he(p,1-g),new he(f,1-m)]:[new he(o,1-l),new he(h,1-d),new he(u,1-g),new he(x,1-m)]}};function N1(s,e,t){if(t.shapes=[],Array.isArray(s))for(let n=0,i=s.length;n<i;n++){const r=s[n];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 Ss extends pt{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const r=e/2,a=t/2,o=Math.floor(n),l=Math.floor(i),c=o+1,h=l+1,d=e/o,p=t/l,u=[],g=[],f=[],x=[];for(let m=0;m<h;m++){const b=m*p-a;for(let v=0;v<c;v++){const y=v*d-r;g.push(y,-b,0),f.push(0,0,1),x.push(v/o),x.push(1-m/l)}}for(let m=0;m<l;m++)for(let b=0;b<o;b++){const v=b+c*m,y=b+c*(m+1),_=b+1+c*(m+1),M=b+1+c*m;u.push(v,y,M),u.push(y,_,M)}this.setIndex(u),this.setAttribute("position",new jt(g,3)),this.setAttribute("normal",new jt(f,3)),this.setAttribute("uv",new jt(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ss(e.width,e.height,e.widthSegments,e.heightSegments)}}class Vh extends pt{constructor(e=1,t=32,n=16,i=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:r,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const l=Math.min(a+o,Math.PI);let c=0;const h=[],d=new P,p=new P,u=[],g=[],f=[],x=[];for(let m=0;m<=n;m++){const b=[],v=m/n;let y=0;m===0&&a===0?y=.5/t:m===n&&l===Math.PI&&(y=-.5/t);for(let _=0;_<=t;_++){const M=_/t;d.x=-e*Math.cos(i+M*r)*Math.sin(a+v*o),d.y=e*Math.cos(a+v*o),d.z=e*Math.sin(i+M*r)*Math.sin(a+v*o),g.push(d.x,d.y,d.z),p.copy(d).normalize(),f.push(p.x,p.y,p.z),x.push(M+y,1-v),b.push(c++)}h.push(b)}for(let m=0;m<n;m++)for(let b=0;b<t;b++){const v=h[m][b+1],y=h[m][b],_=h[m+1][b],M=h[m+1][b+1];(m!==0||a>0)&&u.push(v,y,M),(m!==n-1||l<Math.PI)&&u.push(y,_,M)}this.setIndex(u),this.setAttribute("position",new jt(g,3)),this.setAttribute("normal",new jt(f,3)),this.setAttribute("uv",new jt(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vh(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class B1 extends Lt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Ki extends Ln{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Fe(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 Fe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ro,this.normalScale=new he(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 Rn,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 hi extends Ki{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 he(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return qe(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 Fe(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 Fe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Fe(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 lf extends Ln{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ro,this.normalScale=new he(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 k1 extends Ln{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Fe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Fe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ro,this.normalScale=new he(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Rn,this.combine=pc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class U1 extends Ln{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=qg,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 O1 extends Ln{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}}function Wo(s,e){return!s||s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function z1(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function F1(s){function e(i,r){return s[i]-s[r]}const t=s.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function cf(s,e,t){const n=s.length,i=new s.constructor(n);for(let r=0,a=0;a!==n;++r){const o=t[r]*e;for(let l=0;l!==e;++l)i[a++]=s[o+l]}return i}function hf(s,e,t,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let a=r[n];if(a!==void 0)if(Array.isArray(a))do a=r[n],a!==void 0&&(e.push(r.time),t.push(...a)),r=s[i++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[n],a!==void 0&&(e.push(r.time),a.toArray(t,t.length)),r=s[i++];while(r!==void 0);else do a=r[n],a!==void 0&&(e.push(r.time),t.push(a)),r=s[i++];while(r!==void 0)}class _a{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let a;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break t}a=t.length;break n}if(!(e>=r)){const o=t[1];e<o&&(n=2,r=o);for(let l=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=r,r=t[--n-1],e>=r)break t}a=n,n=0;break n}break e}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let a=0;a!==i;++a)t[a]=n[r+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class H1 extends _a{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Wu,endingEnd:Wu}}intervalChanged_(e,t,n){const i=this.parameterPositions;let r=e-2,a=e+1,o=i[r],l=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case Xu:r=e,o=2*t-n;break;case ju:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Xu:a=e,l=2*n-t;break;case ju:a=1,l=n+i[1]-i[0];break;default:a=e-1,l=t}const c=(n-t)*.5,h=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this._offsetPrev,d=this._offsetNext,p=this._weightPrev,u=this._weightNext,g=(n-t)/(i-t),f=g*g,x=f*g,m=-p*x+2*p*f-p*g,b=(1+p)*x+(-1.5-2*p)*f+(-.5+p)*g+1,v=(-1-u)*x+(1.5+u)*f+.5*g,y=u*x-u*f;for(let _=0;_!==o;++_)r[_]=m*a[h+_]+b*a[c+_]+v*a[l+_]+y*a[d+_];return r}}class V1 extends _a{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=(n-t)/(i-t),d=1-h;for(let p=0;p!==o;++p)r[p]=a[c+p]*d+a[l+p]*h;return r}}class G1 extends _a{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class ti{constructor(e,t,n,i){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=Wo(t,this.TimeBufferType),this.values=Wo(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Wo(e.times,Array),values:Wo(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new G1(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new V1(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new H1(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Qr:t=this.InterpolantFactoryMethodDiscrete;break;case ea:t=this.InterpolantFactoryMethodLinear;break;case $c:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return He("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Qr;case this.InterpolantFactoryMethodLinear:return ea;case this.InterpolantFactoryMethodSmooth:return $c}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let r=0,a=i-1;for(;r!==i&&n[r]<e;)++r;for(;a!==-1&&n[a]>t;)--a;if(++a,r!==0||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=n.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&&(Qe("KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;r===0&&(Qe("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){Qe("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){Qe("KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(i!==void 0&&z1(i))for(let o=0,l=i.length;o!==l;++o){const c=i[o];if(isNaN(c)){Qe("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(),n=this.getValueSize(),i=this.getInterpolation()===$c,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(i)l=!0;else{const d=o*n,p=d-n,u=d+n;for(let g=0;g!==n;++g){const f=t[d+g];if(f!==t[p+g]||f!==t[u+g]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const d=o*n,p=a*n;for(let u=0;u!==n;++u)t[p+u]=t[d+u]}++a}}if(r>0){e[a]=e[r];for(let o=r*n,l=a*n,c=0;c!==n;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}ti.prototype.ValueTypeName="",ti.prototype.TimeBufferType=Float32Array,ti.prototype.ValueBufferType=Float32Array,ti.prototype.DefaultInterpolation=ea;class wr extends ti{constructor(e,t,n){super(e,t,n)}}wr.prototype.ValueTypeName="bool",wr.prototype.ValueBufferType=Array,wr.prototype.DefaultInterpolation=Qr,wr.prototype.InterpolantFactoryMethodLinear=void 0,wr.prototype.InterpolantFactoryMethodSmooth=void 0;class df extends ti{constructor(e,t,n,i){super(e,t,n,i)}}df.prototype.ValueTypeName="color";class Sr extends ti{constructor(e,t,n,i){super(e,t,n,i)}}Sr.prototype.ValueTypeName="number";class W1 extends _a{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-t)/(i-t);let c=e*o;for(let h=c+o;c!==h;c+=4)zn.slerpFlat(r,0,a,c-o,a,c,l);return r}}class Er extends ti{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new W1(this.times,this.values,this.getValueSize(),e)}}Er.prototype.ValueTypeName="quaternion",Er.prototype.InterpolantFactoryMethodSmooth=void 0;class Cr extends ti{constructor(e,t,n){super(e,t,n)}}Cr.prototype.ValueTypeName="string",Cr.prototype.ValueBufferType=Array,Cr.prototype.DefaultInterpolation=Qr,Cr.prototype.InterpolantFactoryMethodLinear=void 0,Cr.prototype.InterpolantFactoryMethodSmooth=void 0;class Tr extends ti{constructor(e,t,n,i){super(e,t,n,i)}}Tr.prototype.ValueTypeName="vector";class X1{constructor(e="",t=-1,n=[],i=Xg){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=On(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(q1(n[a]).scale(i));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=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,a=n.length;r!==a;++r)t.push(ti.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){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=F1(l);l=cf(l,1,h),c=cf(c,1,h),!i&&l[0]===0&&(l.push(r),c.push(c[0])),a.push(new Sr(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},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 p=i[d];p||(i[d]=p=[]),p.push(c)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return a}static parseAnimation(e,t){if(He("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return Qe("AnimationClip: No animation in JSONLoader data."),null;const n=function(d,p,u,g,f){if(u.length!==0){const x=[],m=[];hf(u,x,m,g),x.length!==0&&f.push(new d(p,x,m))}},i=[],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 p=c[d].keys;if(!(!p||p.length===0))if(p[0].morphTargets){const u={};let g;for(g=0;g<p.length;g++)if(p[g].morphTargets)for(let f=0;f<p[g].morphTargets.length;f++)u[p[g].morphTargets[f]]=-1;for(const f in u){const x=[],m=[];for(let b=0;b!==p[g].morphTargets.length;++b){const v=p[g];x.push(v.time),m.push(v.morphTarget===f?1:0)}i.push(new Sr(".morphTargetInfluence["+f+"]",x,m))}l=u.length*a}else{const u=".bones["+t[d].name+"]";n(Tr,u+".position",p,"pos",i),n(Er,u+".quaternion",p,"rot",i),n(Tr,u+".scale",p,"scl",i)}}return i.length===0?null:new this(r,l,i,o)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const r=this.tracks[n];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 n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function j1(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Sr;case"vector":case"vector2":case"vector3":case"vector4":return Tr;case"color":return df;case"quaternion":return Er;case"bool":case"boolean":return wr;case"string":return Cr}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function q1(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=j1(s.type);if(s.times===void 0){const t=[],n=[];hf(s.keys,t,n,"value"),s.times=t,s.values=n}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const Ci={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(this.files[s]=e)},get:function(s){if(this.enabled!==!1)return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};class Z1{constructor(e,t,n){const i=this;let r=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(h){o++,r===!1&&i.onStart!==void 0&&i.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,i.onProgress!==void 0&&i.onProgress(h,a,o),a===o&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,d){return c.push(h,d),this},this.removeHandler=function(h){const d=c.indexOf(h);return d!==-1&&c.splice(d,2),this},this.getHandler=function(h){for(let d=0,p=c.length;d<p;d+=2){const u=c[d],g=c[d+1];if(u.global&&(u.lastIndex=0),u.test(h))return g}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 Y1=new Z1;class Ji{constructor(e){this.manager=e!==void 0?e:Y1,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,r){n.load(e,i,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}}Ji.DEFAULT_MATERIAL_NAME="__DEFAULT";const Ti={};class $1 extends Error{constructor(e,t){super(e),this.response=t}}class Ma extends Ji{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=Ci.get(`file:${e}`);if(r!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(Ti[e]!==void 0){Ti[e].push({onLoad:t,onProgress:n,onError:i});return}Ti[e]=[],Ti[e].push({onLoad:t,onProgress:n,onError:i});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&&He("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=Ti[e],d=c.body.getReader(),p=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),u=p?parseInt(p):0,g=u!==0;let f=0;const x=new ReadableStream({start(m){b();function b(){d.read().then(({done:v,value:y})=>{if(v)m.close();else{f+=y.byteLength;const _=new ProgressEvent("progress",{lengthComputable:g,loaded:f,total:u});for(let M=0,T=h.length;M<T;M++){const R=h[M];R.onProgress&&R.onProgress(_)}m.enqueue(y),b()}},v=>{m.error(v)})}}});return new Response(x)}else throw new $1(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o==="")return c.text();{const d=/charset="?([^;"\s]*)"?/i.exec(o),p=d&&d[1]?d[1].toLowerCase():void 0,u=new TextDecoder(p);return c.arrayBuffer().then(g=>u.decode(g))}}}).then(c=>{Ci.add(`file:${e}`,c);const h=Ti[e];delete Ti[e];for(let d=0,p=h.length;d<p;d++){const u=h[d];u.onLoad&&u.onLoad(c)}}).catch(c=>{const h=Ti[e];if(h===void 0)throw this.manager.itemError(e),c;delete Ti[e];for(let d=0,p=h.length;d<p;d++){const u=h[d];u.onError&&u.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const Ar=new WeakMap;class K1 extends Ji{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Ci.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=Ar.get(a);d===void 0&&(d=[],Ar.set(a,d)),d.push({onLoad:t,onError:i})}return a}const o=ta("img");function l(){h(),t&&t(this);const d=Ar.get(this)||[];for(let p=0;p<d.length;p++){const u=d[p];u.onLoad&&u.onLoad(this)}Ar.delete(this),r.manager.itemEnd(e)}function c(d){h(),i&&i(d),Ci.remove(`image:${e}`);const p=Ar.get(this)||[];for(let u=0;u<p.length;u++){const g=p[u];g.onError&&g.onError(d)}Ar.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),Ci.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class J1 extends Ji{constructor(e){super(e)}load(e,t,n,i){const r=this,a=new ys,o=new Ma(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(i!==void 0)i(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:Un,a.wrapT=c.wrapT!==void 0?c.wrapT:Un,a.magFilter=c.magFilter!==void 0?c.magFilter:Pt,a.minFilter=c.minFilter!==void 0?c.minFilter:Pt,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=ai),c.mipmapCount===1&&(a.minFilter=Pt),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c)},n,i),a}}class Gh extends Ji{constructor(e){super(e)}load(e,t,n,i){const r=new Ft,a=new K1(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)},n,i),r}}class Xo extends Et{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Fe(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}const Wh=new Ie,uf=new P,pf=new P;class Xh{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new he(512,512),this.mapType=$n,this.map=null,this.mapPass=null,this.matrix=new Ie,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Rh,this._frameExtents=new he(1,1),this._viewportCount=1,this._viewports=[new tt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;uf.setFromMatrixPosition(e.matrixWorld),t.position.copy(uf),pf.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(pf),t.updateMatrixWorld(),Wh.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Wh,t.coordinateSystem,t.reversedDepth),t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Wh)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class Q1 extends Xh{constructor(){super(new on(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=er*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;(n!==t.fov||i!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class ev extends Xo{constructor(e,t,n=0,i=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.target=new Et,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new Q1}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const ff=new Ie,wa=new P,jh=new P;class tv extends Xh{constructor(){super(new on(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new he(4,2),this._viewportCount=6,this._viewports=[new tt(2,1,1,1),new tt(0,1,1,1),new tt(3,1,1,1),new tt(1,1,1,1),new tt(3,0,1,1),new tt(1,0,1,1)],this._cubeDirections=[new P(1,0,0),new P(-1,0,0),new P(0,0,1),new P(0,0,-1),new P(0,1,0),new P(0,-1,0)],this._cubeUps=[new P(0,1,0),new P(0,1,0),new P(0,1,0),new P(0,1,0),new P(0,0,1),new P(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),wa.setFromMatrixPosition(e.matrixWorld),n.position.copy(wa),jh.copy(n.position),jh.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(jh),n.updateMatrixWorld(),i.makeTranslation(-wa.x,-wa.y,-wa.z),ff.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ff,n.coordinateSystem,n.reversedDepth)}}class nv extends Xo{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new tv}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class Ai extends bp{constructor(e=-1,t=1,n=1,i=-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=n,this.bottom=i,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,n,i,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=n,this.view.offsetY=i,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),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,a=n+e,o=i+t,l=i-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 iv extends Xh{constructor(){super(new Ai(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Pi extends Xo{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.target=new Et,this.shadow=new iv}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class jo extends Xo{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Sa{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)}}const qh=new WeakMap;class sv extends Ji{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&He("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&He("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Ci.get(`image-bitmap:${e}`);if(a!==void 0){if(r.manager.itemStart(e),a.then){a.then(c=>{if(qh.has(a)===!0)i&&i(qh.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 Ci.add(`image-bitmap:${e}`,c),t&&t(c),r.manager.itemEnd(e),c}).catch(function(c){i&&i(c),qh.set(l,c),Ci.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});Ci.add(`image-bitmap:${e}`,l),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class rv extends on{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class mf{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}const Zh="\\[\\]\\.:\\/",av=new RegExp("["+Zh+"]","g"),Yh="[^"+Zh+"]",ov="[^"+Zh.replace("\\.","")+"]",lv=/((?:WC+[\/:])*)/.source.replace("WC",Yh),cv=/(WCOD+)?/.source.replace("WCOD",ov),hv=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Yh),dv=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Yh),uv=new RegExp("^"+lv+cv+hv+dv+"$"),pv=["material","materials","bones","map"];class fv{constructor(e,t,n){const i=n||dt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class dt{constructor(e,t,n){this.path=t,this.parsedPath=n||dt.parseTrackName(t),this.node=dt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new dt.Composite(e,t,n):new dt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(av,"")}static parseTrackName(e){const t=uv.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const r=n.nodeName.substring(i+1);pv.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(r){for(let a=0;a<r.length;a++){const o=r[a];if(o.name===t||o.uuid===t)return o;const l=n(o.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let r=t.propertyIndex;if(e||(e=dt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){He("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Qe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Qe("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){Qe("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){Qe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Qe("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){Qe("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Qe("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[i];if(a===void 0){const c=t.nodeName;Qe("PropertyBinding: Trying to update property for track: "+c+"."+i+" 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(i==="morphTargetInfluences"){if(!e.geometry){Qe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Qe("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=i;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}}dt.Composite=fv,dt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},dt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},dt.prototype.GetterByBindingType=[dt.prototype._getValue_direct,dt.prototype._getValue_array,dt.prototype._getValue_arrayElement,dt.prototype._getValue_toArray],dt.prototype.SetterByBindingTypeAndVersioning=[[dt.prototype._setValue_direct,dt.prototype._setValue_direct_setNeedsUpdate,dt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_array,dt.prototype._setValue_array_setNeedsUpdate,dt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_arrayElement,dt.prototype._setValue_arrayElement_setNeedsUpdate,dt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_fromArray,dt.prototype._setValue_fromArray_setNeedsUpdate,dt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const gf=new Ie;class Qi{constructor(e,t,n=0,i=1/0){this.ray=new Xi(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new hh,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):Qe("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return gf.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(gf),this}intersectObject(e,t=!0,n=[]){return $h(e,this,n,t),n.sort(xf),n}intersectObjects(e,t=!0,n=[]){for(let i=0,r=e.length;i<r;i++)$h(e[i],this,n,t);return n.sort(xf),n}}function xf(s,e){return s.distance-e.distance}function $h(s,e,t,n){let i=!0;if(s.layers.test(e.layers)&&s.raycast(e,t)===!1&&(i=!1),i===!0&&n===!0){const r=s.children;for(let a=0,o=r.length;a<o;a++)$h(r[a],e,t,!0)}}class Kh{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=qe(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(qe(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const vf=new P,qo=new P,Pr=new P,Rr=new P,Jh=new P,mv=new P,gv=new P;class Vn{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){vf.subVectors(e,this.start),qo.subVectors(this.end,this.start);const n=qo.dot(qo);let r=qo.dot(vf)/n;return t&&(r=qe(r,0,1)),r}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}distanceSqToLine3(e,t=mv,n=gv){const i=10000000000000001e-32;let r,a;const o=this.start,l=e.start,c=this.end,h=e.end;Pr.subVectors(c,o),Rr.subVectors(h,l),Jh.subVectors(o,l);const d=Pr.dot(Pr),p=Rr.dot(Rr),u=Rr.dot(Jh);if(d<=i&&p<=i)return t.copy(o),n.copy(l),t.sub(n),t.dot(t);if(d<=i)r=0,a=u/p,a=qe(a,0,1);else{const g=Pr.dot(Jh);if(p<=i)a=0,r=qe(-g/d,0,1);else{const f=Pr.dot(Rr),x=d*p-f*f;x!==0?r=qe((f*u-g*p)/x,0,1):r=0,a=(f*r+u)/p,a<0?(a=0,r=qe(-g/d,0,1)):a>1&&(a=1,r=qe((f-g)/d,0,1))}}return t.copy(o).add(Pr.multiplyScalar(r)),n.copy(l).add(Rr.multiplyScalar(a)),t.sub(n),t.dot(t)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}class xv extends gs{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){He("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function bf(s,e,t,n){const i=vv(n);switch(t){case Vu:return s*e;case eo:return s*e/i.components*i.byteLength;case vc:return s*e/i.components*i.byteLength;case bc:return s*e*2/i.components*i.byteLength;case yc:return s*e*2/i.components*i.byteLength;case Gu:return s*e*3/i.components*i.byteLength;case vn:return s*e*4/i.components*i.byteLength;case _c:return s*e*4/i.components*i.byteLength;case to:case no:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case io:case so:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case wc:case Ec:return Math.max(s,16)*Math.max(e,8)/4;case Mc:case Sc:return Math.max(s,8)*Math.max(e,8)/2;case Cc:case Tc:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case Ac:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Pc:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Rc:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case Lc:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case Ic:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case Dc:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case Nc:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case Bc:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case kc:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case Uc:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case Oc:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case zc:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case Fc:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case Hc:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case Vc:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case Gc:case Wc:case Xc:return Math.ceil(s/4)*Math.ceil(e/4)*16;case jc:case qc:return Math.ceil(s/4)*Math.ceil(e/4)*8;case Zc:case Yc:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function vv(s){switch(s){case $n:case Ou:return{byteLength:1,components:1};case Kr:case zu:case dn:return{byteLength:2,components:1};case gc:case xc:return{byteLength:2,components:4};case ps:case mc:case hn:return{byteLength:4,components:1};case Fu:case Hu:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${s}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Yr}})),typeof window<"u"&&(window.__THREE__?He("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Yr);function yf(){let s=null,e=!1,t=null,n=null;function i(r,a){t(r,a),n=s.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=s.requestAnimationFrame(i),e=!0)},stop:function(){s.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){s=r}}}function bv(s){const e=new WeakMap;function t(o,l){const c=o.array,h=o.usage,d=c.byteLength,p=s.createBuffer();s.bindBuffer(l,p),s.bufferData(l,c,h),o.onUploadCallback();let u;if(c instanceof Float32Array)u=s.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)u=s.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?u=s.HALF_FLOAT:u=s.UNSIGNED_SHORT;else if(c instanceof Int16Array)u=s.SHORT;else if(c instanceof Uint32Array)u=s.UNSIGNED_INT;else if(c instanceof Int32Array)u=s.INT;else if(c instanceof Int8Array)u=s.BYTE;else if(c instanceof Uint8Array)u=s.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)u=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:p,type:u,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function n(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((u,g)=>u.start-g.start);let p=0;for(let u=1;u<d.length;u++){const g=d[p],f=d[u];f.start<=g.start+g.count+1?g.count=Math.max(g.count,f.start+f.count-g.start):(++p,d[p]=f)}d.length=p+1;for(let u=0,g=d.length;u<g;u++){const f=d[u];s.bufferSubData(c,f.start*h.BYTES_PER_ELEMENT,h,f.start,f.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(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.");n(c.buffer,o,l),c.version=o.version}}return{get:i,remove:r,update:a}}var yv=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,_v=`#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`,Mv=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,wv=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,Sv=`#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`,Ev=`#ifdef USE_ALPHATEST
uniform float alphaTest;
#endif`,Cv=`#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`,Tv=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
#endif`,Av=`#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`,Pv=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,Rv=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
#endif`,Lv=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
#endif`,Iv=`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`,Dv=`#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`,Nv=`#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`,Bv=`#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`,kv=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,Uv=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
#endif`,Ov=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
#endif`,zv=`#if defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
#elif defined( USE_COLOR )
diffuseColor.rgb *= vColor;
#endif`,Fv=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR )
varying vec3 vColor;
#endif`,Hv=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec3 vColor;
#endif`,Vv=`#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`,Gv=`#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`,Wv=`#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`,Xv=`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`,jv=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
#endif`,qv=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,Zv=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,Yv=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
#endif`,$v="gl_FragColor = linearToOutputTexel( gl_FragColor );",Kv=`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 );
}`,Jv=`#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`,Qv=`#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`,eb=`#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`,tb=`#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`,nb=`#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`,ib=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
#endif`,sb=`#ifdef USE_FOG
varying float vFogDepth;
#endif`,rb=`#ifdef USE_FOG
#ifdef FOG_EXP2
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
#else
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
#endif
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif`,ab=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
uniform float fogDensity;
#else
uniform float fogNear;
uniform float fogFar;
#endif
#endif`,ob=`#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
}`,lb=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
#endif`,cb=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,hb=`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`,db=`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`,ub=`#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`,pb=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,fb=`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`,mb=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,gb=`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`,xb=`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`,vb=`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 );
}`,bb=`
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`,yb=`#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`,_b=`#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`,Mb=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,wb=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
#endif`,Sb=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
varying float vFragDepth;
varying float vIsPerspective;
#endif`,Eb=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,Cb=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
#endif`,Tb=`#ifdef USE_MAP
uniform sampler2D map;
#endif`,Ab=`#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`,Pb=`#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`,Rb=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
#endif`,Lb=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
#endif`,Ib=`#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`,Db=`#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`,Nb=`#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`,Bb=`#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`,kb=`#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`,Ub=`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;`,Ob=`#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`,zb=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,Fb=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,Hb=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
#endif
#endif`,Vb=`#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`,Gb=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,Wb=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,Xb=`#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`,jb=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
#endif`,qb=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Zb=`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 );
}`,Yb=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
#endif`,$b=`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;`,Kb=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,Jb=`#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`,Qb=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
#endif`,ey=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
#endif`,ty=`#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`,ny=`#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`,iy=`#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`,sy=`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;
}`,ry=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,ay=`#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`,oy=`#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`,ly=`#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`,cy=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
#endif`,hy=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
#endif`,dy=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,uy=`#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; }`,py=`#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`,fy=`#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`,my=`#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`,gy=`#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`,xy=`#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`,vy=`#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 et={alphahash_fragment:yv,alphahash_pars_fragment:_v,alphamap_fragment:Mv,alphamap_pars_fragment:wv,alphatest_fragment:Sv,alphatest_pars_fragment:Ev,aomap_fragment:Cv,aomap_pars_fragment:Tv,batching_pars_vertex:Av,batching_vertex:Pv,begin_vertex:Rv,beginnormal_vertex:Lv,bsdfs:Iv,iridescence_fragment:Dv,bumpmap_pars_fragment:Nv,clipping_planes_fragment:Bv,clipping_planes_pars_fragment:kv,clipping_planes_pars_vertex:Uv,clipping_planes_vertex:Ov,color_fragment:zv,color_pars_fragment:Fv,color_pars_vertex:Hv,color_vertex:Vv,common:Gv,cube_uv_reflection_fragment:Wv,defaultnormal_vertex:Xv,displacementmap_pars_vertex:jv,displacementmap_vertex:qv,emissivemap_fragment:Zv,emissivemap_pars_fragment:Yv,colorspace_fragment:$v,colorspace_pars_fragment:Kv,envmap_fragment:Jv,envmap_common_pars_fragment:Qv,envmap_pars_fragment:eb,envmap_pars_vertex:tb,envmap_physical_pars_fragment:ub,envmap_vertex:nb,fog_vertex:ib,fog_pars_vertex:sb,fog_fragment:rb,fog_pars_fragment:ab,gradientmap_pars_fragment:ob,lightmap_pars_fragment:lb,lights_lambert_fragment:cb,lights_lambert_pars_fragment:hb,lights_pars_begin:db,lights_toon_fragment:pb,lights_toon_pars_fragment:fb,lights_phong_fragment:mb,lights_phong_pars_fragment:gb,lights_physical_fragment:xb,lights_physical_pars_fragment:vb,lights_fragment_begin:bb,lights_fragment_maps:yb,lights_fragment_end:_b,logdepthbuf_fragment:Mb,logdepthbuf_pars_fragment:wb,logdepthbuf_pars_vertex:Sb,logdepthbuf_vertex:Eb,map_fragment:Cb,map_pars_fragment:Tb,map_particle_fragment:Ab,map_particle_pars_fragment:Pb,metalnessmap_fragment:Rb,metalnessmap_pars_fragment:Lb,morphinstance_vertex:Ib,morphcolor_vertex:Db,morphnormal_vertex:Nb,morphtarget_pars_vertex:Bb,morphtarget_vertex:kb,normal_fragment_begin:Ub,normal_fragment_maps:Ob,normal_pars_fragment:zb,normal_pars_vertex:Fb,normal_vertex:Hb,normalmap_pars_fragment:Vb,clearcoat_normal_fragment_begin:Gb,clearcoat_normal_fragment_maps:Wb,clearcoat_pars_fragment:Xb,iridescence_pars_fragment:jb,opaque_fragment:qb,packing:Zb,premultiplied_alpha_fragment:Yb,project_vertex:$b,dithering_fragment:Kb,dithering_pars_fragment:Jb,roughnessmap_fragment:Qb,roughnessmap_pars_fragment:ey,shadowmap_pars_fragment:ty,shadowmap_pars_vertex:ny,shadowmap_vertex:iy,shadowmask_pars_fragment:sy,skinbase_vertex:ry,skinning_pars_vertex:ay,skinning_vertex:oy,skinnormal_vertex:ly,specularmap_fragment:cy,specularmap_pars_fragment:hy,tonemapping_fragment:dy,tonemapping_pars_fragment:uy,transmission_fragment:py,transmission_pars_fragment:fy,uv_pars_fragment:my,uv_pars_vertex:gy,uv_vertex:xy,worldpos_vertex:vy,background_vert:`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,background_frag:`uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
vec4 texColor = texture2D( t2D, vUv );
#ifdef DECODE_VIDEO_TEXTURE
texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
#endif
texColor.rgb *= backgroundIntensity;
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,backgroundCube_vert:`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,backgroundCube_frag:`#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
uniform mat3 backgroundRotation;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
#ifdef ENVMAP_TYPE_CUBE
vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
#elif defined( ENVMAP_TYPE_CUBE_UV )
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
#else
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
#endif
texColor.rgb *= backgroundIntensity;
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,cube_vert:`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,cube_frag:`uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
void main() {
vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
gl_FragColor = texColor;
gl_FragColor.a *= opacity;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,depth_vert:`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec2 vHighPrecisionZW;
void main() {
#include <uv_vertex>
#include <batching_vertex>
#include <skinbase_vertex>
#include <morphinstance_vertex>
#ifdef USE_DISPLACEMENTMAP
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vHighPrecisionZW = gl_Position.zw;
}`,depth_frag:`#if DEPTH_PACKING == 3200
uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
vec4 diffuseColor = vec4( 1.0 );
#include <clipping_planes_fragment>
#if DEPTH_PACKING == 3200
diffuseColor.a = opacity;
#endif
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <logdepthbuf_fragment>
#ifdef USE_REVERSED_DEPTH_BUFFER
float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
#else
float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
#endif
#if DEPTH_PACKING == 3200
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
#elif DEPTH_PACKING == 3201
gl_FragColor = packDepthToRGBA( fragCoordZ );
#elif DEPTH_PACKING == 3202
gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
#elif DEPTH_PACKING == 3203
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
#endif
}`,distanceRGBA_vert:`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <batching_vertex>
#include <skinbase_vertex>
#include <morphinstance_vertex>
#ifdef USE_DISPLACEMENTMAP
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <worldpos_vertex>
#include <clipping_planes_vertex>
vWorldPosition = worldPosition.xyz;
}`,distanceRGBA_frag:`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <clipping_planes_pars_fragment>
void main () {
vec4 diffuseColor = vec4( 1.0 );
#include <clipping_planes_fragment>
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
float dist = length( vWorldPosition - referencePosition );
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
dist = saturate( dist );
gl_FragColor = packDepthToRGBA( dist );
}`,equirect_vert:`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}`,equirect_frag:`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
vec3 direction = normalize( vWorldDirection );
vec2 sampleUV = equirectUv( direction );
gl_FragColor = texture2D( tEquirect, sampleUV );
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,linedashed_vert:`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
vLineDistance = scale * lineDistance;
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
}`,linedashed_frag:`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
if ( mod( vLineDistance, totalSize ) > dashSize ) {
discard;
}
vec3 outgoingLight = vec3( 0.0 );
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
outgoingLight = diffuseColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}`,meshbasic_vert:`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <envmap_vertex>
#include <fog_vertex>
}`,meshbasic_frag:`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
#else
reflectedLight.indirectDiffuse += vec3( 1.0 );
#endif
#include <aomap_fragment>
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
vec3 outgoingLight = reflectedLight.indirectDiffuse;
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,meshlambert_vert:`#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,meshlambert_frag:`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_lambert_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_lambert_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,meshmatcap_vert:`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
vViewPosition = - mvPosition.xyz;
}`,meshmatcap_frag:`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
vec3 viewDir = normalize( vViewPosition );
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
vec3 y = cross( viewDir, x );
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
#ifdef USE_MATCAP
vec4 matcapColor = texture2D( matcap, uv );
#else
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
#endif
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,meshnormal_vert:`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphinstance_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
vViewPosition = - mvPosition.xyz;
#endif
}`,meshnormal_frag:`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
#include <packing>
#include <uv_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
#include <clipping_planes_fragment>
#include <logdepthbuf_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
#ifdef OPAQUE
gl_FragColor.a = 1.0;
#endif
}`,meshphong_vert:`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphinstance_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,meshphong_frag:`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_phong_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,meshphysical_vert:`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
varying vec3 vWorldPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
#ifdef USE_TRANSMISSION
vWorldPosition = worldPosition.xyz;
#endif
}`,meshphysical_frag:`#define STANDARD
#ifdef PHYSICAL
#define IOR
#define USE_SPECULAR
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef IOR
uniform float ior;
#endif
#ifdef USE_SPECULAR
uniform float specularIntensity;
uniform vec3 specularColor;
#ifdef USE_SPECULAR_COLORMAP
uniform sampler2D specularColorMap;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
uniform sampler2D specularIntensityMap;
#endif
#endif
#ifdef USE_CLEARCOAT
uniform float clearcoat;
uniform float clearcoatRoughness;
#endif
#ifdef USE_DISPERSION
uniform float dispersion;
#endif
#ifdef USE_IRIDESCENCE
uniform float iridescence;
uniform float iridescenceIOR;
uniform float iridescenceThicknessMinimum;
uniform float iridescenceThicknessMaximum;
#endif
#ifdef USE_SHEEN
uniform vec3 sheenColor;
uniform float sheenRoughness;
#ifdef USE_SHEEN_COLORMAP
uniform sampler2D sheenColorMap;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
uniform sampler2D sheenRoughnessMap;
#endif
#endif
#ifdef USE_ANISOTROPY
uniform vec2 anisotropyVector;
#ifdef USE_ANISOTROPYMAP
uniform sampler2D anisotropyMap;
#endif
#endif
varying vec3 vViewPosition;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <iridescence_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_physical_pars_fragment>
#include <transmission_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <iridescence_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <roughnessmap_fragment>
#include <metalnessmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <clearcoat_normal_fragment_begin>
#include <clearcoat_normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_physical_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
#include <transmission_fragment>
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
#ifdef USE_SHEEN
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
#endif
#ifdef USE_CLEARCOAT
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
#endif
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,meshtoon_vert:`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,meshtoon_frag:`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_toon_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,points_vert:`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
#ifdef USE_POINTS_UV
varying vec2 vUv;
uniform mat3 uvTransform;
#endif
void main() {
#ifdef USE_POINTS_UV
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
#endif
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <project_vertex>
gl_PointSize = size;
#ifdef USE_SIZEATTENUATION
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
#endif
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <fog_vertex>
}`,points_frag:`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
vec3 outgoingLight = vec3( 0.0 );
#include <logdepthbuf_fragment>
#include <map_particle_fragment>
#include <color_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
outgoingLight = diffuseColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}`,shadow_vert:`#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphinstance_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,shadow_frag:`uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <logdepthbuf_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
#include <logdepthbuf_fragment>
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
}`,sprite_vert:`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
vec4 mvPosition = modelViewMatrix[ 3 ];
vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
#ifndef USE_SIZEATTENUATION
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
if ( isPerspective ) scale *= - mvPosition.z;
#endif
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
vec2 rotatedPosition;
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
mvPosition.xy += rotatedPosition;
gl_Position = projectionMatrix * mvPosition;
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
}`,sprite_frag:`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
vec3 outgoingLight = vec3( 0.0 );
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
outgoingLight = diffuseColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
}`},Pe={common:{diffuse:{value:new Fe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new $e},alphaMap:{value:null},alphaMapTransform:{value:new $e},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new $e}},envmap:{envMap:{value:null},envMapRotation:{value:new $e},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 $e}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new $e}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new $e},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new $e},normalScale:{value:new he(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new $e},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new $e}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new $e}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new $e}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Fe(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 Fe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new $e},alphaTest:{value:0},uvTransform:{value:new $e}},sprite:{diffuse:{value:new Fe(16777215)},opacity:{value:1},center:{value:new he(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new $e},alphaMap:{value:null},alphaMapTransform:{value:new $e},alphaTest:{value:0}}},di={basic:{uniforms:un([Pe.common,Pe.specularmap,Pe.envmap,Pe.aomap,Pe.lightmap,Pe.fog]),vertexShader:et.meshbasic_vert,fragmentShader:et.meshbasic_frag},lambert:{uniforms:un([Pe.common,Pe.specularmap,Pe.envmap,Pe.aomap,Pe.lightmap,Pe.emissivemap,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,Pe.fog,Pe.lights,{emissive:{value:new Fe(0)}}]),vertexShader:et.meshlambert_vert,fragmentShader:et.meshlambert_frag},phong:{uniforms:un([Pe.common,Pe.specularmap,Pe.envmap,Pe.aomap,Pe.lightmap,Pe.emissivemap,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,Pe.fog,Pe.lights,{emissive:{value:new Fe(0)},specular:{value:new Fe(1118481)},shininess:{value:30}}]),vertexShader:et.meshphong_vert,fragmentShader:et.meshphong_frag},standard:{uniforms:un([Pe.common,Pe.envmap,Pe.aomap,Pe.lightmap,Pe.emissivemap,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,Pe.roughnessmap,Pe.metalnessmap,Pe.fog,Pe.lights,{emissive:{value:new Fe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:et.meshphysical_vert,fragmentShader:et.meshphysical_frag},toon:{uniforms:un([Pe.common,Pe.aomap,Pe.lightmap,Pe.emissivemap,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,Pe.gradientmap,Pe.fog,Pe.lights,{emissive:{value:new Fe(0)}}]),vertexShader:et.meshtoon_vert,fragmentShader:et.meshtoon_frag},matcap:{uniforms:un([Pe.common,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,Pe.fog,{matcap:{value:null}}]),vertexShader:et.meshmatcap_vert,fragmentShader:et.meshmatcap_frag},points:{uniforms:un([Pe.points,Pe.fog]),vertexShader:et.points_vert,fragmentShader:et.points_frag},dashed:{uniforms:un([Pe.common,Pe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:et.linedashed_vert,fragmentShader:et.linedashed_frag},depth:{uniforms:un([Pe.common,Pe.displacementmap]),vertexShader:et.depth_vert,fragmentShader:et.depth_frag},normal:{uniforms:un([Pe.common,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,{opacity:{value:1}}]),vertexShader:et.meshnormal_vert,fragmentShader:et.meshnormal_frag},sprite:{uniforms:un([Pe.sprite,Pe.fog]),vertexShader:et.sprite_vert,fragmentShader:et.sprite_frag},background:{uniforms:{uvTransform:{value:new $e},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:et.background_vert,fragmentShader:et.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new $e}},vertexShader:et.backgroundCube_vert,fragmentShader:et.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:et.cube_vert,fragmentShader:et.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:et.equirect_vert,fragmentShader:et.equirect_frag},distanceRGBA:{uniforms:un([Pe.common,Pe.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:et.distanceRGBA_vert,fragmentShader:et.distanceRGBA_frag},shadow:{uniforms:un([Pe.lights,Pe.fog,{color:{value:new Fe(0)},opacity:{value:1}}]),vertexShader:et.shadow_vert,fragmentShader:et.shadow_frag}};di.physical={uniforms:un([di.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new $e},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new $e},clearcoatNormalScale:{value:new he(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new $e},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new $e},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new $e},sheen:{value:0},sheenColor:{value:new Fe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new $e},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new $e},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new $e},transmissionSamplerSize:{value:new he},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new $e},attenuationDistance:{value:0},attenuationColor:{value:new Fe(0)},specularColor:{value:new Fe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new $e},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new $e},anisotropyVector:{value:new he},anisotropyMap:{value:null},anisotropyMapTransform:{value:new $e}}]),vertexShader:et.meshphysical_vert,fragmentShader:et.meshphysical_frag};const Zo={r:0,b:0,g:0},Es=new Rn,by=new Ie;function yy(s,e,t,n,i,r,a){const o=new Fe(0);let l=r===!0?0:1,c,h,d=null,p=0,u=null;function g(v){let y=v.isScene===!0?v.background:null;return y&&y.isTexture&&(y=(v.backgroundBlurriness>0?t:e).get(y)),y}function f(v){let y=!1;const _=g(v);_===null?m(o,l):_&&_.isColor&&(m(_,1),y=!0);const M=s.xr.getEnvironmentBlendMode();M==="additive"?n.buffers.color.setClear(0,0,0,1,a):M==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(s.autoClear||y)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function x(v,y){const _=g(y);_&&(_.isCubeTexture||_.mapping===Ka)?(h===void 0&&(h=new at(new Zi(1,1,1),new Lt({name:"BackgroundCubeMaterial",uniforms:ur(di.backgroundCube.uniforms),vertexShader:di.backgroundCube.vertexShader,fragmentShader:di.backgroundCube.fragmentShader,side:sn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(M,T,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(h)),Es.copy(y.backgroundRotation),Es.x*=-1,Es.y*=-1,Es.z*=-1,_.isCubeTexture&&_.isRenderTargetTexture===!1&&(Es.y*=-1,Es.z*=-1),h.material.uniforms.envMap.value=_,h.material.uniforms.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(by.makeRotationFromEuler(Es)),h.material.toneMapped=it.getTransfer(_.colorSpace)!==ct,(d!==_||p!==_.version||u!==s.toneMapping)&&(h.material.needsUpdate=!0,d=_,p=_.version,u=s.toneMapping),h.layers.enableAll(),v.unshift(h,h.geometry,h.material,0,0,null)):_&&_.isTexture&&(c===void 0&&(c=new at(new Ss(2,2),new Lt({name:"BackgroundMaterial",uniforms:ur(di.background.uniforms),vertexShader:di.background.vertexShader,fragmentShader:di.background.fragmentShader,side:kn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=_,c.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,c.material.toneMapped=it.getTransfer(_.colorSpace)!==ct,_.matrixAutoUpdate===!0&&_.updateMatrix(),c.material.uniforms.uvTransform.value.copy(_.matrix),(d!==_||p!==_.version||u!==s.toneMapping)&&(c.material.needsUpdate=!0,d=_,p=_.version,u=s.toneMapping),c.layers.enableAll(),v.unshift(c,c.geometry,c.material,0,0,null))}function m(v,y){v.getRGB(Zo,vp(s)),n.buffers.color.setClear(Zo.r,Zo.g,Zo.b,y,a)}function b(){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(v,y=1){o.set(v),l=y,m(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(v){l=v,m(o,l)},render:f,addToRenderList:x,dispose:b}}function _y(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=p(null);let r=i,a=!1;function o(E,I,A,B,S){let U=!1;const H=d(B,A,I);r!==H&&(r=H,c(r.object)),U=u(E,B,A,S),U&&g(E,B,A,S),S!==null&&e.update(S,s.ELEMENT_ARRAY_BUFFER),(U||a)&&(a=!1,y(E,I,A,B),S!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(S).buffer))}function l(){return s.createVertexArray()}function c(E){return s.bindVertexArray(E)}function h(E){return s.deleteVertexArray(E)}function d(E,I,A){const B=A.wireframe===!0;let S=n[E.id];S===void 0&&(S={},n[E.id]=S);let U=S[I.id];U===void 0&&(U={},S[I.id]=U);let H=U[B];return H===void 0&&(H=p(l()),U[B]=H),H}function p(E){const I=[],A=[],B=[];for(let S=0;S<t;S++)I[S]=0,A[S]=0,B[S]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:A,attributeDivisors:B,object:E,attributes:{},index:null}}function u(E,I,A,B){const S=r.attributes,U=I.attributes;let H=0;const G=A.getAttributes();for(const Z in G)if(G[Z].location>=0){const ie=S[Z];let X=U[Z];if(X===void 0&&(Z==="instanceMatrix"&&E.instanceMatrix&&(X=E.instanceMatrix),Z==="instanceColor"&&E.instanceColor&&(X=E.instanceColor)),ie===void 0||ie.attribute!==X||X&&ie.data!==X.data)return!0;H++}return r.attributesNum!==H||r.index!==B}function g(E,I,A,B){const S={},U=I.attributes;let H=0;const G=A.getAttributes();for(const Z in G)if(G[Z].location>=0){let ie=U[Z];ie===void 0&&(Z==="instanceMatrix"&&E.instanceMatrix&&(ie=E.instanceMatrix),Z==="instanceColor"&&E.instanceColor&&(ie=E.instanceColor));const X={};X.attribute=ie,ie&&ie.data&&(X.data=ie.data),S[Z]=X,H++}r.attributes=S,r.attributesNum=H,r.index=B}function f(){const E=r.newAttributes;for(let I=0,A=E.length;I<A;I++)E[I]=0}function x(E){m(E,0)}function m(E,I){const A=r.newAttributes,B=r.enabledAttributes,S=r.attributeDivisors;A[E]=1,B[E]===0&&(s.enableVertexAttribArray(E),B[E]=1),S[E]!==I&&(s.vertexAttribDivisor(E,I),S[E]=I)}function b(){const E=r.newAttributes,I=r.enabledAttributes;for(let A=0,B=I.length;A<B;A++)I[A]!==E[A]&&(s.disableVertexAttribArray(A),I[A]=0)}function v(E,I,A,B,S,U,H){H===!0?s.vertexAttribIPointer(E,I,A,S,U):s.vertexAttribPointer(E,I,A,B,S,U)}function y(E,I,A,B){f();const S=B.attributes,U=A.getAttributes(),H=I.defaultAttributeValues;for(const G in U){const Z=U[G];if(Z.location>=0){let j=S[G];if(j===void 0&&(G==="instanceMatrix"&&E.instanceMatrix&&(j=E.instanceMatrix),G==="instanceColor"&&E.instanceColor&&(j=E.instanceColor)),j!==void 0){const ie=j.normalized,X=j.itemSize,$=e.get(j);if($===void 0)continue;const ue=$.buffer,pe=$.type,fe=$.bytesPerElement,se=pe===s.INT||pe===s.UNSIGNED_INT||j.gpuType===mc;if(j.isInterleavedBufferAttribute){const ce=j.data,me=ce.stride,be=j.offset;if(ce.isInstancedInterleavedBuffer){for(let Se=0;Se<Z.locationSize;Se++)m(Z.location+Se,ce.meshPerAttribute);E.isInstancedMesh!==!0&&B._maxInstanceCount===void 0&&(B._maxInstanceCount=ce.meshPerAttribute*ce.count)}else for(let Se=0;Se<Z.locationSize;Se++)x(Z.location+Se);s.bindBuffer(s.ARRAY_BUFFER,ue);for(let Se=0;Se<Z.locationSize;Se++)v(Z.location+Se,X/Z.locationSize,pe,ie,me*fe,(be+X/Z.locationSize*Se)*fe,se)}else{if(j.isInstancedBufferAttribute){for(let ce=0;ce<Z.locationSize;ce++)m(Z.location+ce,j.meshPerAttribute);E.isInstancedMesh!==!0&&B._maxInstanceCount===void 0&&(B._maxInstanceCount=j.meshPerAttribute*j.count)}else for(let ce=0;ce<Z.locationSize;ce++)x(Z.location+ce);s.bindBuffer(s.ARRAY_BUFFER,ue);for(let ce=0;ce<Z.locationSize;ce++)v(Z.location+ce,X/Z.locationSize,pe,ie,X*fe,X/Z.locationSize*ce*fe,se)}}else if(H!==void 0){const ie=H[G];if(ie!==void 0)switch(ie.length){case 2:s.vertexAttrib2fv(Z.location,ie);break;case 3:s.vertexAttrib3fv(Z.location,ie);break;case 4:s.vertexAttrib4fv(Z.location,ie);break;default:s.vertexAttrib1fv(Z.location,ie)}}}}b()}function _(){R();for(const E in n){const I=n[E];for(const A in I){const B=I[A];for(const S in B)h(B[S].object),delete B[S];delete I[A]}delete n[E]}}function M(E){if(n[E.id]===void 0)return;const I=n[E.id];for(const A in I){const B=I[A];for(const S in B)h(B[S].object),delete B[S];delete I[A]}delete n[E.id]}function T(E){for(const I in n){const A=n[I];if(A[E.id]===void 0)continue;const B=A[E.id];for(const S in B)h(B[S].object),delete B[S];delete A[E.id]}}function R(){w(),a=!0,r!==i&&(r=i,c(r.object))}function w(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:R,resetDefaultState:w,dispose:_,releaseStatesOfGeometry:M,releaseStatesOfProgram:T,initAttributes:f,enableAttribute:x,disableUnusedAttributes:b}}function My(s,e,t){let n;function i(c){n=c}function r(c,h){s.drawArrays(n,c,h),t.update(h,n,1)}function a(c,h,d){d!==0&&(s.drawArraysInstanced(n,c,h,d),t.update(h,n,d))}function o(c,h,d){if(d===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,h,0,d);let u=0;for(let g=0;g<d;g++)u+=h[g];t.update(u,n,1)}function l(c,h,d,p){if(d===0)return;const u=e.get("WEBGL_multi_draw");if(u===null)for(let g=0;g<c.length;g++)a(c[g],h[g],p[g]);else{u.multiDrawArraysInstancedWEBGL(n,c,0,h,0,p,0,d);let g=0;for(let f=0;f<d;f++)g+=h[f]*p[f];t.update(g,n,1)}}this.setMode=i,this.render=r,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function wy(s,e,t,n){let i;function r(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const T=e.get("EXT_texture_filter_anisotropic");i=s.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(T){return!(T!==vn&&n.convert(T)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(T){const R=T===dn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(T!==$n&&n.convert(T)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&T!==hn&&!R)}function l(T){if(T==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="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&&(He("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const d=t.logarithmicDepthBuffer===!0,p=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),u=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),g=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),f=s.getParameter(s.MAX_TEXTURE_SIZE),x=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),m=s.getParameter(s.MAX_VERTEX_ATTRIBS),b=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),v=s.getParameter(s.MAX_VARYING_VECTORS),y=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),_=g>0,M=s.getParameter(s.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:p,maxTextures:u,maxVertexTextures:g,maxTextureSize:f,maxCubemapSize:x,maxAttributes:m,maxVertexUniforms:b,maxVaryings:v,maxFragmentUniforms:y,vertexTextures:_,maxSamples:M}}function Sy(s){const e=this;let t=null,n=0,i=!1,r=!1;const a=new It,o=new $e,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,p){const u=d.length!==0||p||n!==0||i;return i=p,n=d.length,u},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,p){t=h(d,p,0)},this.setState=function(d,p,u){const g=d.clippingPlanes,f=d.clipIntersection,x=d.clipShadows,m=s.get(d);if(!i||g===null||g.length===0||r&&!x)r?h(null):c();else{const b=r?0:n,v=b*4;let y=m.clippingState||null;l.value=y,y=h(g,p,v,u);for(let _=0;_!==v;++_)y[_]=t[_];m.clippingState=y,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(d,p,u,g){const f=d!==null?d.length:0;let x=null;if(f!==0){if(x=l.value,g!==!0||x===null){const m=u+f*4,b=p.matrixWorldInverse;o.getNormalMatrix(b),(x===null||x.length<m)&&(x=new Float32Array(m));for(let v=0,y=u;v!==f;++v,y+=4)a.copy(d[v]).applyMatrix4(b,o),a.normal.toArray(x,y),x[y+3]=a.constant}l.value=x,l.needsUpdate=!0}return e.numPlanes=f,e.numIntersection=0,x}}function Ey(s){let e=new WeakMap;function t(a,o){return o===$a?a.mapping=Ks:o===fc&&(a.mapping=Js),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===$a||o===fc)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 Xx(l.height);return c.fromEquirectangularTexture(s,a),e.set(a,c),a.addEventListener("dispose",i),t(c.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function r(){e=new WeakMap}return{get:n,dispose:r}}const es=4,_f=[.125,.215,.35,.446,.526,.582],Cs=20,Cy=256,Ea=new Ai,Mf=new Fe;let Qh=null,ed=0,td=0,nd=!1;const Ty=new P;class id{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,i=100,r={}){const{size:a=256,position:o=Ty}=r;Qh=this._renderer.getRenderTarget(),ed=this._renderer.getActiveCubeFace(),td=this._renderer.getActiveMipmapLevel(),nd=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,i,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=Ef(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Sf(),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(Qh,ed,td),this._renderer.xr.enabled=nd,e.scissorTest=!1,Lr(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Ks||e.mapping===Js?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Qh=this._renderer.getRenderTarget(),ed=this._renderer.getActiveCubeFace(),td=this._renderer.getActiveMipmapLevel(),nd=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Pt,minFilter:Pt,generateMipmaps:!1,type:dn,format:vn,colorSpace:en,depthBuffer:!1},i=wf(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=wf(e,t,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Ay(r)),this._blurMaterial=Ry(r,e,t),this._ggxMaterial=Py(r,e,t)}return i}_compileMaterial(e){const t=new at(new pt,e);this._renderer.compile(t,Ea)}_sceneToCubeUV(e,t,n,i,r){const l=new on(90,1,t,n),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],d=this._renderer,p=d.autoClear,u=d.toneMapping;d.getClearColor(Mf),d.toneMapping=Fi,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(i),d.clearDepth(),d.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new at(new Zi,new Ht({name:"PMREM.Background",side:sn,depthWrite:!1,depthTest:!1})));const f=this._backgroundBox,x=f.material;let m=!1;const b=e.background;b?b.isColor&&(x.color.copy(b),e.background=null,m=!0):(x.color.copy(Mf),m=!0);for(let v=0;v<6;v++){const y=v%3;y===0?(l.up.set(0,c[v],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x+h[v],r.y,r.z)):y===1?(l.up.set(0,0,c[v]),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y+h[v],r.z)):(l.up.set(0,c[v],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y,r.z+h[v]));const _=this._cubeSize;Lr(i,y*_,v>2?_:0,_,_),d.setRenderTarget(i),m&&d.render(f,l),d.render(e,l)}d.toneMapping=u,d.autoClear=p,e.background=b}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===Ks||e.mapping===Js;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Ef()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Sf());const r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;Lr(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,Ea)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){const i=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const l=a.uniforms,c=n/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),d=Math.sqrt(c*c-h*h),p=.05+c*.95,u=d*p,{_lodMax:g}=this,f=this._sizeLods[n],x=3*f*(n>g-es?n-g+es:0),m=4*(this._cubeSize-f);l.envMap.value=e.texture,l.roughness.value=u,l.mipInt.value=g-t,Lr(r,x,m,3*f,2*f),i.setRenderTarget(r),i.render(o,Ea),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=g-n,Lr(e,x,m,3*f,2*f),i.setRenderTarget(e),i.render(o,Ea)}_blur(e,t,n,i,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",r),this._halfBlur(a,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Qe("blur direction must be either latitudinal or longitudinal!");const h=3,d=this._lodMeshes[i];d.material=c;const p=c.uniforms,u=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*u):2*Math.PI/(2*Cs-1),f=r/g,x=isFinite(r)?1+Math.floor(h*f):Cs;x>Cs&&He(`sigmaRadians, ${r}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${Cs}`);const m=[];let b=0;for(let T=0;T<Cs;++T){const R=T/f,w=Math.exp(-R*R/2);m.push(w),T===0?b+=w:T<x&&(b+=2*w)}for(let T=0;T<m.length;T++)m[T]=m[T]/b;p.envMap.value=e.texture,p.samples.value=x,p.weights.value=m,p.latitudinal.value=a==="latitudinal",o&&(p.poleAxis.value=o);const{_lodMax:v}=this;p.dTheta.value=g,p.mipInt.value=v-n;const y=this._sizeLods[i],_=3*y*(i>v-es?i-v+es:0),M=4*(this._cubeSize-y);Lr(t,_,M,3*y,2*y),l.setRenderTarget(t),l.render(d,Ea)}}function Ay(s){const e=[],t=[],n=[];let i=s;const r=s-es+1+_f.length;for(let a=0;a<r;a++){const o=Math.pow(2,i);e.push(o);let l=1/o;a>s-es?l=_f[a-s+es-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),h=-c,d=1+c,p=[h,h,d,h,d,d,h,h,d,d,h,d],u=6,g=6,f=3,x=2,m=1,b=new Float32Array(f*g*u),v=new Float32Array(x*g*u),y=new Float32Array(m*g*u);for(let M=0;M<u;M++){const T=M%3*2/3-1,R=M>2?0:-1,w=[T,R,0,T+2/3,R,0,T+2/3,R+1,0,T,R,0,T+2/3,R+1,0,T,R+1,0];b.set(w,f*g*M),v.set(p,x*g*M);const E=[M,M,M,M,M,M];y.set(E,m*g*M)}const _=new pt;_.setAttribute("position",new bt(b,f)),_.setAttribute("uv",new bt(v,x)),_.setAttribute("faceIndex",new bt(y,m)),n.push(new at(_,null)),i>es&&i--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function wf(s,e,t){const n=new An(s,e,t);return n.texture.mapping=Ka,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Lr(s,e,t,n,i){s.viewport.set(e,t,n,i),s.scissor.set(e,t,n,i)}function Py(s,e,t){return new Lt({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Cy,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:Yo(),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:St,depthTest:!1,depthWrite:!1})}function Ry(s,e,t){const n=new Float32Array(Cs),i=new P(0,1,0);return new Lt({name:"SphericalGaussianBlur",defines:{n:Cs,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Yo(),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:St,depthTest:!1,depthWrite:!1})}function Sf(){return new Lt({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Yo(),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:St,depthTest:!1,depthWrite:!1})}function Ef(){return new Lt({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Yo(),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:St,depthTest:!1,depthWrite:!1})}function Yo(){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 Ly(s){let e=new WeakMap,t=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===$a||l===fc,h=l===Ks||l===Js;if(c||h){let d=e.get(o);const p=d!==void 0?d.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==p)return t===null&&(t=new id(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 u=o.image;return c&&u&&u.height>0||h&&u&&i(u)?(t===null&&(t=new id(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 i(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:n,dispose:a}}function Iy(s){const e={};function t(n){if(e[n]!==void 0)return e[n];const i=s.getExtension(n);return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const i=t(n);return i===null&&na("WebGLRenderer: "+n+" extension not supported."),i}}}function Dy(s,e,t,n){const i={},r=new WeakMap;function a(d){const p=d.target;p.index!==null&&e.remove(p.index);for(const g in p.attributes)e.remove(p.attributes[g]);p.removeEventListener("dispose",a),delete i[p.id];const u=r.get(p);u&&(e.remove(u),r.delete(p)),n.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,t.memory.geometries--}function o(d,p){return i[p.id]===!0||(p.addEventListener("dispose",a),i[p.id]=!0,t.memory.geometries++),p}function l(d){const p=d.attributes;for(const u in p)e.update(p[u],s.ARRAY_BUFFER)}function c(d){const p=[],u=d.index,g=d.attributes.position;let f=0;if(u!==null){const b=u.array;f=u.version;for(let v=0,y=b.length;v<y;v+=3){const _=b[v+0],M=b[v+1],T=b[v+2];p.push(_,M,M,T,T,_)}}else if(g!==void 0){const b=g.array;f=g.version;for(let v=0,y=b.length/3-1;v<y;v+=3){const _=v+0,M=v+1,T=v+2;p.push(_,M,M,T,T,_)}}else return;const x=new(Ku(p)?fp:pp)(p,1);x.version=f;const m=r.get(d);m&&e.remove(m),r.set(d,x)}function h(d){const p=r.get(d);if(p){const u=d.index;u!==null&&p.version<u.version&&c(d)}else c(d);return r.get(d)}return{get:o,update:l,getWireframeAttribute:h}}function Ny(s,e,t){let n;function i(p){n=p}let r,a;function o(p){r=p.type,a=p.bytesPerElement}function l(p,u){s.drawElements(n,u,r,p*a),t.update(u,n,1)}function c(p,u,g){g!==0&&(s.drawElementsInstanced(n,u,r,p*a,g),t.update(u,n,g))}function h(p,u,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,u,0,r,p,0,g);let x=0;for(let m=0;m<g;m++)x+=u[m];t.update(x,n,1)}function d(p,u,g,f){if(g===0)return;const x=e.get("WEBGL_multi_draw");if(x===null)for(let m=0;m<p.length;m++)c(p[m]/a,u[m],f[m]);else{x.multiDrawElementsInstancedWEBGL(n,u,0,r,p,0,f,0,g);let m=0;for(let b=0;b<g;b++)m+=u[b]*f[b];t.update(m,n,1)}}this.setMode=i,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=d}function By(s){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(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:Qe("WebGLInfo: Unknown draw mode:",a);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function ky(s,e,t){const n=new WeakMap,i=new tt;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 p=n.get(o);if(p===void 0||p.count!==d){let w=function(){T.dispose(),n.delete(o),o.removeEventListener("dispose",w)};p!==void 0&&p.texture.dispose();const u=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,f=o.morphAttributes.color!==void 0,x=o.morphAttributes.position||[],m=o.morphAttributes.normal||[],b=o.morphAttributes.color||[];let v=0;u===!0&&(v=1),g===!0&&(v=2),f===!0&&(v=3);let y=o.attributes.position.count*v,_=1;y>e.maxTextureSize&&(_=Math.ceil(y/e.maxTextureSize),y=e.maxTextureSize);const M=new Float32Array(y*_*4*d),T=new ip(M,y,_,d);T.type=hn,T.needsUpdate=!0;const R=v*4;for(let E=0;E<d;E++){const I=x[E],A=m[E],B=b[E],S=y*_*4*E;for(let U=0;U<I.count;U++){const H=U*R;u===!0&&(i.fromBufferAttribute(I,U),M[S+H+0]=i.x,M[S+H+1]=i.y,M[S+H+2]=i.z,M[S+H+3]=0),g===!0&&(i.fromBufferAttribute(A,U),M[S+H+4]=i.x,M[S+H+5]=i.y,M[S+H+6]=i.z,M[S+H+7]=0),f===!0&&(i.fromBufferAttribute(B,U),M[S+H+8]=i.x,M[S+H+9]=i.y,M[S+H+10]=i.z,M[S+H+11]=B.itemSize===4?i.w:1)}}p={count:d,texture:T,size:new he(y,_)},n.set(o,p),o.addEventListener("dispose",w)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(s,"morphTexture",a.morphTexture,t);else{let u=0;for(let f=0;f<c.length;f++)u+=c[f];const g=o.morphTargetsRelative?1:1-u;l.getUniforms().setValue(s,"morphTargetBaseInfluence",g),l.getUniforms().setValue(s,"morphTargetInfluences",c)}l.getUniforms().setValue(s,"morphTargetsTexture",p.texture,t),l.getUniforms().setValue(s,"morphTargetsTextureSize",p.size)}return{update:r}}function Uy(s,e,t,n){let i=new WeakMap;function r(l){const c=n.render.frame,h=l.geometry,d=e.get(l,h);if(i.get(d)!==c&&(e.update(d),i.set(d,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),i.get(l)!==c&&(t.update(l.instanceMatrix,s.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,s.ARRAY_BUFFER),i.set(l,c))),l.isSkinnedMesh){const p=l.skeleton;i.get(p)!==c&&(p.update(),i.set(p,c))}return d}function a(){i=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 Cf=new Ft,Tf=new Fo(1,1),Af=new ip,Pf=new Cx,Rf=new Mp,Lf=[],If=[],Df=new Float32Array(16),Nf=new Float32Array(9),Bf=new Float32Array(4);function Ir(s,e,t){const n=s[0];if(n<=0||n>0)return s;const i=e*t;let r=Lf[i];if(r===void 0&&(r=new Float32Array(i),Lf[i]=r),e!==0){n.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,s[a].toArray(r,o)}return r}function qt(s,e){if(s.length!==e.length)return!1;for(let t=0,n=s.length;t<n;t++)if(s[t]!==e[t])return!1;return!0}function Zt(s,e){for(let t=0,n=e.length;t<n;t++)s[t]=e[t]}function $o(s,e){let t=If[e];t===void 0&&(t=new Int32Array(e),If[e]=t);for(let n=0;n!==e;++n)t[n]=s.allocateTextureUnit();return t}function Oy(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function zy(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(qt(t,e))return;s.uniform2fv(this.addr,e),Zt(t,e)}}function Fy(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(qt(t,e))return;s.uniform3fv(this.addr,e),Zt(t,e)}}function Hy(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(qt(t,e))return;s.uniform4fv(this.addr,e),Zt(t,e)}}function Vy(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(qt(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),Zt(t,e)}else{if(qt(t,n))return;Bf.set(n),s.uniformMatrix2fv(this.addr,!1,Bf),Zt(t,n)}}function Gy(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(qt(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),Zt(t,e)}else{if(qt(t,n))return;Nf.set(n),s.uniformMatrix3fv(this.addr,!1,Nf),Zt(t,n)}}function Wy(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(qt(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),Zt(t,e)}else{if(qt(t,n))return;Df.set(n),s.uniformMatrix4fv(this.addr,!1,Df),Zt(t,n)}}function Xy(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function jy(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(qt(t,e))return;s.uniform2iv(this.addr,e),Zt(t,e)}}function qy(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(qt(t,e))return;s.uniform3iv(this.addr,e),Zt(t,e)}}function Zy(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(qt(t,e))return;s.uniform4iv(this.addr,e),Zt(t,e)}}function Yy(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function $y(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(qt(t,e))return;s.uniform2uiv(this.addr,e),Zt(t,e)}}function Ky(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(qt(t,e))return;s.uniform3uiv(this.addr,e),Zt(t,e)}}function Jy(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(qt(t,e))return;s.uniform4uiv(this.addr,e),Zt(t,e)}}function Qy(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);let r;this.type===s.SAMPLER_2D_SHADOW?(Tf.compareFunction=Yu,r=Tf):r=Cf,t.setTexture2D(e||r,i)}function e2(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||Pf,i)}function t2(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||Rf,i)}function n2(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||Af,i)}function i2(s){switch(s){case 5126:return Oy;case 35664:return zy;case 35665:return Fy;case 35666:return Hy;case 35674:return Vy;case 35675:return Gy;case 35676:return Wy;case 5124:case 35670:return Xy;case 35667:case 35671:return jy;case 35668:case 35672:return qy;case 35669:case 35673:return Zy;case 5125:return Yy;case 36294:return $y;case 36295:return Ky;case 36296:return Jy;case 35678:case 36198:case 36298:case 36306:case 35682:return Qy;case 35679:case 36299:case 36307:return e2;case 35680:case 36300:case 36308:case 36293:return t2;case 36289:case 36303:case 36311:case 36292:return n2}}function s2(s,e){s.uniform1fv(this.addr,e)}function r2(s,e){const t=Ir(e,this.size,2);s.uniform2fv(this.addr,t)}function a2(s,e){const t=Ir(e,this.size,3);s.uniform3fv(this.addr,t)}function o2(s,e){const t=Ir(e,this.size,4);s.uniform4fv(this.addr,t)}function l2(s,e){const t=Ir(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function c2(s,e){const t=Ir(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function h2(s,e){const t=Ir(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function d2(s,e){s.uniform1iv(this.addr,e)}function u2(s,e){s.uniform2iv(this.addr,e)}function p2(s,e){s.uniform3iv(this.addr,e)}function f2(s,e){s.uniform4iv(this.addr,e)}function m2(s,e){s.uniform1uiv(this.addr,e)}function g2(s,e){s.uniform2uiv(this.addr,e)}function x2(s,e){s.uniform3uiv(this.addr,e)}function v2(s,e){s.uniform4uiv(this.addr,e)}function b2(s,e,t){const n=this.cache,i=e.length,r=$o(t,i);qt(n,r)||(s.uniform1iv(this.addr,r),Zt(n,r));for(let a=0;a!==i;++a)t.setTexture2D(e[a]||Cf,r[a])}function y2(s,e,t){const n=this.cache,i=e.length,r=$o(t,i);qt(n,r)||(s.uniform1iv(this.addr,r),Zt(n,r));for(let a=0;a!==i;++a)t.setTexture3D(e[a]||Pf,r[a])}function _2(s,e,t){const n=this.cache,i=e.length,r=$o(t,i);qt(n,r)||(s.uniform1iv(this.addr,r),Zt(n,r));for(let a=0;a!==i;++a)t.setTextureCube(e[a]||Rf,r[a])}function M2(s,e,t){const n=this.cache,i=e.length,r=$o(t,i);qt(n,r)||(s.uniform1iv(this.addr,r),Zt(n,r));for(let a=0;a!==i;++a)t.setTexture2DArray(e[a]||Af,r[a])}function w2(s){switch(s){case 5126:return s2;case 35664:return r2;case 35665:return a2;case 35666:return o2;case 35674:return l2;case 35675:return c2;case 35676:return h2;case 5124:case 35670:return d2;case 35667:case 35671:return u2;case 35668:case 35672:return p2;case 35669:case 35673:return f2;case 5125:return m2;case 36294:return g2;case 36295:return x2;case 36296:return v2;case 35678:case 36198:case 36298:case 36306:case 35682:return b2;case 35679:case 36299:case 36307:return y2;case 35680:case 36300:case 36308:case 36293:return _2;case 36289:case 36303:case 36311:case 36292:return M2}}class S2{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=i2(t.type)}}class E2{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=w2(t.type)}}class C2{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let r=0,a=i.length;r!==a;++r){const o=i[r];o.setValue(e,t[o.id],n)}}}const sd=/(\w+)(\])?(\[|\.)?/g;function kf(s,e){s.seq.push(e),s.map[e.id]=e}function T2(s,e,t){const n=s.name,i=n.length;for(sd.lastIndex=0;;){const r=sd.exec(n),a=sd.lastIndex;let o=r[1];const l=r[2]==="]",c=r[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===i){kf(t,c===void 0?new S2(o,s,e):new E2(o,s,e));break}else{let d=t.map[o];d===void 0&&(d=new C2(o),kf(t,d)),t=d}}}class Ko{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const r=e.getActiveUniform(t,i),a=e.getUniformLocation(t,r.name);T2(r,a,this)}}setValue(e,t,n,i){const r=this.map[t];r!==void 0&&r.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,a=t.length;r!==a;++r){const o=t[r],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,r=e.length;i!==r;++i){const a=e[i];a.id in t&&n.push(a)}return n}}function Uf(s,e,t){const n=s.createShader(e);return s.shaderSource(n,t),s.compileShader(n),n}const A2=37297;let P2=0;function R2(s,e){const t=s.split(`
`),n=[],i=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=i;a<r;a++){const o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
`)}const Of=new $e;function L2(s){it._getMatrix(Of,it.workingColorSpace,s);const e=`mat3( ${Of.elements.map(t=>t.toFixed(4))} )`;switch(it.getTransfer(s)){case ao:return[e,"LinearTransferOETF"];case ct:return[e,"sRGBTransferOETF"];default:return He("WebGLProgram: Unsupported color space: ",s),[e,"LinearTransferOETF"]}}function zf(s,e,t){const n=s.getShaderParameter(e,s.COMPILE_STATUS),r=(s.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
`+r+`
`+R2(s.getShaderSource(e),o)}else return r}function I2(s,e){const t=L2(e);return[`vec4 ${s}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
`)}function D2(s,e){let t;switch(e){case Au:t="Linear";break;case Pu:t="Reinhard";break;case Ru:t="Cineon";break;case Lu:t="ACESFilmic";break;case Du:t="AgX";break;case Nu:t="Neutral";break;case Iu:t="Custom";break;default:He("WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+s+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Jo=new P;function N2(){it.getLuminanceCoefficients(Jo);const s=Jo.x.toFixed(4),e=Jo.y.toFixed(4),t=Jo.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${s}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
`)}function B2(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ca).join(`
`)}function k2(s){const e=[];for(const t in s){const n=s[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
`)}function U2(s,e){const t={},n=s.getProgramParameter(e,s.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const r=s.getActiveAttrib(e,i),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 Ca(s){return s!==""}function Ff(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 Hf(s,e){return s.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const O2=/^[ \t]*#include +<([\w\d./]+)>/gm;function rd(s){return s.replace(O2,F2)}const z2=new Map;function F2(s,e){let t=et[e];if(t===void 0){const n=z2.get(e);if(n!==void 0)t=et[n],He('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return rd(t)}const H2=/#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 Vf(s){return s.replace(H2,V2)}function V2(s,e,t,n){let i="";for(let r=parseInt(e);r<parseInt(t);r++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return i}function Gf(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 G2(s){let e="SHADOWMAP_TYPE_BASIC";return s.shadowMapType===Su?e="SHADOWMAP_TYPE_PCF":s.shadowMapType===Eu?e="SHADOWMAP_TYPE_PCF_SOFT":s.shadowMapType===vi&&(e="SHADOWMAP_TYPE_VSM"),e}function W2(s){let e="ENVMAP_TYPE_CUBE";if(s.envMap)switch(s.envMapMode){case Ks:case Js:e="ENVMAP_TYPE_CUBE";break;case Ka:e="ENVMAP_TYPE_CUBE_UV";break}return e}function X2(s){let e="ENVMAP_MODE_REFLECTION";if(s.envMap)switch(s.envMapMode){case Js:e="ENVMAP_MODE_REFRACTION";break}return e}function j2(s){let e="ENVMAP_BLENDING_NONE";if(s.envMap)switch(s.combine){case pc:e="ENVMAP_BLENDING_MULTIPLY";break;case Vg:e="ENVMAP_BLENDING_MIX";break;case Gg:e="ENVMAP_BLENDING_ADD";break}return e}function q2(s){const e=s.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function Z2(s,e,t,n){const i=s.getContext(),r=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=G2(t),c=W2(t),h=X2(t),d=j2(t),p=q2(t),u=B2(t),g=k2(r),f=i.createProgram();let x,m,b=t.glslVersion?"#version "+t.glslVersion+`
`:"";t.isRawShaderMaterial?(x=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Ca).join(`
`),x.length>0&&(x+=`
`),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Ca).join(`
`),m.length>0&&(m+=`
`)):(x=[Gf(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,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(Ca).join(`
`),m=[Gf(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+d:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Fi?"#define TONE_MAPPING":"",t.toneMapping!==Fi?et.tonemapping_pars_fragment:"",t.toneMapping!==Fi?D2("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",et.colorspace_pars_fragment,I2("linearToOutputTexel",t.outputColorSpace),N2(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
`].filter(Ca).join(`
`)),a=rd(a),a=Ff(a,t),a=Hf(a,t),o=rd(o),o=Ff(o,t),o=Hf(o,t),a=Vf(a),o=Vf(o),t.isRawShaderMaterial!==!0&&(b=`#version 300 es
`,x=[u,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+x,m=["#define varying in",t.glslVersion===$u?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===$u?"":"#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(`
`)+`
`+m);const v=b+x+a,y=b+m+o,_=Uf(i,i.VERTEX_SHADER,v),M=Uf(i,i.FRAGMENT_SHADER,y);i.attachShader(f,_),i.attachShader(f,M),t.index0AttributeName!==void 0?i.bindAttribLocation(f,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(f,0,"position"),i.linkProgram(f);function T(I){if(s.debug.checkShaderErrors){const A=i.getProgramInfoLog(f)||"",B=i.getShaderInfoLog(_)||"",S=i.getShaderInfoLog(M)||"",U=A.trim(),H=B.trim(),G=S.trim();let Z=!0,j=!0;if(i.getProgramParameter(f,i.LINK_STATUS)===!1)if(Z=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(i,f,_,M);else{const ie=zf(i,_,"vertex"),X=zf(i,M,"fragment");Qe("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(f,i.VALIDATE_STATUS)+`
Material Name: `+I.name+`
Material Type: `+I.type+`
Program Info Log: `+U+`
`+ie+`
`+X)}else U!==""?He("WebGLProgram: Program Info Log:",U):(H===""||G==="")&&(j=!1);j&&(I.diagnostics={runnable:Z,programLog:U,vertexShader:{log:H,prefix:x},fragmentShader:{log:G,prefix:m}})}i.deleteShader(_),i.deleteShader(M),R=new Ko(i,f),w=U2(i,f)}let R;this.getUniforms=function(){return R===void 0&&T(this),R};let w;this.getAttributes=function(){return w===void 0&&T(this),w};let E=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return E===!1&&(E=i.getProgramParameter(f,A2)),E},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(f),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=P2++,this.cacheKey=e,this.usedTimes=1,this.program=f,this.vertexShader=_,this.fragmentShader=M,this}let Y2=0;class $2{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(r)===!1&&(a.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new K2(e),t.set(e,n)),n}}class K2{constructor(e){this.id=Y2++,this.code=e,this.usedTimes=0}}function J2(s,e,t,n,i,r,a){const o=new hh,l=new $2,c=new Set,h=[],d=i.logarithmicDepthBuffer,p=i.vertexTextures;let u=i.precision;const g={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 f(w){return c.add(w),w===0?"uv":`uv${w}`}function x(w,E,I,A,B){const S=A.fog,U=B.geometry,H=w.isMeshStandardMaterial?A.environment:null,G=(w.isMeshStandardMaterial?t:e).get(w.envMap||H),Z=G&&G.mapping===Ka?G.image.height:null,j=g[w.type];w.precision!==null&&(u=i.getMaxPrecision(w.precision),u!==w.precision&&He("WebGLProgram.getParameters:",w.precision,"not supported, using",u,"instead."));const ie=U.morphAttributes.position||U.morphAttributes.normal||U.morphAttributes.color,X=ie!==void 0?ie.length:0;let $=0;U.morphAttributes.position!==void 0&&($=1),U.morphAttributes.normal!==void 0&&($=2),U.morphAttributes.color!==void 0&&($=3);let ue,pe,fe,se;if(j){const mt=di[j];ue=mt.vertexShader,pe=mt.fragmentShader}else ue=w.vertexShader,pe=w.fragmentShader,l.update(w),fe=l.getVertexShaderID(w),se=l.getFragmentShaderID(w);const ce=s.getRenderTarget(),me=s.state.buffers.depth.getReversed(),be=B.isInstancedMesh===!0,Se=B.isBatchedMesh===!0,Be=!!w.map,Je=!!w.matcap,ke=!!G,C=!!w.aoMap,D=!!w.lightMap,W=!!w.bumpMap,O=!!w.normalMap,k=!!w.displacementMap,F=!!w.emissiveMap,ee=!!w.metalnessMap,J=!!w.roughnessMap,q=w.anisotropy>0,N=w.clearcoat>0,L=w.dispersion>0,V=w.iridescence>0,K=w.sheen>0,le=w.transmission>0,te=q&&!!w.anisotropyMap,Te=N&&!!w.clearcoatMap,ye=N&&!!w.clearcoatNormalMap,Re=N&&!!w.clearcoatRoughnessMap,De=V&&!!w.iridescenceMap,de=V&&!!w.iridescenceThicknessMap,_e=K&&!!w.sheenColorMap,Ve=K&&!!w.sheenRoughnessMap,Ue=!!w.specularMap,Ae=!!w.specularColorMap,Ge=!!w.specularIntensityMap,Y=le&&!!w.transmissionMap,Ce=le&&!!w.thicknessMap,Me=!!w.gradientMap,we=!!w.alphaMap,ve=w.alphaTest>0,ge=!!w.alphaHash,Oe=!!w.extensions;let Ye=Fi;w.toneMapped&&(ce===null||ce.isXRRenderTarget===!0)&&(Ye=s.toneMapping);const wt={shaderID:j,shaderType:w.type,shaderName:w.name,vertexShader:ue,fragmentShader:pe,defines:w.defines,customVertexShaderID:fe,customFragmentShaderID:se,isRawShaderMaterial:w.isRawShaderMaterial===!0,glslVersion:w.glslVersion,precision:u,batching:Se,batchingColor:Se&&B._colorsTexture!==null,instancing:be,instancingColor:be&&B.instanceColor!==null,instancingMorph:be&&B.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:ce===null?s.outputColorSpace:ce.isXRRenderTarget===!0?ce.texture.colorSpace:en,alphaToCoverage:!!w.alphaToCoverage,map:Be,matcap:Je,envMap:ke,envMapMode:ke&&G.mapping,envMapCubeUVHeight:Z,aoMap:C,lightMap:D,bumpMap:W,normalMap:O,displacementMap:p&&k,emissiveMap:F,normalMapObjectSpace:O&&w.normalMapType===Yg,normalMapTangentSpace:O&&w.normalMapType===ro,metalnessMap:ee,roughnessMap:J,anisotropy:q,anisotropyMap:te,clearcoat:N,clearcoatMap:Te,clearcoatNormalMap:ye,clearcoatRoughnessMap:Re,dispersion:L,iridescence:V,iridescenceMap:De,iridescenceThicknessMap:de,sheen:K,sheenColorMap:_e,sheenRoughnessMap:Ve,specularMap:Ue,specularColorMap:Ae,specularIntensityMap:Ge,transmission:le,transmissionMap:Y,thicknessMap:Ce,gradientMap:Me,opaque:w.transparent===!1&&w.blending===Ys&&w.alphaToCoverage===!1,alphaMap:we,alphaTest:ve,alphaHash:ge,combine:w.combine,mapUv:Be&&f(w.map.channel),aoMapUv:C&&f(w.aoMap.channel),lightMapUv:D&&f(w.lightMap.channel),bumpMapUv:W&&f(w.bumpMap.channel),normalMapUv:O&&f(w.normalMap.channel),displacementMapUv:k&&f(w.displacementMap.channel),emissiveMapUv:F&&f(w.emissiveMap.channel),metalnessMapUv:ee&&f(w.metalnessMap.channel),roughnessMapUv:J&&f(w.roughnessMap.channel),anisotropyMapUv:te&&f(w.anisotropyMap.channel),clearcoatMapUv:Te&&f(w.clearcoatMap.channel),clearcoatNormalMapUv:ye&&f(w.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Re&&f(w.clearcoatRoughnessMap.channel),iridescenceMapUv:De&&f(w.iridescenceMap.channel),iridescenceThicknessMapUv:de&&f(w.iridescenceThicknessMap.channel),sheenColorMapUv:_e&&f(w.sheenColorMap.channel),sheenRoughnessMapUv:Ve&&f(w.sheenRoughnessMap.channel),specularMapUv:Ue&&f(w.specularMap.channel),specularColorMapUv:Ae&&f(w.specularColorMap.channel),specularIntensityMapUv:Ge&&f(w.specularIntensityMap.channel),transmissionMapUv:Y&&f(w.transmissionMap.channel),thicknessMapUv:Ce&&f(w.thicknessMap.channel),alphaMapUv:we&&f(w.alphaMap.channel),vertexTangents:!!U.attributes.tangent&&(O||q),vertexColors:w.vertexColors,vertexAlphas:w.vertexColors===!0&&!!U.attributes.color&&U.attributes.color.itemSize===4,pointsUvs:B.isPoints===!0&&!!U.attributes.uv&&(Be||we),fog:!!S,useFog:w.fog===!0,fogExp2:!!S&&S.isFogExp2,flatShading:w.flatShading===!0&&w.wireframe===!1,sizeAttenuation:w.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:me,skinning:B.isSkinnedMesh===!0,morphTargets:U.morphAttributes.position!==void 0,morphNormals:U.morphAttributes.normal!==void 0,morphColors:U.morphAttributes.color!==void 0,morphTargetsCount:X,morphTextureStride:$,numDirLights:E.directional.length,numPointLights:E.point.length,numSpotLights:E.spot.length,numSpotLightMaps:E.spotLightMap.length,numRectAreaLights:E.rectArea.length,numHemiLights:E.hemi.length,numDirLightShadows:E.directionalShadowMap.length,numPointLightShadows:E.pointShadowMap.length,numSpotLightShadows:E.spotShadowMap.length,numSpotLightShadowsWithMaps:E.numSpotLightShadowsWithMaps,numLightProbes:E.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:w.dithering,shadowMapEnabled:s.shadowMap.enabled&&I.length>0,shadowMapType:s.shadowMap.type,toneMapping:Ye,decodeVideoTexture:Be&&w.map.isVideoTexture===!0&&it.getTransfer(w.map.colorSpace)===ct,decodeVideoTextureEmissive:F&&w.emissiveMap.isVideoTexture===!0&&it.getTransfer(w.emissiveMap.colorSpace)===ct,premultipliedAlpha:w.premultipliedAlpha,doubleSided:w.side===yt,flipSided:w.side===sn,useDepthPacking:w.depthPacking>=0,depthPacking:w.depthPacking||0,index0AttributeName:w.index0AttributeName,extensionClipCullDistance:Oe&&w.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Oe&&w.extensions.multiDraw===!0||Se)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:w.customProgramCacheKey()};return wt.vertexUv1s=c.has(1),wt.vertexUv2s=c.has(2),wt.vertexUv3s=c.has(3),c.clear(),wt}function m(w){const E=[];if(w.shaderID?E.push(w.shaderID):(E.push(w.customVertexShaderID),E.push(w.customFragmentShaderID)),w.defines!==void 0)for(const I in w.defines)E.push(I),E.push(w.defines[I]);return w.isRawShaderMaterial===!1&&(b(E,w),v(E,w),E.push(s.outputColorSpace)),E.push(w.customProgramCacheKey),E.join()}function b(w,E){w.push(E.precision),w.push(E.outputColorSpace),w.push(E.envMapMode),w.push(E.envMapCubeUVHeight),w.push(E.mapUv),w.push(E.alphaMapUv),w.push(E.lightMapUv),w.push(E.aoMapUv),w.push(E.bumpMapUv),w.push(E.normalMapUv),w.push(E.displacementMapUv),w.push(E.emissiveMapUv),w.push(E.metalnessMapUv),w.push(E.roughnessMapUv),w.push(E.anisotropyMapUv),w.push(E.clearcoatMapUv),w.push(E.clearcoatNormalMapUv),w.push(E.clearcoatRoughnessMapUv),w.push(E.iridescenceMapUv),w.push(E.iridescenceThicknessMapUv),w.push(E.sheenColorMapUv),w.push(E.sheenRoughnessMapUv),w.push(E.specularMapUv),w.push(E.specularColorMapUv),w.push(E.specularIntensityMapUv),w.push(E.transmissionMapUv),w.push(E.thicknessMapUv),w.push(E.combine),w.push(E.fogExp2),w.push(E.sizeAttenuation),w.push(E.morphTargetsCount),w.push(E.morphAttributeCount),w.push(E.numDirLights),w.push(E.numPointLights),w.push(E.numSpotLights),w.push(E.numSpotLightMaps),w.push(E.numHemiLights),w.push(E.numRectAreaLights),w.push(E.numDirLightShadows),w.push(E.numPointLightShadows),w.push(E.numSpotLightShadows),w.push(E.numSpotLightShadowsWithMaps),w.push(E.numLightProbes),w.push(E.shadowMapType),w.push(E.toneMapping),w.push(E.numClippingPlanes),w.push(E.numClipIntersection),w.push(E.depthPacking)}function v(w,E){o.disableAll(),E.supportsVertexTextures&&o.enable(0),E.instancing&&o.enable(1),E.instancingColor&&o.enable(2),E.instancingMorph&&o.enable(3),E.matcap&&o.enable(4),E.envMap&&o.enable(5),E.normalMapObjectSpace&&o.enable(6),E.normalMapTangentSpace&&o.enable(7),E.clearcoat&&o.enable(8),E.iridescence&&o.enable(9),E.alphaTest&&o.enable(10),E.vertexColors&&o.enable(11),E.vertexAlphas&&o.enable(12),E.vertexUv1s&&o.enable(13),E.vertexUv2s&&o.enable(14),E.vertexUv3s&&o.enable(15),E.vertexTangents&&o.enable(16),E.anisotropy&&o.enable(17),E.alphaHash&&o.enable(18),E.batching&&o.enable(19),E.dispersion&&o.enable(20),E.batchingColor&&o.enable(21),E.gradientMap&&o.enable(22),w.push(o.mask),o.disableAll(),E.fog&&o.enable(0),E.useFog&&o.enable(1),E.flatShading&&o.enable(2),E.logarithmicDepthBuffer&&o.enable(3),E.reversedDepthBuffer&&o.enable(4),E.skinning&&o.enable(5),E.morphTargets&&o.enable(6),E.morphNormals&&o.enable(7),E.morphColors&&o.enable(8),E.premultipliedAlpha&&o.enable(9),E.shadowMapEnabled&&o.enable(10),E.doubleSided&&o.enable(11),E.flipSided&&o.enable(12),E.useDepthPacking&&o.enable(13),E.dithering&&o.enable(14),E.transmission&&o.enable(15),E.sheen&&o.enable(16),E.opaque&&o.enable(17),E.pointsUvs&&o.enable(18),E.decodeVideoTexture&&o.enable(19),E.decodeVideoTextureEmissive&&o.enable(20),E.alphaToCoverage&&o.enable(21),w.push(o.mask)}function y(w){const E=g[w.type];let I;if(E){const A=di[E];I=Hn.clone(A.uniforms)}else I=w.uniforms;return I}function _(w,E){let I;for(let A=0,B=h.length;A<B;A++){const S=h[A];if(S.cacheKey===E){I=S,++I.usedTimes;break}}return I===void 0&&(I=new Z2(s,E,w,r),h.push(I)),I}function M(w){if(--w.usedTimes===0){const E=h.indexOf(w);h[E]=h[h.length-1],h.pop(),w.destroy()}}function T(w){l.remove(w)}function R(){l.dispose()}return{getParameters:x,getProgramCacheKey:m,getUniforms:y,acquireProgram:_,releaseProgram:M,releaseShaderCache:T,programs:h,dispose:R}}function Q2(){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 n(a){s.delete(a)}function i(a,o,l){s.get(a)[o]=l}function r(){s=new WeakMap}return{has:e,get:t,remove:n,update:i,dispose:r}}function e3(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 Wf(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 Xf(){const s=[];let e=0;const t=[],n=[],i=[];function r(){e=0,t.length=0,n.length=0,i.length=0}function a(d,p,u,g,f,x){let m=s[e];return m===void 0?(m={id:d.id,object:d,geometry:p,material:u,groupOrder:g,renderOrder:d.renderOrder,z:f,group:x},s[e]=m):(m.id=d.id,m.object=d,m.geometry=p,m.material=u,m.groupOrder=g,m.renderOrder=d.renderOrder,m.z=f,m.group=x),e++,m}function o(d,p,u,g,f,x){const m=a(d,p,u,g,f,x);u.transmission>0?n.push(m):u.transparent===!0?i.push(m):t.push(m)}function l(d,p,u,g,f,x){const m=a(d,p,u,g,f,x);u.transmission>0?n.unshift(m):u.transparent===!0?i.unshift(m):t.unshift(m)}function c(d,p){t.length>1&&t.sort(d||e3),n.length>1&&n.sort(p||Wf),i.length>1&&i.sort(p||Wf)}function h(){for(let d=e,p=s.length;d<p;d++){const u=s[d];if(u.id===null)break;u.id=null,u.object=null,u.geometry=null,u.material=null,u.group=null}}return{opaque:t,transmissive:n,transparent:i,init:r,push:o,unshift:l,finish:h,sort:c}}function t3(){let s=new WeakMap;function e(n,i){const r=s.get(n);let a;return r===void 0?(a=new Xf,s.set(n,[a])):i>=r.length?(a=new Xf,r.push(a)):a=r[i],a}function t(){s=new WeakMap}return{get:e,dispose:t}}function n3(){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 Fe};break;case"SpotLight":t={position:new P,direction:new P,color:new Fe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new P,color:new Fe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new P,skyColor:new Fe,groundColor:new Fe};break;case"RectAreaLight":t={color:new Fe,position:new P,halfWidth:new P,halfHeight:new P};break}return s[e.id]=t,t}}}function i3(){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 he};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new he};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new he,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let s3=0;function r3(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function a3(s){const e=new n3,t=i3(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new P);const i=new P,r=new Ie,a=new Ie;function o(c){let h=0,d=0,p=0;for(let w=0;w<9;w++)n.probe[w].set(0,0,0);let u=0,g=0,f=0,x=0,m=0,b=0,v=0,y=0,_=0,M=0,T=0;c.sort(r3);for(let w=0,E=c.length;w<E;w++){const I=c[w],A=I.color,B=I.intensity,S=I.distance,U=I.shadow&&I.shadow.map?I.shadow.map.texture:null;if(I.isAmbientLight)h+=A.r*B,d+=A.g*B,p+=A.b*B;else if(I.isLightProbe){for(let H=0;H<9;H++)n.probe[H].addScaledVector(I.sh.coefficients[H],B);T++}else if(I.isDirectionalLight){const H=e.get(I);if(H.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){const G=I.shadow,Z=t.get(I);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,n.directionalShadow[u]=Z,n.directionalShadowMap[u]=U,n.directionalShadowMatrix[u]=I.shadow.matrix,b++}n.directional[u]=H,u++}else if(I.isSpotLight){const H=e.get(I);H.position.setFromMatrixPosition(I.matrixWorld),H.color.copy(A).multiplyScalar(B),H.distance=S,H.coneCos=Math.cos(I.angle),H.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),H.decay=I.decay,n.spot[f]=H;const G=I.shadow;if(I.map&&(n.spotLightMap[_]=I.map,_++,G.updateMatrices(I),I.castShadow&&M++),n.spotLightMatrix[f]=G.matrix,I.castShadow){const Z=t.get(I);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,n.spotShadow[f]=Z,n.spotShadowMap[f]=U,y++}f++}else if(I.isRectAreaLight){const H=e.get(I);H.color.copy(A).multiplyScalar(B),H.halfWidth.set(I.width*.5,0,0),H.halfHeight.set(0,I.height*.5,0),n.rectArea[x]=H,x++}else if(I.isPointLight){const H=e.get(I);if(H.color.copy(I.color).multiplyScalar(I.intensity),H.distance=I.distance,H.decay=I.decay,I.castShadow){const G=I.shadow,Z=t.get(I);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,Z.shadowCameraNear=G.camera.near,Z.shadowCameraFar=G.camera.far,n.pointShadow[g]=Z,n.pointShadowMap[g]=U,n.pointShadowMatrix[g]=I.shadow.matrix,v++}n.point[g]=H,g++}else if(I.isHemisphereLight){const H=e.get(I);H.skyColor.copy(I.color).multiplyScalar(B),H.groundColor.copy(I.groundColor).multiplyScalar(B),n.hemi[m]=H,m++}}x>0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=Pe.LTC_FLOAT_1,n.rectAreaLTC2=Pe.LTC_FLOAT_2):(n.rectAreaLTC1=Pe.LTC_HALF_1,n.rectAreaLTC2=Pe.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=p;const R=n.hash;(R.directionalLength!==u||R.pointLength!==g||R.spotLength!==f||R.rectAreaLength!==x||R.hemiLength!==m||R.numDirectionalShadows!==b||R.numPointShadows!==v||R.numSpotShadows!==y||R.numSpotMaps!==_||R.numLightProbes!==T)&&(n.directional.length=u,n.spot.length=f,n.rectArea.length=x,n.point.length=g,n.hemi.length=m,n.directionalShadow.length=b,n.directionalShadowMap.length=b,n.pointShadow.length=v,n.pointShadowMap.length=v,n.spotShadow.length=y,n.spotShadowMap.length=y,n.directionalShadowMatrix.length=b,n.pointShadowMatrix.length=v,n.spotLightMatrix.length=y+_-M,n.spotLightMap.length=_,n.numSpotLightShadowsWithMaps=M,n.numLightProbes=T,R.directionalLength=u,R.pointLength=g,R.spotLength=f,R.rectAreaLength=x,R.hemiLength=m,R.numDirectionalShadows=b,R.numPointShadows=v,R.numSpotShadows=y,R.numSpotMaps=_,R.numLightProbes=T,n.version=s3++)}function l(c,h){let d=0,p=0,u=0,g=0,f=0;const x=h.matrixWorldInverse;for(let m=0,b=c.length;m<b;m++){const v=c[m];if(v.isDirectionalLight){const y=n.directional[d];y.direction.setFromMatrixPosition(v.matrixWorld),i.setFromMatrixPosition(v.target.matrixWorld),y.direction.sub(i),y.direction.transformDirection(x),d++}else if(v.isSpotLight){const y=n.spot[u];y.position.setFromMatrixPosition(v.matrixWorld),y.position.applyMatrix4(x),y.direction.setFromMatrixPosition(v.matrixWorld),i.setFromMatrixPosition(v.target.matrixWorld),y.direction.sub(i),y.direction.transformDirection(x),u++}else if(v.isRectAreaLight){const y=n.rectArea[g];y.position.setFromMatrixPosition(v.matrixWorld),y.position.applyMatrix4(x),a.identity(),r.copy(v.matrixWorld),r.premultiply(x),a.extractRotation(r),y.halfWidth.set(v.width*.5,0,0),y.halfHeight.set(0,v.height*.5,0),y.halfWidth.applyMatrix4(a),y.halfHeight.applyMatrix4(a),g++}else if(v.isPointLight){const y=n.point[p];y.position.setFromMatrixPosition(v.matrixWorld),y.position.applyMatrix4(x),p++}else if(v.isHemisphereLight){const y=n.hemi[f];y.direction.setFromMatrixPosition(v.matrixWorld),y.direction.transformDirection(x),f++}}}return{setup:o,setupView:l,state:n}}function jf(s){const e=new a3(s),t=[],n=[];function i(h){c.camera=h,t.length=0,n.length=0}function r(h){t.push(h)}function a(h){n.push(h)}function o(){e.setup(t)}function l(h){e.setupView(t,h)}const c={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:c,setupLights:o,setupLightsView:l,pushLight:r,pushShadow:a}}function o3(s){let e=new WeakMap;function t(i,r=0){const a=e.get(i);let o;return a===void 0?(o=new jf(s),e.set(i,[o])):r>=a.length?(o=new jf(s),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const l3=`void main() {
gl_Position = vec4( position, 1.0 );
}`,c3=`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 h3(s,e,t){let n=new Rh;const i=new he,r=new he,a=new tt,o=new U1({depthPacking:Zg}),l=new O1,c={},h=t.maxTextureSize,d={[kn]:sn,[sn]:kn,[yt]:yt},p=new Lt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new he},radius:{value:4}},vertexShader:l3,fragmentShader:c3}),u=p.clone();u.defines.HORIZONTAL_PASS=1;const g=new pt;g.setAttribute("position",new bt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new at(g,p),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Su;let m=this.type;this.render=function(M,T,R){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||M.length===0)return;const w=s.getRenderTarget(),E=s.getActiveCubeFace(),I=s.getActiveMipmapLevel(),A=s.state;A.setBlending(St),A.buffers.depth.getReversed()===!0?A.buffers.color.setClear(0,0,0,0):A.buffers.color.setClear(1,1,1,1),A.buffers.depth.setTest(!0),A.setScissorTest(!1);const B=m!==vi&&this.type===vi,S=m===vi&&this.type!==vi;for(let U=0,H=M.length;U<H;U++){const G=M[U],Z=G.shadow;if(Z===void 0){He("WebGLShadowMap:",G,"has no shadow.");continue}if(Z.autoUpdate===!1&&Z.needsUpdate===!1)continue;i.copy(Z.mapSize);const j=Z.getFrameExtents();if(i.multiply(j),r.copy(Z.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(r.x=Math.floor(h/j.x),i.x=r.x*j.x,Z.mapSize.x=r.x),i.y>h&&(r.y=Math.floor(h/j.y),i.y=r.y*j.y,Z.mapSize.y=r.y)),Z.map===null||B===!0||S===!0){const X=this.type!==vi?{minFilter:Xt,magFilter:Xt}:{};Z.map!==null&&Z.map.dispose(),Z.map=new An(i.x,i.y,X),Z.map.texture.name=G.name+".shadowMap",Z.camera.updateProjectionMatrix()}s.setRenderTarget(Z.map),s.clear();const ie=Z.getViewportCount();for(let X=0;X<ie;X++){const $=Z.getViewport(X);a.set(r.x*$.x,r.y*$.y,r.x*$.z,r.y*$.w),A.viewport(a),Z.updateMatrices(G,X),n=Z.getFrustum(),y(T,R,Z.camera,G,this.type)}Z.isPointLightShadow!==!0&&this.type===vi&&b(Z,R),Z.needsUpdate=!1}m=this.type,x.needsUpdate=!1,s.setRenderTarget(w,E,I)};function b(M,T){const R=e.update(f);p.defines.VSM_SAMPLES!==M.blurSamples&&(p.defines.VSM_SAMPLES=M.blurSamples,u.defines.VSM_SAMPLES=M.blurSamples,p.needsUpdate=!0,u.needsUpdate=!0),M.mapPass===null&&(M.mapPass=new An(i.x,i.y)),p.uniforms.shadow_pass.value=M.map.texture,p.uniforms.resolution.value=M.mapSize,p.uniforms.radius.value=M.radius,s.setRenderTarget(M.mapPass),s.clear(),s.renderBufferDirect(T,null,R,p,f,null),u.uniforms.shadow_pass.value=M.mapPass.texture,u.uniforms.resolution.value=M.mapSize,u.uniforms.radius.value=M.radius,s.setRenderTarget(M.map),s.clear(),s.renderBufferDirect(T,null,R,u,f,null)}function v(M,T,R,w){let E=null;const I=R.isPointLight===!0?M.customDistanceMaterial:M.customDepthMaterial;if(I!==void 0)E=I;else if(E=R.isPointLight===!0?l:o,s.localClippingEnabled&&T.clipShadows===!0&&Array.isArray(T.clippingPlanes)&&T.clippingPlanes.length!==0||T.displacementMap&&T.displacementScale!==0||T.alphaMap&&T.alphaTest>0||T.map&&T.alphaTest>0||T.alphaToCoverage===!0){const A=E.uuid,B=T.uuid;let S=c[A];S===void 0&&(S={},c[A]=S);let U=S[B];U===void 0&&(U=E.clone(),S[B]=U,T.addEventListener("dispose",_)),E=U}if(E.visible=T.visible,E.wireframe=T.wireframe,w===vi?E.side=T.shadowSide!==null?T.shadowSide:T.side:E.side=T.shadowSide!==null?T.shadowSide:d[T.side],E.alphaMap=T.alphaMap,E.alphaTest=T.alphaToCoverage===!0?.5:T.alphaTest,E.map=T.map,E.clipShadows=T.clipShadows,E.clippingPlanes=T.clippingPlanes,E.clipIntersection=T.clipIntersection,E.displacementMap=T.displacementMap,E.displacementScale=T.displacementScale,E.displacementBias=T.displacementBias,E.wireframeLinewidth=T.wireframeLinewidth,E.linewidth=T.linewidth,R.isPointLight===!0&&E.isMeshDistanceMaterial===!0){const A=s.properties.get(E);A.light=R}return E}function y(M,T,R,w,E){if(M.visible===!1)return;if(M.layers.test(T.layers)&&(M.isMesh||M.isLine||M.isPoints)&&(M.castShadow||M.receiveShadow&&E===vi)&&(!M.frustumCulled||n.intersectsObject(M))){M.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,M.matrixWorld);const B=e.update(M),S=M.material;if(Array.isArray(S)){const U=B.groups;for(let H=0,G=U.length;H<G;H++){const Z=U[H],j=S[Z.materialIndex];if(j&&j.visible){const ie=v(M,j,w,E);M.onBeforeShadow(s,M,T,R,B,ie,Z),s.renderBufferDirect(R,null,B,ie,M,Z),M.onAfterShadow(s,M,T,R,B,ie,Z)}}}else if(S.visible){const U=v(M,S,w,E);M.onBeforeShadow(s,M,T,R,B,U,null),s.renderBufferDirect(R,null,B,U,M,null),M.onAfterShadow(s,M,T,R,B,U,null)}}const A=M.children;for(let B=0,S=A.length;B<S;B++)y(A[B],T,R,w,E)}function _(M){M.target.removeEventListener("dispose",_);for(const R in c){const w=c[R],E=M.target.uuid;E in w&&(w[E].dispose(),delete w[E])}}}const d3={[ac]:oc,[lc]:dc,[cc]:uc,[$s]:hc,[oc]:ac,[dc]:lc,[uc]:cc,[hc]:$s};function u3(s,e){function t(){let Y=!1;const Ce=new tt;let Me=null;const we=new tt(0,0,0,0);return{setMask:function(ve){Me!==ve&&!Y&&(s.colorMask(ve,ve,ve,ve),Me=ve)},setLocked:function(ve){Y=ve},setClear:function(ve,ge,Oe,Ye,wt){wt===!0&&(ve*=Ye,ge*=Ye,Oe*=Ye),Ce.set(ve,ge,Oe,Ye),we.equals(Ce)===!1&&(s.clearColor(ve,ge,Oe,Ye),we.copy(Ce))},reset:function(){Y=!1,Me=null,we.set(-1,0,0,0)}}}function n(){let Y=!1,Ce=!1,Me=null,we=null,ve=null;return{setReversed:function(ge){if(Ce!==ge){const Oe=e.get("EXT_clip_control");ge?Oe.clipControlEXT(Oe.LOWER_LEFT_EXT,Oe.ZERO_TO_ONE_EXT):Oe.clipControlEXT(Oe.LOWER_LEFT_EXT,Oe.NEGATIVE_ONE_TO_ONE_EXT),Ce=ge;const Ye=ve;ve=null,this.setClear(Ye)}},getReversed:function(){return Ce},setTest:function(ge){ge?ce(s.DEPTH_TEST):me(s.DEPTH_TEST)},setMask:function(ge){Me!==ge&&!Y&&(s.depthMask(ge),Me=ge)},setFunc:function(ge){if(Ce&&(ge=d3[ge]),we!==ge){switch(ge){case ac:s.depthFunc(s.NEVER);break;case oc:s.depthFunc(s.ALWAYS);break;case lc:s.depthFunc(s.LESS);break;case $s:s.depthFunc(s.LEQUAL);break;case cc:s.depthFunc(s.EQUAL);break;case hc:s.depthFunc(s.GEQUAL);break;case dc:s.depthFunc(s.GREATER);break;case uc:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}we=ge}},setLocked:function(ge){Y=ge},setClear:function(ge){ve!==ge&&(Ce&&(ge=1-ge),s.clearDepth(ge),ve=ge)},reset:function(){Y=!1,Me=null,we=null,ve=null,Ce=!1}}}function i(){let Y=!1,Ce=null,Me=null,we=null,ve=null,ge=null,Oe=null,Ye=null,wt=null;return{setTest:function(mt){Y||(mt?ce(s.STENCIL_TEST):me(s.STENCIL_TEST))},setMask:function(mt){Ce!==mt&&!Y&&(s.stencilMask(mt),Ce=mt)},setFunc:function(mt,gi,ri){(Me!==mt||we!==gi||ve!==ri)&&(s.stencilFunc(mt,gi,ri),Me=mt,we=gi,ve=ri)},setOp:function(mt,gi,ri){(ge!==mt||Oe!==gi||Ye!==ri)&&(s.stencilOp(mt,gi,ri),ge=mt,Oe=gi,Ye=ri)},setLocked:function(mt){Y=mt},setClear:function(mt){wt!==mt&&(s.clearStencil(mt),wt=mt)},reset:function(){Y=!1,Ce=null,Me=null,we=null,ve=null,ge=null,Oe=null,Ye=null,wt=null}}}const r=new t,a=new n,o=new i,l=new WeakMap,c=new WeakMap;let h={},d={},p=new WeakMap,u=[],g=null,f=!1,x=null,m=null,b=null,v=null,y=null,_=null,M=null,T=new Fe(0,0,0),R=0,w=!1,E=null,I=null,A=null,B=null,S=null;const U=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let H=!1,G=0;const Z=s.getParameter(s.VERSION);Z.indexOf("WebGL")!==-1?(G=parseFloat(/^WebGL (\d)/.exec(Z)[1]),H=G>=1):Z.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),H=G>=2);let j=null,ie={};const X=s.getParameter(s.SCISSOR_BOX),$=s.getParameter(s.VIEWPORT),ue=new tt().fromArray(X),pe=new tt().fromArray($);function fe(Y,Ce,Me,we){const ve=new Uint8Array(4),ge=s.createTexture();s.bindTexture(Y,ge),s.texParameteri(Y,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(Y,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let Oe=0;Oe<Me;Oe++)Y===s.TEXTURE_3D||Y===s.TEXTURE_2D_ARRAY?s.texImage3D(Ce,0,s.RGBA,1,1,we,0,s.RGBA,s.UNSIGNED_BYTE,ve):s.texImage2D(Ce+Oe,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,ve);return ge}const se={};se[s.TEXTURE_2D]=fe(s.TEXTURE_2D,s.TEXTURE_2D,1),se[s.TEXTURE_CUBE_MAP]=fe(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),se[s.TEXTURE_2D_ARRAY]=fe(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),se[s.TEXTURE_3D]=fe(s.TEXTURE_3D,s.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ce(s.DEPTH_TEST),a.setFunc($s),W(!1),O(wu),ce(s.CULL_FACE),C(St);function ce(Y){h[Y]!==!0&&(s.enable(Y),h[Y]=!0)}function me(Y){h[Y]!==!1&&(s.disable(Y),h[Y]=!1)}function be(Y,Ce){return d[Y]!==Ce?(s.bindFramebuffer(Y,Ce),d[Y]=Ce,Y===s.DRAW_FRAMEBUFFER&&(d[s.FRAMEBUFFER]=Ce),Y===s.FRAMEBUFFER&&(d[s.DRAW_FRAMEBUFFER]=Ce),!0):!1}function Se(Y,Ce){let Me=u,we=!1;if(Y){Me=p.get(Ce),Me===void 0&&(Me=[],p.set(Ce,Me));const ve=Y.textures;if(Me.length!==ve.length||Me[0]!==s.COLOR_ATTACHMENT0){for(let ge=0,Oe=ve.length;ge<Oe;ge++)Me[ge]=s.COLOR_ATTACHMENT0+ge;Me.length=ve.length,we=!0}}else Me[0]!==s.BACK&&(Me[0]=s.BACK,we=!0);we&&s.drawBuffers(Me)}function Be(Y){return g!==Y?(s.useProgram(Y),g=Y,!0):!1}const Je={[Cn]:s.FUNC_ADD,[Ag]:s.FUNC_SUBTRACT,[Pg]:s.FUNC_REVERSE_SUBTRACT};Je[Rg]=s.MIN,Je[Lg]=s.MAX;const ke={[us]:s.ZERO,[Ig]:s.ONE,[Dg]:s.SRC_COLOR,[sc]:s.SRC_ALPHA,[Ug]:s.SRC_ALPHA_SATURATE,[Ya]:s.DST_COLOR,[Za]:s.DST_ALPHA,[Ng]:s.ONE_MINUS_SRC_COLOR,[rc]:s.ONE_MINUS_SRC_ALPHA,[kg]:s.ONE_MINUS_DST_COLOR,[Bg]:s.ONE_MINUS_DST_ALPHA,[Og]:s.CONSTANT_COLOR,[zg]:s.ONE_MINUS_CONSTANT_COLOR,[Fg]:s.CONSTANT_ALPHA,[Hg]:s.ONE_MINUS_CONSTANT_ALPHA};function C(Y,Ce,Me,we,ve,ge,Oe,Ye,wt,mt){if(Y===St){f===!0&&(me(s.BLEND),f=!1);return}if(f===!1&&(ce(s.BLEND),f=!0),Y!==ic){if(Y!==x||mt!==w){if((m!==Cn||y!==Cn)&&(s.blendEquation(s.FUNC_ADD),m=Cn,y=Cn),mt)switch(Y){case Ys:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case nc:s.blendFunc(s.ONE,s.ONE);break;case Cu:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case Tu:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:Qe("WebGLState: Invalid blending: ",Y);break}else switch(Y){case Ys:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case nc:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case Cu:Qe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Tu:Qe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Qe("WebGLState: Invalid blending: ",Y);break}b=null,v=null,_=null,M=null,T.set(0,0,0),R=0,x=Y,w=mt}return}ve=ve||Ce,ge=ge||Me,Oe=Oe||we,(Ce!==m||ve!==y)&&(s.blendEquationSeparate(Je[Ce],Je[ve]),m=Ce,y=ve),(Me!==b||we!==v||ge!==_||Oe!==M)&&(s.blendFuncSeparate(ke[Me],ke[we],ke[ge],ke[Oe]),b=Me,v=we,_=ge,M=Oe),(Ye.equals(T)===!1||wt!==R)&&(s.blendColor(Ye.r,Ye.g,Ye.b,wt),T.copy(Ye),R=wt),x=Y,w=!1}function D(Y,Ce){Y.side===yt?me(s.CULL_FACE):ce(s.CULL_FACE);let Me=Y.side===sn;Ce&&(Me=!Me),W(Me),Y.blending===Ys&&Y.transparent===!1?C(St):C(Y.blending,Y.blendEquation,Y.blendSrc,Y.blendDst,Y.blendEquationAlpha,Y.blendSrcAlpha,Y.blendDstAlpha,Y.blendColor,Y.blendAlpha,Y.premultipliedAlpha),a.setFunc(Y.depthFunc),a.setTest(Y.depthTest),a.setMask(Y.depthWrite),r.setMask(Y.colorWrite);const we=Y.stencilWrite;o.setTest(we),we&&(o.setMask(Y.stencilWriteMask),o.setFunc(Y.stencilFunc,Y.stencilRef,Y.stencilFuncMask),o.setOp(Y.stencilFail,Y.stencilZFail,Y.stencilZPass)),F(Y.polygonOffset,Y.polygonOffsetFactor,Y.polygonOffsetUnits),Y.alphaToCoverage===!0?ce(s.SAMPLE_ALPHA_TO_COVERAGE):me(s.SAMPLE_ALPHA_TO_COVERAGE)}function W(Y){E!==Y&&(Y?s.frontFace(s.CW):s.frontFace(s.CCW),E=Y)}function O(Y){Y!==Cg?(ce(s.CULL_FACE),Y!==I&&(Y===wu?s.cullFace(s.BACK):Y===Tg?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):me(s.CULL_FACE),I=Y}function k(Y){Y!==A&&(H&&s.lineWidth(Y),A=Y)}function F(Y,Ce,Me){Y?(ce(s.POLYGON_OFFSET_FILL),(B!==Ce||S!==Me)&&(s.polygonOffset(Ce,Me),B=Ce,S=Me)):me(s.POLYGON_OFFSET_FILL)}function ee(Y){Y?ce(s.SCISSOR_TEST):me(s.SCISSOR_TEST)}function J(Y){Y===void 0&&(Y=s.TEXTURE0+U-1),j!==Y&&(s.activeTexture(Y),j=Y)}function q(Y,Ce,Me){Me===void 0&&(j===null?Me=s.TEXTURE0+U-1:Me=j);let we=ie[Me];we===void 0&&(we={type:void 0,texture:void 0},ie[Me]=we),(we.type!==Y||we.texture!==Ce)&&(j!==Me&&(s.activeTexture(Me),j=Me),s.bindTexture(Y,Ce||se[Y]),we.type=Y,we.texture=Ce)}function N(){const Y=ie[j];Y!==void 0&&Y.type!==void 0&&(s.bindTexture(Y.type,null),Y.type=void 0,Y.texture=void 0)}function L(){try{s.compressedTexImage2D(...arguments)}catch(Y){Y("WebGLState:",Y)}}function V(){try{s.compressedTexImage3D(...arguments)}catch(Y){Y("WebGLState:",Y)}}function K(){try{s.texSubImage2D(...arguments)}catch(Y){Y("WebGLState:",Y)}}function le(){try{s.texSubImage3D(...arguments)}catch(Y){Y("WebGLState:",Y)}}function te(){try{s.compressedTexSubImage2D(...arguments)}catch(Y){Y("WebGLState:",Y)}}function Te(){try{s.compressedTexSubImage3D(...arguments)}catch(Y){Y("WebGLState:",Y)}}function ye(){try{s.texStorage2D(...arguments)}catch(Y){Y("WebGLState:",Y)}}function Re(){try{s.texStorage3D(...arguments)}catch(Y){Y("WebGLState:",Y)}}function De(){try{s.texImage2D(...arguments)}catch(Y){Y("WebGLState:",Y)}}function de(){try{s.texImage3D(...arguments)}catch(Y){Y("WebGLState:",Y)}}function _e(Y){ue.equals(Y)===!1&&(s.scissor(Y.x,Y.y,Y.z,Y.w),ue.copy(Y))}function Ve(Y){pe.equals(Y)===!1&&(s.viewport(Y.x,Y.y,Y.z,Y.w),pe.copy(Y))}function Ue(Y,Ce){let Me=c.get(Ce);Me===void 0&&(Me=new WeakMap,c.set(Ce,Me));let we=Me.get(Y);we===void 0&&(we=s.getUniformBlockIndex(Ce,Y.name),Me.set(Y,we))}function Ae(Y,Ce){const we=c.get(Ce).get(Y);l.get(Ce)!==we&&(s.uniformBlockBinding(Ce,we,Y.__bindingPointIndex),l.set(Ce,we))}function Ge(){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={},j=null,ie={},d={},p=new WeakMap,u=[],g=null,f=!1,x=null,m=null,b=null,v=null,y=null,_=null,M=null,T=new Fe(0,0,0),R=0,w=!1,E=null,I=null,A=null,B=null,S=null,ue.set(0,0,s.canvas.width,s.canvas.height),pe.set(0,0,s.canvas.width,s.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:ce,disable:me,bindFramebuffer:be,drawBuffers:Se,useProgram:Be,setBlending:C,setMaterial:D,setFlipSided:W,setCullFace:O,setLineWidth:k,setPolygonOffset:F,setScissorTest:ee,activeTexture:J,bindTexture:q,unbindTexture:N,compressedTexImage2D:L,compressedTexImage3D:V,texImage2D:De,texImage3D:de,updateUBOMapping:Ue,uniformBlockBinding:Ae,texStorage2D:ye,texStorage3D:Re,texSubImage2D:K,texSubImage3D:le,compressedTexSubImage2D:te,compressedTexSubImage3D:Te,scissor:_e,viewport:Ve,reset:Ge}}function p3(s,e,t,n,i,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 he,h=new WeakMap;let d;const p=new WeakMap;let u=!1;try{u=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(N,L){return u?new OffscreenCanvas(N,L):ta("canvas")}function f(N,L,V){let K=1;const le=q(N);if((le.width>V||le.height>V)&&(K=V/Math.max(le.width,le.height)),K<1)if(typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&N instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&N instanceof ImageBitmap||typeof VideoFrame<"u"&&N instanceof VideoFrame){const te=Math.floor(K*le.width),Te=Math.floor(K*le.height);d===void 0&&(d=g(te,Te));const ye=L?g(te,Te):d;return ye.width=te,ye.height=Te,ye.getContext("2d").drawImage(N,0,0,te,Te),He("WebGLRenderer: Texture has been resized from ("+le.width+"x"+le.height+") to ("+te+"x"+Te+")."),ye}else return"data"in N&&He("WebGLRenderer: Image in DataTexture is too big ("+le.width+"x"+le.height+")."),N;return N}function x(N){return N.generateMipmaps}function m(N){s.generateMipmap(N)}function b(N){return N.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:N.isWebGL3DRenderTarget?s.TEXTURE_3D:N.isWebGLArrayRenderTarget||N.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function v(N,L,V,K,le=!1){if(N!==null){if(s[N]!==void 0)return s[N];He("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+N+"'")}let te=L;if(L===s.RED&&(V===s.FLOAT&&(te=s.R32F),V===s.HALF_FLOAT&&(te=s.R16F),V===s.UNSIGNED_BYTE&&(te=s.R8)),L===s.RED_INTEGER&&(V===s.UNSIGNED_BYTE&&(te=s.R8UI),V===s.UNSIGNED_SHORT&&(te=s.R16UI),V===s.UNSIGNED_INT&&(te=s.R32UI),V===s.BYTE&&(te=s.R8I),V===s.SHORT&&(te=s.R16I),V===s.INT&&(te=s.R32I)),L===s.RG&&(V===s.FLOAT&&(te=s.RG32F),V===s.HALF_FLOAT&&(te=s.RG16F),V===s.UNSIGNED_BYTE&&(te=s.RG8)),L===s.RG_INTEGER&&(V===s.UNSIGNED_BYTE&&(te=s.RG8UI),V===s.UNSIGNED_SHORT&&(te=s.RG16UI),V===s.UNSIGNED_INT&&(te=s.RG32UI),V===s.BYTE&&(te=s.RG8I),V===s.SHORT&&(te=s.RG16I),V===s.INT&&(te=s.RG32I)),L===s.RGB_INTEGER&&(V===s.UNSIGNED_BYTE&&(te=s.RGB8UI),V===s.UNSIGNED_SHORT&&(te=s.RGB16UI),V===s.UNSIGNED_INT&&(te=s.RGB32UI),V===s.BYTE&&(te=s.RGB8I),V===s.SHORT&&(te=s.RGB16I),V===s.INT&&(te=s.RGB32I)),L===s.RGBA_INTEGER&&(V===s.UNSIGNED_BYTE&&(te=s.RGBA8UI),V===s.UNSIGNED_SHORT&&(te=s.RGBA16UI),V===s.UNSIGNED_INT&&(te=s.RGBA32UI),V===s.BYTE&&(te=s.RGBA8I),V===s.SHORT&&(te=s.RGBA16I),V===s.INT&&(te=s.RGBA32I)),L===s.RGB&&(V===s.UNSIGNED_INT_5_9_9_9_REV&&(te=s.RGB9_E5),V===s.UNSIGNED_INT_10F_11F_11F_REV&&(te=s.R11F_G11F_B10F)),L===s.RGBA){const Te=le?ao:it.getTransfer(K);V===s.FLOAT&&(te=s.RGBA32F),V===s.HALF_FLOAT&&(te=s.RGBA16F),V===s.UNSIGNED_BYTE&&(te=Te===ct?s.SRGB8_ALPHA8:s.RGBA8),V===s.UNSIGNED_SHORT_4_4_4_4&&(te=s.RGBA4),V===s.UNSIGNED_SHORT_5_5_5_1&&(te=s.RGB5_A1)}return(te===s.R16F||te===s.R32F||te===s.RG16F||te===s.RG32F||te===s.RGBA16F||te===s.RGBA32F)&&e.get("EXT_color_buffer_float"),te}function y(N,L){let V;return N?L===null||L===ps||L===fs?V=s.DEPTH24_STENCIL8:L===hn?V=s.DEPTH32F_STENCIL8:L===Kr&&(V=s.DEPTH24_STENCIL8,He("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===ps||L===fs?V=s.DEPTH_COMPONENT24:L===hn?V=s.DEPTH_COMPONENT32F:L===Kr&&(V=s.DEPTH_COMPONENT16),V}function _(N,L){return x(N)===!0||N.isFramebufferTexture&&N.minFilter!==Xt&&N.minFilter!==Pt?Math.log2(Math.max(L.width,L.height))+1:N.mipmaps!==void 0&&N.mipmaps.length>0?N.mipmaps.length:N.isCompressedTexture&&Array.isArray(N.image)?L.mipmaps.length:1}function M(N){const L=N.target;L.removeEventListener("dispose",M),R(L),L.isVideoTexture&&h.delete(L)}function T(N){const L=N.target;L.removeEventListener("dispose",T),E(L)}function R(N){const L=n.get(N);if(L.__webglInit===void 0)return;const V=N.source,K=p.get(V);if(K){const le=K[L.__cacheKey];le.usedTimes--,le.usedTimes===0&&w(N),Object.keys(K).length===0&&p.delete(V)}n.remove(N)}function w(N){const L=n.get(N);s.deleteTexture(L.__webglTexture);const V=N.source,K=p.get(V);delete K[L.__cacheKey],a.memory.textures--}function E(N){const L=n.get(N);if(N.depthTexture&&(N.depthTexture.dispose(),n.remove(N.depthTexture)),N.isWebGLCubeRenderTarget)for(let K=0;K<6;K++){if(Array.isArray(L.__webglFramebuffer[K]))for(let le=0;le<L.__webglFramebuffer[K].length;le++)s.deleteFramebuffer(L.__webglFramebuffer[K][le]);else s.deleteFramebuffer(L.__webglFramebuffer[K]);L.__webglDepthbuffer&&s.deleteRenderbuffer(L.__webglDepthbuffer[K])}else{if(Array.isArray(L.__webglFramebuffer))for(let K=0;K<L.__webglFramebuffer.length;K++)s.deleteFramebuffer(L.__webglFramebuffer[K]);else s.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&s.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&s.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let K=0;K<L.__webglColorRenderbuffer.length;K++)L.__webglColorRenderbuffer[K]&&s.deleteRenderbuffer(L.__webglColorRenderbuffer[K]);L.__webglDepthRenderbuffer&&s.deleteRenderbuffer(L.__webglDepthRenderbuffer)}const V=N.textures;for(let K=0,le=V.length;K<le;K++){const te=n.get(V[K]);te.__webglTexture&&(s.deleteTexture(te.__webglTexture),a.memory.textures--),n.remove(V[K])}n.remove(N)}let I=0;function A(){I=0}function B(){const N=I;return N>=i.maxTextures&&He("WebGLTextures: Trying to use "+N+" texture units while this GPU supports only "+i.maxTextures),I+=1,N}function S(N){const L=[];return L.push(N.wrapS),L.push(N.wrapT),L.push(N.wrapR||0),L.push(N.magFilter),L.push(N.minFilter),L.push(N.anisotropy),L.push(N.internalFormat),L.push(N.format),L.push(N.type),L.push(N.generateMipmaps),L.push(N.premultiplyAlpha),L.push(N.flipY),L.push(N.unpackAlignment),L.push(N.colorSpace),L.join()}function U(N,L){const V=n.get(N);if(N.isVideoTexture&&ee(N),N.isRenderTargetTexture===!1&&N.isExternalTexture!==!0&&N.version>0&&V.__version!==N.version){const K=N.image;if(K===null)He("WebGLRenderer: Texture marked for update but no image data found.");else if(K.complete===!1)He("WebGLRenderer: Texture marked for update but image is incomplete");else{se(V,N,L);return}}else N.isExternalTexture&&(V.__webglTexture=N.sourceTexture?N.sourceTexture:null);t.bindTexture(s.TEXTURE_2D,V.__webglTexture,s.TEXTURE0+L)}function H(N,L){const V=n.get(N);if(N.isRenderTargetTexture===!1&&N.version>0&&V.__version!==N.version){se(V,N,L);return}else N.isExternalTexture&&(V.__webglTexture=N.sourceTexture?N.sourceTexture:null);t.bindTexture(s.TEXTURE_2D_ARRAY,V.__webglTexture,s.TEXTURE0+L)}function G(N,L){const V=n.get(N);if(N.isRenderTargetTexture===!1&&N.version>0&&V.__version!==N.version){se(V,N,L);return}t.bindTexture(s.TEXTURE_3D,V.__webglTexture,s.TEXTURE0+L)}function Z(N,L){const V=n.get(N);if(N.version>0&&V.__version!==N.version){ce(V,N,L);return}t.bindTexture(s.TEXTURE_CUBE_MAP,V.__webglTexture,s.TEXTURE0+L)}const j={[Tn]:s.REPEAT,[Un]:s.CLAMP_TO_EDGE,[Ja]:s.MIRRORED_REPEAT},ie={[Xt]:s.NEAREST,[Uu]:s.NEAREST_MIPMAP_NEAREST,[$r]:s.NEAREST_MIPMAP_LINEAR,[Pt]:s.LINEAR,[Qa]:s.LINEAR_MIPMAP_NEAREST,[ai]:s.LINEAR_MIPMAP_LINEAR},X={[$g]:s.NEVER,[nx]:s.ALWAYS,[Kg]:s.LESS,[Yu]:s.LEQUAL,[Jg]:s.EQUAL,[tx]:s.GEQUAL,[Qg]:s.GREATER,[ex]:s.NOTEQUAL};function $(N,L){if(L.type===hn&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===Pt||L.magFilter===Qa||L.magFilter===$r||L.magFilter===ai||L.minFilter===Pt||L.minFilter===Qa||L.minFilter===$r||L.minFilter===ai)&&He("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(N,s.TEXTURE_WRAP_S,j[L.wrapS]),s.texParameteri(N,s.TEXTURE_WRAP_T,j[L.wrapT]),(N===s.TEXTURE_3D||N===s.TEXTURE_2D_ARRAY)&&s.texParameteri(N,s.TEXTURE_WRAP_R,j[L.wrapR]),s.texParameteri(N,s.TEXTURE_MAG_FILTER,ie[L.magFilter]),s.texParameteri(N,s.TEXTURE_MIN_FILTER,ie[L.minFilter]),L.compareFunction&&(s.texParameteri(N,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(N,s.TEXTURE_COMPARE_FUNC,X[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===Xt||L.minFilter!==$r&&L.minFilter!==ai||L.type===hn&&e.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||n.get(L).__currentAnisotropy){const V=e.get("EXT_texture_filter_anisotropic");s.texParameterf(N,V.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),n.get(L).__currentAnisotropy=L.anisotropy}}}function ue(N,L){let V=!1;N.__webglInit===void 0&&(N.__webglInit=!0,L.addEventListener("dispose",M));const K=L.source;let le=p.get(K);le===void 0&&(le={},p.set(K,le));const te=S(L);if(te!==N.__cacheKey){le[te]===void 0&&(le[te]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,V=!0),le[te].usedTimes++;const Te=le[N.__cacheKey];Te!==void 0&&(le[N.__cacheKey].usedTimes--,Te.usedTimes===0&&w(L)),N.__cacheKey=te,N.__webglTexture=le[te].texture}return V}function pe(N,L,V){return Math.floor(Math.floor(N/V)/L)}function fe(N,L,V,K){const te=N.updateRanges;if(te.length===0)t.texSubImage2D(s.TEXTURE_2D,0,0,0,L.width,L.height,V,K,L.data);else{te.sort((de,_e)=>de.start-_e.start);let Te=0;for(let de=1;de<te.length;de++){const _e=te[Te],Ve=te[de],Ue=_e.start+_e.count,Ae=pe(Ve.start,L.width,4),Ge=pe(_e.start,L.width,4);Ve.start<=Ue+1&&Ae===Ge&&pe(Ve.start+Ve.count-1,L.width,4)===Ae?_e.count=Math.max(_e.count,Ve.start+Ve.count-_e.start):(++Te,te[Te]=Ve)}te.length=Te+1;const ye=s.getParameter(s.UNPACK_ROW_LENGTH),Re=s.getParameter(s.UNPACK_SKIP_PIXELS),De=s.getParameter(s.UNPACK_SKIP_ROWS);s.pixelStorei(s.UNPACK_ROW_LENGTH,L.width);for(let de=0,_e=te.length;de<_e;de++){const Ve=te[de],Ue=Math.floor(Ve.start/4),Ae=Math.ceil(Ve.count/4),Ge=Ue%L.width,Y=Math.floor(Ue/L.width),Ce=Ae,Me=1;s.pixelStorei(s.UNPACK_SKIP_PIXELS,Ge),s.pixelStorei(s.UNPACK_SKIP_ROWS,Y),t.texSubImage2D(s.TEXTURE_2D,0,Ge,Y,Ce,Me,V,K,L.data)}N.clearUpdateRanges(),s.pixelStorei(s.UNPACK_ROW_LENGTH,ye),s.pixelStorei(s.UNPACK_SKIP_PIXELS,Re),s.pixelStorei(s.UNPACK_SKIP_ROWS,De)}}function se(N,L,V){let K=s.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(K=s.TEXTURE_2D_ARRAY),L.isData3DTexture&&(K=s.TEXTURE_3D);const le=ue(N,L),te=L.source;t.bindTexture(K,N.__webglTexture,s.TEXTURE0+V);const Te=n.get(te);if(te.version!==Te.__version||le===!0){t.activeTexture(s.TEXTURE0+V);const ye=it.getPrimaries(it.workingColorSpace),Re=L.colorSpace===Hi?null:it.getPrimaries(L.colorSpace),De=L.colorSpace===Hi||ye===Re?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,L.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,L.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,De);let de=f(L.image,!1,i.maxTextureSize);de=J(L,de);const _e=r.convert(L.format,L.colorSpace),Ve=r.convert(L.type);let Ue=v(L.internalFormat,_e,Ve,L.colorSpace,L.isVideoTexture);$(K,L);let Ae;const Ge=L.mipmaps,Y=L.isVideoTexture!==!0,Ce=Te.__version===void 0||le===!0,Me=te.dataReady,we=_(L,de);if(L.isDepthTexture)Ue=y(L.format===ms,L.type),Ce&&(Y?t.texStorage2D(s.TEXTURE_2D,1,Ue,de.width,de.height):t.texImage2D(s.TEXTURE_2D,0,Ue,de.width,de.height,0,_e,Ve,null));else if(L.isDataTexture)if(Ge.length>0){Y&&Ce&&t.texStorage2D(s.TEXTURE_2D,we,Ue,Ge[0].width,Ge[0].height);for(let ve=0,ge=Ge.length;ve<ge;ve++)Ae=Ge[ve],Y?Me&&t.texSubImage2D(s.TEXTURE_2D,ve,0,0,Ae.width,Ae.height,_e,Ve,Ae.data):t.texImage2D(s.TEXTURE_2D,ve,Ue,Ae.width,Ae.height,0,_e,Ve,Ae.data);L.generateMipmaps=!1}else Y?(Ce&&t.texStorage2D(s.TEXTURE_2D,we,Ue,de.width,de.height),Me&&fe(L,de,_e,Ve)):t.texImage2D(s.TEXTURE_2D,0,Ue,de.width,de.height,0,_e,Ve,de.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){Y&&Ce&&t.texStorage3D(s.TEXTURE_2D_ARRAY,we,Ue,Ge[0].width,Ge[0].height,de.depth);for(let ve=0,ge=Ge.length;ve<ge;ve++)if(Ae=Ge[ve],L.format!==vn)if(_e!==null)if(Y){if(Me)if(L.layerUpdates.size>0){const Oe=bf(Ae.width,Ae.height,L.format,L.type);for(const Ye of L.layerUpdates){const wt=Ae.data.subarray(Ye*Oe/Ae.data.BYTES_PER_ELEMENT,(Ye+1)*Oe/Ae.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,ve,0,0,Ye,Ae.width,Ae.height,1,_e,wt)}L.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,ve,0,0,0,Ae.width,Ae.height,de.depth,_e,Ae.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,ve,Ue,Ae.width,Ae.height,de.depth,0,Ae.data,0,0);else He("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Y?Me&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,ve,0,0,0,Ae.width,Ae.height,de.depth,_e,Ve,Ae.data):t.texImage3D(s.TEXTURE_2D_ARRAY,ve,Ue,Ae.width,Ae.height,de.depth,0,_e,Ve,Ae.data)}else{Y&&Ce&&t.texStorage2D(s.TEXTURE_2D,we,Ue,Ge[0].width,Ge[0].height);for(let ve=0,ge=Ge.length;ve<ge;ve++)Ae=Ge[ve],L.format!==vn?_e!==null?Y?Me&&t.compressedTexSubImage2D(s.TEXTURE_2D,ve,0,0,Ae.width,Ae.height,_e,Ae.data):t.compressedTexImage2D(s.TEXTURE_2D,ve,Ue,Ae.width,Ae.height,0,Ae.data):He("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Y?Me&&t.texSubImage2D(s.TEXTURE_2D,ve,0,0,Ae.width,Ae.height,_e,Ve,Ae.data):t.texImage2D(s.TEXTURE_2D,ve,Ue,Ae.width,Ae.height,0,_e,Ve,Ae.data)}else if(L.isDataArrayTexture)if(Y){if(Ce&&t.texStorage3D(s.TEXTURE_2D_ARRAY,we,Ue,de.width,de.height,de.depth),Me)if(L.layerUpdates.size>0){const ve=bf(de.width,de.height,L.format,L.type);for(const ge of L.layerUpdates){const Oe=de.data.subarray(ge*ve/de.data.BYTES_PER_ELEMENT,(ge+1)*ve/de.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,ge,de.width,de.height,1,_e,Ve,Oe)}L.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,de.width,de.height,de.depth,_e,Ve,de.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,Ue,de.width,de.height,de.depth,0,_e,Ve,de.data);else if(L.isData3DTexture)Y?(Ce&&t.texStorage3D(s.TEXTURE_3D,we,Ue,de.width,de.height,de.depth),Me&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,de.width,de.height,de.depth,_e,Ve,de.data)):t.texImage3D(s.TEXTURE_3D,0,Ue,de.width,de.height,de.depth,0,_e,Ve,de.data);else if(L.isFramebufferTexture){if(Ce)if(Y)t.texStorage2D(s.TEXTURE_2D,we,Ue,de.width,de.height);else{let ve=de.width,ge=de.height;for(let Oe=0;Oe<we;Oe++)t.texImage2D(s.TEXTURE_2D,Oe,Ue,ve,ge,0,_e,Ve,null),ve>>=1,ge>>=1}}else if(Ge.length>0){if(Y&&Ce){const ve=q(Ge[0]);t.texStorage2D(s.TEXTURE_2D,we,Ue,ve.width,ve.height)}for(let ve=0,ge=Ge.length;ve<ge;ve++)Ae=Ge[ve],Y?Me&&t.texSubImage2D(s.TEXTURE_2D,ve,0,0,_e,Ve,Ae):t.texImage2D(s.TEXTURE_2D,ve,Ue,_e,Ve,Ae);L.generateMipmaps=!1}else if(Y){if(Ce){const ve=q(de);t.texStorage2D(s.TEXTURE_2D,we,Ue,ve.width,ve.height)}Me&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,_e,Ve,de)}else t.texImage2D(s.TEXTURE_2D,0,Ue,_e,Ve,de);x(L)&&m(K),Te.__version=te.version,L.onUpdate&&L.onUpdate(L)}N.__version=L.version}function ce(N,L,V){if(L.image.length!==6)return;const K=ue(N,L),le=L.source;t.bindTexture(s.TEXTURE_CUBE_MAP,N.__webglTexture,s.TEXTURE0+V);const te=n.get(le);if(le.version!==te.__version||K===!0){t.activeTexture(s.TEXTURE0+V);const Te=it.getPrimaries(it.workingColorSpace),ye=L.colorSpace===Hi?null:it.getPrimaries(L.colorSpace),Re=L.colorSpace===Hi||Te===ye?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,L.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,L.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Re);const De=L.isCompressedTexture||L.image[0].isCompressedTexture,de=L.image[0]&&L.image[0].isDataTexture,_e=[];for(let ge=0;ge<6;ge++)!De&&!de?_e[ge]=f(L.image[ge],!0,i.maxCubemapSize):_e[ge]=de?L.image[ge].image:L.image[ge],_e[ge]=J(L,_e[ge]);const Ve=_e[0],Ue=r.convert(L.format,L.colorSpace),Ae=r.convert(L.type),Ge=v(L.internalFormat,Ue,Ae,L.colorSpace),Y=L.isVideoTexture!==!0,Ce=te.__version===void 0||K===!0,Me=le.dataReady;let we=_(L,Ve);$(s.TEXTURE_CUBE_MAP,L);let ve;if(De){Y&&Ce&&t.texStorage2D(s.TEXTURE_CUBE_MAP,we,Ge,Ve.width,Ve.height);for(let ge=0;ge<6;ge++){ve=_e[ge].mipmaps;for(let Oe=0;Oe<ve.length;Oe++){const Ye=ve[Oe];L.format!==vn?Ue!==null?Y?Me&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Oe,0,0,Ye.width,Ye.height,Ue,Ye.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Oe,Ge,Ye.width,Ye.height,0,Ye.data):He("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Y?Me&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Oe,0,0,Ye.width,Ye.height,Ue,Ae,Ye.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Oe,Ge,Ye.width,Ye.height,0,Ue,Ae,Ye.data)}}}else{if(ve=L.mipmaps,Y&&Ce){ve.length>0&&we++;const ge=q(_e[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,we,Ge,ge.width,ge.height)}for(let ge=0;ge<6;ge++)if(de){Y?Me&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ge,0,0,0,_e[ge].width,_e[ge].height,Ue,Ae,_e[ge].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ge,0,Ge,_e[ge].width,_e[ge].height,0,Ue,Ae,_e[ge].data);for(let Oe=0;Oe<ve.length;Oe++){const wt=ve[Oe].image[ge].image;Y?Me&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Oe+1,0,0,wt.width,wt.height,Ue,Ae,wt.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Oe+1,Ge,wt.width,wt.height,0,Ue,Ae,wt.data)}}else{Y?Me&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ge,0,0,0,Ue,Ae,_e[ge]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ge,0,Ge,Ue,Ae,_e[ge]);for(let Oe=0;Oe<ve.length;Oe++){const Ye=ve[Oe];Y?Me&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Oe+1,0,0,Ue,Ae,Ye.image[ge]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Oe+1,Ge,Ue,Ae,Ye.image[ge])}}}x(L)&&m(s.TEXTURE_CUBE_MAP),te.__version=le.version,L.onUpdate&&L.onUpdate(L)}N.__version=L.version}function me(N,L,V,K,le,te){const Te=r.convert(V.format,V.colorSpace),ye=r.convert(V.type),Re=v(V.internalFormat,Te,ye,V.colorSpace),De=n.get(L),de=n.get(V);if(de.__renderTarget=L,!De.__hasExternalTextures){const _e=Math.max(1,L.width>>te),Ve=Math.max(1,L.height>>te);le===s.TEXTURE_3D||le===s.TEXTURE_2D_ARRAY?t.texImage3D(le,te,Re,_e,Ve,L.depth,0,Te,ye,null):t.texImage2D(le,te,Re,_e,Ve,0,Te,ye,null)}t.bindFramebuffer(s.FRAMEBUFFER,N),F(L)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,K,le,de.__webglTexture,0,k(L)):(le===s.TEXTURE_2D||le>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&le<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,K,le,de.__webglTexture,te),t.bindFramebuffer(s.FRAMEBUFFER,null)}function be(N,L,V){if(s.bindRenderbuffer(s.RENDERBUFFER,N),L.depthBuffer){const K=L.depthTexture,le=K&&K.isDepthTexture?K.type:null,te=y(L.stencilBuffer,le),Te=L.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,ye=k(L);F(L)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,ye,te,L.width,L.height):V?s.renderbufferStorageMultisample(s.RENDERBUFFER,ye,te,L.width,L.height):s.renderbufferStorage(s.RENDERBUFFER,te,L.width,L.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,Te,s.RENDERBUFFER,N)}else{const K=L.textures;for(let le=0;le<K.length;le++){const te=K[le],Te=r.convert(te.format,te.colorSpace),ye=r.convert(te.type),Re=v(te.internalFormat,Te,ye,te.colorSpace),De=k(L);V&&F(L)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,De,Re,L.width,L.height):F(L)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,De,Re,L.width,L.height):s.renderbufferStorage(s.RENDERBUFFER,Re,L.width,L.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function Se(N,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(s.FRAMEBUFFER,N),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const K=n.get(L.depthTexture);K.__renderTarget=L,(!K.__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),U(L.depthTexture,0);const le=K.__webglTexture,te=k(L);if(L.depthTexture.format===Jr)F(L)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,le,0,te):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,le,0);else if(L.depthTexture.format===ms)F(L)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,le,0,te):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,le,0);else throw new Error("Unknown depthTexture format")}function Be(N){const L=n.get(N),V=N.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==N.depthTexture){const K=N.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),K){const le=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,K.removeEventListener("dispose",le)};K.addEventListener("dispose",le),L.__depthDisposeCallback=le}L.__boundDepthTexture=K}if(N.depthTexture&&!L.__autoAllocateDepthBuffer){if(V)throw new Error("target.depthTexture not supported in Cube render targets");const K=N.texture.mipmaps;K&&K.length>0?Se(L.__webglFramebuffer[0],N):Se(L.__webglFramebuffer,N)}else if(V){L.__webglDepthbuffer=[];for(let K=0;K<6;K++)if(t.bindFramebuffer(s.FRAMEBUFFER,L.__webglFramebuffer[K]),L.__webglDepthbuffer[K]===void 0)L.__webglDepthbuffer[K]=s.createRenderbuffer(),be(L.__webglDepthbuffer[K],N,!1);else{const le=N.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,te=L.__webglDepthbuffer[K];s.bindRenderbuffer(s.RENDERBUFFER,te),s.framebufferRenderbuffer(s.FRAMEBUFFER,le,s.RENDERBUFFER,te)}}else{const K=N.texture.mipmaps;if(K&&K.length>0?t.bindFramebuffer(s.FRAMEBUFFER,L.__webglFramebuffer[0]):t.bindFramebuffer(s.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=s.createRenderbuffer(),be(L.__webglDepthbuffer,N,!1);else{const le=N.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,te=L.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,te),s.framebufferRenderbuffer(s.FRAMEBUFFER,le,s.RENDERBUFFER,te)}}t.bindFramebuffer(s.FRAMEBUFFER,null)}function Je(N,L,V){const K=n.get(N);L!==void 0&&me(K.__webglFramebuffer,N,N.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),V!==void 0&&Be(N)}function ke(N){const L=N.texture,V=n.get(N),K=n.get(L);N.addEventListener("dispose",T);const le=N.textures,te=N.isWebGLCubeRenderTarget===!0,Te=le.length>1;if(Te||(K.__webglTexture===void 0&&(K.__webglTexture=s.createTexture()),K.__version=L.version,a.memory.textures++),te){V.__webglFramebuffer=[];for(let ye=0;ye<6;ye++)if(L.mipmaps&&L.mipmaps.length>0){V.__webglFramebuffer[ye]=[];for(let Re=0;Re<L.mipmaps.length;Re++)V.__webglFramebuffer[ye][Re]=s.createFramebuffer()}else V.__webglFramebuffer[ye]=s.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){V.__webglFramebuffer=[];for(let ye=0;ye<L.mipmaps.length;ye++)V.__webglFramebuffer[ye]=s.createFramebuffer()}else V.__webglFramebuffer=s.createFramebuffer();if(Te)for(let ye=0,Re=le.length;ye<Re;ye++){const De=n.get(le[ye]);De.__webglTexture===void 0&&(De.__webglTexture=s.createTexture(),a.memory.textures++)}if(N.samples>0&&F(N)===!1){V.__webglMultisampledFramebuffer=s.createFramebuffer(),V.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,V.__webglMultisampledFramebuffer);for(let ye=0;ye<le.length;ye++){const Re=le[ye];V.__webglColorRenderbuffer[ye]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,V.__webglColorRenderbuffer[ye]);const De=r.convert(Re.format,Re.colorSpace),de=r.convert(Re.type),_e=v(Re.internalFormat,De,de,Re.colorSpace,N.isXRRenderTarget===!0),Ve=k(N);s.renderbufferStorageMultisample(s.RENDERBUFFER,Ve,_e,N.width,N.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+ye,s.RENDERBUFFER,V.__webglColorRenderbuffer[ye])}s.bindRenderbuffer(s.RENDERBUFFER,null),N.depthBuffer&&(V.__webglDepthRenderbuffer=s.createRenderbuffer(),be(V.__webglDepthRenderbuffer,N,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(te){t.bindTexture(s.TEXTURE_CUBE_MAP,K.__webglTexture),$(s.TEXTURE_CUBE_MAP,L);for(let ye=0;ye<6;ye++)if(L.mipmaps&&L.mipmaps.length>0)for(let Re=0;Re<L.mipmaps.length;Re++)me(V.__webglFramebuffer[ye][Re],N,L,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Re);else me(V.__webglFramebuffer[ye],N,L,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0);x(L)&&m(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Te){for(let ye=0,Re=le.length;ye<Re;ye++){const De=le[ye],de=n.get(De);let _e=s.TEXTURE_2D;(N.isWebGL3DRenderTarget||N.isWebGLArrayRenderTarget)&&(_e=N.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(_e,de.__webglTexture),$(_e,De),me(V.__webglFramebuffer,N,De,s.COLOR_ATTACHMENT0+ye,_e,0),x(De)&&m(_e)}t.unbindTexture()}else{let ye=s.TEXTURE_2D;if((N.isWebGL3DRenderTarget||N.isWebGLArrayRenderTarget)&&(ye=N.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(ye,K.__webglTexture),$(ye,L),L.mipmaps&&L.mipmaps.length>0)for(let Re=0;Re<L.mipmaps.length;Re++)me(V.__webglFramebuffer[Re],N,L,s.COLOR_ATTACHMENT0,ye,Re);else me(V.__webglFramebuffer,N,L,s.COLOR_ATTACHMENT0,ye,0);x(L)&&m(ye),t.unbindTexture()}N.depthBuffer&&Be(N)}function C(N){const L=N.textures;for(let V=0,K=L.length;V<K;V++){const le=L[V];if(x(le)){const te=b(N),Te=n.get(le).__webglTexture;t.bindTexture(te,Te),m(te),t.unbindTexture()}}}const D=[],W=[];function O(N){if(N.samples>0){if(F(N)===!1){const L=N.textures,V=N.width,K=N.height;let le=s.COLOR_BUFFER_BIT;const te=N.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Te=n.get(N),ye=L.length>1;if(ye)for(let De=0;De<L.length;De++)t.bindFramebuffer(s.FRAMEBUFFER,Te.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+De,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,Te.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+De,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,Te.__webglMultisampledFramebuffer);const Re=N.texture.mipmaps;Re&&Re.length>0?t.bindFramebuffer(s.DRAW_FRAMEBUFFER,Te.__webglFramebuffer[0]):t.bindFramebuffer(s.DRAW_FRAMEBUFFER,Te.__webglFramebuffer);for(let De=0;De<L.length;De++){if(N.resolveDepthBuffer&&(N.depthBuffer&&(le|=s.DEPTH_BUFFER_BIT),N.stencilBuffer&&N.resolveStencilBuffer&&(le|=s.STENCIL_BUFFER_BIT)),ye){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,Te.__webglColorRenderbuffer[De]);const de=n.get(L[De]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,de,0)}s.blitFramebuffer(0,0,V,K,0,0,V,K,le,s.NEAREST),l===!0&&(D.length=0,W.length=0,D.push(s.COLOR_ATTACHMENT0+De),N.depthBuffer&&N.resolveDepthBuffer===!1&&(D.push(te),W.push(te),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,W)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,D))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),ye)for(let De=0;De<L.length;De++){t.bindFramebuffer(s.FRAMEBUFFER,Te.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+De,s.RENDERBUFFER,Te.__webglColorRenderbuffer[De]);const de=n.get(L[De]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,Te.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+De,s.TEXTURE_2D,de,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,Te.__webglMultisampledFramebuffer)}else if(N.depthBuffer&&N.resolveDepthBuffer===!1&&l){const L=N.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[L])}}}function k(N){return Math.min(i.maxSamples,N.samples)}function F(N){const L=n.get(N);return N.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function ee(N){const L=a.render.frame;h.get(N)!==L&&(h.set(N,L),N.update())}function J(N,L){const V=N.colorSpace,K=N.format,le=N.type;return N.isCompressedTexture===!0||N.isVideoTexture===!0||V!==en&&V!==Hi&&(it.getTransfer(V)===ct?(K!==vn||le!==$n)&&He("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Qe("WebGLTextures: Unsupported texture color space:",V)),L}function q(N){return typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement?(c.width=N.naturalWidth||N.width,c.height=N.naturalHeight||N.height):typeof VideoFrame<"u"&&N instanceof VideoFrame?(c.width=N.displayWidth,c.height=N.displayHeight):(c.width=N.width,c.height=N.height),c}this.allocateTextureUnit=B,this.resetTextureUnits=A,this.setTexture2D=U,this.setTexture2DArray=H,this.setTexture3D=G,this.setTextureCube=Z,this.rebindTextures=Je,this.setupRenderTarget=ke,this.updateRenderTargetMipmap=C,this.updateMultisampleRenderTarget=O,this.setupDepthRenderbuffer=Be,this.setupFrameBufferTexture=me,this.useMultisampledRTT=F}function f3(s,e){function t(n,i=Hi){let r;const a=it.getTransfer(i);if(n===$n)return s.UNSIGNED_BYTE;if(n===gc)return s.UNSIGNED_SHORT_4_4_4_4;if(n===xc)return s.UNSIGNED_SHORT_5_5_5_1;if(n===Fu)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===Hu)return s.UNSIGNED_INT_10F_11F_11F_REV;if(n===Ou)return s.BYTE;if(n===zu)return s.SHORT;if(n===Kr)return s.UNSIGNED_SHORT;if(n===mc)return s.INT;if(n===ps)return s.UNSIGNED_INT;if(n===hn)return s.FLOAT;if(n===dn)return s.HALF_FLOAT;if(n===Vu)return s.ALPHA;if(n===Gu)return s.RGB;if(n===vn)return s.RGBA;if(n===Jr)return s.DEPTH_COMPONENT;if(n===ms)return s.DEPTH_STENCIL;if(n===eo)return s.RED;if(n===vc)return s.RED_INTEGER;if(n===bc)return s.RG;if(n===yc)return s.RG_INTEGER;if(n===_c)return s.RGBA_INTEGER;if(n===to||n===no||n===io||n===so)if(a===ct)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===to)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===no)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===io)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===so)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===to)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===no)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===io)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===so)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Mc||n===wc||n===Sc||n===Ec)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Mc)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===wc)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Sc)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Ec)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Cc||n===Tc||n===Ac)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Cc||n===Tc)return a===ct?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Ac)return a===ct?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Pc||n===Rc||n===Lc||n===Ic||n===Dc||n===Nc||n===Bc||n===kc||n===Uc||n===Oc||n===zc||n===Fc||n===Hc||n===Vc)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Pc)return a===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Rc)return a===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Lc)return a===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Ic)return a===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Dc)return a===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Nc)return a===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Bc)return a===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===kc)return a===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Uc)return a===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Oc)return a===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===zc)return a===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Fc)return a===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Hc)return a===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Vc)return a===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Gc||n===Wc||n===Xc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===Gc)return a===ct?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Wc)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Xc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===jc||n===qc||n===Zc||n===Yc)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===jc)return r.COMPRESSED_RED_RGTC1_EXT;if(n===qc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Zc)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Yc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===fs?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:t}}const m3=`
void main() {
gl_Position = vec4( position, 1.0 );
}`,g3=`
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 x3{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new jp(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Lt({vertexShader:m3,fragmentShader:g3,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new at(new Ss(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class v3 extends gs{constructor(e,t){super();const n=this;let i=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,d=null,p=null,u=null,g=null;const f=typeof XRWebGLBinding<"u",x=new x3,m={},b=t.getContextAttributes();let v=null,y=null;const _=[],M=[],T=new he;let R=null;const w=new on;w.viewport=new tt;const E=new on;E.viewport=new tt;const I=[w,E],A=new rv;let B=null,S=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(se){let ce=_[se];return ce===void 0&&(ce=new Mh,_[se]=ce),ce.getTargetRaySpace()},this.getControllerGrip=function(se){let ce=_[se];return ce===void 0&&(ce=new Mh,_[se]=ce),ce.getGripSpace()},this.getHand=function(se){let ce=_[se];return ce===void 0&&(ce=new Mh,_[se]=ce),ce.getHandSpace()};function U(se){const ce=M.indexOf(se.inputSource);if(ce===-1)return;const me=_[ce];me!==void 0&&(me.update(se.inputSource,se.frame,c||a),me.dispatchEvent({type:se.type,data:se.inputSource}))}function H(){i.removeEventListener("select",U),i.removeEventListener("selectstart",U),i.removeEventListener("selectend",U),i.removeEventListener("squeeze",U),i.removeEventListener("squeezestart",U),i.removeEventListener("squeezeend",U),i.removeEventListener("end",H),i.removeEventListener("inputsourceschange",G);for(let se=0;se<_.length;se++){const ce=M[se];ce!==null&&(M[se]=null,_[se].disconnect(ce))}B=null,S=null,x.reset();for(const se in m)delete m[se];e.setRenderTarget(v),u=null,p=null,d=null,i=null,y=null,fe.stop(),n.isPresenting=!1,e.setPixelRatio(R),e.setSize(T.width,T.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(se){r=se,n.isPresenting===!0&&He("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(se){o=se,n.isPresenting===!0&&He("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(se){c=se},this.getBaseLayer=function(){return p!==null?p:u},this.getBinding=function(){return d===null&&f&&(d=new XRWebGLBinding(i,t)),d},this.getFrame=function(){return g},this.getSession=function(){return i},this.setSession=async function(se){if(i=se,i!==null){if(v=e.getRenderTarget(),i.addEventListener("select",U),i.addEventListener("selectstart",U),i.addEventListener("selectend",U),i.addEventListener("squeeze",U),i.addEventListener("squeezestart",U),i.addEventListener("squeezeend",U),i.addEventListener("end",H),i.addEventListener("inputsourceschange",G),b.xrCompatible!==!0&&await t.makeXRCompatible(),R=e.getPixelRatio(),e.getSize(T),f&&"createProjectionLayer"in XRWebGLBinding.prototype){let me=null,be=null,Se=null;b.depth&&(Se=b.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,me=b.stencil?ms:Jr,be=b.stencil?fs:ps);const Be={colorFormat:t.RGBA8,depthFormat:Se,scaleFactor:r};d=this.getBinding(),p=d.createProjectionLayer(Be),i.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),y=new An(p.textureWidth,p.textureHeight,{format:vn,type:$n,depthTexture:new Fo(p.textureWidth,p.textureHeight,be,void 0,void 0,void 0,void 0,void 0,void 0,me),stencilBuffer:b.stencil,colorSpace:e.outputColorSpace,samples:b.antialias?4:0,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}else{const me={antialias:b.antialias,alpha:!0,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:r};u=new XRWebGLLayer(i,t,me),i.updateRenderState({baseLayer:u}),e.setPixelRatio(1),e.setSize(u.framebufferWidth,u.framebufferHeight,!1),y=new An(u.framebufferWidth,u.framebufferHeight,{format:vn,type:$n,colorSpace:e.outputColorSpace,stencilBuffer:b.stencil,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await i.requestReferenceSpace(o),fe.setContext(i),fe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function G(se){for(let ce=0;ce<se.removed.length;ce++){const me=se.removed[ce],be=M.indexOf(me);be>=0&&(M[be]=null,_[be].disconnect(me))}for(let ce=0;ce<se.added.length;ce++){const me=se.added[ce];let be=M.indexOf(me);if(be===-1){for(let Be=0;Be<_.length;Be++)if(Be>=M.length){M.push(me),be=Be;break}else if(M[Be]===null){M[Be]=me,be=Be;break}if(be===-1)break}const Se=_[be];Se&&Se.connect(me)}}const Z=new P,j=new P;function ie(se,ce,me){Z.setFromMatrixPosition(ce.matrixWorld),j.setFromMatrixPosition(me.matrixWorld);const be=Z.distanceTo(j),Se=ce.projectionMatrix.elements,Be=me.projectionMatrix.elements,Je=Se[14]/(Se[10]-1),ke=Se[14]/(Se[10]+1),C=(Se[9]+1)/Se[5],D=(Se[9]-1)/Se[5],W=(Se[8]-1)/Se[0],O=(Be[8]+1)/Be[0],k=Je*W,F=Je*O,ee=be/(-W+O),J=ee*-W;if(ce.matrixWorld.decompose(se.position,se.quaternion,se.scale),se.translateX(J),se.translateZ(ee),se.matrixWorld.compose(se.position,se.quaternion,se.scale),se.matrixWorldInverse.copy(se.matrixWorld).invert(),Se[10]===-1)se.projectionMatrix.copy(ce.projectionMatrix),se.projectionMatrixInverse.copy(ce.projectionMatrixInverse);else{const q=Je+ee,N=ke+ee,L=k-J,V=F+(be-J),K=C*ke/N*q,le=D*ke/N*q;se.projectionMatrix.makePerspective(L,V,K,le,q,N),se.projectionMatrixInverse.copy(se.projectionMatrix).invert()}}function X(se,ce){ce===null?se.matrixWorld.copy(se.matrix):se.matrixWorld.multiplyMatrices(ce.matrixWorld,se.matrix),se.matrixWorldInverse.copy(se.matrixWorld).invert()}this.updateCamera=function(se){if(i===null)return;let ce=se.near,me=se.far;x.texture!==null&&(x.depthNear>0&&(ce=x.depthNear),x.depthFar>0&&(me=x.depthFar)),A.near=E.near=w.near=ce,A.far=E.far=w.far=me,(B!==A.near||S!==A.far)&&(i.updateRenderState({depthNear:A.near,depthFar:A.far}),B=A.near,S=A.far),A.layers.mask=se.layers.mask|6,w.layers.mask=A.layers.mask&3,E.layers.mask=A.layers.mask&5;const be=se.parent,Se=A.cameras;X(A,be);for(let Be=0;Be<Se.length;Be++)X(Se[Be],be);Se.length===2?ie(A,w,E):A.projectionMatrix.copy(w.projectionMatrix),$(se,A,be)};function $(se,ce,me){me===null?se.matrix.copy(ce.matrixWorld):(se.matrix.copy(me.matrixWorld),se.matrix.invert(),se.matrix.multiply(ce.matrixWorld)),se.matrix.decompose(se.position,se.quaternion,se.scale),se.updateMatrixWorld(!0),se.projectionMatrix.copy(ce.projectionMatrix),se.projectionMatrixInverse.copy(ce.projectionMatrixInverse),se.isPerspectiveCamera&&(se.fov=er*2*Math.atan(1/se.projectionMatrix.elements[5]),se.zoom=1)}this.getCamera=function(){return A},this.getFoveation=function(){if(!(p===null&&u===null))return l},this.setFoveation=function(se){l=se,p!==null&&(p.fixedFoveation=se),u!==null&&u.fixedFoveation!==void 0&&(u.fixedFoveation=se)},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(A)},this.getCameraTexture=function(se){return m[se]};let ue=null;function pe(se,ce){if(h=ce.getViewerPose(c||a),g=ce,h!==null){const me=h.views;u!==null&&(e.setRenderTargetFramebuffer(y,u.framebuffer),e.setRenderTarget(y));let be=!1;me.length!==A.cameras.length&&(A.cameras.length=0,be=!0);for(let ke=0;ke<me.length;ke++){const C=me[ke];let D=null;if(u!==null)D=u.getViewport(C);else{const O=d.getViewSubImage(p,C);D=O.viewport,ke===0&&(e.setRenderTargetTextures(y,O.colorTexture,O.depthStencilTexture),e.setRenderTarget(y))}let W=I[ke];W===void 0&&(W=new on,W.layers.enable(ke),W.viewport=new tt,I[ke]=W),W.matrix.fromArray(C.transform.matrix),W.matrix.decompose(W.position,W.quaternion,W.scale),W.projectionMatrix.fromArray(C.projectionMatrix),W.projectionMatrixInverse.copy(W.projectionMatrix).invert(),W.viewport.set(D.x,D.y,D.width,D.height),ke===0&&(A.matrix.copy(W.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),be===!0&&A.cameras.push(W)}const Se=i.enabledFeatures;if(Se&&Se.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&f){d=n.getBinding();const ke=d.getDepthInformation(me[0]);ke&&ke.isValid&&ke.texture&&x.init(ke,i.renderState)}if(Se&&Se.includes("camera-access")&&f){e.state.unbindTexture(),d=n.getBinding();for(let ke=0;ke<me.length;ke++){const C=me[ke].camera;if(C){let D=m[C];D||(D=new jp,m[C]=D);const W=d.getCameraImage(C);D.sourceTexture=W}}}}for(let me=0;me<_.length;me++){const be=M[me],Se=_[me];be!==null&&Se!==void 0&&Se.update(be,ce,c||a)}ue&&ue(se,ce),ce.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ce}),g=null}const fe=new yf;fe.setAnimationLoop(pe),this.setAnimationLoop=function(se){ue=se},this.dispose=function(){}}}const Ts=new Rn,b3=new Ie;function y3(s,e){function t(x,m){x.matrixAutoUpdate===!0&&x.updateMatrix(),m.value.copy(x.matrix)}function n(x,m){m.color.getRGB(x.fogColor.value,vp(s)),m.isFog?(x.fogNear.value=m.near,x.fogFar.value=m.far):m.isFogExp2&&(x.fogDensity.value=m.density)}function i(x,m,b,v,y){m.isMeshBasicMaterial||m.isMeshLambertMaterial?r(x,m):m.isMeshToonMaterial?(r(x,m),d(x,m)):m.isMeshPhongMaterial?(r(x,m),h(x,m)):m.isMeshStandardMaterial?(r(x,m),p(x,m),m.isMeshPhysicalMaterial&&u(x,m,y)):m.isMeshMatcapMaterial?(r(x,m),g(x,m)):m.isMeshDepthMaterial?r(x,m):m.isMeshDistanceMaterial?(r(x,m),f(x,m)):m.isMeshNormalMaterial?r(x,m):m.isLineBasicMaterial?(a(x,m),m.isLineDashedMaterial&&o(x,m)):m.isPointsMaterial?l(x,m,b,v):m.isSpriteMaterial?c(x,m):m.isShadowMaterial?(x.color.value.copy(m.color),x.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function r(x,m){x.opacity.value=m.opacity,m.color&&x.diffuse.value.copy(m.color),m.emissive&&x.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(x.map.value=m.map,t(m.map,x.mapTransform)),m.alphaMap&&(x.alphaMap.value=m.alphaMap,t(m.alphaMap,x.alphaMapTransform)),m.bumpMap&&(x.bumpMap.value=m.bumpMap,t(m.bumpMap,x.bumpMapTransform),x.bumpScale.value=m.bumpScale,m.side===sn&&(x.bumpScale.value*=-1)),m.normalMap&&(x.normalMap.value=m.normalMap,t(m.normalMap,x.normalMapTransform),x.normalScale.value.copy(m.normalScale),m.side===sn&&x.normalScale.value.negate()),m.displacementMap&&(x.displacementMap.value=m.displacementMap,t(m.displacementMap,x.displacementMapTransform),x.displacementScale.value=m.displacementScale,x.displacementBias.value=m.displacementBias),m.emissiveMap&&(x.emissiveMap.value=m.emissiveMap,t(m.emissiveMap,x.emissiveMapTransform)),m.specularMap&&(x.specularMap.value=m.specularMap,t(m.specularMap,x.specularMapTransform)),m.alphaTest>0&&(x.alphaTest.value=m.alphaTest);const b=e.get(m),v=b.envMap,y=b.envMapRotation;v&&(x.envMap.value=v,Ts.copy(y),Ts.x*=-1,Ts.y*=-1,Ts.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(Ts.y*=-1,Ts.z*=-1),x.envMapRotation.value.setFromMatrix4(b3.makeRotationFromEuler(Ts)),x.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,x.reflectivity.value=m.reflectivity,x.ior.value=m.ior,x.refractionRatio.value=m.refractionRatio),m.lightMap&&(x.lightMap.value=m.lightMap,x.lightMapIntensity.value=m.lightMapIntensity,t(m.lightMap,x.lightMapTransform)),m.aoMap&&(x.aoMap.value=m.aoMap,x.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,x.aoMapTransform))}function a(x,m){x.diffuse.value.copy(m.color),x.opacity.value=m.opacity,m.map&&(x.map.value=m.map,t(m.map,x.mapTransform))}function o(x,m){x.dashSize.value=m.dashSize,x.totalSize.value=m.dashSize+m.gapSize,x.scale.value=m.scale}function l(x,m,b,v){x.diffuse.value.copy(m.color),x.opacity.value=m.opacity,x.size.value=m.size*b,x.scale.value=v*.5,m.map&&(x.map.value=m.map,t(m.map,x.uvTransform)),m.alphaMap&&(x.alphaMap.value=m.alphaMap,t(m.alphaMap,x.alphaMapTransform)),m.alphaTest>0&&(x.alphaTest.value=m.alphaTest)}function c(x,m){x.diffuse.value.copy(m.color),x.opacity.value=m.opacity,x.rotation.value=m.rotation,m.map&&(x.map.value=m.map,t(m.map,x.mapTransform)),m.alphaMap&&(x.alphaMap.value=m.alphaMap,t(m.alphaMap,x.alphaMapTransform)),m.alphaTest>0&&(x.alphaTest.value=m.alphaTest)}function h(x,m){x.specular.value.copy(m.specular),x.shininess.value=Math.max(m.shininess,1e-4)}function d(x,m){m.gradientMap&&(x.gradientMap.value=m.gradientMap)}function p(x,m){x.metalness.value=m.metalness,m.metalnessMap&&(x.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,x.metalnessMapTransform)),x.roughness.value=m.roughness,m.roughnessMap&&(x.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,x.roughnessMapTransform)),m.envMap&&(x.envMapIntensity.value=m.envMapIntensity)}function u(x,m,b){x.ior.value=m.ior,m.sheen>0&&(x.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),x.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(x.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,x.sheenColorMapTransform)),m.sheenRoughnessMap&&(x.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,x.sheenRoughnessMapTransform))),m.clearcoat>0&&(x.clearcoat.value=m.clearcoat,x.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(x.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,x.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(x.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,x.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(x.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,x.clearcoatNormalMapTransform),x.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===sn&&x.clearcoatNormalScale.value.negate())),m.dispersion>0&&(x.dispersion.value=m.dispersion),m.iridescence>0&&(x.iridescence.value=m.iridescence,x.iridescenceIOR.value=m.iridescenceIOR,x.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],x.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(x.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,x.iridescenceMapTransform)),m.iridescenceThicknessMap&&(x.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,x.iridescenceThicknessMapTransform))),m.transmission>0&&(x.transmission.value=m.transmission,x.transmissionSamplerMap.value=b.texture,x.transmissionSamplerSize.value.set(b.width,b.height),m.transmissionMap&&(x.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,x.transmissionMapTransform)),x.thickness.value=m.thickness,m.thicknessMap&&(x.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,x.thicknessMapTransform)),x.attenuationDistance.value=m.attenuationDistance,x.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(x.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(x.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,x.anisotropyMapTransform))),x.specularIntensity.value=m.specularIntensity,x.specularColor.value.copy(m.specularColor),m.specularColorMap&&(x.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,x.specularColorMapTransform)),m.specularIntensityMap&&(x.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,x.specularIntensityMapTransform))}function g(x,m){m.matcap&&(x.matcap.value=m.matcap)}function f(x,m){const b=e.get(m).light;x.referencePosition.value.setFromMatrixPosition(b.matrixWorld),x.nearDistance.value=b.shadow.camera.near,x.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function _3(s,e,t,n){let i={},r={},a=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function l(b,v){const y=v.program;n.uniformBlockBinding(b,y)}function c(b,v){let y=i[b.id];y===void 0&&(g(b),y=h(b),i[b.id]=y,b.addEventListener("dispose",x));const _=v.program;n.updateUBOMapping(b,_);const M=e.render.frame;r[b.id]!==M&&(p(b),r[b.id]=M)}function h(b){const v=d();b.__bindingPointIndex=v;const y=s.createBuffer(),_=b.__size,M=b.usage;return s.bindBuffer(s.UNIFORM_BUFFER,y),s.bufferData(s.UNIFORM_BUFFER,_,M),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,v,y),y}function d(){for(let b=0;b<o;b++)if(a.indexOf(b)===-1)return a.push(b),b;return Qe("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(b){const v=i[b.id],y=b.uniforms,_=b.__cache;s.bindBuffer(s.UNIFORM_BUFFER,v);for(let M=0,T=y.length;M<T;M++){const R=Array.isArray(y[M])?y[M]:[y[M]];for(let w=0,E=R.length;w<E;w++){const I=R[w];if(u(I,M,w,_)===!0){const A=I.__offset,B=Array.isArray(I.value)?I.value:[I.value];let S=0;for(let U=0;U<B.length;U++){const H=B[U],G=f(H);typeof H=="number"||typeof H=="boolean"?(I.__data[0]=H,s.bufferSubData(s.UNIFORM_BUFFER,A+S,I.__data)):H.isMatrix3?(I.__data[0]=H.elements[0],I.__data[1]=H.elements[1],I.__data[2]=H.elements[2],I.__data[3]=0,I.__data[4]=H.elements[3],I.__data[5]=H.elements[4],I.__data[6]=H.elements[5],I.__data[7]=0,I.__data[8]=H.elements[6],I.__data[9]=H.elements[7],I.__data[10]=H.elements[8],I.__data[11]=0):(H.toArray(I.__data,S),S+=G.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,A,I.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function u(b,v,y,_){const M=b.value,T=v+"_"+y;if(_[T]===void 0)return typeof M=="number"||typeof M=="boolean"?_[T]=M:_[T]=M.clone(),!0;{const R=_[T];if(typeof M=="number"||typeof M=="boolean"){if(R!==M)return _[T]=M,!0}else if(R.equals(M)===!1)return R.copy(M),!0}return!1}function g(b){const v=b.uniforms;let y=0;const _=16;for(let T=0,R=v.length;T<R;T++){const w=Array.isArray(v[T])?v[T]:[v[T]];for(let E=0,I=w.length;E<I;E++){const A=w[E],B=Array.isArray(A.value)?A.value:[A.value];for(let S=0,U=B.length;S<U;S++){const H=B[S],G=f(H),Z=y%_,j=Z%G.boundary,ie=Z+j;y+=j,ie!==0&&_-ie<G.storage&&(y+=_-ie),A.__data=new Float32Array(G.storage/Float32Array.BYTES_PER_ELEMENT),A.__offset=y,y+=G.storage}}}const M=y%_;return M>0&&(y+=_-M),b.__size=y,b.__cache={},this}function f(b){const v={boundary:0,storage:0};return typeof b=="number"||typeof b=="boolean"?(v.boundary=4,v.storage=4):b.isVector2?(v.boundary=8,v.storage=8):b.isVector3||b.isColor?(v.boundary=16,v.storage=12):b.isVector4?(v.boundary=16,v.storage=16):b.isMatrix3?(v.boundary=48,v.storage=48):b.isMatrix4?(v.boundary=64,v.storage=64):b.isTexture?He("WebGLRenderer: Texture samplers can not be part of an uniforms group."):He("WebGLRenderer: Unsupported uniform value type.",b),v}function x(b){const v=b.target;v.removeEventListener("dispose",x);const y=a.indexOf(v.__bindingPointIndex);a.splice(y,1),s.deleteBuffer(i[v.id]),delete i[v.id],delete r[v.id]}function m(){for(const b in i)s.deleteBuffer(i[b]);a=[],i={},r={}}return{bind:l,update:c,dispose:m}}const M3=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 Ri=null;function w3(){return Ri===null&&(Ri=new ys(M3,32,32,bc,dn),Ri.minFilter=Pt,Ri.magFilter=Pt,Ri.wrapS=Un,Ri.wrapT=Un,Ri.generateMipmaps=!1,Ri.needsUpdate=!0),Ri}class ad{constructor(e={}){const{canvas:t=ix(),context:n=null,depth:i=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:p=!1}=e;this.isWebGLRenderer=!0;let u;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");u=n.getContextAttributes().alpha}else u=a;const g=new Set([_c,yc,vc]),f=new Set([$n,ps,Kr,fs,gc,xc]),x=new Uint32Array(4),m=new Int32Array(4);let b=null,v=null;const y=[],_=[];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=Fi,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const M=this;let T=!1;this._outputColorSpace=Rt;let R=0,w=0,E=null,I=-1,A=null;const B=new tt,S=new tt;let U=null;const H=new Fe(0);let G=0,Z=t.width,j=t.height,ie=1,X=null,$=null;const ue=new tt(0,0,Z,j),pe=new tt(0,0,Z,j);let fe=!1;const se=new Rh;let ce=!1,me=!1;const be=new Ie,Se=new P,Be=new tt,Je={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ke=!1;function C(){return E===null?ie:1}let D=n;function W(z,Q){return t.getContext(z,Q)}try{const z={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Yr}`),t.addEventListener("webglcontextlost",ve,!1),t.addEventListener("webglcontextrestored",ge,!1),t.addEventListener("webglcontextcreationerror",Oe,!1),D===null){const Q="webgl2";if(D=W(Q,z),D===null)throw W(Q)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(z){throw z("WebGLRenderer: "+z.message),z}let O,k,F,ee,J,q,N,L,V,K,le,te,Te,ye,Re,De,de,_e,Ve,Ue,Ae,Ge,Y,Ce;function Me(){O=new Iy(D),O.init(),Ge=new f3(D,O),k=new wy(D,O,e,Ge),F=new u3(D,O),k.reversedDepthBuffer&&p&&F.buffers.depth.setReversed(!0),ee=new By(D),J=new Q2,q=new p3(D,O,F,J,k,Ge,ee),N=new Ey(M),L=new Ly(M),V=new bv(D),Y=new _y(D,V),K=new Dy(D,V,ee,Y),le=new Uy(D,K,V,ee),Ve=new ky(D,k,q),De=new Sy(J),te=new J2(M,N,L,O,k,Y,De),Te=new y3(M,J),ye=new t3,Re=new o3(O),_e=new yy(M,N,L,F,le,u,l),de=new h3(M,le,k),Ce=new _3(D,ee,k,F),Ue=new My(D,O,ee),Ae=new Ny(D,O,ee),ee.programs=te.programs,M.capabilities=k,M.extensions=O,M.properties=J,M.renderLists=ye,M.shadowMap=de,M.state=F,M.info=ee}Me();const we=new v3(M,D);this.xr=we,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){const z=O.get("WEBGL_lose_context");z&&z.loseContext()},this.forceContextRestore=function(){const z=O.get("WEBGL_lose_context");z&&z.restoreContext()},this.getPixelRatio=function(){return ie},this.setPixelRatio=function(z){z!==void 0&&(ie=z,this.setSize(Z,j,!1))},this.getSize=function(z){return z.set(Z,j)},this.setSize=function(z,Q,ae=!0){if(we.isPresenting){He("WebGLRenderer: Can't change size while VR device is presenting.");return}Z=z,j=Q,t.width=Math.floor(z*ie),t.height=Math.floor(Q*ie),ae===!0&&(t.style.width=z+"px",t.style.height=Q+"px"),this.setViewport(0,0,z,Q)},this.getDrawingBufferSize=function(z){return z.set(Z*ie,j*ie).floor()},this.setDrawingBufferSize=function(z,Q,ae){Z=z,j=Q,ie=ae,t.width=Math.floor(z*ae),t.height=Math.floor(Q*ae),this.setViewport(0,0,z,Q)},this.getCurrentViewport=function(z){return z.copy(B)},this.getViewport=function(z){return z.copy(ue)},this.setViewport=function(z,Q,ae,oe){z.isVector4?ue.set(z.x,z.y,z.z,z.w):ue.set(z,Q,ae,oe),F.viewport(B.copy(ue).multiplyScalar(ie).round())},this.getScissor=function(z){return z.copy(pe)},this.setScissor=function(z,Q,ae,oe){z.isVector4?pe.set(z.x,z.y,z.z,z.w):pe.set(z,Q,ae,oe),F.scissor(S.copy(pe).multiplyScalar(ie).round())},this.getScissorTest=function(){return fe},this.setScissorTest=function(z){F.setScissorTest(fe=z)},this.setOpaqueSort=function(z){X=z},this.setTransparentSort=function(z){$=z},this.getClearColor=function(z){return z.copy(_e.getClearColor())},this.setClearColor=function(){_e.setClearColor(...arguments)},this.getClearAlpha=function(){return _e.getClearAlpha()},this.setClearAlpha=function(){_e.setClearAlpha(...arguments)},this.clear=function(z=!0,Q=!0,ae=!0){let oe=0;if(z){let ne=!1;if(E!==null){const Ee=E.texture.format;ne=g.has(Ee)}if(ne){const Ee=E.texture.type,Le=f.has(Ee),ze=_e.getClearColor(),Ne=_e.getClearAlpha(),je=ze.r,Ze=ze.g,We=ze.b;Le?(x[0]=je,x[1]=Ze,x[2]=We,x[3]=Ne,D.clearBufferuiv(D.COLOR,0,x)):(m[0]=je,m[1]=Ze,m[2]=We,m[3]=Ne,D.clearBufferiv(D.COLOR,0,m))}else oe|=D.COLOR_BUFFER_BIT}Q&&(oe|=D.DEPTH_BUFFER_BIT),ae&&(oe|=D.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),D.clear(oe)},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",ve,!1),t.removeEventListener("webglcontextrestored",ge,!1),t.removeEventListener("webglcontextcreationerror",Oe,!1),_e.dispose(),ye.dispose(),Re.dispose(),J.dispose(),N.dispose(),L.dispose(),le.dispose(),Y.dispose(),Ce.dispose(),te.dispose(),we.dispose(),we.removeEventListener("sessionstart",cg),we.removeEventListener("sessionend",hg),Ws.stop()};function ve(z){z.preventDefault(),lo("WebGLRenderer: Context Lost."),T=!0}function ge(){lo("WebGLRenderer: Context Restored."),T=!1;const z=ee.autoReset,Q=de.enabled,ae=de.autoUpdate,oe=de.needsUpdate,ne=de.type;Me(),ee.autoReset=z,de.enabled=Q,de.autoUpdate=ae,de.needsUpdate=oe,de.type=ne}function Oe(z){Qe("WebGLRenderer: A WebGL context could not be created. Reason: ",z.statusMessage)}function Ye(z){const Q=z.target;Q.removeEventListener("dispose",Ye),wt(Q)}function wt(z){mt(z),J.remove(z)}function mt(z){const Q=J.get(z).programs;Q!==void 0&&(Q.forEach(function(ae){te.releaseProgram(ae)}),z.isShaderMaterial&&te.releaseShaderCache(z))}this.renderBufferDirect=function(z,Q,ae,oe,ne,Ee){Q===null&&(Q=Je);const Le=ne.isMesh&&ne.matrixWorld.determinant()<0,ze=mT(z,Q,ae,oe,ne);F.setMaterial(oe,Le);let Ne=ae.index,je=1;if(oe.wireframe===!0){if(Ne=K.getWireframeAttribute(ae),Ne===void 0)return;je=2}const Ze=ae.drawRange,We=ae.attributes.position;let st=Ze.start*je,gt=(Ze.start+Ze.count)*je;Ee!==null&&(st=Math.max(st,Ee.start*je),gt=Math.min(gt,(Ee.start+Ee.count)*je)),Ne!==null?(st=Math.max(st,0),gt=Math.min(gt,Ne.count)):We!=null&&(st=Math.max(st,0),gt=Math.min(gt,We.count));const Bt=gt-st;if(Bt<0||Bt===1/0)return;Y.setup(ne,oe,ze,ae,Ne);let kt,xt=Ue;if(Ne!==null&&(kt=V.get(Ne),xt=Ae,xt.setIndex(kt)),ne.isMesh)oe.wireframe===!0?(F.setLineWidth(oe.wireframeLinewidth*C()),xt.setMode(D.LINES)):xt.setMode(D.TRIANGLES);else if(ne.isLine){let Xe=oe.linewidth;Xe===void 0&&(Xe=1),F.setLineWidth(Xe*C()),ne.isLineSegments?xt.setMode(D.LINES):ne.isLineLoop?xt.setMode(D.LINE_LOOP):xt.setMode(D.LINE_STRIP)}else ne.isPoints?xt.setMode(D.POINTS):ne.isSprite&&xt.setMode(D.TRIANGLES);if(ne.isBatchedMesh)if(ne._multiDrawInstances!==null)na("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),xt.renderMultiDrawInstances(ne._multiDrawStarts,ne._multiDrawCounts,ne._multiDrawCount,ne._multiDrawInstances);else if(O.get("WEBGL_multi_draw"))xt.renderMultiDraw(ne._multiDrawStarts,ne._multiDrawCounts,ne._multiDrawCount);else{const Xe=ne._multiDrawStarts,Tt=ne._multiDrawCounts,lt=ne._multiDrawCount,Nn=Ne?V.get(Ne).bytesPerElement:1,qr=J.get(oe).currentProgram.getUniforms();for(let Bn=0;Bn<lt;Bn++)qr.setValue(D,"_gl_DrawID",Bn),xt.render(Xe[Bn]/Nn,Tt[Bn])}else if(ne.isInstancedMesh)xt.renderInstances(st,Bt,ne.count);else if(ae.isInstancedBufferGeometry){const Xe=ae._maxInstanceCount!==void 0?ae._maxInstanceCount:1/0,Tt=Math.min(ae.instanceCount,Xe);xt.renderInstances(st,Bt,Tt)}else xt.render(st,Bt)};function gi(z,Q,ae){z.transparent===!0&&z.side===yt&&z.forceSinglePass===!1?(z.side=sn,z.needsUpdate=!0,ec(z,Q,ae),z.side=kn,z.needsUpdate=!0,ec(z,Q,ae),z.side=yt):ec(z,Q,ae)}this.compile=function(z,Q,ae=null){ae===null&&(ae=z),v=Re.get(ae),v.init(Q),_.push(v),ae.traverseVisible(function(ne){ne.isLight&&ne.layers.test(Q.layers)&&(v.pushLight(ne),ne.castShadow&&v.pushShadow(ne))}),z!==ae&&z.traverseVisible(function(ne){ne.isLight&&ne.layers.test(Q.layers)&&(v.pushLight(ne),ne.castShadow&&v.pushShadow(ne))}),v.setupLights();const oe=new Set;return z.traverse(function(ne){if(!(ne.isMesh||ne.isPoints||ne.isLine||ne.isSprite))return;const Ee=ne.material;if(Ee)if(Array.isArray(Ee))for(let Le=0;Le<Ee.length;Le++){const ze=Ee[Le];gi(ze,ae,ne),oe.add(ze)}else gi(Ee,ae,ne),oe.add(Ee)}),v=_.pop(),oe},this.compileAsync=function(z,Q,ae=null){const oe=this.compile(z,Q,ae);return new Promise(ne=>{function Ee(){if(oe.forEach(function(Le){J.get(Le).currentProgram.isReady()&&oe.delete(Le)}),oe.size===0){ne(z);return}setTimeout(Ee,10)}O.get("KHR_parallel_shader_compile")!==null?Ee():setTimeout(Ee,10)})};let ri=null;function fT(z){ri&&ri(z)}function cg(){Ws.stop()}function hg(){Ws.start()}const Ws=new yf;Ws.setAnimationLoop(fT),typeof self<"u"&&Ws.setContext(self),this.setAnimationLoop=function(z){ri=z,we.setAnimationLoop(z),z===null?Ws.stop():Ws.start()},we.addEventListener("sessionstart",cg),we.addEventListener("sessionend",hg),this.render=function(z,Q){if(Q!==void 0&&Q.isCamera!==!0){Qe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;if(z.matrixWorldAutoUpdate===!0&&z.updateMatrixWorld(),Q.parent===null&&Q.matrixWorldAutoUpdate===!0&&Q.updateMatrixWorld(),we.enabled===!0&&we.isPresenting===!0&&(we.cameraAutoUpdate===!0&&we.updateCamera(Q),Q=we.getCamera()),z.isScene===!0&&z.onBeforeRender(M,z,Q,E),v=Re.get(z,_.length),v.init(Q),_.push(v),be.multiplyMatrices(Q.projectionMatrix,Q.matrixWorldInverse),se.setFromProjectionMatrix(be,oi,Q.reversedDepth),me=this.localClippingEnabled,ce=De.init(this.clippingPlanes,me),b=ye.get(z,y.length),b.init(),y.push(b),we.enabled===!0&&we.isPresenting===!0){const Ee=M.xr.getDepthSensingMesh();Ee!==null&&yu(Ee,Q,-1/0,M.sortObjects)}yu(z,Q,0,M.sortObjects),b.finish(),M.sortObjects===!0&&b.sort(X,$),ke=we.enabled===!1||we.isPresenting===!1||we.hasDepthSensing()===!1,ke&&_e.addToRenderList(b,z),this.info.render.frame++,ce===!0&&De.beginShadows();const ae=v.state.shadowsArray;de.render(ae,z,Q),ce===!0&&De.endShadows(),this.info.autoReset===!0&&this.info.reset();const oe=b.opaque,ne=b.transmissive;if(v.setupLights(),Q.isArrayCamera){const Ee=Q.cameras;if(ne.length>0)for(let Le=0,ze=Ee.length;Le<ze;Le++){const Ne=Ee[Le];ug(oe,ne,z,Ne)}ke&&_e.render(z);for(let Le=0,ze=Ee.length;Le<ze;Le++){const Ne=Ee[Le];dg(b,z,Ne,Ne.viewport)}}else ne.length>0&&ug(oe,ne,z,Q),ke&&_e.render(z),dg(b,z,Q);E!==null&&w===0&&(q.updateMultisampleRenderTarget(E),q.updateRenderTargetMipmap(E)),z.isScene===!0&&z.onAfterRender(M,z,Q),Y.resetDefaultState(),I=-1,A=null,_.pop(),_.length>0?(v=_[_.length-1],ce===!0&&De.setGlobalState(M.clippingPlanes,v.state.camera)):v=null,y.pop(),y.length>0?b=y[y.length-1]:b=null};function yu(z,Q,ae,oe){if(z.visible===!1)return;if(z.layers.test(Q.layers)){if(z.isGroup)ae=z.renderOrder;else if(z.isLOD)z.autoUpdate===!0&&z.update(Q);else if(z.isLight)v.pushLight(z),z.castShadow&&v.pushShadow(z);else if(z.isSprite){if(!z.frustumCulled||se.intersectsSprite(z)){oe&&Be.setFromMatrixPosition(z.matrixWorld).applyMatrix4(be);const Le=le.update(z),ze=z.material;ze.visible&&b.push(z,Le,ze,ae,Be.z,null)}}else if((z.isMesh||z.isLine||z.isPoints)&&(!z.frustumCulled||se.intersectsObject(z))){const Le=le.update(z),ze=z.material;if(oe&&(z.boundingSphere!==void 0?(z.boundingSphere===null&&z.computeBoundingSphere(),Be.copy(z.boundingSphere.center)):(Le.boundingSphere===null&&Le.computeBoundingSphere(),Be.copy(Le.boundingSphere.center)),Be.applyMatrix4(z.matrixWorld).applyMatrix4(be)),Array.isArray(ze)){const Ne=Le.groups;for(let je=0,Ze=Ne.length;je<Ze;je++){const We=Ne[je],st=ze[We.materialIndex];st&&st.visible&&b.push(z,Le,st,ae,Be.z,We)}}else ze.visible&&b.push(z,Le,ze,ae,Be.z,null)}}const Ee=z.children;for(let Le=0,ze=Ee.length;Le<ze;Le++)yu(Ee[Le],Q,ae,oe)}function dg(z,Q,ae,oe){const{opaque:ne,transmissive:Ee,transparent:Le}=z;v.setupLightsView(ae),ce===!0&&De.setGlobalState(M.clippingPlanes,ae),oe&&F.viewport(B.copy(oe)),ne.length>0&&Ql(ne,Q,ae),Ee.length>0&&Ql(Ee,Q,ae),Le.length>0&&Ql(Le,Q,ae),F.buffers.depth.setTest(!0),F.buffers.depth.setMask(!0),F.buffers.color.setMask(!0),F.setPolygonOffset(!1)}function ug(z,Q,ae,oe){if((ae.isScene===!0?ae.overrideMaterial:null)!==null)return;v.state.transmissionRenderTarget[oe.id]===void 0&&(v.state.transmissionRenderTarget[oe.id]=new An(1,1,{generateMipmaps:!0,type:O.has("EXT_color_buffer_half_float")||O.has("EXT_color_buffer_float")?dn:$n,minFilter:ai,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:it.workingColorSpace}));const Ee=v.state.transmissionRenderTarget[oe.id],Le=oe.viewport||B;Ee.setSize(Le.z*M.transmissionResolutionScale,Le.w*M.transmissionResolutionScale);const ze=M.getRenderTarget(),Ne=M.getActiveCubeFace(),je=M.getActiveMipmapLevel();M.setRenderTarget(Ee),M.getClearColor(H),G=M.getClearAlpha(),G<1&&M.setClearColor(16777215,.5),M.clear(),ke&&_e.render(ae);const Ze=M.toneMapping;M.toneMapping=Fi;const We=oe.viewport;if(oe.viewport!==void 0&&(oe.viewport=void 0),v.setupLightsView(oe),ce===!0&&De.setGlobalState(M.clippingPlanes,oe),Ql(z,ae,oe),q.updateMultisampleRenderTarget(Ee),q.updateRenderTargetMipmap(Ee),O.has("WEBGL_multisampled_render_to_texture")===!1){let st=!1;for(let gt=0,Bt=Q.length;gt<Bt;gt++){const kt=Q[gt],{object:xt,geometry:Xe,material:Tt,group:lt}=kt;if(Tt.side===yt&&xt.layers.test(oe.layers)){const Nn=Tt.side;Tt.side=sn,Tt.needsUpdate=!0,pg(xt,ae,oe,Xe,Tt,lt),Tt.side=Nn,Tt.needsUpdate=!0,st=!0}}st===!0&&(q.updateMultisampleRenderTarget(Ee),q.updateRenderTargetMipmap(Ee))}M.setRenderTarget(ze,Ne,je),M.setClearColor(H,G),We!==void 0&&(oe.viewport=We),M.toneMapping=Ze}function Ql(z,Q,ae){const oe=Q.isScene===!0?Q.overrideMaterial:null;for(let ne=0,Ee=z.length;ne<Ee;ne++){const Le=z[ne],{object:ze,geometry:Ne,group:je}=Le;let Ze=Le.material;Ze.allowOverride===!0&&oe!==null&&(Ze=oe),ze.layers.test(ae.layers)&&pg(ze,Q,ae,Ne,Ze,je)}}function pg(z,Q,ae,oe,ne,Ee){z.onBeforeRender(M,Q,ae,oe,ne,Ee),z.modelViewMatrix.multiplyMatrices(ae.matrixWorldInverse,z.matrixWorld),z.normalMatrix.getNormalMatrix(z.modelViewMatrix),ne.onBeforeRender(M,Q,ae,oe,z,Ee),ne.transparent===!0&&ne.side===yt&&ne.forceSinglePass===!1?(ne.side=sn,ne.needsUpdate=!0,M.renderBufferDirect(ae,Q,oe,ne,z,Ee),ne.side=kn,ne.needsUpdate=!0,M.renderBufferDirect(ae,Q,oe,ne,z,Ee),ne.side=yt):M.renderBufferDirect(ae,Q,oe,ne,z,Ee),z.onAfterRender(M,Q,ae,oe,ne,Ee)}function ec(z,Q,ae){Q.isScene!==!0&&(Q=Je);const oe=J.get(z),ne=v.state.lights,Ee=v.state.shadowsArray,Le=ne.state.version,ze=te.getParameters(z,ne.state,Ee,Q,ae),Ne=te.getProgramCacheKey(ze);let je=oe.programs;oe.environment=z.isMeshStandardMaterial?Q.environment:null,oe.fog=Q.fog,oe.envMap=(z.isMeshStandardMaterial?L:N).get(z.envMap||oe.environment),oe.envMapRotation=oe.environment!==null&&z.envMap===null?Q.environmentRotation:z.envMapRotation,je===void 0&&(z.addEventListener("dispose",Ye),je=new Map,oe.programs=je);let Ze=je.get(Ne);if(Ze!==void 0){if(oe.currentProgram===Ze&&oe.lightsStateVersion===Le)return mg(z,ze),Ze}else ze.uniforms=te.getUniforms(z),z.onBeforeCompile(ze,M),Ze=te.acquireProgram(ze,Ne),je.set(Ne,Ze),oe.uniforms=ze.uniforms;const We=oe.uniforms;return(!z.isShaderMaterial&&!z.isRawShaderMaterial||z.clipping===!0)&&(We.clippingPlanes=De.uniform),mg(z,ze),oe.needsLights=xT(z),oe.lightsStateVersion=Le,oe.needsLights&&(We.ambientLightColor.value=ne.state.ambient,We.lightProbe.value=ne.state.probe,We.directionalLights.value=ne.state.directional,We.directionalLightShadows.value=ne.state.directionalShadow,We.spotLights.value=ne.state.spot,We.spotLightShadows.value=ne.state.spotShadow,We.rectAreaLights.value=ne.state.rectArea,We.ltc_1.value=ne.state.rectAreaLTC1,We.ltc_2.value=ne.state.rectAreaLTC2,We.pointLights.value=ne.state.point,We.pointLightShadows.value=ne.state.pointShadow,We.hemisphereLights.value=ne.state.hemi,We.directionalShadowMap.value=ne.state.directionalShadowMap,We.directionalShadowMatrix.value=ne.state.directionalShadowMatrix,We.spotShadowMap.value=ne.state.spotShadowMap,We.spotLightMatrix.value=ne.state.spotLightMatrix,We.spotLightMap.value=ne.state.spotLightMap,We.pointShadowMap.value=ne.state.pointShadowMap,We.pointShadowMatrix.value=ne.state.pointShadowMatrix),oe.currentProgram=Ze,oe.uniformsList=null,Ze}function fg(z){if(z.uniformsList===null){const Q=z.currentProgram.getUniforms();z.uniformsList=Ko.seqWithValue(Q.seq,z.uniforms)}return z.uniformsList}function mg(z,Q){const ae=J.get(z);ae.outputColorSpace=Q.outputColorSpace,ae.batching=Q.batching,ae.batchingColor=Q.batchingColor,ae.instancing=Q.instancing,ae.instancingColor=Q.instancingColor,ae.instancingMorph=Q.instancingMorph,ae.skinning=Q.skinning,ae.morphTargets=Q.morphTargets,ae.morphNormals=Q.morphNormals,ae.morphColors=Q.morphColors,ae.morphTargetsCount=Q.morphTargetsCount,ae.numClippingPlanes=Q.numClippingPlanes,ae.numIntersection=Q.numClipIntersection,ae.vertexAlphas=Q.vertexAlphas,ae.vertexTangents=Q.vertexTangents,ae.toneMapping=Q.toneMapping}function mT(z,Q,ae,oe,ne){Q.isScene!==!0&&(Q=Je),q.resetTextureUnits();const Ee=Q.fog,Le=oe.isMeshStandardMaterial?Q.environment:null,ze=E===null?M.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:en,Ne=(oe.isMeshStandardMaterial?L:N).get(oe.envMap||Le),je=oe.vertexColors===!0&&!!ae.attributes.color&&ae.attributes.color.itemSize===4,Ze=!!ae.attributes.tangent&&(!!oe.normalMap||oe.anisotropy>0),We=!!ae.morphAttributes.position,st=!!ae.morphAttributes.normal,gt=!!ae.morphAttributes.color;let Bt=Fi;oe.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(Bt=M.toneMapping);const kt=ae.morphAttributes.position||ae.morphAttributes.normal||ae.morphAttributes.color,xt=kt!==void 0?kt.length:0,Xe=J.get(oe),Tt=v.state.lights;if(ce===!0&&(me===!0||z!==A)){const xn=z===A&&oe.id===I;De.setState(oe,z,xn)}let lt=!1;oe.version===Xe.__version?(Xe.needsLights&&Xe.lightsStateVersion!==Tt.state.version||Xe.outputColorSpace!==ze||ne.isBatchedMesh&&Xe.batching===!1||!ne.isBatchedMesh&&Xe.batching===!0||ne.isBatchedMesh&&Xe.batchingColor===!0&&ne.colorTexture===null||ne.isBatchedMesh&&Xe.batchingColor===!1&&ne.colorTexture!==null||ne.isInstancedMesh&&Xe.instancing===!1||!ne.isInstancedMesh&&Xe.instancing===!0||ne.isSkinnedMesh&&Xe.skinning===!1||!ne.isSkinnedMesh&&Xe.skinning===!0||ne.isInstancedMesh&&Xe.instancingColor===!0&&ne.instanceColor===null||ne.isInstancedMesh&&Xe.instancingColor===!1&&ne.instanceColor!==null||ne.isInstancedMesh&&Xe.instancingMorph===!0&&ne.morphTexture===null||ne.isInstancedMesh&&Xe.instancingMorph===!1&&ne.morphTexture!==null||Xe.envMap!==Ne||oe.fog===!0&&Xe.fog!==Ee||Xe.numClippingPlanes!==void 0&&(Xe.numClippingPlanes!==De.numPlanes||Xe.numIntersection!==De.numIntersection)||Xe.vertexAlphas!==je||Xe.vertexTangents!==Ze||Xe.morphTargets!==We||Xe.morphNormals!==st||Xe.morphColors!==gt||Xe.toneMapping!==Bt||Xe.morphTargetsCount!==xt)&&(lt=!0):(lt=!0,Xe.__version=oe.version);let Nn=Xe.currentProgram;lt===!0&&(Nn=ec(oe,Q,ne));let qr=!1,Bn=!1,qa=!1;const At=Nn.getUniforms(),Sn=Xe.uniforms;if(F.useProgram(Nn.program)&&(qr=!0,Bn=!0,qa=!0),oe.id!==I&&(I=oe.id,Bn=!0),qr||A!==z){F.buffers.depth.getReversed()&&z.reversedDepth!==!0&&(z._reversedDepth=!0,z.updateProjectionMatrix()),At.setValue(D,"projectionMatrix",z.projectionMatrix),At.setValue(D,"viewMatrix",z.matrixWorldInverse);const En=At.map.cameraPosition;En!==void 0&&En.setValue(D,Se.setFromMatrixPosition(z.matrixWorld)),k.logarithmicDepthBuffer&&At.setValue(D,"logDepthBufFC",2/(Math.log(z.far+1)/Math.LN2)),(oe.isMeshPhongMaterial||oe.isMeshToonMaterial||oe.isMeshLambertMaterial||oe.isMeshBasicMaterial||oe.isMeshStandardMaterial||oe.isShaderMaterial)&&At.setValue(D,"isOrthographic",z.isOrthographicCamera===!0),A!==z&&(A=z,Bn=!0,qa=!0)}if(ne.isSkinnedMesh){At.setOptional(D,ne,"bindMatrix"),At.setOptional(D,ne,"bindMatrixInverse");const xn=ne.skeleton;xn&&(xn.boneTexture===null&&xn.computeBoneTexture(),At.setValue(D,"boneTexture",xn.boneTexture,q))}ne.isBatchedMesh&&(At.setOptional(D,ne,"batchingTexture"),At.setValue(D,"batchingTexture",ne._matricesTexture,q),At.setOptional(D,ne,"batchingIdTexture"),At.setValue(D,"batchingIdTexture",ne._indirectTexture,q),At.setOptional(D,ne,"batchingColorTexture"),ne._colorsTexture!==null&&At.setValue(D,"batchingColorTexture",ne._colorsTexture,q));const Yn=ae.morphAttributes;if((Yn.position!==void 0||Yn.normal!==void 0||Yn.color!==void 0)&&Ve.update(ne,ae,Nn),(Bn||Xe.receiveShadow!==ne.receiveShadow)&&(Xe.receiveShadow=ne.receiveShadow,At.setValue(D,"receiveShadow",ne.receiveShadow)),oe.isMeshGouraudMaterial&&oe.envMap!==null&&(Sn.envMap.value=Ne,Sn.flipEnvMap.value=Ne.isCubeTexture&&Ne.isRenderTargetTexture===!1?-1:1),oe.isMeshStandardMaterial&&oe.envMap===null&&Q.environment!==null&&(Sn.envMapIntensity.value=Q.environmentIntensity),Sn.dfgLUT!==void 0&&(Sn.dfgLUT.value=w3()),Bn&&(At.setValue(D,"toneMappingExposure",M.toneMappingExposure),Xe.needsLights&&gT(Sn,qa),Ee&&oe.fog===!0&&Te.refreshFogUniforms(Sn,Ee),Te.refreshMaterialUniforms(Sn,oe,ie,j,v.state.transmissionRenderTarget[z.id]),Ko.upload(D,fg(Xe),Sn,q)),oe.isShaderMaterial&&oe.uniformsNeedUpdate===!0&&(Ko.upload(D,fg(Xe),Sn,q),oe.uniformsNeedUpdate=!1),oe.isSpriteMaterial&&At.setValue(D,"center",ne.center),At.setValue(D,"modelViewMatrix",ne.modelViewMatrix),At.setValue(D,"normalMatrix",ne.normalMatrix),At.setValue(D,"modelMatrix",ne.matrixWorld),oe.isShaderMaterial||oe.isRawShaderMaterial){const xn=oe.uniformsGroups;for(let En=0,_u=xn.length;En<_u;En++){const Xs=xn[En];Ce.update(Xs,Nn),Ce.bind(Xs,Nn)}}return Nn}function gT(z,Q){z.ambientLightColor.needsUpdate=Q,z.lightProbe.needsUpdate=Q,z.directionalLights.needsUpdate=Q,z.directionalLightShadows.needsUpdate=Q,z.pointLights.needsUpdate=Q,z.pointLightShadows.needsUpdate=Q,z.spotLights.needsUpdate=Q,z.spotLightShadows.needsUpdate=Q,z.rectAreaLights.needsUpdate=Q,z.hemisphereLights.needsUpdate=Q}function xT(z){return z.isMeshLambertMaterial||z.isMeshToonMaterial||z.isMeshPhongMaterial||z.isMeshStandardMaterial||z.isShadowMaterial||z.isShaderMaterial&&z.lights===!0}this.getActiveCubeFace=function(){return R},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(z,Q,ae){const oe=J.get(z);oe.__autoAllocateDepthBuffer=z.resolveDepthBuffer===!1,oe.__autoAllocateDepthBuffer===!1&&(oe.__useRenderToTexture=!1),J.get(z.texture).__webglTexture=Q,J.get(z.depthTexture).__webglTexture=oe.__autoAllocateDepthBuffer?void 0:ae,oe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(z,Q){const ae=J.get(z);ae.__webglFramebuffer=Q,ae.__useDefaultFramebuffer=Q===void 0};const vT=D.createFramebuffer();this.setRenderTarget=function(z,Q=0,ae=0){E=z,R=Q,w=ae;let oe=!0,ne=null,Ee=!1,Le=!1;if(z){const Ne=J.get(z);if(Ne.__useDefaultFramebuffer!==void 0)F.bindFramebuffer(D.FRAMEBUFFER,null),oe=!1;else if(Ne.__webglFramebuffer===void 0)q.setupRenderTarget(z);else if(Ne.__hasExternalTextures)q.rebindTextures(z,J.get(z.texture).__webglTexture,J.get(z.depthTexture).__webglTexture);else if(z.depthBuffer){const We=z.depthTexture;if(Ne.__boundDepthTexture!==We){if(We!==null&&J.has(We)&&(z.width!==We.image.width||z.height!==We.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");q.setupDepthRenderbuffer(z)}}const je=z.texture;(je.isData3DTexture||je.isDataArrayTexture||je.isCompressedArrayTexture)&&(Le=!0);const Ze=J.get(z).__webglFramebuffer;z.isWebGLCubeRenderTarget?(Array.isArray(Ze[Q])?ne=Ze[Q][ae]:ne=Ze[Q],Ee=!0):z.samples>0&&q.useMultisampledRTT(z)===!1?ne=J.get(z).__webglMultisampledFramebuffer:Array.isArray(Ze)?ne=Ze[ae]:ne=Ze,B.copy(z.viewport),S.copy(z.scissor),U=z.scissorTest}else B.copy(ue).multiplyScalar(ie).floor(),S.copy(pe).multiplyScalar(ie).floor(),U=fe;if(ae!==0&&(ne=vT),F.bindFramebuffer(D.FRAMEBUFFER,ne)&&oe&&F.drawBuffers(z,ne),F.viewport(B),F.scissor(S),F.setScissorTest(U),Ee){const Ne=J.get(z.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Ne.__webglTexture,ae)}else if(Le){const Ne=Q;for(let je=0;je<z.textures.length;je++){const Ze=J.get(z.textures[je]);D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0+je,Ze.__webglTexture,ae,Ne)}}else if(z!==null&&ae!==0){const Ne=J.get(z.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Ne.__webglTexture,ae)}I=-1},this.readRenderTargetPixels=function(z,Q,ae,oe,ne,Ee,Le,ze=0){if(!(z&&z.isWebGLRenderTarget)){Qe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ne=J.get(z).__webglFramebuffer;if(z.isWebGLCubeRenderTarget&&Le!==void 0&&(Ne=Ne[Le]),Ne){F.bindFramebuffer(D.FRAMEBUFFER,Ne);try{const je=z.textures[ze],Ze=je.format,We=je.type;if(!k.textureFormatReadable(Ze)){Qe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!k.textureTypeReadable(We)){Qe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Q>=0&&Q<=z.width-oe&&ae>=0&&ae<=z.height-ne&&(z.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+ze),D.readPixels(Q,ae,oe,ne,Ge.convert(Ze),Ge.convert(We),Ee))}finally{const je=E!==null?J.get(E).__webglFramebuffer:null;F.bindFramebuffer(D.FRAMEBUFFER,je)}}},this.readRenderTargetPixelsAsync=async function(z,Q,ae,oe,ne,Ee,Le,ze=0){if(!(z&&z.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ne=J.get(z).__webglFramebuffer;if(z.isWebGLCubeRenderTarget&&Le!==void 0&&(Ne=Ne[Le]),Ne)if(Q>=0&&Q<=z.width-oe&&ae>=0&&ae<=z.height-ne){F.bindFramebuffer(D.FRAMEBUFFER,Ne);const je=z.textures[ze],Ze=je.format,We=je.type;if(!k.textureFormatReadable(Ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!k.textureTypeReadable(We))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const st=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,st),D.bufferData(D.PIXEL_PACK_BUFFER,Ee.byteLength,D.STREAM_READ),z.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+ze),D.readPixels(Q,ae,oe,ne,Ge.convert(Ze),Ge.convert(We),0);const gt=E!==null?J.get(E).__webglFramebuffer:null;F.bindFramebuffer(D.FRAMEBUFFER,gt);const Bt=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await sx(D,Bt,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,st),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,Ee),D.deleteBuffer(st),D.deleteSync(Bt),Ee}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(z,Q=null,ae=0){const oe=Math.pow(2,-ae),ne=Math.floor(z.image.width*oe),Ee=Math.floor(z.image.height*oe),Le=Q!==null?Q.x:0,ze=Q!==null?Q.y:0;q.setTexture2D(z,0),D.copyTexSubImage2D(D.TEXTURE_2D,ae,0,0,Le,ze,ne,Ee),F.unbindTexture()};const bT=D.createFramebuffer(),yT=D.createFramebuffer();this.copyTextureToTexture=function(z,Q,ae=null,oe=null,ne=0,Ee=null){Ee===null&&(ne!==0?(na("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Ee=ne,ne=0):Ee=0);let Le,ze,Ne,je,Ze,We,st,gt,Bt;const kt=z.isCompressedTexture?z.mipmaps[Ee]:z.image;if(ae!==null)Le=ae.max.x-ae.min.x,ze=ae.max.y-ae.min.y,Ne=ae.isBox3?ae.max.z-ae.min.z:1,je=ae.min.x,Ze=ae.min.y,We=ae.isBox3?ae.min.z:0;else{const Yn=Math.pow(2,-ne);Le=Math.floor(kt.width*Yn),ze=Math.floor(kt.height*Yn),z.isDataArrayTexture?Ne=kt.depth:z.isData3DTexture?Ne=Math.floor(kt.depth*Yn):Ne=1,je=0,Ze=0,We=0}oe!==null?(st=oe.x,gt=oe.y,Bt=oe.z):(st=0,gt=0,Bt=0);const xt=Ge.convert(Q.format),Xe=Ge.convert(Q.type);let Tt;Q.isData3DTexture?(q.setTexture3D(Q,0),Tt=D.TEXTURE_3D):Q.isDataArrayTexture||Q.isCompressedArrayTexture?(q.setTexture2DArray(Q,0),Tt=D.TEXTURE_2D_ARRAY):(q.setTexture2D(Q,0),Tt=D.TEXTURE_2D),D.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,Q.flipY),D.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Q.premultiplyAlpha),D.pixelStorei(D.UNPACK_ALIGNMENT,Q.unpackAlignment);const lt=D.getParameter(D.UNPACK_ROW_LENGTH),Nn=D.getParameter(D.UNPACK_IMAGE_HEIGHT),qr=D.getParameter(D.UNPACK_SKIP_PIXELS),Bn=D.getParameter(D.UNPACK_SKIP_ROWS),qa=D.getParameter(D.UNPACK_SKIP_IMAGES);D.pixelStorei(D.UNPACK_ROW_LENGTH,kt.width),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,kt.height),D.pixelStorei(D.UNPACK_SKIP_PIXELS,je),D.pixelStorei(D.UNPACK_SKIP_ROWS,Ze),D.pixelStorei(D.UNPACK_SKIP_IMAGES,We);const At=z.isDataArrayTexture||z.isData3DTexture,Sn=Q.isDataArrayTexture||Q.isData3DTexture;if(z.isDepthTexture){const Yn=J.get(z),xn=J.get(Q),En=J.get(Yn.__renderTarget),_u=J.get(xn.__renderTarget);F.bindFramebuffer(D.READ_FRAMEBUFFER,En.__webglFramebuffer),F.bindFramebuffer(D.DRAW_FRAMEBUFFER,_u.__webglFramebuffer);for(let Xs=0;Xs<Ne;Xs++)At&&(D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,J.get(z).__webglTexture,ne,We+Xs),D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,J.get(Q).__webglTexture,Ee,Bt+Xs)),D.blitFramebuffer(je,Ze,Le,ze,st,gt,Le,ze,D.DEPTH_BUFFER_BIT,D.NEAREST);F.bindFramebuffer(D.READ_FRAMEBUFFER,null),F.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(ne!==0||z.isRenderTargetTexture||J.has(z)){const Yn=J.get(z),xn=J.get(Q);F.bindFramebuffer(D.READ_FRAMEBUFFER,bT),F.bindFramebuffer(D.DRAW_FRAMEBUFFER,yT);for(let En=0;En<Ne;En++)At?D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Yn.__webglTexture,ne,We+En):D.framebufferTexture2D(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Yn.__webglTexture,ne),Sn?D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,xn.__webglTexture,Ee,Bt+En):D.framebufferTexture2D(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,xn.__webglTexture,Ee),ne!==0?D.blitFramebuffer(je,Ze,Le,ze,st,gt,Le,ze,D.COLOR_BUFFER_BIT,D.NEAREST):Sn?D.copyTexSubImage3D(Tt,Ee,st,gt,Bt+En,je,Ze,Le,ze):D.copyTexSubImage2D(Tt,Ee,st,gt,je,Ze,Le,ze);F.bindFramebuffer(D.READ_FRAMEBUFFER,null),F.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else Sn?z.isDataTexture||z.isData3DTexture?D.texSubImage3D(Tt,Ee,st,gt,Bt,Le,ze,Ne,xt,Xe,kt.data):Q.isCompressedArrayTexture?D.compressedTexSubImage3D(Tt,Ee,st,gt,Bt,Le,ze,Ne,xt,kt.data):D.texSubImage3D(Tt,Ee,st,gt,Bt,Le,ze,Ne,xt,Xe,kt):z.isDataTexture?D.texSubImage2D(D.TEXTURE_2D,Ee,st,gt,Le,ze,xt,Xe,kt.data):z.isCompressedTexture?D.compressedTexSubImage2D(D.TEXTURE_2D,Ee,st,gt,kt.width,kt.height,xt,kt.data):D.texSubImage2D(D.TEXTURE_2D,Ee,st,gt,Le,ze,xt,Xe,kt);D.pixelStorei(D.UNPACK_ROW_LENGTH,lt),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,Nn),D.pixelStorei(D.UNPACK_SKIP_PIXELS,qr),D.pixelStorei(D.UNPACK_SKIP_ROWS,Bn),D.pixelStorei(D.UNPACK_SKIP_IMAGES,qa),Ee===0&&Q.generateMipmaps&&D.generateMipmap(Tt),F.unbindTexture()},this.initRenderTarget=function(z){J.get(z).__webglFramebuffer===void 0&&q.setupRenderTarget(z)},this.initTexture=function(z){z.isCubeTexture?q.setTextureCube(z,0):z.isData3DTexture?q.setTexture3D(z,0):z.isDataArrayTexture||z.isCompressedArrayTexture?q.setTexture2DArray(z,0):q.setTexture2D(z,0),F.unbindTexture()},this.resetState=function(){R=0,w=0,E=null,F.reset(),Y.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return oi}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=it._getDrawingBufferColorSpace(e),t.unpackColorSpace=it._getUnpackColorSpace()}}class S3{engine;scene;constructor(e){this.engine=e,this.scene=new wp;let t=new ln;t.name="groupEdge",this.scene.add(t)}}class E3{engine;perspectiveCamera;orthographicCamera;constructor(e){this.engine=e,this.perspectiveCamera=new on(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,n=this.engine.container.clientWidth/this.engine.container.clientHeight;this.orthographicCamera=new Ai(t*n/-2,t*n/2,t/2,t/-2,.1,1e3)}switchCurrentCamera(){this.engine.camera===this.perspectiveCamera?this.switchToOrthographicCamera():this.switchToPerspectiveCamera()}updateComposerCamera(){if(!this.engine.composerModule?.composer)return;const e=this.engine.camera,t=this.engine.composerModule.composer;if(t.passes)for(const n of t.passes)n.camera!==void 0&&(n.camera=e)}switchToPerspectiveCamera(){if(!this.engine.controls)return;const e=this.engine.camera.position.clone(),t=this.engine.controls.target.clone();this.engine.camera=this.perspectiveCamera,this.engine.scene.camera=this.perspectiveCamera,this.perspectiveCamera.position.copy(e),this.perspectiveCamera.lookAt(t),this.engine.controlModule.orbitControls.object=this.perspectiveCamera,this.engine.controlModule.firstPersonControls.camera=this.perspectiveCamera,this.updateComposerCamera(),this.perspectiveCamera.updateProjectionMatrix(),this.perspectiveCamera.updateMatrixWorld()}switchToOrthographicCamera(){if(!this.engine.controls)return;const e=this.engine.camera.position.clone(),t=this.engine.controls.target.clone();this.engine.camera=this.orthographicCamera,this.engine.scene.camera=this.orthographicCamera,this.orthographicCamera.position.copy(e),this.orthographicCamera.lookAt(t),this.engine.controlModule.orbitControls.object=this.orthographicCamera,this.engine.controlModule.firstPersonControls.camera=this.orthographicCamera,this.updateComposerCamera(),this.orthographicCamera.updateProjectionMatrix(),this.orthographicCamera.updateMatrixWorld()}getCameraType(){return this.engine.camera===this.perspectiveCamera?"perspective":this.engine.camera===this.orthographicCamera?"orthographic":"perspective"}getCameraPose(){const e=this.engine.camera,t=this.getCameraType(),n={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&&this.engine.controls.target&&(n.target={x:this.engine.controls.target.x,y:this.engine.controls.target.y,z:this.engine.controls.target.z}),t==="orthographic"&&(n.zoom=e.zoom),n}restoreCameraPose(e){this.getCameraType()!==e.type&&(e.type==="perspective"?this.switchToPerspectiveCamera():this.switchToOrthographicCamera());const t=this.engine.camera;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&&this.engine.controls.target&&this.engine.controls.target.set(e.target.x,e.target.y,e.target.z),e.type==="orthographic"&&e.zoom!==void 0&&(t.zoom=e.zoom,t.updateProjectionMatrix()),t.updateMatrix(),t.updateMatrixWorld(!0),this.engine.controls&&this.engine.controls.update&&this.engine.controls.update()}}class C3{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,n=e.some(c=>c.test(t)),i="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 n||i&&o||i&&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}}}class T3{engine;renderer;constructor(e){this.engine=e,this.renderer=null}createRenderer(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize();return this.renderer=new ad({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=Eu,this.renderer.localClippingEnabled=!0,this.renderer.outputColorSpace=Rt,this.engine.container.appendChild(this.renderer.domElement),this.renderer}disposeRenderer(){this.renderer?.dispose()}}const qf={type:"change"},od={type:"start"},Zf={type:"end"},Qo=new Xi,Yf=new It,A3=Math.cos(70*zt.DEG2RAD),Gt=new P,bn=2*Math.PI,ft={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},ld=1e-6;class P3 extends xv{constructor(e,t,n=null){super(t,n),this.engine=e,this.state=ft.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.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:qs.ROTATE,MIDDLE:qs.DOLLY,RIGHT:qs.PAN},this.touches={ONE:Zs.ROTATE,TWO:Zs.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 zn,this._lastTargetPosition=new P,this._quat=new zn().setFromUnitVectors(t.up,new P(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Kh,this._sphericalDelta=new Kh,this._scale=1,this._panOffset=new P,this._rotateStart=new he,this._rotateEnd=new he,this._rotateDelta=new he,this._panStart=new he,this._panEnd=new he,this._panDelta=new he,this._dollyStart=new he,this._dollyEnd=new he,this._dollyDelta=new he,this._dollyDirection=new P,this._mouse=new he,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=L3.bind(this),this._onPointerDown=R3.bind(this),this._onPointerUp=I3.bind(this),this._onContextMenu=z3.bind(this),this._onMouseWheel=B3.bind(this),this._onKeyDown=k3.bind(this),this._onTouchStart=U3.bind(this),this._onTouchMove=O3.bind(this),this._onMouseDown=D3.bind(this),this._onMouseMove=N3.bind(this),this._interceptControlDown=F3.bind(this),this._interceptControlUp=H3.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(qf),this.update(),this.state=ft.NONE}update(e=null){this.engine&&this.engine.interactionManager&&this.engine.interactionManager.origin&&this.origin.copy(this.engine.interactionManager.origin);const t=this.object.position;Gt.copy(t).sub(this.target),Gt.applyQuaternion(this._quat),this._spherical.setFromVector3(Gt),this.autoRotate&&this.state===ft.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(n)&&isFinite(i)&&(n<-Math.PI?n+=bn:n>Math.PI&&(n-=bn),i<-Math.PI?i+=bn:i>Math.PI&&(i-=bn),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,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 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(Gt.setFromSpherical(this._spherical),Gt.applyQuaternion(this._quatInverse),this.engine&&this.engine.deviceType==="PC"){const a=new P;if(a.copy(this.origin).sub(this.target),a.lengthSq()>1e-4&&(this._sphericalDelta.theta!==0||this._sphericalDelta.phi!==0)){const o=this.enableDamping?this.dampingFactor*3:1,l=new P(0,1,0),c=new P;this.object.getWorldDirection(c);const h=c.clone().cross(l).normalize(),d=new P().copy(this.object.position).sub(this.origin);d.applyAxisAngle(l,Math.PI*this._sphericalDelta.theta*o),d.applyAxisAngle(h,Math.PI*this._sphericalDelta.phi*o),t.copy(this.origin).add(d);const p=new P().copy(this.target).sub(this.origin);p.applyAxisAngle(l,Math.PI*this._sphericalDelta.theta*o),p.applyAxisAngle(h,Math.PI*this._sphericalDelta.phi*o),this.target.copy(this.origin).add(p)}else if(this._panOffset.lengthSq()===0&&this._sphericalDelta.phi===0&&this._sphericalDelta.theta===0){if(this._scale!==1){const o=new P;this.object.getWorldDirection(o);const l=this._spherical.radius*.05*(this._scale-1);t.add(o.multiplyScalar(l))}}else t.copy(this.target).add(Gt);this.object.lookAt(this.target)}else t.copy(this.target).add(Gt),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 a=null;if(this.object.isPerspectiveCamera){const o=Gt.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=Gt.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):(Qo.origin.copy(this.object.position),Qo.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Qo.direction))<A3?this.object.lookAt(this.target):(Yf.setFromNormalAndCoplanarPoint(this.object.up,this.target),Qo.intersectPlane(Yf,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)>ld||8*(1-this._lastQuaternion.dot(this.object.quaternion))>ld||this._lastTargetPosition.distanceToSquared(this.target)>ld?(this.dispatchEvent(qf),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?bn/60*this.autoRotateSpeed*e:bn/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){Gt.setFromMatrixColumn(t,0),Gt.multiplyScalar(-e),this._panOffset.add(Gt)}_panUp(e,t){this.screenSpacePanning===!0?Gt.setFromMatrixColumn(t,1):(Gt.setFromMatrixColumn(t,0),Gt.crossVectors(this.object.up,Gt)),Gt.multiplyScalar(e),this._panOffset.add(Gt)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Gt.copy(i).sub(this.target);let r=Gt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,a=n.width,o=n.height;this._mouse.x=i/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(bn*this._rotateDelta.x/t.clientHeight),this._rotateUp(bn*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);let t;if(this.object.isOrthographicCamera)e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY!==0&&this._dollyOut(this._getZoomScale(e.deltaY));else{const n=Math.abs(e.deltaY*.01);t=Math.pow(1.15,this.zoomSpeed*n),e.deltaY>0?this._scale/=t:e.deltaY!==0&&(this._scale*=t)}this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(bn*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(-bn*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(bn*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(-bn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);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 n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(bn*this._rotateDelta.x/t.clientHeight),this._rotateUp(bn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(n,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(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);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 he,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function R3(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 L3(s){this.enabled!==!1&&(s.pointerType==="touch"?this._onTouchMove(s):this._onMouseMove(s))}function I3(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(Zf),this.state=ft.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 D3(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 qs.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(s),this.state=ft.DOLLY;break;case qs.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=ft.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=ft.ROTATE}break;case qs.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=ft.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=ft.PAN}break;default:this.state=ft.NONE}this.state!==ft.NONE&&this.dispatchEvent(od)}function N3(s){switch(this.state){case ft.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(s);break;case ft.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(s);break;case ft.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(s);break}}function B3(s){this.enabled===!1||this.enableZoom===!1||this.state!==ft.NONE||(s.preventDefault(),this.dispatchEvent(od),this._handleMouseWheel(this._customWheelEvent(s)),this.dispatchEvent(Zf))}function k3(s){this.enabled!==!1&&this._handleKeyDown(s)}function U3(s){switch(this._trackPointer(s),this._pointers.length){case 1:switch(this.touches.ONE){case Zs.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(s),this.state=ft.TOUCH_ROTATE;break;case Zs.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(s),this.state=ft.TOUCH_PAN;break;default:this.state=ft.NONE}break;case 2:switch(this.touches.TWO){case Zs.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(s),this.state=ft.TOUCH_DOLLY_PAN;break;case Zs.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(s),this.state=ft.TOUCH_DOLLY_ROTATE;break;default:this.state=ft.NONE}break;default:this.state=ft.NONE}this.state!==ft.NONE&&this.dispatchEvent(od)}function O3(s){switch(this._trackPointer(s),this.state){case ft.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(s),this.update();break;case ft.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(s),this.update();break;case ft.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(s),this.update();break;case ft.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(s),this.update();break;default:this.state=ft.NONE}}function z3(s){this.enabled!==!1&&s.preventDefault()}function F3(s){s.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function H3(s){s.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class $f{constructor(e,t,n,i){this._Engine=e,this.camera=t,this.domElement=n,this._isEnabled=!1,this._rayOriginOffset=new P(0,-1,0),this._camerLocalDirection=new P,this._tmpVector=new P,this._rayCaster=new Qi,this._fallingTime=0,this._euler=new Rn(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=.008,this.moveSpeed=.02,this.playerHeight=1.4,this.maxRotateX=.8,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.needMousewheel=!1,this.moveWheelRun=!0,this.moveWheelStop=!1,this.wheelClock,this.keydown=!1,this.GetEngine=()=>e}set colliders(e){this._rayCastObjects=e}set enabled(e){this._isEnabled!==e&&(this._isEnabled=e,this._euler.setFromQuaternion(this.camera.quaternion),e?this.addEvents():this.removeEvents())}get enabled(){return this._isEnabled}addEvents(){const e=this._Engine?.DeviceType,t=e==="PC"||!e;console.log("[FirstPersonCameraControl] addEvents - DeviceType:",e,"isPC:",t),t?(console.log("[FirstPersonCameraControl] 添加鼠标事件监听器 - mousedown, mouseup"),this.domElement.addEventListener("mousedown",this.bindmousedown,!1),this.domElement.addEventListener("mouseup",this.bindmouseup,!1)):(console.log("[FirstPersonCameraControl] 添加触摸事件监听器"),this.domElement.addEventListener("touchstart",this.bindmousedown,!1),this.domElement.addEventListener("touchend",this.bindmouseup,!1)),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)),window.removeEventListener("keydown",this.bindonKeyDown),window.removeEventListener("keyup",this.bindonKeyUp),this.needMousewheel&&(document.addEventListener&&document.removeEventListener("DOMMouseScroll",this.bindMousewheel),window.removeEventListener("mousewheel",this.bindMousewheel))}onMousewheel(e){debugger;let t;switch(e.wheelDelta?(e.wheelDelta>0&&(t="up"),e.wheelDelta<0&&(t="down")):e.detail&&(e.detail<0&&(t="up"),e.detail>0&&(t="down")),t){case"up":this._camerLocalDirection.z=1;break;case"down":this._camerLocalDirection.z=-1;break}this.moveWheelRun==!0?(this.moveWheelRun=!1,this.moveWheelStop=!0,this.wheelClock=setTimeout(()=>{this.moveWheelStop==!0&&(this.moveWheelStop=!1,this.moveWheelRun=!0,this._camerLocalDirection.z=0)},200)):(clearTimeout(this.wheelClock),this.wheelClock=setTimeout(()=>{this.moveWheelStop==!0&&(this.moveWheelStop=!1,this.moveWheelRun=!0,this._camerLocalDirection.z=0)},150))}onMouseDown(e){console.log("[FirstPersonCameraControl] onMouseDown 被调用",e),this.domElement.addEventListener("mousemove",this.bindmousemove,!1),this._prevMouseX=e.screenX,this._prevMouseY=e.screenY}onMouseMove(e){if(this._isEnabled==!1)return;let t=this._prevMouseX?e.screenX-this._prevMouseX:0,n=this._prevMouseY?e.screenY-this._prevMouseY:0,i=this._euler.x-n*this.lookflag*this.lookSpeed;i>=0?i<this.maxRotateX?this._euler.x=i:this._euler.x=this.maxRotateX:i>-this.maxRotateX?this._euler.x=i: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,n=this._prevMouseY?e.targetTouches[0].clientY-this._prevMouseY:0,i=this._euler.x-n*this.lookflag*this.lookSpeed;i>=0?i<this.maxRotateX?this._euler.x=i:this._euler.x=this.maxRotateX:i>-this.maxRotateX?this._euler.x=i: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){var t=new CustomEvent("bimengine:camerachange",{detail:""});let n=this.GetEngine();switch(n.movefirst=!0,window.dispatchEvent(t),e.keyCode){case 38:this.rotateY(-1);break;case 81:this.keydown=!0,this._camerLocalDirection.y=1;break;case 69:this._camerLocalDirection.y=-1;break;case 87:this._camerLocalDirection.z=1;break;case 37:this.rotateX(-1);break;case 65:this._camerLocalDirection.x=-1;break;case 40:this.rotateY(1);break;case 83:this._camerLocalDirection.z=-1;break;case 39:this.rotateX(1);break;case 68:this._camerLocalDirection.x=1;break}}onKeyUp(e){let t=this.GetEngine();switch(t.movefirst=!1,e.keyCode){case 38:case 87:this._camerLocalDirection.z=0;break;case 37:case 65:this._camerLocalDirection.x=0;break;case 40:case 83:this._camerLocalDirection.z=0;break;case 39:case 68:this._camerLocalDirection.x=0;break;case 81:case 69:this.keydown=!1,this._camerLocalDirection.y=0;break}}rotateX(e){this._euler.y-=e*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler)}rotateY(e){let t=this._euler.x-e*this.lookflag*.5*this.lookSpeed;t>=0?t<this.maxRotateX?this._euler.x=t:this._euler.x=this.maxRotateX:t>-this.maxRotateX?this._euler.x=t:this._euler.x=-this.maxRotateX,this.camera.quaternion.setFromEuler(this._euler)}update(){this.keydown||this.gravityTest(),this.collisionTest()}gravityTest(){if(this.applyGravity){let e=!0;this._fallingTime+=.01,this._tmpVector.set(0,-1,0);const t=this.hitTest();if(t){const n=t.point.add(new P(0,this.playerHeight,0));if(this.positionEasing){if(n.y>=this.camera.position.y||n.y-this.camera.position.y<.2){this.setCameraHeight(this.camera.position.y+(n.y-this.camera.position.y)*.08),this._fallingTime=0,e=!1;return}}else t.distance<this.playerHeight&&(this.setCameraHeight(n.y),this._fallingTime=0,e=!1)}e&&this.setCameraHeight(this.camera.position.y-this.g*Math.pow(this._fallingTime,2))}else this.setCameraHeight(this.camera.position.y)}collisionTest(){this._camerLocalDirection.x!==0&&this.collisionTestX(),this._camerLocalDirection.z!==0&&this.collisionTestZ(),this._camerLocalDirection.y!==0&&this.collisionTestY()}collisionTestX(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector.multiplyScalar(this._camerLocalDirection.x),this.applyCollision){const t=this.hitTest();if(t&&t.distance<.3)return}this.camera.position.addScaledVector(this._tmpVector,this.moveSpeed)}collisionTestZ(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector.crossVectors(this.camera.up,this._tmpVector),this._tmpVector.multiplyScalar(this._camerLocalDirection.z),this.applyCollision){const t=this.hitTest();if(t&&t.distance<.3)return}this.camera.position.addScaledVector(this._tmpVector,this.moveSpeed)}collisionTestY(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector=new P(0,1,0),this._tmpVector.multiplyScalar(this._camerLocalDirection.y),this.applyCollision){const n=this.hitTest();if(n&&n.distance<.3)return}let t=this.camera.position.clone().addScaledVector(this._tmpVector,this.moveSpeed);this.setCameraHeight(t.y)}setCameraHeight(e){let t=this.getMinHeight();this.gravityMinHeight&&t!==void 0&&e<t?this.camera.position.y=t:this.camera.position.y=e}getMinHeight(){let e,t=this.GetEngine(),n=t.ToolUntils?t.ToolUntils.GetBoundingBox(t):null;return t&&n&&(e=n.min.y),e}hitTest(){const e=this.camera.position.clone().add(this._rayOriginOffset);this._rayCaster.ray.origin=e,this._rayCaster.ray.direction=this._tmpVector;var t=this.GetEngine().scene.ground;return t&&t.material.type,null}}class yn{constructor(e,t,n){this.camera=e,this.renderer=t,this.scene=n,this.raycaster=new Qi}raycaster;worldToScreenNormalized(e){const t=e.clone();return t.project(this.camera),new he(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 he(t.x,t.y)}screenToNormalized(e,t){const n=this.renderer.domElement.clientWidth,i=this.renderer.domElement.clientHeight,r=e/n*2-1,a=-(t/i*2-1);return new he(r,a)}screenToWorld(e,t,n){if(!this.scene&&!n)return console.warn("WorldToScreen: 需要提供 scene 或 objects 参数才能进行屏幕坐标转世界坐标"),null;const i=this.screenToNormalized(e,t);this.raycaster.setFromCamera(i,this.camera);const r=n||this.scene.children,a=this.raycaster.intersectObjects(r,!0);return a.length>0?a[0].point:null}screenToWorldWithDepth(e,t,n=0){const i=this.screenToNormalized(e,t);this.raycaster.setFromCamera(i,this.camera);const r=new P;return this.raycaster.ray.at(n,r),r}updateCamera(e){this.camera=e}updateRenderer(e){this.renderer=e}updateScene(e){this.scene=e}}function cd(s){const e={self:null,options:null,mouseDownTime:0,mouseDownPosition:null,lastClickTime:0};e.init=function(f,x){e.self!=null&&e.self.disActive!=null&&e.self.type!=f.type&&e.self.disActive(),e.self=f,x==null&&(x={showCatch:!1}),e.options=x},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",u,{passive:!1}),s.renderer.domElement.addEventListener("touchmove",p,{passive:!1}),window.addEventListener("keydown",t),window.addEventListener("keyup",n)},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",u),s.renderer.domElement.removeEventListener("touchmove",p),window.removeEventListener("keydown",t),window.removeEventListener("keyup",n)};function t(f){(f.keyCode===8||f.keyCode===46)&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),f.keyCode===27&&e.self&&e.self.handelKeyEscDown!=null&&e.self.handelKeyEscDown(),f.keyCode===13&&e.self&&e.self.handelKeyEnterDown!=null&&e.self.handelKeyEnterDown(),f.keyCode===32&&e.self&&e.self.handelKeySpaceDown!=null&&e.self.handelKeySpaceDown(),f.key==="Control"&&e.self&&e.self.handelKeyCtrlDown!=null&&e.self.handelKeyCtrlDown(),f.key==="Delete"&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),f.key==="Shift"&&e.self&&e.self.handelKeyShiftDown!=null&&e.self.handelKeyShiftDown(),f.key==="Meta"&&e.self&&e.self.handelKeyMetaDown!=null&&e.self.handelKeyMetaDown()}function n(f){f.key==="Alt"&&e.self&&e.self.handelKeyAltUp!=null&&e.self.handelKeyAltUp(),f.key==="Tab"&&e.self&&e.self.handelKeyTabUp!=null&&e.self.handelKeyTabUp(),f.key==="Control"&&e.self&&e.self.handelKeyCtrlUp!=null&&e.self.handelKeyCtrlUp(),f.key==="Shift"&&e.self&&e.self.handelKeyShiftUp!=null&&e.self.handelKeyShiftUp(),f.key==="Meta"&&e.self&&e.self.handelKeyMetaUp!=null&&e.self.handelKeyMetaUp(),f.key==="Command"&&e.self&&e.self.handelKeyCommandUp!=null&&e.self.handelKeyCommandUp(),f.key==="Windows"&&e.self&&e.self.handelKeyWindowsUp!=null&&e.self.handelKeyWindowsUp()}function i(f){const x=new he,m=s.renderer.domElement.clientWidth,b=s.renderer.domElement.clientHeight;return x.x=f.offsetX/m*2-1,x.y=-(f.offsetY/b)*2+1,x}function r(f){const x=new Qi,m=i(f);return x.setFromCamera(m,s.camera),x}function a(f,x=!1){const m=r(f);if(f.raycaster=m,x){const b=g(m,f);f.catch=b}}function o(f){f.button===0&&(e.mouseDownTime=Date.now(),e.mouseDownPosition=new P(f.offsetX,f.offsetY,0),e.self&&e.self.handleMouseDown!=null&&(s.engineStatus.isFree=!0,a(f,!0),f.catch!=null&&s.controlModule.orbitControls.origin.set(f.catch.point.x,f.catch.point.y,f.catch.point.z),e.self.handleMouseDown(f)))}function l(f){e.self&&e.self.handleMouseMove!=null&&(a(f,!0),e.self.handleMouseMove(f))}function c(f){if(f.button!==0)return;const x=Date.now(),m=x-e.mouseDownTime,b=new P(f.offsetX,f.offsetY,0);e.self&&e.self.handleMouseUp!=null&&(a(f,!1),e.self.handleMouseUp(f));const v=b.distanceTo(e.mouseDownPosition);if((m<100||v==0)&&e.self&&e.self.handleMouseClick!=null){a(f,!0);const y=x-e.lastClickTime;console.log(y),y<200?e.self.handleMouseDoubleClick!=null&&e.self.handleMouseDoubleClick(f):e.self.handleMouseClick!=null&&e.self.handleMouseClick(f),e.lastClickTime=Date.now()}}function h(f){const x=f.touches[0]||f.changedTouches[0];if(!x)return null;const m=s.renderer.domElement.getBoundingClientRect(),b=x.clientX-m.left,v=x.clientY-m.top;return{offsetX:b,offsetY:v,button:0,clientX:x.clientX,clientY:x.clientY,preventDefault:()=>f.preventDefault(),stopPropagation:()=>f.stopPropagation(),originalEvent:f}}function d(f){if(f.preventDefault(),f.touches.length!==1)return;const x=h(f);x&&o(x)}function p(f){if(f.preventDefault(),f.touches.length!==1)return;const x=h(f);x&&l(x)}function u(f){f.preventDefault();const x=h(f);x&&c(x)}function g(f,x){if(!s.engineStatus.isFree){s.hoverHighLight.clearHighlight();return}s.catchSvg.innerHTML="";const m=s.octreeBox.rayInterationModel(f);let b=f.intersectObjects(s.scene.children.filter(U=>U instanceof Ut),!0);if(b.length>0&&(m.length==0||b[0].distance<m[0].distance)){let U=b[0].object;if(U.ids!=null&&U.ids.length!=0){let H=U.ids[b[0].instanceId],G={object:{url:U.url,id:H,name:H,isInstance:!0},face:b[0].face,distance:b[0].distance,point:b[0].point,instanceId:b[0].instanceId,matrix:U.matrixs[b[0].instanceId]};m.splice(0,0,G)}}if(m.length===0)return;let v=m[0].object.url,y=m[0].object.name,_=s.modelEdge.getModelEdge(v,y);_||(_=[0,0,[]]);let M=[];_[2].forEach(U=>{U[0]!=null&&U[1]!=null&&M.push({X:U[0].X*.5+U[1].X*.5,Y:U[0].Y*.5+U[1].Y*.5,Z:U[0].Z*.5+U[1].Z*.5})});let T=[..._[2].map(U=>U[0]),...M],R="face",w=[],E=[],I=10;if(T.forEach(U=>{if(U!=null){let H=new P(U.X,U.Z,-U.Y),G=s.worldToScreen.worldToScreen(H),Z=Math.sqrt(Math.pow(G.x-x.offsetX,2)+Math.pow(G.y-x.offsetY,2));Z<I&&(I=Z,w.push({point:H,distance:Z,pointxy:G}))}}),w.length>0?(w.sort((U,H)=>U.distance-H.distance),R="point"):(_[2].forEach(U=>{if(U[0]!=null&&U[1]!=null){let H=new P(U[0].X,U[0].Z,-U[0].Y),G=new P(U[1].X,U[1].Z,-U[1].Y),Z=s.worldToScreen.worldToScreen(H),j=s.worldToScreen.worldToScreen(G),ie=A(new he(x.offsetX,x.offsetY),Z,j);if(ie<I){let X=B(new he(x.offsetX,x.offsetY),Z,j),$=S(X,H,G);E.push({distance:ie,point:$,pointxy:s.worldToScreen.worldToScreen($),start:Z,end:j})}}}),E.length>0&&(E.sort((U,H)=>U.distance-H.distance),R="line")),R=="point"&&e.options.showCatch){const U=new yn(s.camera,s.renderer,s.scene).worldToScreen(w[0].point);s.catchSvg.innerHTML="";const H=U.x+s.reactBoundingClientRect.left,G=U.y+s.reactBoundingClientRect.top;console.log(H,G);const Z=document.createElementNS("http://www.w3.org/2000/svg","polygon");Z.setAttribute("class","catchPoint"),Z.setAttribute("points",`${H},${G-8} ${H-7},${G+4} ${H+7},${G+4}`),s.catchSvg.appendChild(Z),m[0].point=w[0].point}else if(R=="line"&&e.options.showCatch){s.worldToScreen.worldToScreen(E[0].point);const U=E[0].start,H=E[0].end;s.catchSvg.innerHTML="";const G=document.createElementNS("http://www.w3.org/2000/svg","line");G.setAttribute("class","catchLine"),G.setAttribute("x1",(U.x+s.reactBoundingClientRect.left).toString()),G.setAttribute("y1",(U.y+s.reactBoundingClientRect.top).toString()),G.setAttribute("x2",(H.x+s.reactBoundingClientRect.left).toString()),G.setAttribute("y2",(H.y+s.reactBoundingClientRect.top).toString()),G.setAttribute("stroke","rgb(8, 223, 215)"),G.setAttribute("stroke-width","2"),s.catchSvg.appendChild(G),m[0].point=E[0].point}else if(R=="face"&&e.options.showCatch){let U=m[0].point.clone(),H=m[0].normal||(m[0].face?m[0].face.normal:null);const G=(H?H.clone():new P(0,0,1)).normalize(),Z=Math.abs(G.y)<.9?new P(0,1,0):new P(1,0,0),j=new P().crossVectors(G,Z).normalize(),ie=new P().crossVectors(G,j).normalize(),X=.05,$=[new P().copy(j).add(ie).multiplyScalar(X),new P().copy(j).sub(ie).multiplyScalar(X),new P().copy(j).multiplyScalar(-1).sub(ie).multiplyScalar(X),new P().copy(j).multiplyScalar(-1).add(ie).multiplyScalar(X)].map(pe=>new P().copy(U).add(pe)).map(pe=>s.worldToScreen.worldToScreen(pe));s.catchSvg.innerHTML="";const ue=document.createElementNS("http://www.w3.org/2000/svg","polygon");ue.setAttribute("class","catchFace"),ue.setAttribute("points",$.map(pe=>`${pe.x+s.reactBoundingClientRect.left},${pe.y+s.reactBoundingClientRect.top}`).join(" ")),ue.setAttribute("fill","rgba(1, 238, 255, 0.2)"),ue.setAttribute("stroke","rgb(0, 255, 247)"),ue.setAttribute("stroke-width","1"),s.catchSvg.appendChild(ue)}return m[0];function A(U,H,G){const Z=new he().subVectors(G,H),j=Z.lengthSq();if(j<1e-10)return U.distanceTo(H);const ie=new he().subVectors(U,H),X=zt.clamp(ie.dot(Z)/j,0,1),$=new he().copy(Z).multiplyScalar(X).add(H);return U.distanceTo($)}function B(U,H,G){const Z=new he().subVectors(G,H),j=Z.lengthSq();if(j<1e-10)return 0;const ie=new he().subVectors(U,H);return zt.clamp(ie.dot(Z)/j,0,1)}function S(U,H,G){const Z=zt.clamp(U,0,1);return new P().lerpVectors(H,G,Z)}}return e}class V3{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=cd(this.engine),this.handelBehaved.init(this,null),this.handelBehaved.active()}init(){this.orbitControls=new P3(this.engine,this.engine.camera,this.engine.renderer.domElement),this.orbitControls.showOriginIcon=!0,this.firstPersonControls=new $f(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}getMoveSpeed(){return this.firstPersonControls.moveSpeed}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 $f(this.engine,this.engine.camera,this.engine.renderer.domElement,[]),this.orbitControls.enabled=!1,this.firstPersonControls.enabled=!0,this.firstPersonControls.isActive=!0}switchDefaultMode(){this.firstPersonControls&&(this.firstPersonControls.enabled=!1,this.engine.cameraModule.switchToOrthographicCamera()),this.orbitControls.enabled=!0}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 As={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 Ps{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 G3=new Ai(-1,1,1,-1,0,1);class W3 extends pt{constructor(){super(),this.setAttribute("position",new jt([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new jt([0,2,0,0,2,0],2))}}const X3=new W3;class el{constructor(e){this._mesh=new at(X3,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,G3)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class tl extends Ps{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof Lt?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Hn.clone(e.uniforms),this.material=new Lt({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 el(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class Kf extends Ps{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const i=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(i.REPLACE,i.REPLACE,i.REPLACE),r.buffers.stencil.setFunc(i.ALWAYS,a,4294967295),r.buffers.stencil.setClear(o),r.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),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(i.EQUAL,1,4294967295),r.buffers.stencil.setOp(i.KEEP,i.KEEP,i.KEEP),r.buffers.stencil.setLocked(!0)}}class j3 extends Ps{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class q3{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new he);this._width=n.width,this._height=n.height,t=new An(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:dn}),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 tl(As),this.copyPass.material.blending=St,this.clock=new mf}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){e===void 0&&(e=this.clock.getDelta());const t=this.renderer.getRenderTarget();let n=!1;for(let i=0,r=this.passes.length;i<r;i++){const a=this.passes[i];if(a.enabled!==!1){if(a.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(i),a.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),a.needsSwap){if(n){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()}Kf!==void 0&&(a instanceof Kf?n=!0:a instanceof j3&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new he);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,i=this._height*this._pixelRatio;this.renderTarget1.setSize(n,i),this.renderTarget2.setSize(n,i);for(let r=0;r<this.passes.length;r++)this.passes[r].setSize(n,i)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class Z3 extends Ps{constructor(e,t,n=null,i=null,r=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=i,this.clearAlpha=r,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new Fe}render(e,t,n){const i=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:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(r),this.overrideMaterial!==null&&(this.scene.overrideMaterial=a),e.autoClear=i}}const nl={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 he},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new Ie},cameraProjectionMatrixInverse:{value:new Ie},cameraWorldMatrix:{value:new Ie},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) {
vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);
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);
if (depth >= 1.0) {
discard;
return;
}
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;
}`},il={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 );
}`},hd={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 Y3(s=5){const e=Math.floor(s)%2===0?Math.floor(s)+1:Math.floor(s),t=$3(e),n=t.length,i=new Uint8Array(n*4);for(let a=0;a<n;++a){const o=t[a],l=2*Math.PI*o/n,c=new P(Math.cos(l),Math.sin(l),0).normalize();i[a*4]=(c.x*.5+.5)*255,i[a*4+1]=(c.y*.5+.5)*255,i[a*4+2]=127,i[a*4+3]=255}const r=new ys(i,e,e);return r.wrapS=Tn,r.wrapT=Tn,r.needsUpdate=!0,r}function $3(s){const e=Math.floor(s)%2===0?Math.floor(s)+1:Math.floor(s),t=e*e,n=Array(t).fill(0);let i=Math.floor(e/2),r=e-1;for(let a=1;a<=t;){if(i===-1&&r===e?(r=e-2,i=0):(r===e&&(r=0),i<0&&(i=e-1)),n[i*e+r]!==0){r-=2,i++;continue}else n[i*e+r]=a++;r++,i--}return n}const sl={defines:{SAMPLES:16,SAMPLE_VECTORS:Jf(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 he},cameraProjectionMatrixInverse:{value:new Ie},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) {
vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);
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 Jf(s,e,t){const n=K3(s,e,t);let i="vec3[SAMPLES](";for(let r=0;r<s;r++){const a=n[r];i+=`vec3(${a.x}, ${a.y}, ${a.z})${r<s-1?",":")"}`}return i}function K3(s,e,t){const n=[];for(let i=0;i<s;i++){const r=2*Math.PI*e*i/s,a=Math.pow(i/(s-1),t);n.push(new P(Math.cos(r),Math.sin(r),a))}return n}class Qf{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 n,i,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,p=l-d,u=c-d,g=e-p,f=t-u;let x,m;g>f?(x=1,m=0):(x=0,m=1);const b=g-x+h,v=f-m+h,y=g-1+2*h,_=f-1+2*h,M=l&255,T=c&255,R=this.perm[M+this.perm[T]]%12,w=this.perm[M+x+this.perm[T+m]]%12,E=this.perm[M+1+this.perm[T+1]]%12;let I=.5-g*g-f*f;I<0?n=0:(I*=I,n=I*I*this._dot(this.grad3[R],g,f));let A=.5-b*b-v*v;A<0?i=0:(A*=A,i=A*A*this._dot(this.grad3[w],b,v));let B=.5-y*y-_*_;return B<0?r=0:(B*=B,r=B*B*this._dot(this.grad3[E],y,_)),70*(n+i+r)}noise3d(e,t,n){let i,r,a,o;const l=(e+t+n)*.3333333333333333,c=Math.floor(e+l),h=Math.floor(t+l),d=Math.floor(n+l),p=1/6,u=(c+h+d)*p,g=c-u,f=h-u,x=d-u,m=e-g,b=t-f,v=n-x;let y,_,M,T,R,w;m>=b?b>=v?(y=1,_=0,M=0,T=1,R=1,w=0):m>=v?(y=1,_=0,M=0,T=1,R=0,w=1):(y=0,_=0,M=1,T=1,R=0,w=1):b<v?(y=0,_=0,M=1,T=0,R=1,w=1):m<v?(y=0,_=1,M=0,T=0,R=1,w=1):(y=0,_=1,M=0,T=1,R=1,w=0);const E=m-y+p,I=b-_+p,A=v-M+p,B=m-T+2*p,S=b-R+2*p,U=v-w+2*p,H=m-1+3*p,G=b-1+3*p,Z=v-1+3*p,j=c&255,ie=h&255,X=d&255,$=this.perm[j+this.perm[ie+this.perm[X]]]%12,ue=this.perm[j+y+this.perm[ie+_+this.perm[X+M]]]%12,pe=this.perm[j+T+this.perm[ie+R+this.perm[X+w]]]%12,fe=this.perm[j+1+this.perm[ie+1+this.perm[X+1]]]%12;let se=.6-m*m-b*b-v*v;se<0?i=0:(se*=se,i=se*se*this._dot3(this.grad3[$],m,b,v));let ce=.6-E*E-I*I-A*A;ce<0?r=0:(ce*=ce,r=ce*ce*this._dot3(this.grad3[ue],E,I,A));let me=.6-B*B-S*S-U*U;me<0?a=0:(me*=me,a=me*me*this._dot3(this.grad3[pe],B,S,U));let be=.6-H*H-G*G-Z*Z;return be<0?o=0:(be*=be,o=be*be*this._dot3(this.grad3[fe],H,G,Z)),32*(i+r+a+o)}noise4d(e,t,n,i){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,p,u,g;const f=(e+t+n+i)*l,x=Math.floor(e+f),m=Math.floor(t+f),b=Math.floor(n+f),v=Math.floor(i+f),y=(x+m+b+v)*c,_=x-y,M=m-y,T=b-y,R=v-y,w=e-_,E=t-M,I=n-T,A=i-R,B=w>E?32:0,S=w>I?16:0,U=E>I?8:0,H=w>A?4:0,G=E>A?2:0,Z=I>A?1:0,j=B+S+U+H+G+Z,ie=a[j][0]>=3?1:0,X=a[j][1]>=3?1:0,$=a[j][2]>=3?1:0,ue=a[j][3]>=3?1:0,pe=a[j][0]>=2?1:0,fe=a[j][1]>=2?1:0,se=a[j][2]>=2?1:0,ce=a[j][3]>=2?1:0,me=a[j][0]>=1?1:0,be=a[j][1]>=1?1:0,Se=a[j][2]>=1?1:0,Be=a[j][3]>=1?1:0,Je=w-ie+c,ke=E-X+c,C=I-$+c,D=A-ue+c,W=w-pe+2*c,O=E-fe+2*c,k=I-se+2*c,F=A-ce+2*c,ee=w-me+3*c,J=E-be+3*c,q=I-Se+3*c,N=A-Be+3*c,L=w-1+4*c,V=E-1+4*c,K=I-1+4*c,le=A-1+4*c,te=x&255,Te=m&255,ye=b&255,Re=v&255,De=o[te+o[Te+o[ye+o[Re]]]]%32,de=o[te+ie+o[Te+X+o[ye+$+o[Re+ue]]]]%32,_e=o[te+pe+o[Te+fe+o[ye+se+o[Re+ce]]]]%32,Ve=o[te+me+o[Te+be+o[ye+Se+o[Re+Be]]]]%32,Ue=o[te+1+o[Te+1+o[ye+1+o[Re+1]]]]%32;let Ae=.6-w*w-E*E-I*I-A*A;Ae<0?h=0:(Ae*=Ae,h=Ae*Ae*this._dot4(r[De],w,E,I,A));let Ge=.6-Je*Je-ke*ke-C*C-D*D;Ge<0?d=0:(Ge*=Ge,d=Ge*Ge*this._dot4(r[de],Je,ke,C,D));let Y=.6-W*W-O*O-k*k-F*F;Y<0?p=0:(Y*=Y,p=Y*Y*this._dot4(r[_e],W,O,k,F));let Ce=.6-ee*ee-J*J-q*q-N*N;Ce<0?u=0:(Ce*=Ce,u=Ce*Ce*this._dot4(r[Ve],ee,J,q,N));let Me=.6-L*L-V*V-K*K-le*le;return Me<0?g=0:(Me*=Me,g=Me*Me*this._dot4(r[Ue],L,V,K,le)),27*(h+d+p+u+g)}_dot(e,t,n){return e[0]*t+e[1]*n}_dot3(e,t,n,i){return e[0]*t+e[1]*n+e[2]*i}_dot4(e,t,n,i,r){return e[0]*t+e[1]*n+e[2]*i+e[3]*r}}class _n extends Ps{constructor(e,t,n=512,i=512,r,a,o){super(),this.width=n,this.height=i,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=Y3(),this.pdNoiseTexture=this._generateNoise(),this.gtaoRenderTarget=new An(this.width,this.height,{type:dn}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new Lt({defines:Object.assign({},nl.defines),uniforms:Hn.clone(nl.uniforms),vertexShader:nl.vertexShader,fragmentShader:nl.fragmentShader,blending:St,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 lf,this.normalMaterial.blending=St,this.pdMaterial=new Lt({defines:Object.assign({},sl.defines),uniforms:Hn.clone(sl.uniforms),vertexShader:sl.vertexShader,fragmentShader:sl.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 Lt({defines:Object.assign({},il.defines),uniforms:Hn.clone(il.uniforms),vertexShader:il.vertexShader,fragmentShader:il.fragmentShader,blending:St}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new Lt({uniforms:Hn.clone(As.uniforms),vertexShader:As.vertexShader,fragmentShader:As.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:Ya,blendDst:us,blendEquation:Cn,blendSrcAlpha:Za,blendDstAlpha:us,blendEquationAlpha:Cn}),this.blendMaterial=new Lt({uniforms:Hn.clone(hd.uniforms),vertexShader:hd.vertexShader,fragmentShader:hd.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:ic,blendSrc:Ya,blendDst:us,blendEquation:Cn,blendSrcAlpha:Za,blendDstAlpha:us,blendEquationAlpha:Cn}),this._fsQuad=new el(null),this._originalClearColor=new Fe,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 Fo,this.depthTexture.format=ms,this.depthTexture.type=fs,this.normalRenderTarget=new An(this.width,this.height,{minFilter:Xt,magFilter:Xt,type:dn,depthTexture:this.depthTexture}),this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0);const n=this.normalTexture?1:0,i=this.depthTexture===this.normalTexture?"w":"x";this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=n,this.gtaoMaterial.defines.DEPTH_SWIZZLING=i,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=n,this.pdMaterial.defines.DEPTH_SWIZZLING=i,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=Jf(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(e,t,n){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 _n.OUTPUT.Off:break;case _n.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=St,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case _n.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=St,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case _n.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=St,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case _n.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 _n.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=St,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case _n.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=St,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,n,i,r){e.getClearColor(this._originalClearColor);const a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i!=null&&(e.setClearColor(i),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,n,i,r){e.getClearColor(this._originalClearColor);const a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i=t.clearColor||i,r=t.clearAlpha||r,i!=null&&(e.setClearColor(i),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(n){(n.isPoints||n.isLine||n.isLine2)&&n.visible&&(n.visible=!1,t.push(n))})}_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 Qf,n=e*e*4,i=new Uint8Array(n);for(let a=0;a<e;a++)for(let o=0;o<e;o++){const l=a,c=o;i[(a*e+o)*4]=(t.noise(l,c)*.5+.5)*255,i[(a*e+o)*4+1]=(t.noise(l+e,c)*.5+.5)*255,i[(a*e+o)*4+2]=(t.noise(l,c+e)*.5+.5)*255,i[(a*e+o)*4+3]=(t.noise(l+e,c+e)*.5+.5)*255}const r=new ys(i,e,e,vn,$n);return r.wrapS=Tn,r.wrapT=Tn,r.needsUpdate=!0,r}}_n.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};const rl={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 he},cameraProjectionMatrix:{value:new Ie},cameraInverseProjectionMatrix:{value:new Ie},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>
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 == 1.0 ) {
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 );
}
}`},al={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 );
}`},ol={uniforms:{tDiffuse:{value:null},resolution:{value:new he}},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 Li extends Ps{constructor(e,t,n=512,i=512,r=32){super(),this.width=n,this.height=i,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 Fo;a.format=ms,a.type=fs,this.normalRenderTarget=new An(this.width,this.height,{minFilter:Xt,magFilter:Xt,type:dn,depthTexture:a}),this.ssaoRenderTarget=new An(this.width,this.height,{type:dn}),this.blurRenderTarget=this.ssaoRenderTarget.clone(),this.ssaoMaterial=new Lt({defines:Object.assign({},rl.defines),uniforms:Hn.clone(rl.uniforms),vertexShader:rl.vertexShader,fragmentShader:rl.fragmentShader,blending:St}),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 lf,this.normalMaterial.blending=St,this.blurMaterial=new Lt({defines:Object.assign({},ol.defines),uniforms:Hn.clone(ol.uniforms),vertexShader:ol.vertexShader,fragmentShader:ol.fragmentShader}),this.blurMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.depthRenderMaterial=new Lt({defines:Object.assign({},al.defines),uniforms:Hn.clone(al.uniforms),vertexShader:al.vertexShader,fragmentShader:al.fragmentShader,blending:St}),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 Lt({uniforms:Hn.clone(As.uniforms),vertexShader:As.vertexShader,fragmentShader:As.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:Ya,blendDst:us,blendEquation:Cn,blendSrcAlpha:Za,blendDstAlpha:us,blendEquationAlpha:Cn}),this._fsQuad=new el(null),this._originalClearColor=new Fe}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,n){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 Li.OUTPUT.SSAO:this.copyMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.copyMaterial.blending=St,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:n);break;case Li.OUTPUT.Blur:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=St,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:n);break;case Li.OUTPUT.Depth:this._renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:n);break;case Li.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=St,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:n);break;case Li.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=ic,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:n);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,n,i,r){e.getClearColor(this._originalClearColor);const a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i!=null&&(e.setClearColor(i),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,n,i,r){e.getClearColor(this._originalClearColor);const a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i=t.clearColor||i,r=t.clearAlpha||r,i!=null&&(e.setClearColor(i),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 n=0;n<e;n++){const i=new P;i.x=Math.random()*2-1,i.y=Math.random()*2-1,i.z=Math.random(),i.normalize();let r=n/e;r=zt.lerp(.1,1,r*r),i.multiplyScalar(r),t.push(i)}}_generateRandomKernelRotations(){const e=new Qf,t=16,n=new Float32Array(t);for(let i=0;i<t;i++){const r=Math.random()*2-1,a=Math.random()*2-1,o=0;n[i]=e.noise3d(r,a,o)}this.noiseTexture=new ys(n,4,4,eo,hn),this.noiseTexture.wrapS=Tn,this.noiseTexture.wrapT=Tn,this.noiseTexture.needsUpdate=!0}_overrideVisibility(){const e=this.scene,t=this._visibilityCache;e.traverse(function(n){(n.isPoints||n.isLine||n.isLine2)&&n.visible&&(n.visible=!1,t.push(n))})}_restoreVisibility(){const e=this._visibilityCache;for(let t=0;t<e.length;t++)e[t].visible=!0;e.length=0}}Li.OUTPUT={Default:0,SSAO:1,Blur:2,Depth:3,Normal:4};const ll={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 J3 extends Ps{constructor(){super(),this.uniforms=Hn.clone(ll.uniforms),this.material=new B1({name:ll.name,uniforms:this.uniforms,vertexShader:ll.vertexShader,fragmentShader:ll.fragmentShader}),this._fsQuad=new el(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.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)===ct&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===Au?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===Pu?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===Ru?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===Lu?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===Du?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===Nu?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===Iu&&(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 Q3={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new he(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 );
}`},e_={uniforms:{tDiffuse:{value:null},saturation:{value:1.2},contrast:{value:1.2}},vertexShader:`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`,fragmentShader:`
uniform sampler2D tDiffuse;
uniform float saturation;
uniform float contrast;
varying vec2 vUv;
void main() {
vec4 color = texture2D(tDiffuse, vUv);
// 转换为灰度值用于饱和度调整
float gray = dot(color.rgb, vec3(0.299, 0.587, 0.114));
// 混合原始颜色和灰度值来调整饱和度
color.rgb = mix(vec3(gray), color.rgb, saturation);
// 调整对比度
color.rgb = (color.rgb - 0.5) * contrast + 0.5;
gl_FragColor = color;
}
`};class t_{engine;composer;saturationPass;ssaoPass;gtaoPass;outputPass;fxaaPass;constructor(e){this.engine=e}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 n=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1;this.composer.setPixelRatio(n),this.composer.setSize(e,t);const i=this.composer.passes.find(r=>r instanceof tl&&r.material.uniforms.resolution);i&&(i.material.uniforms.resolution.value.x=1/(e*n),i.material.uniforms.resolution.value.y=1/(t*n))}init(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize(),n=this.engine.scene,i=this.engine.camera,r=this.engine.renderer,a=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1,o=new An(e,t,{minFilter:Pt,magFilter:Pt,format:vn,samples:4});this.composer=new q3(r,o),this.composer.setPixelRatio(a),this.composer.setSize(e,t);const l=new Z3(n,i);this.composer.addPass(l),this.gtaoPass=new _n(n,i,e,t),this.gtaoPass.output=_n.OUTPUT.Default,this.gtaoPass.blendIntensity=.3,this.gtaoPass.enabled=!1,this.gtaoPass.updateGtaoMaterial&&this.gtaoPass.updateGtaoMaterial({radius:1,distanceExponent:1,thickness:1,scale:1,distanceFallOff:1,screenSpaceRadius:!0}),this.composer.addPass(this.gtaoPass),this.ssaoPass=new Li(n,i,e,t),this.ssaoPass.kernelRadius=8,this.ssaoPass.minDistance=.005,this.ssaoPass.maxDistance=.1,this.ssaoPass.output=Li.OUTPUT.Default,this.ssaoPass.enabled=!1,this.composer.addPass(this.ssaoPass),this.saturationPass=new tl(e_),this.saturationPass.uniforms.saturation.value=1.3,this.saturationPass.uniforms.contrast.value=1.1,this.saturationPass.enabled=!1,this.composer.addPass(this.saturationPass),this.outputPass=new J3,this.outputPass.enabled=!1,this.composer.addPass(this.outputPass),this.fxaaPass=new tl(Q3),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 cl=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function em(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function hl(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 tm={exports:{}},nm;function n_(){return nm||(nm=1,(function(s,e){(function(t){s.exports=t()})(function(){return(function t(n,i,r){function a(c,h){if(!i[c]){if(!n[c]){var d=typeof hl=="function"&&hl;if(!h&&d)return d(c,!0);if(o)return o(c,!0);var p=new Error("Cannot find module '"+c+"'");throw p.code="MODULE_NOT_FOUND",p}var u=i[c]={exports:{}};n[c][0].call(u.exports,function(g){var f=n[c][1][g];return a(f||g)},u,u.exports,t,n,i,r)}return i[c].exports}for(var o=typeof hl=="function"&&hl,l=0;l<r.length;l++)a(r[l]);return a})({1:[function(t,n,i){var r=t("./utils"),a=t("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(l){for(var c,h,d,p,u,g,f,x=[],m=0,b=l.length,v=b,y=r.getTypeOf(l)!=="string";m<l.length;)v=b-m,d=y?(c=l[m++],h=m<b?l[m++]:0,m<b?l[m++]:0):(c=l.charCodeAt(m++),h=m<b?l.charCodeAt(m++):0,m<b?l.charCodeAt(m++):0),p=c>>2,u=(3&c)<<4|h>>4,g=1<v?(15&h)<<2|d>>6:64,f=2<v?63&d:64,x.push(o.charAt(p)+o.charAt(u)+o.charAt(g)+o.charAt(f));return x.join("")},i.decode=function(l){var c,h,d,p,u,g,f=0,x=0,m="data:";if(l.substr(0,m.length)===m)throw new Error("Invalid base64 input, it looks like a data url.");var b,v=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===o.charAt(64)&&v--,l.charAt(l.length-2)===o.charAt(64)&&v--,v%1!=0)throw new Error("Invalid base64 input, bad content length.");for(b=a.uint8array?new Uint8Array(0|v):new Array(0|v);f<l.length;)c=o.indexOf(l.charAt(f++))<<2|(p=o.indexOf(l.charAt(f++)))>>4,h=(15&p)<<4|(u=o.indexOf(l.charAt(f++)))>>2,d=(3&u)<<6|(g=o.indexOf(l.charAt(f++))),b[x++]=c,u!==64&&(b[x++]=h),g!==64&&(b[x++]=d);return b}},{"./support":30,"./utils":32}],2:[function(t,n,i){var r=t("./external"),a=t("./stream/DataWorker"),o=t("./stream/Crc32Probe"),l=t("./stream/DataLengthProbe");function c(h,d,p,u,g){this.compressedSize=h,this.uncompressedSize=d,this.crc32=p,this.compression=u,this.compressedContent=g}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,p){return h.pipe(new o).pipe(new l("uncompressedSize")).pipe(d.compressWorker(p)).pipe(new l("compressedSize")).withStreamInfo("compression",d)},n.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,n,i){var r=t("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},i.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,n,i){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})();n.exports=function(o,l){return o!==void 0&&o.length?r.getTypeOf(o)!=="string"?(function(c,h,d,p){var u=a,g=p+d;c^=-1;for(var f=p;f<g;f++)c=c>>>8^u[255&(c^h[f])];return-1^c})(0|l,o,o.length,0):(function(c,h,d,p){var u=a,g=p+d;c^=-1;for(var f=p;f<g;f++)c=c>>>8^u[255&(c^h.charCodeAt(f))];return-1^c})(0|l,o,o.length,0):0}},{"./utils":32}],5:[function(t,n,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(t,n,i){var r=null;r=typeof Promise<"u"?Promise:t("lie"),n.exports={Promise:r}},{lie:37}],7:[function(t,n,i){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,p){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=p,this.meta={}}i.magic="\b\0",o.inherits(h,l),h.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(c,d.data),!1)},h.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},h.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},h.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var d=this;this._pako.onData=function(p){d.push({data:p,meta:d.meta})}},i.compressWorker=function(d){return new h("Deflate",d)},i.uncompressWorker=function(){return new h("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,n,i){function r(u,g){var f,x="";for(f=0;f<g;f++)x+=String.fromCharCode(255&u),u>>>=8;return x}function a(u,g,f,x,m,b){var v,y,_=u.file,M=u.compression,T=b!==c.utf8encode,R=o.transformTo("string",b(_.name)),w=o.transformTo("string",c.utf8encode(_.name)),E=_.comment,I=o.transformTo("string",b(E)),A=o.transformTo("string",c.utf8encode(E)),B=w.length!==_.name.length,S=A.length!==E.length,U="",H="",G="",Z=_.dir,j=_.date,ie={crc32:0,compressedSize:0,uncompressedSize:0};g&&!f||(ie.crc32=u.crc32,ie.compressedSize=u.compressedSize,ie.uncompressedSize=u.uncompressedSize);var X=0;g&&(X|=8),T||!B&&!S||(X|=2048);var $=0,ue=0;Z&&($|=16),m==="UNIX"?(ue=798,$|=(function(fe,se){var ce=fe;return fe||(ce=se?16893:33204),(65535&ce)<<16})(_.unixPermissions,Z)):(ue=20,$|=(function(fe){return 63&(fe||0)})(_.dosPermissions)),v=j.getUTCHours(),v<<=6,v|=j.getUTCMinutes(),v<<=5,v|=j.getUTCSeconds()/2,y=j.getUTCFullYear()-1980,y<<=4,y|=j.getUTCMonth()+1,y<<=5,y|=j.getUTCDate(),B&&(H=r(1,1)+r(h(R),4)+w,U+="up"+r(H.length,2)+H),S&&(G=r(1,1)+r(h(I),4)+A,U+="uc"+r(G.length,2)+G);var pe="";return pe+=`
\0`,pe+=r(X,2),pe+=M.magic,pe+=r(v,2),pe+=r(y,2),pe+=r(ie.crc32,4),pe+=r(ie.compressedSize,4),pe+=r(ie.uncompressedSize,4),pe+=r(R.length,2),pe+=r(U.length,2),{fileRecord:d.LOCAL_FILE_HEADER+pe+R+U,dirRecord:d.CENTRAL_FILE_HEADER+r(ue,2)+pe+r(I.length,2)+"\0\0\0\0"+r($,4)+r(x,4)+R+U+I}}var o=t("../utils"),l=t("../stream/GenericWorker"),c=t("../utf8"),h=t("../crc32"),d=t("../signature");function p(u,g,f,x){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=g,this.zipPlatform=f,this.encodeFileName=x,this.streamFiles=u,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(p,l),p.prototype.push=function(u){var g=u.meta.percent||0,f=this.entriesCount,x=this._sources.length;this.accumulate?this.contentBuffer.push(u):(this.bytesWritten+=u.data.length,l.prototype.push.call(this,{data:u.data,meta:{currentFile:this.currentFile,percent:f?(g+100*(f-x-1))/f:100}}))},p.prototype.openedSource=function(u){this.currentSourceOffset=this.bytesWritten,this.currentFile=u.file.name;var g=this.streamFiles&&!u.file.dir;if(g){var f=a(u,g,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:f.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(u){this.accumulate=!1;var g=this.streamFiles&&!u.file.dir,f=a(u,g,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(f.dirRecord),g)this.push({data:(function(x){return d.DATA_DESCRIPTOR+r(x.crc32,4)+r(x.compressedSize,4)+r(x.uncompressedSize,4)})(u),meta:{percent:100}});else for(this.push({data:f.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var u=this.bytesWritten,g=0;g<this.dirRecords.length;g++)this.push({data:this.dirRecords[g],meta:{percent:100}});var f=this.bytesWritten-u,x=(function(m,b,v,y,_){var M=o.transformTo("string",_(y));return d.CENTRAL_DIRECTORY_END+"\0\0\0\0"+r(m,2)+r(m,2)+r(b,4)+r(v,4)+r(M.length,2)+M})(this.dirRecords.length,f,u,this.zipComment,this.encodeFileName);this.push({data:x,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(u){this._sources.push(u);var g=this;return u.on("data",function(f){g.processChunk(f)}),u.on("end",function(){g.closedSource(g.previous.streamInfo),g._sources.length?g.prepareNextSource():g.end()}),u.on("error",function(f){g.error(f)}),this},p.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},p.prototype.error=function(u){var g=this._sources;if(!l.prototype.error.call(this,u))return!1;for(var f=0;f<g.length;f++)try{g[f].error(u)}catch{}return!0},p.prototype.lock=function(){l.prototype.lock.call(this);for(var u=this._sources,g=0;g<u.length;g++)u[g].lock()},n.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,n,i){var r=t("../compressions"),a=t("./ZipFileWorker");i.generateWorker=function(o,l,c){var h=new a(l.streamFiles,c,l.platform,l.encodeFileName),d=0;try{o.forEach(function(p,u){d++;var g=(function(b,v){var y=b||v,_=r[y];if(!_)throw new Error(y+" is not a valid compression method !");return _})(u.options.compression,l.compression),f=u.options.compressionOptions||l.compressionOptions||{},x=u.dir,m=u.date;u._compressWorker(g,f).withStreamInfo("file",{name:p,dir:x,date:m,comment:u.comment||"",unixPermissions:u.unixPermissions,dosPermissions:u.dosPermissions}).pipe(h)}),h.entriesCount=d}catch(p){h.error(p)}return h}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(t,n,i){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"),n.exports=r},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(t,n,i){var r=t("./utils"),a=t("./external"),o=t("./utf8"),l=t("./zipEntries"),c=t("./stream/Crc32Probe"),h=t("./nodejsUtils");function d(p){return new a.Promise(function(u,g){var f=p.decompressed.getContentWorker().pipe(new c);f.on("error",function(x){g(x)}).on("end",function(){f.streamInfo.crc32!==p.decompressed.crc32?g(new Error("Corrupted zip : CRC32 mismatch")):u()}).resume()})}n.exports=function(p,u){var g=this;return u=r.extend(u||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),h.isNode&&h.isStream(p)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):r.prepareContent("the loaded zip file",p,!0,u.optimizedBinaryString,u.base64).then(function(f){var x=new l(u);return x.load(f),x}).then(function(f){var x=[a.Promise.resolve(f)],m=f.files;if(u.checkCRC32)for(var b=0;b<m.length;b++)x.push(d(m[b]));return a.Promise.all(x)}).then(function(f){for(var x=f.shift(),m=x.files,b=0;b<m.length;b++){var v=m[b],y=v.fileNameStr,_=r.resolve(v.fileNameStr);g.file(_,v.decompressed,{binary:!0,optimizedBinaryString:!0,date:v.date,dir:v.dir,comment:v.fileCommentStr.length?v.fileCommentStr:null,unixPermissions:v.unixPermissions,dosPermissions:v.dosPermissions,createFolders:u.createFolders}),v.dir||(g.file(_).unsafeOriginalName=y)}return x.zipComment.length&&(g.comment=x.zipComment),g})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,n,i){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)},n.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(t,n,i){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,p){h.push(d)||h._helper.pause(),c&&c(p)}).on("error",function(d){h.emit("error",d)}).on("end",function(){h.push(null)})}t("../utils").inherits(a,r),a.prototype._read=function(){this._helper.resume()},n.exports=a},{"../utils":32,"readable-stream":16}],14:[function(t,n,i){n.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,n,i){function r(_,M,T){var R,w=o.getTypeOf(M),E=o.extend(T||{},h);E.date=E.date||new Date,E.compression!==null&&(E.compression=E.compression.toUpperCase()),typeof E.unixPermissions=="string"&&(E.unixPermissions=parseInt(E.unixPermissions,8)),E.unixPermissions&&16384&E.unixPermissions&&(E.dir=!0),E.dosPermissions&&16&E.dosPermissions&&(E.dir=!0),E.dir&&(_=m(_)),E.createFolders&&(R=x(_))&&b.call(this,R,!0);var I=w==="string"&&E.binary===!1&&E.base64===!1;T&&T.binary!==void 0||(E.binary=!I),(M instanceof d&&M.uncompressedSize===0||E.dir||!M||M.length===0)&&(E.base64=!1,E.binary=!0,M="",E.compression="STORE",w="string");var A=null;A=M instanceof d||M instanceof l?M:g.isNode&&g.isStream(M)?new f(_,M):o.prepareContent(_,M,E.binary,E.optimizedBinaryString,E.base64);var B=new p(_,A,E);this.files[_]=B}var a=t("./utf8"),o=t("./utils"),l=t("./stream/GenericWorker"),c=t("./stream/StreamHelper"),h=t("./defaults"),d=t("./compressedObject"),p=t("./zipObject"),u=t("./generate"),g=t("./nodejsUtils"),f=t("./nodejs/NodejsStreamInputAdapter"),x=function(_){_.slice(-1)==="/"&&(_=_.substring(0,_.length-1));var M=_.lastIndexOf("/");return 0<M?_.substring(0,M):""},m=function(_){return _.slice(-1)!=="/"&&(_+="/"),_},b=function(_,M){return M=M!==void 0?M:h.createFolders,_=m(_),this.files[_]||r.call(this,_,null,{dir:!0,createFolders:M}),this.files[_]};function v(_){return Object.prototype.toString.call(_)==="[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(_){var M,T,R;for(M in this.files)R=this.files[M],(T=M.slice(this.root.length,M.length))&&M.slice(0,this.root.length)===this.root&&_(T,R)},filter:function(_){var M=[];return this.forEach(function(T,R){_(T,R)&&M.push(R)}),M},file:function(_,M,T){if(arguments.length!==1)return _=this.root+_,r.call(this,_,M,T),this;if(v(_)){var R=_;return this.filter(function(E,I){return!I.dir&&R.test(E)})}var w=this.files[this.root+_];return w&&!w.dir?w:null},folder:function(_){if(!_)return this;if(v(_))return this.filter(function(w,E){return E.dir&&_.test(w)});var M=this.root+_,T=b.call(this,M),R=this.clone();return R.root=T.name,R},remove:function(_){_=this.root+_;var M=this.files[_];if(M||(_.slice(-1)!=="/"&&(_+="/"),M=this.files[_]),M&&!M.dir)delete this.files[_];else for(var T=this.filter(function(w,E){return E.name.slice(0,_.length)===_}),R=0;R<T.length;R++)delete this.files[T[R].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(_){var M,T={};try{if((T=o.extend(_||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=T.type.toLowerCase(),T.compression=T.compression.toUpperCase(),T.type==="binarystring"&&(T.type="string"),!T.type)throw new Error("No output type specified.");o.checkSupport(T.type),T.platform!=="darwin"&&T.platform!=="freebsd"&&T.platform!=="linux"&&T.platform!=="sunos"||(T.platform="UNIX"),T.platform==="win32"&&(T.platform="DOS");var R=T.comment||this.comment||"";M=u.generateWorker(this,T,R)}catch(w){(M=new l("error")).error(w)}return new c(M,T.type||"string",T.mimeType)},generateAsync:function(_,M){return this.generateInternalStream(_).accumulate(M)},generateNodeStream:function(_,M){return(_=_||{}).type||(_.type="nodebuffer"),this.generateInternalStream(_).toNodejsStream(M)}};n.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,n,i){n.exports=t("stream")},{stream:void 0}],17:[function(t,n,i){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),p=this.length-4;0<=p;--p)if(this.data[p]===l&&this.data[p+1]===c&&this.data[p+2]===h&&this.data[p+3]===d)return p-this.zero;return-1},a.prototype.readAndCheckSignature=function(o){var l=o.charCodeAt(0),c=o.charCodeAt(1),h=o.charCodeAt(2),d=o.charCodeAt(3),p=this.readData(4);return l===p[0]&&c===p[1]&&h===p[2]&&d===p[3]},a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},n.exports=a},{"../utils":32,"./DataReader":18}],18:[function(t,n,i){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))}},n.exports=a},{"../utils":32}],19:[function(t,n,i){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},n.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,n,i){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},n.exports=a},{"../utils":32,"./DataReader":18}],21:[function(t,n,i){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},n.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(t,n,i){var r=t("../utils"),a=t("../support"),o=t("./ArrayReader"),l=t("./StringReader"),c=t("./NodeBufferReader"),h=t("./Uint8ArrayReader");n.exports=function(d){var p=r.getTypeOf(d);return r.checkSupport(p),p!=="string"||a.uint8array?p==="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,n,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,n,i){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})},n.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(t,n,i){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)},n.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,n,i){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)},n.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(t,n,i){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}})},n.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(t,n,i){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}},n.exports=r},{}],29:[function(t,n,i){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 p(g,f){return new h.Promise(function(x,m){var b=[],v=g._internalType,y=g._outputType,_=g._mimeType;g.on("data",function(M,T){b.push(M),f&&f(T)}).on("error",function(M){b=[],m(M)}).on("end",function(){try{var M=(function(T,R,w){switch(T){case"blob":return r.newBlob(r.transformTo("arraybuffer",R),w);case"base64":return l.encode(R);default:return r.transformTo(T,R)}})(y,(function(T,R){var w,E=0,I=null,A=0;for(w=0;w<R.length;w++)A+=R[w].length;switch(T){case"string":return R.join("");case"array":return Array.prototype.concat.apply([],R);case"uint8array":for(I=new Uint8Array(A),w=0;w<R.length;w++)I.set(R[w],E),E+=R[w].length;return I;case"nodebuffer":return Buffer.concat(R);default:throw new Error("concat : unsupported type '"+T+"'")}})(v,b),_);x(M)}catch(T){m(T)}b=[]}).resume()})}function u(g,f,x){var m=f;switch(f){case"blob":case"arraybuffer":m="uint8array";break;case"base64":m="string"}try{this._internalType=m,this._outputType=f,this._mimeType=x,r.checkSupport(m),this._worker=g.pipe(new a(m)),g.lock()}catch(b){this._worker=new o("error"),this._worker.error(b)}}u.prototype={accumulate:function(g){return p(this,g)},on:function(g,f){var x=this;return g==="data"?this._worker.on(g,function(m){f.call(x,m.data,m.meta)}):this._worker.on(g,function(){r.delay(f,arguments,x)}),this},resume:function(){return r.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(g){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"},g)}},n.exports=u},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(t,n,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var r=new ArrayBuffer(0);try{i.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),i.blob=a.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!t("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(t,n,i){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 p(){l.call(this,"utf-8 encode")}i.utf8encode=function(u){return a.nodebuffer?o.newBufferFrom(u,"utf-8"):(function(g){var f,x,m,b,v,y=g.length,_=0;for(b=0;b<y;b++)(64512&(x=g.charCodeAt(b)))==55296&&b+1<y&&(64512&(m=g.charCodeAt(b+1)))==56320&&(x=65536+(x-55296<<10)+(m-56320),b++),_+=x<128?1:x<2048?2:x<65536?3:4;for(f=a.uint8array?new Uint8Array(_):new Array(_),b=v=0;v<_;b++)(64512&(x=g.charCodeAt(b)))==55296&&b+1<y&&(64512&(m=g.charCodeAt(b+1)))==56320&&(x=65536+(x-55296<<10)+(m-56320),b++),x<128?f[v++]=x:(x<2048?f[v++]=192|x>>>6:(x<65536?f[v++]=224|x>>>12:(f[v++]=240|x>>>18,f[v++]=128|x>>>12&63),f[v++]=128|x>>>6&63),f[v++]=128|63&x);return f})(u)},i.utf8decode=function(u){return a.nodebuffer?r.transformTo("nodebuffer",u).toString("utf-8"):(function(g){var f,x,m,b,v=g.length,y=new Array(2*v);for(f=x=0;f<v;)if((m=g[f++])<128)y[x++]=m;else if(4<(b=c[m]))y[x++]=65533,f+=b-1;else{for(m&=b===2?31:b===3?15:7;1<b&&f<v;)m=m<<6|63&g[f++],b--;1<b?y[x++]=65533:m<65536?y[x++]=m:(m-=65536,y[x++]=55296|m>>10&1023,y[x++]=56320|1023&m)}return y.length!==x&&(y.subarray?y=y.subarray(0,x):y.length=x),r.applyFromCharCode(y)})(u=r.transformTo(a.uint8array?"uint8array":"array",u))},r.inherits(d,l),d.prototype.processChunk=function(u){var g=r.transformTo(a.uint8array?"uint8array":"array",u.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var f=g;(g=new Uint8Array(f.length+this.leftOver.length)).set(this.leftOver,0),g.set(f,this.leftOver.length)}else g=this.leftOver.concat(g);this.leftOver=null}var x=(function(b,v){var y;for((v=v||b.length)>b.length&&(v=b.length),y=v-1;0<=y&&(192&b[y])==128;)y--;return y<0||y===0?v:y+c[b[y]]>v?y:v})(g),m=g;x!==g.length&&(a.uint8array?(m=g.subarray(0,x),this.leftOver=g.subarray(x,g.length)):(m=g.slice(0,x),this.leftOver=g.slice(x,g.length))),this.push({data:i.utf8decode(m),meta:u.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=d,r.inherits(p,l),p.prototype.processChunk=function(u){this.push({data:i.utf8encode(u.data),meta:u.meta})},i.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,n,i){var r=t("./support"),a=t("./base64"),o=t("./nodejsUtils"),l=t("./external");function c(f){return f}function h(f,x){for(var m=0;m<f.length;++m)x[m]=255&f.charCodeAt(m);return x}t("setimmediate"),i.newBlob=function(f,x){i.checkSupport("blob");try{return new Blob([f],{type:x})}catch{try{var m=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return m.append(f),m.getBlob(x)}catch{throw new Error("Bug : can't construct the Blob.")}}};var d={stringifyByChunk:function(f,x,m){var b=[],v=0,y=f.length;if(y<=m)return String.fromCharCode.apply(null,f);for(;v<y;)x==="array"||x==="nodebuffer"?b.push(String.fromCharCode.apply(null,f.slice(v,Math.min(v+m,y)))):b.push(String.fromCharCode.apply(null,f.subarray(v,Math.min(v+m,y)))),v+=m;return b.join("")},stringifyByChar:function(f){for(var x="",m=0;m<f.length;m++)x+=String.fromCharCode(f[m]);return x},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 p(f){var x=65536,m=i.getTypeOf(f),b=!0;if(m==="uint8array"?b=d.applyCanBeUsed.uint8array:m==="nodebuffer"&&(b=d.applyCanBeUsed.nodebuffer),b)for(;1<x;)try{return d.stringifyByChunk(f,m,x)}catch{x=Math.floor(x/2)}return d.stringifyByChar(f)}function u(f,x){for(var m=0;m<f.length;m++)x[m]=f[m];return x}i.applyFromCharCode=p;var g={};g.string={string:c,array:function(f){return h(f,new Array(f.length))},arraybuffer:function(f){return g.string.uint8array(f).buffer},uint8array:function(f){return h(f,new Uint8Array(f.length))},nodebuffer:function(f){return h(f,o.allocBuffer(f.length))}},g.array={string:p,array:c,arraybuffer:function(f){return new Uint8Array(f).buffer},uint8array:function(f){return new Uint8Array(f)},nodebuffer:function(f){return o.newBufferFrom(f)}},g.arraybuffer={string:function(f){return p(new Uint8Array(f))},array:function(f){return u(new Uint8Array(f),new Array(f.byteLength))},arraybuffer:c,uint8array:function(f){return new Uint8Array(f)},nodebuffer:function(f){return o.newBufferFrom(new Uint8Array(f))}},g.uint8array={string:p,array:function(f){return u(f,new Array(f.length))},arraybuffer:function(f){return f.buffer},uint8array:c,nodebuffer:function(f){return o.newBufferFrom(f)}},g.nodebuffer={string:p,array:function(f){return u(f,new Array(f.length))},arraybuffer:function(f){return g.nodebuffer.uint8array(f).buffer},uint8array:function(f){return u(f,new Uint8Array(f.length))},nodebuffer:c},i.transformTo=function(f,x){if(x=x||"",!f)return x;i.checkSupport(f);var m=i.getTypeOf(x);return g[m][f](x)},i.resolve=function(f){for(var x=f.split("/"),m=[],b=0;b<x.length;b++){var v=x[b];v==="."||v===""&&b!==0&&b!==x.length-1||(v===".."?m.pop():m.push(v))}return m.join("/")},i.getTypeOf=function(f){return typeof f=="string"?"string":Object.prototype.toString.call(f)==="[object Array]"?"array":r.nodebuffer&&o.isBuffer(f)?"nodebuffer":r.uint8array&&f instanceof Uint8Array?"uint8array":r.arraybuffer&&f instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(f){if(!r[f.toLowerCase()])throw new Error(f+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(f){var x,m,b="";for(m=0;m<(f||"").length;m++)b+="\\x"+((x=f.charCodeAt(m))<16?"0":"")+x.toString(16).toUpperCase();return b},i.delay=function(f,x,m){setImmediate(function(){f.apply(m||null,x||[])})},i.inherits=function(f,x){function m(){}m.prototype=x.prototype,f.prototype=new m},i.extend=function(){var f,x,m={};for(f=0;f<arguments.length;f++)for(x in arguments[f])Object.prototype.hasOwnProperty.call(arguments[f],x)&&m[x]===void 0&&(m[x]=arguments[f][x]);return m},i.prepareContent=function(f,x,m,b,v){return l.Promise.resolve(x).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(_,M){var T=new FileReader;T.onload=function(R){_(R.target.result)},T.onerror=function(R){M(R.target.error)},T.readAsArrayBuffer(y)}):y}).then(function(y){var _=i.getTypeOf(y);return _?(_==="arraybuffer"?y=i.transformTo("uint8array",y):_==="string"&&(v?y=a.decode(y):m&&b!==!0&&(y=(function(M){return h(M,r.uint8array?new Uint8Array(M.length):new Array(M.length))})(y))),y):l.Promise.reject(new Error("Can't read the data of '"+f+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(t,n,i){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 p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(p)+", expected "+a.pretty(d)+")")}},isSignature:function(d,p){var u=this.reader.index;this.reader.setIndex(d);var g=this.reader.readString(4)===p;return this.reader.setIndex(u),g},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var d=this.reader.readData(this.zipCommentLength),p=c.uint8array?"uint8array":"array",u=a.transformTo(p,d);this.zipComment=this.loadOptions.decodeFileName(u)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var d,p,u,g=this.zip64EndOfCentralSize-44;0<g;)d=this.reader.readInt(2),p=this.reader.readInt(4),u=this.reader.readData(p),this.zip64ExtensibleData[d]={id:d,length:p,value:u}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var d,p;for(d=0;d<this.files.length;d++)p=this.files[d],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var d;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(d=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(d);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var d=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(d<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(d);var p=d;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(d=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(d),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var u=this.centralDirOffset+this.centralDirSize;this.zip64&&(u+=20,u+=12+this.zip64EndOfCentralSize);var g=p-u;if(0<g)this.isSignature(p,o.CENTRAL_FILE_HEADER)||(this.reader.zero=g);else if(g<0)throw new Error("Corrupted zip: missing "+Math.abs(g)+" bytes.")},prepareReader:function(d){this.reader=r(d)},load:function(d){this.prepareReader(d),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},n.exports=h},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(t,n,i){var r=t("./reader/readerFor"),a=t("./utils"),o=t("./compressedObject"),l=t("./crc32"),c=t("./utf8"),h=t("./compressions"),d=t("./support");function p(u,g){this.options=u,this.loadOptions=g}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(u){var g,f;if(u.skip(22),this.fileNameLength=u.readInt(2),f=u.readInt(2),this.fileName=u.readData(this.fileNameLength),u.skip(f),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((g=(function(x){for(var m in h)if(Object.prototype.hasOwnProperty.call(h,m)&&h[m].magic===x)return h[m];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,g,u.readData(this.compressedSize))},readCentralPart:function(u){this.versionMadeBy=u.readInt(2),u.skip(2),this.bitFlag=u.readInt(2),this.compressionMethod=u.readString(2),this.date=u.readDate(),this.crc32=u.readInt(4),this.compressedSize=u.readInt(4),this.uncompressedSize=u.readInt(4);var g=u.readInt(2);if(this.extraFieldsLength=u.readInt(2),this.fileCommentLength=u.readInt(2),this.diskNumberStart=u.readInt(2),this.internalFileAttributes=u.readInt(2),this.externalFileAttributes=u.readInt(4),this.localHeaderOffset=u.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");u.skip(g),this.readExtraFields(u),this.parseZIP64ExtraField(u),this.fileComment=u.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var u=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),u==0&&(this.dosPermissions=63&this.externalFileAttributes),u==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var u=r(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=u.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=u.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=u.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=u.readInt(4))}},readExtraFields:function(u){var g,f,x,m=u.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});u.index+4<m;)g=u.readInt(2),f=u.readInt(2),x=u.readData(f),this.extraFields[g]={id:g,length:f,value:x};u.setIndex(m)},handleUTF8:function(){var u=d.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var g=this.findExtraFieldUnicodePath();if(g!==null)this.fileNameStr=g;else{var f=a.transformTo(u,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(f)}var x=this.findExtraFieldUnicodeComment();if(x!==null)this.fileCommentStr=x;else{var m=a.transformTo(u,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(m)}}},findExtraFieldUnicodePath:function(){var u=this.extraFields[28789];if(u){var g=r(u.value);return g.readInt(1)!==1||l(this.fileName)!==g.readInt(4)?null:c.utf8decode(g.readData(u.length-5))}return null},findExtraFieldUnicodeComment:function(){var u=this.extraFields[25461];if(u){var g=r(u.value);return g.readInt(1)!==1||l(this.fileComment)!==g.readInt(4)?null:c.utf8decode(g.readData(u.length-5))}return null}},n.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(t,n,i){function r(g,f,x){this.name=g,this.dir=x.dir,this.date=x.date,this.comment=x.comment,this.unixPermissions=x.unixPermissions,this.dosPermissions=x.dosPermissions,this._data=f,this._dataBinary=x.binary,this.options={compression:x.compression,compressionOptions:x.compressionOptions}}var a=t("./stream/StreamHelper"),o=t("./stream/DataWorker"),l=t("./utf8"),c=t("./compressedObject"),h=t("./stream/GenericWorker");r.prototype={internalStream:function(g){var f=null,x="string";try{if(!g)throw new Error("No output type specified.");var m=(x=g.toLowerCase())==="string"||x==="text";x!=="binarystring"&&x!=="text"||(x="string"),f=this._decompressWorker();var b=!this._dataBinary;b&&!m&&(f=f.pipe(new l.Utf8EncodeWorker)),!b&&m&&(f=f.pipe(new l.Utf8DecodeWorker))}catch(v){(f=new h("error")).error(v)}return new a(f,x,"")},async:function(g,f){return this.internalStream(g).accumulate(f)},nodeStream:function(g,f){return this.internalStream(g||"nodebuffer").toNodejsStream(f)},_compressWorker:function(g,f){if(this._data instanceof c&&this._data.compression.magic===g.magic)return this._data.getCompressedWorker();var x=this._decompressWorker();return this._dataBinary||(x=x.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(x,g,f)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof h?this._data:new o(this._data)}};for(var d=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},u=0;u<d.length;u++)r.prototype[d[u]]=p;n.exports=r},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,n,i){(function(r){var a,o,l=r.MutationObserver||r.WebKitMutationObserver;if(l){var c=0,h=new l(g),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 f=r.document.createElement("script");f.onreadystatechange=function(){g(),f.onreadystatechange=null,f.parentNode.removeChild(f),f=null},r.document.documentElement.appendChild(f)}:function(){setTimeout(g,0)};else{var p=new r.MessageChannel;p.port1.onmessage=g,a=function(){p.port2.postMessage(0)}}var u=[];function g(){var f,x;o=!0;for(var m=u.length;m;){for(x=u,u=[],f=-1;++f<m;)x[f]();m=u.length}o=!1}n.exports=function(f){u.push(f)!==1||o||a()}}).call(this,typeof cl<"u"?cl:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(t,n,i){var r=t("immediate");function a(){}var o={},l=["REJECTED"],c=["FULFILLED"],h=["PENDING"];function d(m){if(typeof m!="function")throw new TypeError("resolver must be a function");this.state=h,this.queue=[],this.outcome=void 0,m!==a&&f(this,m)}function p(m,b,v){this.promise=m,typeof b=="function"&&(this.onFulfilled=b,this.callFulfilled=this.otherCallFulfilled),typeof v=="function"&&(this.onRejected=v,this.callRejected=this.otherCallRejected)}function u(m,b,v){r(function(){var y;try{y=b(v)}catch(_){return o.reject(m,_)}y===m?o.reject(m,new TypeError("Cannot resolve promise with itself")):o.resolve(m,y)})}function g(m){var b=m&&m.then;if(m&&(typeof m=="object"||typeof m=="function")&&typeof b=="function")return function(){b.apply(m,arguments)}}function f(m,b){var v=!1;function y(T){v||(v=!0,o.reject(m,T))}function _(T){v||(v=!0,o.resolve(m,T))}var M=x(function(){b(_,y)});M.status==="error"&&y(M.value)}function x(m,b){var v={};try{v.value=m(b),v.status="success"}catch(y){v.status="error",v.value=y}return v}(n.exports=d).prototype.finally=function(m){if(typeof m!="function")return this;var b=this.constructor;return this.then(function(v){return b.resolve(m()).then(function(){return v})},function(v){return b.resolve(m()).then(function(){throw v})})},d.prototype.catch=function(m){return this.then(null,m)},d.prototype.then=function(m,b){if(typeof m!="function"&&this.state===c||typeof b!="function"&&this.state===l)return this;var v=new this.constructor(a);return this.state!==h?u(v,this.state===c?m:b,this.outcome):this.queue.push(new p(v,m,b)),v},p.prototype.callFulfilled=function(m){o.resolve(this.promise,m)},p.prototype.otherCallFulfilled=function(m){u(this.promise,this.onFulfilled,m)},p.prototype.callRejected=function(m){o.reject(this.promise,m)},p.prototype.otherCallRejected=function(m){u(this.promise,this.onRejected,m)},o.resolve=function(m,b){var v=x(g,b);if(v.status==="error")return o.reject(m,v.value);var y=v.value;if(y)f(m,y);else{m.state=c,m.outcome=b;for(var _=-1,M=m.queue.length;++_<M;)m.queue[_].callFulfilled(b)}return m},o.reject=function(m,b){m.state=l,m.outcome=b;for(var v=-1,y=m.queue.length;++v<y;)m.queue[v].callRejected(b);return m},d.resolve=function(m){return m instanceof this?m:o.resolve(new this(a),m)},d.reject=function(m){var b=new this(a);return o.reject(b,m)},d.all=function(m){var b=this;if(Object.prototype.toString.call(m)!=="[object Array]")return this.reject(new TypeError("must be an array"));var v=m.length,y=!1;if(!v)return this.resolve([]);for(var _=new Array(v),M=0,T=-1,R=new this(a);++T<v;)w(m[T],T);return R;function w(E,I){b.resolve(E).then(function(A){_[I]=A,++M!==v||y||(y=!0,o.resolve(R,_))},function(A){y||(y=!0,o.reject(R,A))})}},d.race=function(m){var b=this;if(Object.prototype.toString.call(m)!=="[object Array]")return this.reject(new TypeError("must be an array"));var v=m.length,y=!1;if(!v)return this.resolve([]);for(var _=-1,M=new this(a);++_<v;)T=m[_],b.resolve(T).then(function(R){y||(y=!0,o.resolve(M,R))},function(R){y||(y=!0,o.reject(M,R))});var T;return M}},{immediate:36}],38:[function(t,n,i){var r={};(0,t("./lib/utils/common").assign)(r,t("./lib/deflate"),t("./lib/inflate"),t("./lib/zlib/constants")),n.exports=r},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(t,n,i){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,p=-1,u=0,g=8;function f(m){if(!(this instanceof f))return new f(m);this.options=a.assign({level:p,method:g,chunkSize:16384,windowBits:15,memLevel:8,strategy:u,to:""},m||{});var b=this.options;b.raw&&0<b.windowBits?b.windowBits=-b.windowBits:b.gzip&&0<b.windowBits&&b.windowBits<16&&(b.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var v=r.deflateInit2(this.strm,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(v!==d)throw new Error(l[v]);if(b.header&&r.deflateSetHeader(this.strm,b.header),b.dictionary){var y;if(y=typeof b.dictionary=="string"?o.string2buf(b.dictionary):h.call(b.dictionary)==="[object ArrayBuffer]"?new Uint8Array(b.dictionary):b.dictionary,(v=r.deflateSetDictionary(this.strm,y))!==d)throw new Error(l[v]);this._dict_set=!0}}function x(m,b){var v=new f(b);if(v.push(m,!0),v.err)throw v.msg||l[v.err];return v.result}f.prototype.push=function(m,b){var v,y,_=this.strm,M=this.options.chunkSize;if(this.ended)return!1;y=b===~~b?b:b===!0?4:0,typeof m=="string"?_.input=o.string2buf(m):h.call(m)==="[object ArrayBuffer]"?_.input=new Uint8Array(m):_.input=m,_.next_in=0,_.avail_in=_.input.length;do{if(_.avail_out===0&&(_.output=new a.Buf8(M),_.next_out=0,_.avail_out=M),(v=r.deflate(_,y))!==1&&v!==d)return this.onEnd(v),!(this.ended=!0);_.avail_out!==0&&(_.avail_in!==0||y!==4&&y!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(a.shrinkBuf(_.output,_.next_out))):this.onData(a.shrinkBuf(_.output,_.next_out)))}while((0<_.avail_in||_.avail_out===0)&&v!==1);return y===4?(v=r.deflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===d):y!==2||(this.onEnd(d),!(_.avail_out=0))},f.prototype.onData=function(m){this.chunks.push(m)},f.prototype.onEnd=function(m){m===d&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},i.Deflate=f,i.deflate=x,i.deflateRaw=function(m,b){return(b=b||{}).raw=!0,x(m,b)},i.gzip=function(m,b){return(b=b||{}).gzip=!0,x(m,b)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(t,n,i){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"),p=Object.prototype.toString;function u(f){if(!(this instanceof u))return new u(f);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},f||{});var x=this.options;x.raw&&0<=x.windowBits&&x.windowBits<16&&(x.windowBits=-x.windowBits,x.windowBits===0&&(x.windowBits=-15)),!(0<=x.windowBits&&x.windowBits<16)||f&&f.windowBits||(x.windowBits+=32),15<x.windowBits&&x.windowBits<48&&(15&x.windowBits)==0&&(x.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var m=r.inflateInit2(this.strm,x.windowBits);if(m!==l.Z_OK)throw new Error(c[m]);this.header=new d,r.inflateGetHeader(this.strm,this.header)}function g(f,x){var m=new u(x);if(m.push(f,!0),m.err)throw m.msg||c[m.err];return m.result}u.prototype.push=function(f,x){var m,b,v,y,_,M,T=this.strm,R=this.options.chunkSize,w=this.options.dictionary,E=!1;if(this.ended)return!1;b=x===~~x?x:x===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof f=="string"?T.input=o.binstring2buf(f):p.call(f)==="[object ArrayBuffer]"?T.input=new Uint8Array(f):T.input=f,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new a.Buf8(R),T.next_out=0,T.avail_out=R),(m=r.inflate(T,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&w&&(M=typeof w=="string"?o.string2buf(w):p.call(w)==="[object ArrayBuffer]"?new Uint8Array(w):w,m=r.inflateSetDictionary(this.strm,M)),m===l.Z_BUF_ERROR&&E===!0&&(m=l.Z_OK,E=!1),m!==l.Z_STREAM_END&&m!==l.Z_OK)return this.onEnd(m),!(this.ended=!0);T.next_out&&(T.avail_out!==0&&m!==l.Z_STREAM_END&&(T.avail_in!==0||b!==l.Z_FINISH&&b!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(v=o.utf8border(T.output,T.next_out),y=T.next_out-v,_=o.buf2string(T.output,v),T.next_out=y,T.avail_out=R-y,y&&a.arraySet(T.output,T.output,v,y,0),this.onData(_)):this.onData(a.shrinkBuf(T.output,T.next_out)))),T.avail_in===0&&T.avail_out===0&&(E=!0)}while((0<T.avail_in||T.avail_out===0)&&m!==l.Z_STREAM_END);return m===l.Z_STREAM_END&&(b=l.Z_FINISH),b===l.Z_FINISH?(m=r.inflateEnd(this.strm),this.onEnd(m),this.ended=!0,m===l.Z_OK):b!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(T.avail_out=0))},u.prototype.onData=function(f){this.chunks.push(f)},u.prototype.onEnd=function(f){f===l.Z_OK&&(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},i.Inflate=u,i.inflate=g,i.inflateRaw=function(f,x){return(x=x||{}).raw=!0,g(f,x)},i.ungzip=g},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(t,n,i){var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.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},i.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var a={arraySet:function(l,c,h,d,p){if(c.subarray&&l.subarray)l.set(c.subarray(h,h+d),p);else for(var u=0;u<d;u++)l[p+u]=c[h+u]},flattenChunks:function(l){var c,h,d,p,u,g;for(c=d=0,h=l.length;c<h;c++)d+=l[c].length;for(g=new Uint8Array(d),c=p=0,h=l.length;c<h;c++)u=l[c],g.set(u,p),p+=u.length;return g}},o={arraySet:function(l,c,h,d,p){for(var u=0;u<d;u++)l[p+u]=c[h+u]},flattenChunks:function(l){return[].concat.apply([],l)}};i.setTyped=function(l){l?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,a)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,o))},i.setTyped(r)},{}],42:[function(t,n,i){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,p){if(p<65537&&(d.subarray&&o||!d.subarray&&a))return String.fromCharCode.apply(null,r.shrinkBuf(d,p));for(var u="",g=0;g<p;g++)u+=String.fromCharCode(d[g]);return u}l[254]=l[254]=1,i.string2buf=function(d){var p,u,g,f,x,m=d.length,b=0;for(f=0;f<m;f++)(64512&(u=d.charCodeAt(f)))==55296&&f+1<m&&(64512&(g=d.charCodeAt(f+1)))==56320&&(u=65536+(u-55296<<10)+(g-56320),f++),b+=u<128?1:u<2048?2:u<65536?3:4;for(p=new r.Buf8(b),f=x=0;x<b;f++)(64512&(u=d.charCodeAt(f)))==55296&&f+1<m&&(64512&(g=d.charCodeAt(f+1)))==56320&&(u=65536+(u-55296<<10)+(g-56320),f++),u<128?p[x++]=u:(u<2048?p[x++]=192|u>>>6:(u<65536?p[x++]=224|u>>>12:(p[x++]=240|u>>>18,p[x++]=128|u>>>12&63),p[x++]=128|u>>>6&63),p[x++]=128|63&u);return p},i.buf2binstring=function(d){return h(d,d.length)},i.binstring2buf=function(d){for(var p=new r.Buf8(d.length),u=0,g=p.length;u<g;u++)p[u]=d.charCodeAt(u);return p},i.buf2string=function(d,p){var u,g,f,x,m=p||d.length,b=new Array(2*m);for(u=g=0;u<m;)if((f=d[u++])<128)b[g++]=f;else if(4<(x=l[f]))b[g++]=65533,u+=x-1;else{for(f&=x===2?31:x===3?15:7;1<x&&u<m;)f=f<<6|63&d[u++],x--;1<x?b[g++]=65533:f<65536?b[g++]=f:(f-=65536,b[g++]=55296|f>>10&1023,b[g++]=56320|1023&f)}return h(b,g)},i.utf8border=function(d,p){var u;for((p=p||d.length)>d.length&&(p=d.length),u=p-1;0<=u&&(192&d[u])==128;)u--;return u<0||u===0?p:u+l[d[u]]>p?u:p}},{"./common":41}],43:[function(t,n,i){n.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,n,i){n.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,n,i){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})();n.exports=function(a,o,l,c){var h=r,d=c+l;a^=-1;for(var p=c;p<d;p++)a=a>>>8^h[255&(a^o[p])];return-1^a}},{}],46:[function(t,n,i){var r,a=t("../utils/common"),o=t("./trees"),l=t("./adler32"),c=t("./crc32"),h=t("./messages"),d=0,p=4,u=0,g=-2,f=-1,x=4,m=2,b=8,v=9,y=286,_=30,M=19,T=2*y+1,R=15,w=3,E=258,I=E+w+1,A=42,B=113,S=1,U=2,H=3,G=4;function Z(C,D){return C.msg=h[D],D}function j(C){return(C<<1)-(4<C?9:0)}function ie(C){for(var D=C.length;0<=--D;)C[D]=0}function X(C){var D=C.state,W=D.pending;W>C.avail_out&&(W=C.avail_out),W!==0&&(a.arraySet(C.output,D.pending_buf,D.pending_out,W,C.next_out),C.next_out+=W,D.pending_out+=W,C.total_out+=W,C.avail_out-=W,D.pending-=W,D.pending===0&&(D.pending_out=0))}function $(C,D){o._tr_flush_block(C,0<=C.block_start?C.block_start:-1,C.strstart-C.block_start,D),C.block_start=C.strstart,X(C.strm)}function ue(C,D){C.pending_buf[C.pending++]=D}function pe(C,D){C.pending_buf[C.pending++]=D>>>8&255,C.pending_buf[C.pending++]=255&D}function fe(C,D){var W,O,k=C.max_chain_length,F=C.strstart,ee=C.prev_length,J=C.nice_match,q=C.strstart>C.w_size-I?C.strstart-(C.w_size-I):0,N=C.window,L=C.w_mask,V=C.prev,K=C.strstart+E,le=N[F+ee-1],te=N[F+ee];C.prev_length>=C.good_match&&(k>>=2),J>C.lookahead&&(J=C.lookahead);do if(N[(W=D)+ee]===te&&N[W+ee-1]===le&&N[W]===N[F]&&N[++W]===N[F+1]){F+=2,W++;do;while(N[++F]===N[++W]&&N[++F]===N[++W]&&N[++F]===N[++W]&&N[++F]===N[++W]&&N[++F]===N[++W]&&N[++F]===N[++W]&&N[++F]===N[++W]&&N[++F]===N[++W]&&F<K);if(O=E-(K-F),F=K-E,ee<O){if(C.match_start=D,J<=(ee=O))break;le=N[F+ee-1],te=N[F+ee]}}while((D=V[D&L])>q&&--k!=0);return ee<=C.lookahead?ee:C.lookahead}function se(C){var D,W,O,k,F,ee,J,q,N,L,V=C.w_size;do{if(k=C.window_size-C.lookahead-C.strstart,C.strstart>=V+(V-I)){for(a.arraySet(C.window,C.window,V,V,0),C.match_start-=V,C.strstart-=V,C.block_start-=V,D=W=C.hash_size;O=C.head[--D],C.head[D]=V<=O?O-V:0,--W;);for(D=W=V;O=C.prev[--D],C.prev[D]=V<=O?O-V:0,--W;);k+=V}if(C.strm.avail_in===0)break;if(ee=C.strm,J=C.window,q=C.strstart+C.lookahead,N=k,L=void 0,L=ee.avail_in,N<L&&(L=N),W=L===0?0:(ee.avail_in-=L,a.arraySet(J,ee.input,ee.next_in,L,q),ee.state.wrap===1?ee.adler=l(ee.adler,J,L,q):ee.state.wrap===2&&(ee.adler=c(ee.adler,J,L,q)),ee.next_in+=L,ee.total_in+=L,L),C.lookahead+=W,C.lookahead+C.insert>=w)for(F=C.strstart-C.insert,C.ins_h=C.window[F],C.ins_h=(C.ins_h<<C.hash_shift^C.window[F+1])&C.hash_mask;C.insert&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[F+w-1])&C.hash_mask,C.prev[F&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=F,F++,C.insert--,!(C.lookahead+C.insert<w)););}while(C.lookahead<I&&C.strm.avail_in!==0)}function ce(C,D){for(var W,O;;){if(C.lookahead<I){if(se(C),C.lookahead<I&&D===d)return S;if(C.lookahead===0)break}if(W=0,C.lookahead>=w&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+w-1])&C.hash_mask,W=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),W!==0&&C.strstart-W<=C.w_size-I&&(C.match_length=fe(C,W)),C.match_length>=w)if(O=o._tr_tally(C,C.strstart-C.match_start,C.match_length-w),C.lookahead-=C.match_length,C.match_length<=C.max_lazy_match&&C.lookahead>=w){for(C.match_length--;C.strstart++,C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+w-1])&C.hash_mask,W=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart,--C.match_length!=0;);C.strstart++}else C.strstart+=C.match_length,C.match_length=0,C.ins_h=C.window[C.strstart],C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+1])&C.hash_mask;else O=o._tr_tally(C,0,C.window[C.strstart]),C.lookahead--,C.strstart++;if(O&&($(C,!1),C.strm.avail_out===0))return S}return C.insert=C.strstart<w-1?C.strstart:w-1,D===p?($(C,!0),C.strm.avail_out===0?H:G):C.last_lit&&($(C,!1),C.strm.avail_out===0)?S:U}function me(C,D){for(var W,O,k;;){if(C.lookahead<I){if(se(C),C.lookahead<I&&D===d)return S;if(C.lookahead===0)break}if(W=0,C.lookahead>=w&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+w-1])&C.hash_mask,W=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),C.prev_length=C.match_length,C.prev_match=C.match_start,C.match_length=w-1,W!==0&&C.prev_length<C.max_lazy_match&&C.strstart-W<=C.w_size-I&&(C.match_length=fe(C,W),C.match_length<=5&&(C.strategy===1||C.match_length===w&&4096<C.strstart-C.match_start)&&(C.match_length=w-1)),C.prev_length>=w&&C.match_length<=C.prev_length){for(k=C.strstart+C.lookahead-w,O=o._tr_tally(C,C.strstart-1-C.prev_match,C.prev_length-w),C.lookahead-=C.prev_length-1,C.prev_length-=2;++C.strstart<=k&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+w-1])&C.hash_mask,W=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),--C.prev_length!=0;);if(C.match_available=0,C.match_length=w-1,C.strstart++,O&&($(C,!1),C.strm.avail_out===0))return S}else if(C.match_available){if((O=o._tr_tally(C,0,C.window[C.strstart-1]))&&$(C,!1),C.strstart++,C.lookahead--,C.strm.avail_out===0)return S}else C.match_available=1,C.strstart++,C.lookahead--}return C.match_available&&(O=o._tr_tally(C,0,C.window[C.strstart-1]),C.match_available=0),C.insert=C.strstart<w-1?C.strstart:w-1,D===p?($(C,!0),C.strm.avail_out===0?H:G):C.last_lit&&($(C,!1),C.strm.avail_out===0)?S:U}function be(C,D,W,O,k){this.good_length=C,this.max_lazy=D,this.nice_length=W,this.max_chain=O,this.func=k}function Se(){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=b,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*T),this.dyn_dtree=new a.Buf16(2*(2*_+1)),this.bl_tree=new a.Buf16(2*(2*M+1)),ie(this.dyn_ltree),ie(this.dyn_dtree),ie(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(R+1),this.heap=new a.Buf16(2*y+1),ie(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*y+1),ie(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 Be(C){var D;return C&&C.state?(C.total_in=C.total_out=0,C.data_type=m,(D=C.state).pending=0,D.pending_out=0,D.wrap<0&&(D.wrap=-D.wrap),D.status=D.wrap?A:B,C.adler=D.wrap===2?0:1,D.last_flush=d,o._tr_init(D),u):Z(C,g)}function Je(C){var D=Be(C);return D===u&&(function(W){W.window_size=2*W.w_size,ie(W.head),W.max_lazy_match=r[W.level].max_lazy,W.good_match=r[W.level].good_length,W.nice_match=r[W.level].nice_length,W.max_chain_length=r[W.level].max_chain,W.strstart=0,W.block_start=0,W.lookahead=0,W.insert=0,W.match_length=W.prev_length=w-1,W.match_available=0,W.ins_h=0})(C.state),D}function ke(C,D,W,O,k,F){if(!C)return g;var ee=1;if(D===f&&(D=6),O<0?(ee=0,O=-O):15<O&&(ee=2,O-=16),k<1||v<k||W!==b||O<8||15<O||D<0||9<D||F<0||x<F)return Z(C,g);O===8&&(O=9);var J=new Se;return(C.state=J).strm=C,J.wrap=ee,J.gzhead=null,J.w_bits=O,J.w_size=1<<J.w_bits,J.w_mask=J.w_size-1,J.hash_bits=k+7,J.hash_size=1<<J.hash_bits,J.hash_mask=J.hash_size-1,J.hash_shift=~~((J.hash_bits+w-1)/w),J.window=new a.Buf8(2*J.w_size),J.head=new a.Buf16(J.hash_size),J.prev=new a.Buf16(J.w_size),J.lit_bufsize=1<<k+6,J.pending_buf_size=4*J.lit_bufsize,J.pending_buf=new a.Buf8(J.pending_buf_size),J.d_buf=1*J.lit_bufsize,J.l_buf=3*J.lit_bufsize,J.level=D,J.strategy=F,J.method=W,Je(C)}r=[new be(0,0,0,0,function(C,D){var W=65535;for(W>C.pending_buf_size-5&&(W=C.pending_buf_size-5);;){if(C.lookahead<=1){if(se(C),C.lookahead===0&&D===d)return S;if(C.lookahead===0)break}C.strstart+=C.lookahead,C.lookahead=0;var O=C.block_start+W;if((C.strstart===0||C.strstart>=O)&&(C.lookahead=C.strstart-O,C.strstart=O,$(C,!1),C.strm.avail_out===0)||C.strstart-C.block_start>=C.w_size-I&&($(C,!1),C.strm.avail_out===0))return S}return C.insert=0,D===p?($(C,!0),C.strm.avail_out===0?H:G):(C.strstart>C.block_start&&($(C,!1),C.strm.avail_out),S)}),new be(4,4,8,4,ce),new be(4,5,16,8,ce),new be(4,6,32,32,ce),new be(4,4,16,16,me),new be(8,16,32,32,me),new be(8,16,128,128,me),new be(8,32,128,256,me),new be(32,128,258,1024,me),new be(32,258,258,4096,me)],i.deflateInit=function(C,D){return ke(C,D,b,15,8,0)},i.deflateInit2=ke,i.deflateReset=Je,i.deflateResetKeep=Be,i.deflateSetHeader=function(C,D){return C&&C.state?C.state.wrap!==2?g:(C.state.gzhead=D,u):g},i.deflate=function(C,D){var W,O,k,F;if(!C||!C.state||5<D||D<0)return C?Z(C,g):g;if(O=C.state,!C.output||!C.input&&C.avail_in!==0||O.status===666&&D!==p)return Z(C,C.avail_out===0?-5:g);if(O.strm=C,W=O.last_flush,O.last_flush=D,O.status===A)if(O.wrap===2)C.adler=0,ue(O,31),ue(O,139),ue(O,8),O.gzhead?(ue(O,(O.gzhead.text?1:0)+(O.gzhead.hcrc?2:0)+(O.gzhead.extra?4:0)+(O.gzhead.name?8:0)+(O.gzhead.comment?16:0)),ue(O,255&O.gzhead.time),ue(O,O.gzhead.time>>8&255),ue(O,O.gzhead.time>>16&255),ue(O,O.gzhead.time>>24&255),ue(O,O.level===9?2:2<=O.strategy||O.level<2?4:0),ue(O,255&O.gzhead.os),O.gzhead.extra&&O.gzhead.extra.length&&(ue(O,255&O.gzhead.extra.length),ue(O,O.gzhead.extra.length>>8&255)),O.gzhead.hcrc&&(C.adler=c(C.adler,O.pending_buf,O.pending,0)),O.gzindex=0,O.status=69):(ue(O,0),ue(O,0),ue(O,0),ue(O,0),ue(O,0),ue(O,O.level===9?2:2<=O.strategy||O.level<2?4:0),ue(O,3),O.status=B);else{var ee=b+(O.w_bits-8<<4)<<8;ee|=(2<=O.strategy||O.level<2?0:O.level<6?1:O.level===6?2:3)<<6,O.strstart!==0&&(ee|=32),ee+=31-ee%31,O.status=B,pe(O,ee),O.strstart!==0&&(pe(O,C.adler>>>16),pe(O,65535&C.adler)),C.adler=1}if(O.status===69)if(O.gzhead.extra){for(k=O.pending;O.gzindex<(65535&O.gzhead.extra.length)&&(O.pending!==O.pending_buf_size||(O.gzhead.hcrc&&O.pending>k&&(C.adler=c(C.adler,O.pending_buf,O.pending-k,k)),X(C),k=O.pending,O.pending!==O.pending_buf_size));)ue(O,255&O.gzhead.extra[O.gzindex]),O.gzindex++;O.gzhead.hcrc&&O.pending>k&&(C.adler=c(C.adler,O.pending_buf,O.pending-k,k)),O.gzindex===O.gzhead.extra.length&&(O.gzindex=0,O.status=73)}else O.status=73;if(O.status===73)if(O.gzhead.name){k=O.pending;do{if(O.pending===O.pending_buf_size&&(O.gzhead.hcrc&&O.pending>k&&(C.adler=c(C.adler,O.pending_buf,O.pending-k,k)),X(C),k=O.pending,O.pending===O.pending_buf_size)){F=1;break}F=O.gzindex<O.gzhead.name.length?255&O.gzhead.name.charCodeAt(O.gzindex++):0,ue(O,F)}while(F!==0);O.gzhead.hcrc&&O.pending>k&&(C.adler=c(C.adler,O.pending_buf,O.pending-k,k)),F===0&&(O.gzindex=0,O.status=91)}else O.status=91;if(O.status===91)if(O.gzhead.comment){k=O.pending;do{if(O.pending===O.pending_buf_size&&(O.gzhead.hcrc&&O.pending>k&&(C.adler=c(C.adler,O.pending_buf,O.pending-k,k)),X(C),k=O.pending,O.pending===O.pending_buf_size)){F=1;break}F=O.gzindex<O.gzhead.comment.length?255&O.gzhead.comment.charCodeAt(O.gzindex++):0,ue(O,F)}while(F!==0);O.gzhead.hcrc&&O.pending>k&&(C.adler=c(C.adler,O.pending_buf,O.pending-k,k)),F===0&&(O.status=103)}else O.status=103;if(O.status===103&&(O.gzhead.hcrc?(O.pending+2>O.pending_buf_size&&X(C),O.pending+2<=O.pending_buf_size&&(ue(O,255&C.adler),ue(O,C.adler>>8&255),C.adler=0,O.status=B)):O.status=B),O.pending!==0){if(X(C),C.avail_out===0)return O.last_flush=-1,u}else if(C.avail_in===0&&j(D)<=j(W)&&D!==p)return Z(C,-5);if(O.status===666&&C.avail_in!==0)return Z(C,-5);if(C.avail_in!==0||O.lookahead!==0||D!==d&&O.status!==666){var J=O.strategy===2?(function(q,N){for(var L;;){if(q.lookahead===0&&(se(q),q.lookahead===0)){if(N===d)return S;break}if(q.match_length=0,L=o._tr_tally(q,0,q.window[q.strstart]),q.lookahead--,q.strstart++,L&&($(q,!1),q.strm.avail_out===0))return S}return q.insert=0,N===p?($(q,!0),q.strm.avail_out===0?H:G):q.last_lit&&($(q,!1),q.strm.avail_out===0)?S:U})(O,D):O.strategy===3?(function(q,N){for(var L,V,K,le,te=q.window;;){if(q.lookahead<=E){if(se(q),q.lookahead<=E&&N===d)return S;if(q.lookahead===0)break}if(q.match_length=0,q.lookahead>=w&&0<q.strstart&&(V=te[K=q.strstart-1])===te[++K]&&V===te[++K]&&V===te[++K]){le=q.strstart+E;do;while(V===te[++K]&&V===te[++K]&&V===te[++K]&&V===te[++K]&&V===te[++K]&&V===te[++K]&&V===te[++K]&&V===te[++K]&&K<le);q.match_length=E-(le-K),q.match_length>q.lookahead&&(q.match_length=q.lookahead)}if(q.match_length>=w?(L=o._tr_tally(q,1,q.match_length-w),q.lookahead-=q.match_length,q.strstart+=q.match_length,q.match_length=0):(L=o._tr_tally(q,0,q.window[q.strstart]),q.lookahead--,q.strstart++),L&&($(q,!1),q.strm.avail_out===0))return S}return q.insert=0,N===p?($(q,!0),q.strm.avail_out===0?H:G):q.last_lit&&($(q,!1),q.strm.avail_out===0)?S:U})(O,D):r[O.level].func(O,D);if(J!==H&&J!==G||(O.status=666),J===S||J===H)return C.avail_out===0&&(O.last_flush=-1),u;if(J===U&&(D===1?o._tr_align(O):D!==5&&(o._tr_stored_block(O,0,0,!1),D===3&&(ie(O.head),O.lookahead===0&&(O.strstart=0,O.block_start=0,O.insert=0))),X(C),C.avail_out===0))return O.last_flush=-1,u}return D!==p?u:O.wrap<=0?1:(O.wrap===2?(ue(O,255&C.adler),ue(O,C.adler>>8&255),ue(O,C.adler>>16&255),ue(O,C.adler>>24&255),ue(O,255&C.total_in),ue(O,C.total_in>>8&255),ue(O,C.total_in>>16&255),ue(O,C.total_in>>24&255)):(pe(O,C.adler>>>16),pe(O,65535&C.adler)),X(C),0<O.wrap&&(O.wrap=-O.wrap),O.pending!==0?u:1)},i.deflateEnd=function(C){var D;return C&&C.state?(D=C.state.status)!==A&&D!==69&&D!==73&&D!==91&&D!==103&&D!==B&&D!==666?Z(C,g):(C.state=null,D===B?Z(C,-3):u):g},i.deflateSetDictionary=function(C,D){var W,O,k,F,ee,J,q,N,L=D.length;if(!C||!C.state||(F=(W=C.state).wrap)===2||F===1&&W.status!==A||W.lookahead)return g;for(F===1&&(C.adler=l(C.adler,D,L,0)),W.wrap=0,L>=W.w_size&&(F===0&&(ie(W.head),W.strstart=0,W.block_start=0,W.insert=0),N=new a.Buf8(W.w_size),a.arraySet(N,D,L-W.w_size,W.w_size,0),D=N,L=W.w_size),ee=C.avail_in,J=C.next_in,q=C.input,C.avail_in=L,C.next_in=0,C.input=D,se(W);W.lookahead>=w;){for(O=W.strstart,k=W.lookahead-(w-1);W.ins_h=(W.ins_h<<W.hash_shift^W.window[O+w-1])&W.hash_mask,W.prev[O&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=O,O++,--k;);W.strstart=O,W.lookahead=w-1,se(W)}return W.strstart+=W.lookahead,W.block_start=W.strstart,W.insert=W.lookahead,W.lookahead=0,W.match_length=W.prev_length=w-1,W.match_available=0,C.next_in=J,C.input=q,C.avail_in=ee,W.wrap=F,u},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(t,n,i){n.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,n,i){n.exports=function(r,a){var o,l,c,h,d,p,u,g,f,x,m,b,v,y,_,M,T,R,w,E,I,A,B,S,U;o=r.state,l=r.next_in,S=r.input,c=l+(r.avail_in-5),h=r.next_out,U=r.output,d=h-(a-r.avail_out),p=h+(r.avail_out-257),u=o.dmax,g=o.wsize,f=o.whave,x=o.wnext,m=o.window,b=o.hold,v=o.bits,y=o.lencode,_=o.distcode,M=(1<<o.lenbits)-1,T=(1<<o.distbits)-1;e:do{v<15&&(b+=S[l++]<<v,v+=8,b+=S[l++]<<v,v+=8),R=y[b&M];t:for(;;){if(b>>>=w=R>>>24,v-=w,(w=R>>>16&255)===0)U[h++]=65535&R;else{if(!(16&w)){if((64&w)==0){R=y[(65535&R)+(b&(1<<w)-1)];continue t}if(32&w){o.mode=12;break e}r.msg="invalid literal/length code",o.mode=30;break e}E=65535&R,(w&=15)&&(v<w&&(b+=S[l++]<<v,v+=8),E+=b&(1<<w)-1,b>>>=w,v-=w),v<15&&(b+=S[l++]<<v,v+=8,b+=S[l++]<<v,v+=8),R=_[b&T];n:for(;;){if(b>>>=w=R>>>24,v-=w,!(16&(w=R>>>16&255))){if((64&w)==0){R=_[(65535&R)+(b&(1<<w)-1)];continue n}r.msg="invalid distance code",o.mode=30;break e}if(I=65535&R,v<(w&=15)&&(b+=S[l++]<<v,(v+=8)<w&&(b+=S[l++]<<v,v+=8)),u<(I+=b&(1<<w)-1)){r.msg="invalid distance too far back",o.mode=30;break e}if(b>>>=w,v-=w,(w=h-d)<I){if(f<(w=I-w)&&o.sane){r.msg="invalid distance too far back",o.mode=30;break e}if(B=m,(A=0)===x){if(A+=g-w,w<E){for(E-=w;U[h++]=m[A++],--w;);A=h-I,B=U}}else if(x<w){if(A+=g+x-w,(w-=x)<E){for(E-=w;U[h++]=m[A++],--w;);if(A=0,x<E){for(E-=w=x;U[h++]=m[A++],--w;);A=h-I,B=U}}}else if(A+=x-w,w<E){for(E-=w;U[h++]=m[A++],--w;);A=h-I,B=U}for(;2<E;)U[h++]=B[A++],U[h++]=B[A++],U[h++]=B[A++],E-=3;E&&(U[h++]=B[A++],1<E&&(U[h++]=B[A++]))}else{for(A=h-I;U[h++]=U[A++],U[h++]=U[A++],U[h++]=U[A++],2<(E-=3););E&&(U[h++]=U[A++],1<E&&(U[h++]=U[A++]))}break}}break}}while(l<c&&h<p);l-=E=v>>3,b&=(1<<(v-=E<<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<p?p-h+257:257-(h-p),o.hold=b,o.bits=v}},{}],49:[function(t,n,i){var r=t("../utils/common"),a=t("./adler32"),o=t("./crc32"),l=t("./inffast"),c=t("./inftrees"),h=1,d=2,p=0,u=-2,g=1,f=852,x=592;function m(A){return(A>>>24&255)+(A>>>8&65280)+((65280&A)<<8)+((255&A)<<24)}function b(){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 v(A){var B;return A&&A.state?(B=A.state,A.total_in=A.total_out=B.total=0,A.msg="",B.wrap&&(A.adler=1&B.wrap),B.mode=g,B.last=0,B.havedict=0,B.dmax=32768,B.head=null,B.hold=0,B.bits=0,B.lencode=B.lendyn=new r.Buf32(f),B.distcode=B.distdyn=new r.Buf32(x),B.sane=1,B.back=-1,p):u}function y(A){var B;return A&&A.state?((B=A.state).wsize=0,B.whave=0,B.wnext=0,v(A)):u}function _(A,B){var S,U;return A&&A.state?(U=A.state,B<0?(S=0,B=-B):(S=1+(B>>4),B<48&&(B&=15)),B&&(B<8||15<B)?u:(U.window!==null&&U.wbits!==B&&(U.window=null),U.wrap=S,U.wbits=B,y(A))):u}function M(A,B){var S,U;return A?(U=new b,(A.state=U).window=null,(S=_(A,B))!==p&&(A.state=null),S):u}var T,R,w=!0;function E(A){if(w){var B;for(T=new r.Buf32(512),R=new r.Buf32(32),B=0;B<144;)A.lens[B++]=8;for(;B<256;)A.lens[B++]=9;for(;B<280;)A.lens[B++]=7;for(;B<288;)A.lens[B++]=8;for(c(h,A.lens,0,288,T,0,A.work,{bits:9}),B=0;B<32;)A.lens[B++]=5;c(d,A.lens,0,32,R,0,A.work,{bits:5}),w=!1}A.lencode=T,A.lenbits=9,A.distcode=R,A.distbits=5}function I(A,B,S,U){var H,G=A.state;return G.window===null&&(G.wsize=1<<G.wbits,G.wnext=0,G.whave=0,G.window=new r.Buf8(G.wsize)),U>=G.wsize?(r.arraySet(G.window,B,S-G.wsize,G.wsize,0),G.wnext=0,G.whave=G.wsize):(U<(H=G.wsize-G.wnext)&&(H=U),r.arraySet(G.window,B,S-U,H,G.wnext),(U-=H)?(r.arraySet(G.window,B,S-U,U,0),G.wnext=U,G.whave=G.wsize):(G.wnext+=H,G.wnext===G.wsize&&(G.wnext=0),G.whave<G.wsize&&(G.whave+=H))),0}i.inflateReset=y,i.inflateReset2=_,i.inflateResetKeep=v,i.inflateInit=function(A){return M(A,15)},i.inflateInit2=M,i.inflate=function(A,B){var S,U,H,G,Z,j,ie,X,$,ue,pe,fe,se,ce,me,be,Se,Be,Je,ke,C,D,W,O,k=0,F=new r.Buf8(4),ee=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!A||!A.state||!A.output||!A.input&&A.avail_in!==0)return u;(S=A.state).mode===12&&(S.mode=13),Z=A.next_out,H=A.output,ie=A.avail_out,G=A.next_in,U=A.input,j=A.avail_in,X=S.hold,$=S.bits,ue=j,pe=ie,D=p;e:for(;;)switch(S.mode){case g:if(S.wrap===0){S.mode=13;break}for(;$<16;){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}if(2&S.wrap&&X===35615){F[S.check=0]=255&X,F[1]=X>>>8&255,S.check=o(S.check,F,2,0),$=X=0,S.mode=2;break}if(S.flags=0,S.head&&(S.head.done=!1),!(1&S.wrap)||(((255&X)<<8)+(X>>8))%31){A.msg="incorrect header check",S.mode=30;break}if((15&X)!=8){A.msg="unknown compression method",S.mode=30;break}if($-=4,C=8+(15&(X>>>=4)),S.wbits===0)S.wbits=C;else if(C>S.wbits){A.msg="invalid window size",S.mode=30;break}S.dmax=1<<C,A.adler=S.check=1,S.mode=512&X?10:12,$=X=0;break;case 2:for(;$<16;){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}if(S.flags=X,(255&S.flags)!=8){A.msg="unknown compression method",S.mode=30;break}if(57344&S.flags){A.msg="unknown header flags set",S.mode=30;break}S.head&&(S.head.text=X>>8&1),512&S.flags&&(F[0]=255&X,F[1]=X>>>8&255,S.check=o(S.check,F,2,0)),$=X=0,S.mode=3;case 3:for(;$<32;){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}S.head&&(S.head.time=X),512&S.flags&&(F[0]=255&X,F[1]=X>>>8&255,F[2]=X>>>16&255,F[3]=X>>>24&255,S.check=o(S.check,F,4,0)),$=X=0,S.mode=4;case 4:for(;$<16;){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}S.head&&(S.head.xflags=255&X,S.head.os=X>>8),512&S.flags&&(F[0]=255&X,F[1]=X>>>8&255,S.check=o(S.check,F,2,0)),$=X=0,S.mode=5;case 5:if(1024&S.flags){for(;$<16;){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}S.length=X,S.head&&(S.head.extra_len=X),512&S.flags&&(F[0]=255&X,F[1]=X>>>8&255,S.check=o(S.check,F,2,0)),$=X=0}else S.head&&(S.head.extra=null);S.mode=6;case 6:if(1024&S.flags&&(j<(fe=S.length)&&(fe=j),fe&&(S.head&&(C=S.head.extra_len-S.length,S.head.extra||(S.head.extra=new Array(S.head.extra_len)),r.arraySet(S.head.extra,U,G,fe,C)),512&S.flags&&(S.check=o(S.check,U,fe,G)),j-=fe,G+=fe,S.length-=fe),S.length))break e;S.length=0,S.mode=7;case 7:if(2048&S.flags){if(j===0)break e;for(fe=0;C=U[G+fe++],S.head&&C&&S.length<65536&&(S.head.name+=String.fromCharCode(C)),C&&fe<j;);if(512&S.flags&&(S.check=o(S.check,U,fe,G)),j-=fe,G+=fe,C)break e}else S.head&&(S.head.name=null);S.length=0,S.mode=8;case 8:if(4096&S.flags){if(j===0)break e;for(fe=0;C=U[G+fe++],S.head&&C&&S.length<65536&&(S.head.comment+=String.fromCharCode(C)),C&&fe<j;);if(512&S.flags&&(S.check=o(S.check,U,fe,G)),j-=fe,G+=fe,C)break e}else S.head&&(S.head.comment=null);S.mode=9;case 9:if(512&S.flags){for(;$<16;){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}if(X!==(65535&S.check)){A.msg="header crc mismatch",S.mode=30;break}$=X=0}S.head&&(S.head.hcrc=S.flags>>9&1,S.head.done=!0),A.adler=S.check=0,S.mode=12;break;case 10:for(;$<32;){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}A.adler=S.check=m(X),$=X=0,S.mode=11;case 11:if(S.havedict===0)return A.next_out=Z,A.avail_out=ie,A.next_in=G,A.avail_in=j,S.hold=X,S.bits=$,2;A.adler=S.check=1,S.mode=12;case 12:if(B===5||B===6)break e;case 13:if(S.last){X>>>=7&$,$-=7&$,S.mode=27;break}for(;$<3;){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}switch(S.last=1&X,$-=1,3&(X>>>=1)){case 0:S.mode=14;break;case 1:if(E(S),S.mode=20,B!==6)break;X>>>=2,$-=2;break e;case 2:S.mode=17;break;case 3:A.msg="invalid block type",S.mode=30}X>>>=2,$-=2;break;case 14:for(X>>>=7&$,$-=7&$;$<32;){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}if((65535&X)!=(X>>>16^65535)){A.msg="invalid stored block lengths",S.mode=30;break}if(S.length=65535&X,$=X=0,S.mode=15,B===6)break e;case 15:S.mode=16;case 16:if(fe=S.length){if(j<fe&&(fe=j),ie<fe&&(fe=ie),fe===0)break e;r.arraySet(H,U,G,fe,Z),j-=fe,G+=fe,ie-=fe,Z+=fe,S.length-=fe;break}S.mode=12;break;case 17:for(;$<14;){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}if(S.nlen=257+(31&X),X>>>=5,$-=5,S.ndist=1+(31&X),X>>>=5,$-=5,S.ncode=4+(15&X),X>>>=4,$-=4,286<S.nlen||30<S.ndist){A.msg="too many length or distance symbols",S.mode=30;break}S.have=0,S.mode=18;case 18:for(;S.have<S.ncode;){for(;$<3;){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}S.lens[ee[S.have++]]=7&X,X>>>=3,$-=3}for(;S.have<19;)S.lens[ee[S.have++]]=0;if(S.lencode=S.lendyn,S.lenbits=7,W={bits:S.lenbits},D=c(0,S.lens,0,19,S.lencode,0,S.work,W),S.lenbits=W.bits,D){A.msg="invalid code lengths set",S.mode=30;break}S.have=0,S.mode=19;case 19:for(;S.have<S.nlen+S.ndist;){for(;be=(k=S.lencode[X&(1<<S.lenbits)-1])>>>16&255,Se=65535&k,!((me=k>>>24)<=$);){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}if(Se<16)X>>>=me,$-=me,S.lens[S.have++]=Se;else{if(Se===16){for(O=me+2;$<O;){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}if(X>>>=me,$-=me,S.have===0){A.msg="invalid bit length repeat",S.mode=30;break}C=S.lens[S.have-1],fe=3+(3&X),X>>>=2,$-=2}else if(Se===17){for(O=me+3;$<O;){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}$-=me,C=0,fe=3+(7&(X>>>=me)),X>>>=3,$-=3}else{for(O=me+7;$<O;){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}$-=me,C=0,fe=11+(127&(X>>>=me)),X>>>=7,$-=7}if(S.have+fe>S.nlen+S.ndist){A.msg="invalid bit length repeat",S.mode=30;break}for(;fe--;)S.lens[S.have++]=C}}if(S.mode===30)break;if(S.lens[256]===0){A.msg="invalid code -- missing end-of-block",S.mode=30;break}if(S.lenbits=9,W={bits:S.lenbits},D=c(h,S.lens,0,S.nlen,S.lencode,0,S.work,W),S.lenbits=W.bits,D){A.msg="invalid literal/lengths set",S.mode=30;break}if(S.distbits=6,S.distcode=S.distdyn,W={bits:S.distbits},D=c(d,S.lens,S.nlen,S.ndist,S.distcode,0,S.work,W),S.distbits=W.bits,D){A.msg="invalid distances set",S.mode=30;break}if(S.mode=20,B===6)break e;case 20:S.mode=21;case 21:if(6<=j&&258<=ie){A.next_out=Z,A.avail_out=ie,A.next_in=G,A.avail_in=j,S.hold=X,S.bits=$,l(A,pe),Z=A.next_out,H=A.output,ie=A.avail_out,G=A.next_in,U=A.input,j=A.avail_in,X=S.hold,$=S.bits,S.mode===12&&(S.back=-1);break}for(S.back=0;be=(k=S.lencode[X&(1<<S.lenbits)-1])>>>16&255,Se=65535&k,!((me=k>>>24)<=$);){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}if(be&&(240&be)==0){for(Be=me,Je=be,ke=Se;be=(k=S.lencode[ke+((X&(1<<Be+Je)-1)>>Be)])>>>16&255,Se=65535&k,!(Be+(me=k>>>24)<=$);){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}X>>>=Be,$-=Be,S.back+=Be}if(X>>>=me,$-=me,S.back+=me,S.length=Se,be===0){S.mode=26;break}if(32&be){S.back=-1,S.mode=12;break}if(64&be){A.msg="invalid literal/length code",S.mode=30;break}S.extra=15&be,S.mode=22;case 22:if(S.extra){for(O=S.extra;$<O;){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}S.length+=X&(1<<S.extra)-1,X>>>=S.extra,$-=S.extra,S.back+=S.extra}S.was=S.length,S.mode=23;case 23:for(;be=(k=S.distcode[X&(1<<S.distbits)-1])>>>16&255,Se=65535&k,!((me=k>>>24)<=$);){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}if((240&be)==0){for(Be=me,Je=be,ke=Se;be=(k=S.distcode[ke+((X&(1<<Be+Je)-1)>>Be)])>>>16&255,Se=65535&k,!(Be+(me=k>>>24)<=$);){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}X>>>=Be,$-=Be,S.back+=Be}if(X>>>=me,$-=me,S.back+=me,64&be){A.msg="invalid distance code",S.mode=30;break}S.offset=Se,S.extra=15&be,S.mode=24;case 24:if(S.extra){for(O=S.extra;$<O;){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}S.offset+=X&(1<<S.extra)-1,X>>>=S.extra,$-=S.extra,S.back+=S.extra}if(S.offset>S.dmax){A.msg="invalid distance too far back",S.mode=30;break}S.mode=25;case 25:if(ie===0)break e;if(fe=pe-ie,S.offset>fe){if((fe=S.offset-fe)>S.whave&&S.sane){A.msg="invalid distance too far back",S.mode=30;break}se=fe>S.wnext?(fe-=S.wnext,S.wsize-fe):S.wnext-fe,fe>S.length&&(fe=S.length),ce=S.window}else ce=H,se=Z-S.offset,fe=S.length;for(ie<fe&&(fe=ie),ie-=fe,S.length-=fe;H[Z++]=ce[se++],--fe;);S.length===0&&(S.mode=21);break;case 26:if(ie===0)break e;H[Z++]=S.length,ie--,S.mode=21;break;case 27:if(S.wrap){for(;$<32;){if(j===0)break e;j--,X|=U[G++]<<$,$+=8}if(pe-=ie,A.total_out+=pe,S.total+=pe,pe&&(A.adler=S.check=S.flags?o(S.check,H,pe,Z-pe):a(S.check,H,pe,Z-pe)),pe=ie,(S.flags?X:m(X))!==S.check){A.msg="incorrect data check",S.mode=30;break}$=X=0}S.mode=28;case 28:if(S.wrap&&S.flags){for(;$<32;){if(j===0)break e;j--,X+=U[G++]<<$,$+=8}if(X!==(4294967295&S.total)){A.msg="incorrect length check",S.mode=30;break}$=X=0}S.mode=29;case 29:D=1;break e;case 30:D=-3;break e;case 31:return-4;case 32:default:return u}return A.next_out=Z,A.avail_out=ie,A.next_in=G,A.avail_in=j,S.hold=X,S.bits=$,(S.wsize||pe!==A.avail_out&&S.mode<30&&(S.mode<27||B!==4))&&I(A,A.output,A.next_out,pe-A.avail_out)?(S.mode=31,-4):(ue-=A.avail_in,pe-=A.avail_out,A.total_in+=ue,A.total_out+=pe,S.total+=pe,S.wrap&&pe&&(A.adler=S.check=S.flags?o(S.check,H,pe,A.next_out-pe):a(S.check,H,pe,A.next_out-pe)),A.data_type=S.bits+(S.last?64:0)+(S.mode===12?128:0)+(S.mode===20||S.mode===15?256:0),(ue==0&&pe===0||B===4)&&D===p&&(D=-5),D)},i.inflateEnd=function(A){if(!A||!A.state)return u;var B=A.state;return B.window&&(B.window=null),A.state=null,p},i.inflateGetHeader=function(A,B){var S;return A&&A.state?(2&(S=A.state).wrap)==0?u:((S.head=B).done=!1,p):u},i.inflateSetDictionary=function(A,B){var S,U=B.length;return A&&A.state?(S=A.state).wrap!==0&&S.mode!==11?u:S.mode===11&&a(1,B,U,0)!==S.check?-3:I(A,B,U,U)?(S.mode=31,-4):(S.havedict=1,p):u},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(t,n,i){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];n.exports=function(h,d,p,u,g,f,x,m){var b,v,y,_,M,T,R,w,E,I=m.bits,A=0,B=0,S=0,U=0,H=0,G=0,Z=0,j=0,ie=0,X=0,$=null,ue=0,pe=new r.Buf16(16),fe=new r.Buf16(16),se=null,ce=0;for(A=0;A<=15;A++)pe[A]=0;for(B=0;B<u;B++)pe[d[p+B]]++;for(H=I,U=15;1<=U&&pe[U]===0;U--);if(U<H&&(H=U),U===0)return g[f++]=20971520,g[f++]=20971520,m.bits=1,0;for(S=1;S<U&&pe[S]===0;S++);for(H<S&&(H=S),A=j=1;A<=15;A++)if(j<<=1,(j-=pe[A])<0)return-1;if(0<j&&(h===0||U!==1))return-1;for(fe[1]=0,A=1;A<15;A++)fe[A+1]=fe[A]+pe[A];for(B=0;B<u;B++)d[p+B]!==0&&(x[fe[d[p+B]]++]=B);if(T=h===0?($=se=x,19):h===1?($=a,ue-=257,se=o,ce-=257,256):($=l,se=c,-1),A=S,M=f,Z=B=X=0,y=-1,_=(ie=1<<(G=H))-1,h===1&&852<ie||h===2&&592<ie)return 1;for(;;){for(R=A-Z,E=x[B]<T?(w=0,x[B]):x[B]>T?(w=se[ce+x[B]],$[ue+x[B]]):(w=96,0),b=1<<A-Z,S=v=1<<G;g[M+(X>>Z)+(v-=b)]=R<<24|w<<16|E|0,v!==0;);for(b=1<<A-1;X&b;)b>>=1;if(b!==0?(X&=b-1,X+=b):X=0,B++,--pe[A]==0){if(A===U)break;A=d[p+x[B]]}if(H<A&&(X&_)!==y){for(Z===0&&(Z=H),M+=S,j=1<<(G=A-Z);G+Z<U&&!((j-=pe[G+Z])<=0);)G++,j<<=1;if(ie+=1<<G,h===1&&852<ie||h===2&&592<ie)return 1;g[y=X&_]=H<<24|G<<16|M-f|0}}return X!==0&&(g[M+X]=A-Z<<24|64<<16|0),m.bits=H,0}},{"../utils/common":41}],51:[function(t,n,i){n.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,n,i){var r=t("../utils/common"),a=0,o=1;function l(k){for(var F=k.length;0<=--F;)k[F]=0}var c=0,h=29,d=256,p=d+1+h,u=30,g=19,f=2*p+1,x=15,m=16,b=7,v=256,y=16,_=17,M=18,T=[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],R=[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],E=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],I=new Array(2*(p+2));l(I);var A=new Array(2*u);l(A);var B=new Array(512);l(B);var S=new Array(256);l(S);var U=new Array(h);l(U);var H,G,Z,j=new Array(u);function ie(k,F,ee,J,q){this.static_tree=k,this.extra_bits=F,this.extra_base=ee,this.elems=J,this.max_length=q,this.has_stree=k&&k.length}function X(k,F){this.dyn_tree=k,this.max_code=0,this.stat_desc=F}function $(k){return k<256?B[k]:B[256+(k>>>7)]}function ue(k,F){k.pending_buf[k.pending++]=255&F,k.pending_buf[k.pending++]=F>>>8&255}function pe(k,F,ee){k.bi_valid>m-ee?(k.bi_buf|=F<<k.bi_valid&65535,ue(k,k.bi_buf),k.bi_buf=F>>m-k.bi_valid,k.bi_valid+=ee-m):(k.bi_buf|=F<<k.bi_valid&65535,k.bi_valid+=ee)}function fe(k,F,ee){pe(k,ee[2*F],ee[2*F+1])}function se(k,F){for(var ee=0;ee|=1&k,k>>>=1,ee<<=1,0<--F;);return ee>>>1}function ce(k,F,ee){var J,q,N=new Array(x+1),L=0;for(J=1;J<=x;J++)N[J]=L=L+ee[J-1]<<1;for(q=0;q<=F;q++){var V=k[2*q+1];V!==0&&(k[2*q]=se(N[V]++,V))}}function me(k){var F;for(F=0;F<p;F++)k.dyn_ltree[2*F]=0;for(F=0;F<u;F++)k.dyn_dtree[2*F]=0;for(F=0;F<g;F++)k.bl_tree[2*F]=0;k.dyn_ltree[2*v]=1,k.opt_len=k.static_len=0,k.last_lit=k.matches=0}function be(k){8<k.bi_valid?ue(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 Se(k,F,ee,J){var q=2*F,N=2*ee;return k[q]<k[N]||k[q]===k[N]&&J[F]<=J[ee]}function Be(k,F,ee){for(var J=k.heap[ee],q=ee<<1;q<=k.heap_len&&(q<k.heap_len&&Se(F,k.heap[q+1],k.heap[q],k.depth)&&q++,!Se(F,J,k.heap[q],k.depth));)k.heap[ee]=k.heap[q],ee=q,q<<=1;k.heap[ee]=J}function Je(k,F,ee){var J,q,N,L,V=0;if(k.last_lit!==0)for(;J=k.pending_buf[k.d_buf+2*V]<<8|k.pending_buf[k.d_buf+2*V+1],q=k.pending_buf[k.l_buf+V],V++,J===0?fe(k,q,F):(fe(k,(N=S[q])+d+1,F),(L=T[N])!==0&&pe(k,q-=U[N],L),fe(k,N=$(--J),ee),(L=R[N])!==0&&pe(k,J-=j[N],L)),V<k.last_lit;);fe(k,v,F)}function ke(k,F){var ee,J,q,N=F.dyn_tree,L=F.stat_desc.static_tree,V=F.stat_desc.has_stree,K=F.stat_desc.elems,le=-1;for(k.heap_len=0,k.heap_max=f,ee=0;ee<K;ee++)N[2*ee]!==0?(k.heap[++k.heap_len]=le=ee,k.depth[ee]=0):N[2*ee+1]=0;for(;k.heap_len<2;)N[2*(q=k.heap[++k.heap_len]=le<2?++le:0)]=1,k.depth[q]=0,k.opt_len--,V&&(k.static_len-=L[2*q+1]);for(F.max_code=le,ee=k.heap_len>>1;1<=ee;ee--)Be(k,N,ee);for(q=K;ee=k.heap[1],k.heap[1]=k.heap[k.heap_len--],Be(k,N,1),J=k.heap[1],k.heap[--k.heap_max]=ee,k.heap[--k.heap_max]=J,N[2*q]=N[2*ee]+N[2*J],k.depth[q]=(k.depth[ee]>=k.depth[J]?k.depth[ee]:k.depth[J])+1,N[2*ee+1]=N[2*J+1]=q,k.heap[1]=q++,Be(k,N,1),2<=k.heap_len;);k.heap[--k.heap_max]=k.heap[1],(function(te,Te){var ye,Re,De,de,_e,Ve,Ue=Te.dyn_tree,Ae=Te.max_code,Ge=Te.stat_desc.static_tree,Y=Te.stat_desc.has_stree,Ce=Te.stat_desc.extra_bits,Me=Te.stat_desc.extra_base,we=Te.stat_desc.max_length,ve=0;for(de=0;de<=x;de++)te.bl_count[de]=0;for(Ue[2*te.heap[te.heap_max]+1]=0,ye=te.heap_max+1;ye<f;ye++)we<(de=Ue[2*Ue[2*(Re=te.heap[ye])+1]+1]+1)&&(de=we,ve++),Ue[2*Re+1]=de,Ae<Re||(te.bl_count[de]++,_e=0,Me<=Re&&(_e=Ce[Re-Me]),Ve=Ue[2*Re],te.opt_len+=Ve*(de+_e),Y&&(te.static_len+=Ve*(Ge[2*Re+1]+_e)));if(ve!==0){do{for(de=we-1;te.bl_count[de]===0;)de--;te.bl_count[de]--,te.bl_count[de+1]+=2,te.bl_count[we]--,ve-=2}while(0<ve);for(de=we;de!==0;de--)for(Re=te.bl_count[de];Re!==0;)Ae<(De=te.heap[--ye])||(Ue[2*De+1]!==de&&(te.opt_len+=(de-Ue[2*De+1])*Ue[2*De],Ue[2*De+1]=de),Re--)}})(k,F),ce(N,le,k.bl_count)}function C(k,F,ee){var J,q,N=-1,L=F[1],V=0,K=7,le=4;for(L===0&&(K=138,le=3),F[2*(ee+1)+1]=65535,J=0;J<=ee;J++)q=L,L=F[2*(J+1)+1],++V<K&&q===L||(V<le?k.bl_tree[2*q]+=V:q!==0?(q!==N&&k.bl_tree[2*q]++,k.bl_tree[2*y]++):V<=10?k.bl_tree[2*_]++:k.bl_tree[2*M]++,N=q,le=(V=0)===L?(K=138,3):q===L?(K=6,3):(K=7,4))}function D(k,F,ee){var J,q,N=-1,L=F[1],V=0,K=7,le=4;for(L===0&&(K=138,le=3),J=0;J<=ee;J++)if(q=L,L=F[2*(J+1)+1],!(++V<K&&q===L)){if(V<le)for(;fe(k,q,k.bl_tree),--V!=0;);else q!==0?(q!==N&&(fe(k,q,k.bl_tree),V--),fe(k,y,k.bl_tree),pe(k,V-3,2)):V<=10?(fe(k,_,k.bl_tree),pe(k,V-3,3)):(fe(k,M,k.bl_tree),pe(k,V-11,7));N=q,le=(V=0)===L?(K=138,3):q===L?(K=6,3):(K=7,4)}}l(j);var W=!1;function O(k,F,ee,J){pe(k,(c<<1)+(J?1:0),3),(function(q,N,L,V){be(q),ue(q,L),ue(q,~L),r.arraySet(q.pending_buf,q.window,N,L,q.pending),q.pending+=L})(k,F,ee)}i._tr_init=function(k){W||((function(){var F,ee,J,q,N,L=new Array(x+1);for(q=J=0;q<h-1;q++)for(U[q]=J,F=0;F<1<<T[q];F++)S[J++]=q;for(S[J-1]=q,q=N=0;q<16;q++)for(j[q]=N,F=0;F<1<<R[q];F++)B[N++]=q;for(N>>=7;q<u;q++)for(j[q]=N<<7,F=0;F<1<<R[q]-7;F++)B[256+N++]=q;for(ee=0;ee<=x;ee++)L[ee]=0;for(F=0;F<=143;)I[2*F+1]=8,F++,L[8]++;for(;F<=255;)I[2*F+1]=9,F++,L[9]++;for(;F<=279;)I[2*F+1]=7,F++,L[7]++;for(;F<=287;)I[2*F+1]=8,F++,L[8]++;for(ce(I,p+1,L),F=0;F<u;F++)A[2*F+1]=5,A[2*F]=se(F,5);H=new ie(I,T,d+1,p,x),G=new ie(A,R,0,u,x),Z=new ie(new Array(0),w,0,g,b)})(),W=!0),k.l_desc=new X(k.dyn_ltree,H),k.d_desc=new X(k.dyn_dtree,G),k.bl_desc=new X(k.bl_tree,Z),k.bi_buf=0,k.bi_valid=0,me(k)},i._tr_stored_block=O,i._tr_flush_block=function(k,F,ee,J){var q,N,L=0;0<k.level?(k.strm.data_type===2&&(k.strm.data_type=(function(V){var K,le=4093624447;for(K=0;K<=31;K++,le>>>=1)if(1&le&&V.dyn_ltree[2*K]!==0)return a;if(V.dyn_ltree[18]!==0||V.dyn_ltree[20]!==0||V.dyn_ltree[26]!==0)return o;for(K=32;K<d;K++)if(V.dyn_ltree[2*K]!==0)return o;return a})(k)),ke(k,k.l_desc),ke(k,k.d_desc),L=(function(V){var K;for(C(V,V.dyn_ltree,V.l_desc.max_code),C(V,V.dyn_dtree,V.d_desc.max_code),ke(V,V.bl_desc),K=g-1;3<=K&&V.bl_tree[2*E[K]+1]===0;K--);return V.opt_len+=3*(K+1)+5+5+4,K})(k),q=k.opt_len+3+7>>>3,(N=k.static_len+3+7>>>3)<=q&&(q=N)):q=N=ee+5,ee+4<=q&&F!==-1?O(k,F,ee,J):k.strategy===4||N===q?(pe(k,2+(J?1:0),3),Je(k,I,A)):(pe(k,4+(J?1:0),3),(function(V,K,le,te){var Te;for(pe(V,K-257,5),pe(V,le-1,5),pe(V,te-4,4),Te=0;Te<te;Te++)pe(V,V.bl_tree[2*E[Te]+1],3);D(V,V.dyn_ltree,K-1),D(V,V.dyn_dtree,le-1)})(k,k.l_desc.max_code+1,k.d_desc.max_code+1,L+1),Je(k,k.dyn_ltree,k.dyn_dtree)),me(k),J&&be(k)},i._tr_tally=function(k,F,ee){return k.pending_buf[k.d_buf+2*k.last_lit]=F>>>8&255,k.pending_buf[k.d_buf+2*k.last_lit+1]=255&F,k.pending_buf[k.l_buf+k.last_lit]=255&ee,k.last_lit++,F===0?k.dyn_ltree[2*ee]++:(k.matches++,F--,k.dyn_ltree[2*(S[ee]+d+1)]++,k.dyn_dtree[2*$(F)]++),k.last_lit===k.lit_bufsize-1},i._tr_align=function(k){pe(k,2,3),fe(k,v,I),(function(F){F.bi_valid===16?(ue(F,F.bi_buf),F.bi_buf=0,F.bi_valid=0):8<=F.bi_valid&&(F.pending_buf[F.pending++]=255&F.bi_buf,F.bi_buf>>=8,F.bi_valid-=8)})(k)}},{"../utils/common":41}],53:[function(t,n,i){n.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,n,i){(function(r){(function(a,o){if(!a.setImmediate){var l,c,h,d,p=1,u={},g=!1,f=a.document,x=Object.getPrototypeOf&&Object.getPrototypeOf(a);x=x&&x.setTimeout?x:a,l={}.toString.call(a.process)==="[object process]"?function(y){process.nextTick(function(){b(y)})}:(function(){if(a.postMessage&&!a.importScripts){var y=!0,_=a.onmessage;return a.onmessage=function(){y=!1},a.postMessage("","*"),a.onmessage=_,y}})()?(d="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",v,!1):a.attachEvent("onmessage",v),function(y){a.postMessage(d+y,"*")}):a.MessageChannel?((h=new MessageChannel).port1.onmessage=function(y){b(y.data)},function(y){h.port2.postMessage(y)}):f&&"onreadystatechange"in f.createElement("script")?(c=f.documentElement,function(y){var _=f.createElement("script");_.onreadystatechange=function(){b(y),_.onreadystatechange=null,c.removeChild(_),_=null},c.appendChild(_)}):function(y){setTimeout(b,0,y)},x.setImmediate=function(y){typeof y!="function"&&(y=new Function(""+y));for(var _=new Array(arguments.length-1),M=0;M<_.length;M++)_[M]=arguments[M+1];var T={callback:y,args:_};return u[p]=T,l(p),p++},x.clearImmediate=m}function m(y){delete u[y]}function b(y){if(g)setTimeout(b,0,y);else{var _=u[y];if(_){g=!0;try{(function(M){var T=M.callback,R=M.args;switch(R.length){case 0:T();break;case 1:T(R[0]);break;case 2:T(R[0],R[1]);break;case 3:T(R[0],R[1],R[2]);break;default:T.apply(o,R)}})(_)}finally{m(y),g=!1}}}}function v(y){y.source===a&&typeof y.data=="string"&&y.data.indexOf(d)===0&&b(+y.data.slice(d.length))}})(typeof self>"u"?r===void 0?this:r:self)}).call(this,typeof cl<"u"?cl:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(tm)),tm.exports}var i_=n_();const im=em(i_);function sm(s,e){return function(){return s.apply(e,arguments)}}const{toString:s_}=Object.prototype,{getPrototypeOf:dd}=Object,{iterator:dl,toStringTag:rm}=Symbol,ul=(s=>e=>{const t=s_.call(e);return s[t]||(s[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),ni=s=>(s=s.toLowerCase(),e=>ul(e)===s),pl=s=>e=>typeof e===s,{isArray:Dr}=Array,Nr=pl("undefined");function Ta(s){return s!==null&&!Nr(s)&&s.constructor!==null&&!Nr(s.constructor)&&Mn(s.constructor.isBuffer)&&s.constructor.isBuffer(s)}const am=ni("ArrayBuffer");function r_(s){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(s):e=s&&s.buffer&&am(s.buffer),e}const a_=pl("string"),Mn=pl("function"),om=pl("number"),Aa=s=>s!==null&&typeof s=="object",o_=s=>s===!0||s===!1,fl=s=>{if(ul(s)!=="object")return!1;const e=dd(s);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(rm in s)&&!(dl in s)},l_=s=>{if(!Aa(s)||Ta(s))return!1;try{return Object.keys(s).length===0&&Object.getPrototypeOf(s)===Object.prototype}catch{return!1}},c_=ni("Date"),h_=ni("File"),d_=ni("Blob"),u_=ni("FileList"),p_=s=>Aa(s)&&Mn(s.pipe),f_=s=>{let e;return s&&(typeof FormData=="function"&&s instanceof FormData||Mn(s.append)&&((e=ul(s))==="formdata"||e==="object"&&Mn(s.toString)&&s.toString()==="[object FormData]"))},m_=ni("URLSearchParams"),[g_,x_,v_,b_]=["ReadableStream","Request","Response","Headers"].map(ni),y_=s=>s.trim?s.trim():s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Pa(s,e,{allOwnKeys:t=!1}={}){if(s===null||typeof s>"u")return;let n,i;if(typeof s!="object"&&(s=[s]),Dr(s))for(n=0,i=s.length;n<i;n++)e.call(null,s[n],n,s);else{if(Ta(s))return;const r=t?Object.getOwnPropertyNames(s):Object.keys(s),a=r.length;let o;for(n=0;n<a;n++)o=r[n],e.call(null,s[o],o,s)}}function lm(s,e){if(Ta(s))return null;e=e.toLowerCase();const t=Object.keys(s);let n=t.length,i;for(;n-- >0;)if(i=t[n],e===i.toLowerCase())return i;return null}const Rs=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,cm=s=>!Nr(s)&&s!==Rs;function ud(){const{caseless:s,skipUndefined:e}=cm(this)&&this||{},t={},n=(i,r)=>{const a=s&&lm(t,r)||r;fl(t[a])&&fl(i)?t[a]=ud(t[a],i):fl(i)?t[a]=ud({},i):Dr(i)?t[a]=i.slice():(!e||!Nr(i))&&(t[a]=i)};for(let i=0,r=arguments.length;i<r;i++)arguments[i]&&Pa(arguments[i],n);return t}const __=(s,e,t,{allOwnKeys:n}={})=>(Pa(e,(i,r)=>{t&&Mn(i)?s[r]=sm(i,t):s[r]=i},{allOwnKeys:n}),s),M_=s=>(s.charCodeAt(0)===65279&&(s=s.slice(1)),s),w_=(s,e,t,n)=>{s.prototype=Object.create(e.prototype,n),s.prototype.constructor=s,Object.defineProperty(s,"super",{value:e.prototype}),t&&Object.assign(s.prototype,t)},S_=(s,e,t,n)=>{let i,r,a;const o={};if(e=e||{},s==null)return e;do{for(i=Object.getOwnPropertyNames(s),r=i.length;r-- >0;)a=i[r],(!n||n(a,s,e))&&!o[a]&&(e[a]=s[a],o[a]=!0);s=t!==!1&&dd(s)}while(s&&(!t||t(s,e))&&s!==Object.prototype);return e},E_=(s,e,t)=>{s=String(s),(t===void 0||t>s.length)&&(t=s.length),t-=e.length;const n=s.indexOf(e,t);return n!==-1&&n===t},C_=s=>{if(!s)return null;if(Dr(s))return s;let e=s.length;if(!om(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=s[e];return t},T_=(s=>e=>s&&e instanceof s)(typeof Uint8Array<"u"&&dd(Uint8Array)),A_=(s,e)=>{const t=(s&&s[dl]).call(s);let n;for(;(n=t.next())&&!n.done;){const i=n.value;e.call(s,i[0],i[1])}},P_=(s,e)=>{let t;const n=[];for(;(t=s.exec(e))!==null;)n.push(t);return n},R_=ni("HTMLFormElement"),L_=s=>s.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),hm=(({hasOwnProperty:s})=>(e,t)=>s.call(e,t))(Object.prototype),I_=ni("RegExp"),dm=(s,e)=>{const t=Object.getOwnPropertyDescriptors(s),n={};Pa(t,(i,r)=>{let a;(a=e(i,r,s))!==!1&&(n[r]=a||i)}),Object.defineProperties(s,n)},D_=s=>{dm(s,(e,t)=>{if(Mn(s)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const n=s[t];if(Mn(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},N_=(s,e)=>{const t={},n=i=>{i.forEach(r=>{t[r]=!0})};return Dr(s)?n(s):n(String(s).split(e)),t},B_=()=>{},k_=(s,e)=>s!=null&&Number.isFinite(s=+s)?s:e;function U_(s){return!!(s&&Mn(s.append)&&s[rm]==="FormData"&&s[dl])}const O_=s=>{const e=new Array(10),t=(n,i)=>{if(Aa(n)){if(e.indexOf(n)>=0)return;if(Ta(n))return n;if(!("toJSON"in n)){e[i]=n;const r=Dr(n)?[]:{};return Pa(n,(a,o)=>{const l=t(a,i+1);!Nr(l)&&(r[o]=l)}),e[i]=void 0,r}}return n};return t(s,0)},z_=ni("AsyncFunction"),F_=s=>s&&(Aa(s)||Mn(s))&&Mn(s.then)&&Mn(s.catch),um=((s,e)=>s?setImmediate:e?((t,n)=>(Rs.addEventListener("message",({source:i,data:r})=>{i===Rs&&r===t&&n.length&&n.shift()()},!1),i=>{n.push(i),Rs.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",Mn(Rs.postMessage)),H_=typeof queueMicrotask<"u"?queueMicrotask.bind(Rs):typeof process<"u"&&process.nextTick||um,V_=s=>s!=null&&Mn(s[dl]),re={isArray:Dr,isArrayBuffer:am,isBuffer:Ta,isFormData:f_,isArrayBufferView:r_,isString:a_,isNumber:om,isBoolean:o_,isObject:Aa,isPlainObject:fl,isEmptyObject:l_,isReadableStream:g_,isRequest:x_,isResponse:v_,isHeaders:b_,isUndefined:Nr,isDate:c_,isFile:h_,isBlob:d_,isRegExp:I_,isFunction:Mn,isStream:p_,isURLSearchParams:m_,isTypedArray:T_,isFileList:u_,forEach:Pa,merge:ud,extend:__,trim:y_,stripBOM:M_,inherits:w_,toFlatObject:S_,kindOf:ul,kindOfTest:ni,endsWith:E_,toArray:C_,forEachEntry:A_,matchAll:P_,isHTMLForm:R_,hasOwnProperty:hm,hasOwnProp:hm,reduceDescriptors:dm,freezeMethods:D_,toObjectSet:N_,toCamelCase:L_,noop:B_,toFiniteNumber:k_,findKey:lm,global:Rs,isContextDefined:cm,isSpecCompliantForm:U_,toJSONObject:O_,isAsyncFn:z_,isThenable:F_,setImmediate:um,asap:H_,isIterable:V_};function Ke(s,e,t,n,i){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),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}re.inherits(Ke,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:re.toJSONObject(this.config),code:this.code,status:this.status}}});const pm=Ke.prototype,fm={};["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=>{fm[s]={value:s}}),Object.defineProperties(Ke,fm),Object.defineProperty(pm,"isAxiosError",{value:!0}),Ke.from=(s,e,t,n,i,r)=>{const a=Object.create(pm);re.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 Ke.call(a,o,l,t,n,i),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 G_=null;function pd(s){return re.isPlainObject(s)||re.isArray(s)}function mm(s){return re.endsWith(s,"[]")?s.slice(0,-2):s}function gm(s,e,t){return s?s.concat(e).map(function(n,i){return n=mm(n),!t&&i?"["+n+"]":n}).join(t?".":""):e}function W_(s){return re.isArray(s)&&!s.some(pd)}const X_=re.toFlatObject(re,{},null,function(s){return/^is[A-Z]/.test(s)});function ml(s,e,t){if(!re.isObject(s))throw new TypeError("target must be an object");e=e||new FormData,t=re.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(u,g){return!re.isUndefined(g[u])});const n=t.metaTokens,i=t.visitor||c,r=t.dots,a=t.indexes,o=(t.Blob||typeof Blob<"u"&&Blob)&&re.isSpecCompliantForm(e);if(!re.isFunction(i))throw new TypeError("visitor must be a function");function l(u){if(u===null)return"";if(re.isDate(u))return u.toISOString();if(re.isBoolean(u))return u.toString();if(!o&&re.isBlob(u))throw new Ke("Blob is not supported. Use a Buffer instead.");return re.isArrayBuffer(u)||re.isTypedArray(u)?o&&typeof Blob=="function"?new Blob([u]):Buffer.from(u):u}function c(u,g,f){let x=u;if(u&&!f&&typeof u=="object"){if(re.endsWith(g,"{}"))g=n?g:g.slice(0,-2),u=JSON.stringify(u);else if(re.isArray(u)&&W_(u)||(re.isFileList(u)||re.endsWith(g,"[]"))&&(x=re.toArray(u)))return g=mm(g),x.forEach(function(m,b){!(re.isUndefined(m)||m===null)&&e.append(a===!0?gm([g],b,r):a===null?g:g+"[]",l(m))}),!1}return pd(u)?!0:(e.append(gm(f,g,r),l(u)),!1)}const h=[],d=Object.assign(X_,{defaultVisitor:c,convertValue:l,isVisitable:pd});function p(u,g){if(!re.isUndefined(u)){if(h.indexOf(u)!==-1)throw Error("Circular reference detected in "+g.join("."));h.push(u),re.forEach(u,function(f,x){(!(re.isUndefined(f)||f===null)&&i.call(e,f,re.isString(x)?x.trim():x,g,d))===!0&&p(f,g?g.concat(x):[x])}),h.pop()}}if(!re.isObject(s))throw new TypeError("data must be an object");return p(s),e}function xm(s){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(s).replace(/[!'()~]|%20|%00/g,function(t){return e[t]})}function fd(s,e){this._pairs=[],s&&ml(s,this,e)}const vm=fd.prototype;vm.append=function(s,e){this._pairs.push([s,e])},vm.toString=function(s){const e=s?function(t){return s.call(this,t,xm)}:xm;return this._pairs.map(function(t){return e(t[0])+"="+e(t[1])},"").join("&")};function j_(s){return encodeURIComponent(s).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function bm(s,e,t){if(!e)return s;const n=t&&t.encode||j_;re.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let r;if(i?r=i(e,t):r=re.isURLSearchParams(e)?e.toString():new fd(e,t).toString(n),r){const a=s.indexOf("#");a!==-1&&(s=s.slice(0,a)),s+=(s.indexOf("?")===-1?"?":"&")+r}return s}class ym{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){re.forEach(this.handlers,function(t){t!==null&&e(t)})}}const _m={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},q_=typeof URLSearchParams<"u"?URLSearchParams:fd,Z_=typeof FormData<"u"?FormData:null,Y_=typeof Blob<"u"?Blob:null,$_={isBrowser:!0,classes:{URLSearchParams:q_,FormData:Z_,Blob:Y_},protocols:["http","https","file","blob","url","data"]},md=typeof window<"u"&&typeof document<"u",gd=typeof navigator=="object"&&navigator||void 0,K_=md&&(!gd||["ReactNative","NativeScript","NS"].indexOf(gd.product)<0),J_=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Q_=md&&window.location.href||"http://localhost",eM=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:md,hasStandardBrowserEnv:K_,hasStandardBrowserWebWorkerEnv:J_,navigator:gd,origin:Q_},Symbol.toStringTag,{value:"Module"})),cn={...eM,...$_};function tM(s,e){return ml(s,new cn.classes.URLSearchParams,{visitor:function(t,n,i,r){return cn.isNode&&re.isBuffer(t)?(this.append(n,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...e})}function nM(s){return re.matchAll(/\w+|\[(\w*)]/g,s).map(e=>e[0]==="[]"?"":e[1]||e[0])}function iM(s){const e={},t=Object.keys(s);let n;const i=t.length;let r;for(n=0;n<i;n++)r=t[n],e[r]=s[r];return e}function Mm(s){function e(t,n,i,r){let a=t[r++];if(a==="__proto__")return!0;const o=Number.isFinite(+a),l=r>=t.length;return a=!a&&re.isArray(i)?i.length:a,l?(re.hasOwnProp(i,a)?i[a]=[i[a],n]:i[a]=n,!o):((!i[a]||!re.isObject(i[a]))&&(i[a]=[]),e(t,n,i[a],r)&&re.isArray(i[a])&&(i[a]=iM(i[a])),!o)}if(re.isFormData(s)&&re.isFunction(s.entries)){const t={};return re.forEachEntry(s,(n,i)=>{e(nM(n),i,t,0)}),t}return null}function sM(s,e,t){if(re.isString(s))try{return(e||JSON.parse)(s),re.trim(s)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(s)}const Ra={transitional:_m,adapter:["xhr","http","fetch"],transformRequest:[function(s,e){const t=e.getContentType()||"",n=t.indexOf("application/json")>-1,i=re.isObject(s);if(i&&re.isHTMLForm(s)&&(s=new FormData(s)),re.isFormData(s))return n?JSON.stringify(Mm(s)):s;if(re.isArrayBuffer(s)||re.isBuffer(s)||re.isStream(s)||re.isFile(s)||re.isBlob(s)||re.isReadableStream(s))return s;if(re.isArrayBufferView(s))return s.buffer;if(re.isURLSearchParams(s))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),s.toString();let r;if(i){if(t.indexOf("application/x-www-form-urlencoded")>-1)return tM(s,this.formSerializer).toString();if((r=re.isFileList(s))||t.indexOf("multipart/form-data")>-1){const a=this.env&&this.env.FormData;return ml(r?{"files[]":s}:s,a&&new a,this.formSerializer)}}return i||n?(e.setContentType("application/json",!1),sM(s)):s}],transformResponse:[function(s){const e=this.transitional||Ra.transitional,t=e&&e.forcedJSONParsing,n=this.responseType==="json";if(re.isResponse(s)||re.isReadableStream(s))return s;if(s&&re.isString(s)&&(t&&!this.responseType||n)){const i=!(e&&e.silentJSONParsing)&&n;try{return JSON.parse(s,this.parseReviver)}catch(r){if(i)throw r.name==="SyntaxError"?Ke.from(r,Ke.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:cn.classes.FormData,Blob:cn.classes.Blob},validateStatus:function(s){return s>=200&&s<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};re.forEach(["delete","get","head","post","put","patch"],s=>{Ra.headers[s]={}});const rM=re.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"]),aM=s=>{const e={};let t,n,i;return s&&s.split(`
`).forEach(function(r){i=r.indexOf(":"),t=r.substring(0,i).trim().toLowerCase(),n=r.substring(i+1).trim(),!(!t||e[t]&&rM[t])&&(t==="set-cookie"?e[t]?e[t].push(n):e[t]=[n]:e[t]=e[t]?e[t]+", "+n:n)}),e},wm=Symbol("internals");function La(s){return s&&String(s).trim().toLowerCase()}function gl(s){return s===!1||s==null?s:re.isArray(s)?s.map(gl):String(s)}function oM(s){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=t.exec(s);)e[n[1]]=n[2];return e}const lM=s=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(s.trim());function xd(s,e,t,n,i){if(re.isFunction(n))return n.call(this,e,t);if(i&&(e=t),!!re.isString(e)){if(re.isString(n))return e.indexOf(n)!==-1;if(re.isRegExp(n))return n.test(e)}}function cM(s){return s.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function hM(s,e){const t=re.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(s,n+t,{value:function(i,r,a){return this[n].call(this,e,i,r,a)},configurable:!0})})}let wn=class{constructor(s){s&&this.set(s)}set(s,e,t){const n=this;function i(a,o,l){const c=La(o);if(!c)throw new Error("header name must be a non-empty string");const h=re.findKey(n,c);(!h||n[h]===void 0||l===!0||l===void 0&&n[h]!==!1)&&(n[h||o]=gl(a))}const r=(a,o)=>re.forEach(a,(l,c)=>i(l,c,o));if(re.isPlainObject(s)||s instanceof this.constructor)r(s,e);else if(re.isString(s)&&(s=s.trim())&&!lM(s))r(aM(s),e);else if(re.isObject(s)&&re.isIterable(s)){let a={},o,l;for(const c of s){if(!re.isArray(c))throw TypeError("Object iterator must return a key-value pair");a[l=c[0]]=(o=a[l])?re.isArray(o)?[...o,c[1]]:[o,c[1]]:c[1]}r(a,e)}else s!=null&&i(e,s,t);return this}get(s,e){if(s=La(s),s){const t=re.findKey(this,s);if(t){const n=this[t];if(!e)return n;if(e===!0)return oM(n);if(re.isFunction(e))return e.call(this,n,t);if(re.isRegExp(e))return e.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(s,e){if(s=La(s),s){const t=re.findKey(this,s);return!!(t&&this[t]!==void 0&&(!e||xd(this,this[t],t,e)))}return!1}delete(s,e){const t=this;let n=!1;function i(r){if(r=La(r),r){const a=re.findKey(t,r);a&&(!e||xd(t,t[a],a,e))&&(delete t[a],n=!0)}}return re.isArray(s)?s.forEach(i):i(s),n}clear(s){const e=Object.keys(this);let t=e.length,n=!1;for(;t--;){const i=e[t];(!s||xd(this,this[i],i,s,!0))&&(delete this[i],n=!0)}return n}normalize(s){const e=this,t={};return re.forEach(this,(n,i)=>{const r=re.findKey(t,i);if(r){e[r]=gl(n),delete e[i];return}const a=s?cM(i):String(i).trim();a!==i&&delete e[i],e[a]=gl(n),t[a]=!0}),this}concat(...s){return this.constructor.concat(this,...s)}toJSON(s){const e=Object.create(null);return re.forEach(this,(t,n)=>{t!=null&&t!==!1&&(e[n]=s&&re.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(n=>t.set(n)),t}static accessor(s){const e=(this[wm]=this[wm]={accessors:{}}).accessors,t=this.prototype;function n(i){const r=La(i);e[r]||(hM(t,i),e[r]=!0)}return re.isArray(s)?s.forEach(n):n(s),this}};wn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),re.reduceDescriptors(wn.prototype,({value:s},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>s,set(n){this[t]=n}}}),re.freezeMethods(wn);function vd(s,e){const t=this||Ra,n=e||t,i=wn.from(n.headers);let r=n.data;return re.forEach(s,function(a){r=a.call(t,r,i.normalize(),e?e.status:void 0)}),i.normalize(),r}function Sm(s){return!!(s&&s.__CANCEL__)}function Br(s,e,t){Ke.call(this,s??"canceled",Ke.ERR_CANCELED,e,t),this.name="CanceledError"}re.inherits(Br,Ke,{__CANCEL__:!0});function Em(s,e,t){const n=t.config.validateStatus;!t.status||!n||n(t.status)?s(t):e(new Ke("Request failed with status code "+t.status,[Ke.ERR_BAD_REQUEST,Ke.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function dM(s){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(s);return e&&e[1]||""}function uM(s,e){s=s||10;const t=new Array(s),n=new Array(s);let i=0,r=0,a;return e=e!==void 0?e:1e3,function(o){const l=Date.now(),c=n[r];a||(a=l),t[i]=o,n[i]=l;let h=r,d=0;for(;h!==i;)d+=t[h++],h=h%s;if(i=(i+1)%s,i===r&&(r=(r+1)%s),l-a<e)return;const p=c&&l-c;return p?Math.round(d*1e3/p):void 0}}function pM(s,e){let t=0,n=1e3/e,i,r;const a=(o,l=Date.now())=>{t=l,i=null,r&&(clearTimeout(r),r=null),s(...o)};return[(...o)=>{const l=Date.now(),c=l-t;c>=n?a(o,l):(i=o,r||(r=setTimeout(()=>{r=null,a(i)},n-c)))},()=>i&&a(i)]}const xl=(s,e,t=3)=>{let n=0;const i=uM(50,250);return pM(r=>{const a=r.loaded,o=r.lengthComputable?r.total:void 0,l=a-n,c=i(l),h=a<=o;n=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)},Cm=(s,e)=>{const t=s!=null;return[n=>e[0]({lengthComputable:t,total:s,loaded:n}),e[1]]},Tm=s=>(...e)=>re.asap(()=>s(...e)),fM=cn.hasStandardBrowserEnv?((s,e)=>t=>(t=new URL(t,cn.origin),s.protocol===t.protocol&&s.host===t.host&&(e||s.port===t.port)))(new URL(cn.origin),cn.navigator&&/(msie|trident)/i.test(cn.navigator.userAgent)):()=>!0,mM=cn.hasStandardBrowserEnv?{write(s,e,t,n,i,r,a){if(typeof document>"u")return;const o=[`${s}=${encodeURIComponent(e)}`];re.isNumber(t)&&o.push(`expires=${new Date(t).toUTCString()}`),re.isString(n)&&o.push(`path=${n}`),re.isString(i)&&o.push(`domain=${i}`),r===!0&&o.push("secure"),re.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 gM(s){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(s)}function xM(s,e){return e?s.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):s}function Am(s,e,t){let n=!gM(e);return s&&(n||t==!1)?xM(s,e):e}const Pm=s=>s instanceof wn?{...s}:s;function Ls(s,e){e=e||{};const t={};function n(c,h,d,p){return re.isPlainObject(c)&&re.isPlainObject(h)?re.merge.call({caseless:p},c,h):re.isPlainObject(h)?re.merge({},h):re.isArray(h)?h.slice():h}function i(c,h,d,p){if(re.isUndefined(h)){if(!re.isUndefined(c))return n(void 0,c,d,p)}else return n(c,h,d,p)}function r(c,h){if(!re.isUndefined(h))return n(void 0,h)}function a(c,h){if(re.isUndefined(h)){if(!re.isUndefined(c))return n(void 0,c)}else return n(void 0,h)}function o(c,h,d){if(d in e)return n(c,h);if(d in s)return n(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)=>i(Pm(c),Pm(h),d,!0)};return re.forEach(Object.keys({...s,...e}),function(c){const h=l[c]||i,d=h(s[c],e[c],c);re.isUndefined(d)&&h!==o||(t[c]=d)}),t}const Rm=s=>{const e=Ls({},s);let{data:t,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:r,headers:a,auth:o}=e;if(e.headers=a=wn.from(a),e.url=bm(Am(e.baseURL,e.url,e.allowAbsoluteUrls),s.params,s.paramsSerializer),o&&a.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):""))),re.isFormData(t)){if(cn.hasStandardBrowserEnv||cn.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(re.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(cn.hasStandardBrowserEnv&&(n&&re.isFunction(n)&&(n=n(e)),n||n!==!1&&fM(e.url))){const l=i&&r&&mM.read(r);l&&a.set(i,l)}return e},vM=typeof XMLHttpRequest<"u",bM=vM&&function(s){return new Promise(function(e,t){const n=Rm(s);let i=n.data;const r=wn.from(n.headers).normalize();let{responseType:a,onUploadProgress:o,onDownloadProgress:l}=n,c,h,d,p,u;function g(){p&&p(),u&&u(),n.cancelToken&&n.cancelToken.unsubscribe(c),n.signal&&n.signal.removeEventListener("abort",c)}let f=new XMLHttpRequest;f.open(n.method.toUpperCase(),n.url,!0),f.timeout=n.timeout;function x(){if(!f)return;const b=wn.from("getAllResponseHeaders"in f&&f.getAllResponseHeaders()),v={data:!a||a==="text"||a==="json"?f.responseText:f.response,status:f.status,statusText:f.statusText,headers:b,config:s,request:f};Em(function(y){e(y),g()},function(y){t(y),g()},v),f=null}"onloadend"in f?f.onloadend=x:f.onreadystatechange=function(){!f||f.readyState!==4||f.status===0&&!(f.responseURL&&f.responseURL.indexOf("file:")===0)||setTimeout(x)},f.onabort=function(){f&&(t(new Ke("Request aborted",Ke.ECONNABORTED,s,f)),f=null)},f.onerror=function(b){const v=b&&b.message?b.message:"Network Error",y=new Ke(v,Ke.ERR_NETWORK,s,f);y.event=b||null,t(y),f=null},f.ontimeout=function(){let b=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const v=n.transitional||_m;n.timeoutErrorMessage&&(b=n.timeoutErrorMessage),t(new Ke(b,v.clarifyTimeoutError?Ke.ETIMEDOUT:Ke.ECONNABORTED,s,f)),f=null},i===void 0&&r.setContentType(null),"setRequestHeader"in f&&re.forEach(r.toJSON(),function(b,v){f.setRequestHeader(v,b)}),re.isUndefined(n.withCredentials)||(f.withCredentials=!!n.withCredentials),a&&a!=="json"&&(f.responseType=n.responseType),l&&([d,u]=xl(l,!0),f.addEventListener("progress",d)),o&&f.upload&&([h,p]=xl(o),f.upload.addEventListener("progress",h),f.upload.addEventListener("loadend",p)),(n.cancelToken||n.signal)&&(c=b=>{f&&(t(!b||b.type?new Br(null,s,f):b),f.abort(),f=null)},n.cancelToken&&n.cancelToken.subscribe(c),n.signal&&(n.signal.aborted?c():n.signal.addEventListener("abort",c)));const m=dM(n.url);if(m&&cn.protocols.indexOf(m)===-1){t(new Ke("Unsupported protocol "+m+":",Ke.ERR_BAD_REQUEST,s));return}f.send(i||null)})},yM=(s,e)=>{const{length:t}=s=s?s.filter(Boolean):[];if(e||t){let n=new AbortController,i;const r=function(c){if(!i){i=!0,o();const h=c instanceof Error?c:this.reason;n.abort(h instanceof Ke?h:new Br(h instanceof Error?h.message:h))}};let a=e&&setTimeout(()=>{a=null,r(new Ke(`timeout ${e} of ms exceeded`,Ke.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}=n;return l.unsubscribe=()=>re.asap(o),l}},_M=function*(s,e){let t=s.byteLength;if(t<e){yield s;return}let n=0,i;for(;n<t;)i=n+e,yield s.slice(n,i),n=i},MM=async function*(s,e){for await(const t of wM(s))yield*_M(t,e)},wM=async function*(s){if(s[Symbol.asyncIterator]){yield*s;return}const e=s.getReader();try{for(;;){const{done:t,value:n}=await e.read();if(t)break;yield n}}finally{await e.cancel()}},Lm=(s,e,t,n)=>{const i=MM(s,e);let r=0,a,o=l=>{a||(a=!0,n&&n(l))};return new ReadableStream({async pull(l){try{const{done:c,value:h}=await i.next();if(c){o(),l.close();return}let d=h.byteLength;if(t){let p=r+=d;t(p)}l.enqueue(new Uint8Array(h))}catch(c){throw o(c),c}},cancel(l){return o(l),i.return()}},{highWaterMark:2})},Im=64*1024,{isFunction:vl}=re,SM=(({Request:s,Response:e})=>({Request:s,Response:e}))(re.global),{ReadableStream:Dm,TextEncoder:Nm}=re.global,Bm=(s,...e)=>{try{return!!s(...e)}catch{return!1}},EM=s=>{s=re.merge.call({skipUndefined:!0},SM,s);const{fetch:e,Request:t,Response:n}=s,i=e?vl(e):typeof fetch=="function",r=vl(t),a=vl(n);if(!i)return!1;const o=i&&vl(Dm),l=i&&(typeof Nm=="function"?(g=>f=>g.encode(f))(new Nm):async g=>new Uint8Array(await new t(g).arrayBuffer())),c=r&&o&&Bm(()=>{let g=!1;const f=new t(cn.origin,{body:new Dm,method:"POST",get duplex(){return g=!0,"half"}}).headers.has("Content-Type");return g&&!f}),h=a&&o&&Bm(()=>re.isReadableStream(new n("").body)),d={stream:h&&(g=>g.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(g=>{!d[g]&&(d[g]=(f,x)=>{let m=f&&f[g];if(m)return m.call(f);throw new Ke(`Response type '${g}' is not supported`,Ke.ERR_NOT_SUPPORT,x)})});const p=async g=>{if(g==null)return 0;if(re.isBlob(g))return g.size;if(re.isSpecCompliantForm(g))return(await new t(cn.origin,{method:"POST",body:g}).arrayBuffer()).byteLength;if(re.isArrayBufferView(g)||re.isArrayBuffer(g))return g.byteLength;if(re.isURLSearchParams(g)&&(g=g+""),re.isString(g))return(await l(g)).byteLength},u=async(g,f)=>re.toFiniteNumber(g.getContentLength())??p(f);return async g=>{let{url:f,method:x,data:m,signal:b,cancelToken:v,timeout:y,onDownloadProgress:_,onUploadProgress:M,responseType:T,headers:R,withCredentials:w="same-origin",fetchOptions:E}=Rm(g),I=e||fetch;T=T?(T+"").toLowerCase():"text";let A=yM([b,v&&v.toAbortSignal()],y),B=null;const S=A&&A.unsubscribe&&(()=>{A.unsubscribe()});let U;try{if(M&&c&&x!=="get"&&x!=="head"&&(U=await u(R,m))!==0){let X=new t(f,{method:"POST",body:m,duplex:"half"}),$;if(re.isFormData(m)&&($=X.headers.get("content-type"))&&R.setContentType($),X.body){const[ue,pe]=Cm(U,xl(Tm(M)));m=Lm(X.body,Im,ue,pe)}}re.isString(w)||(w=w?"include":"omit");const H=r&&"credentials"in t.prototype,G={...E,signal:A,method:x.toUpperCase(),headers:R.normalize().toJSON(),body:m,duplex:"half",credentials:H?w:void 0};B=r&&new t(f,G);let Z=await(r?I(B,E):I(f,G));const j=h&&(T==="stream"||T==="response");if(h&&(_||j&&S)){const X={};["status","statusText","headers"].forEach(fe=>{X[fe]=Z[fe]});const $=re.toFiniteNumber(Z.headers.get("content-length")),[ue,pe]=_&&Cm($,xl(Tm(_),!0))||[];Z=new n(Lm(Z.body,Im,ue,()=>{pe&&pe(),S&&S()}),X)}T=T||"text";let ie=await d[re.findKey(d,T)||"text"](Z,g);return!j&&S&&S(),await new Promise((X,$)=>{Em(X,$,{data:ie,headers:wn.from(Z.headers),status:Z.status,statusText:Z.statusText,config:g,request:B})})}catch(H){throw S&&S(),H&&H.name==="TypeError"&&/Load failed|fetch/i.test(H.message)?Object.assign(new Ke("Network Error",Ke.ERR_NETWORK,g,B),{cause:H.cause||H}):Ke.from(H,H&&H.code,g,B)}}},CM=new Map,km=s=>{let e=s&&s.env||{};const{fetch:t,Request:n,Response:i}=e,r=[n,i,t];let a=r.length,o=a,l,c,h=CM;for(;o--;)l=r[o],c=h.get(l),c===void 0&&h.set(l,c=o?new Map:EM(e)),h=c;return c};km();const bd={http:G_,xhr:bM,fetch:{get:km}};re.forEach(bd,(s,e)=>{if(s){try{Object.defineProperty(s,"name",{value:e})}catch{}Object.defineProperty(s,"adapterName",{value:e})}});const Um=s=>`- ${s}`,TM=s=>re.isFunction(s)||s===null||s===!1;function AM(s,e){s=re.isArray(s)?s:[s];const{length:t}=s;let n,i;const r={};for(let a=0;a<t;a++){n=s[a];let o;if(i=n,!TM(n)&&(i=bd[(o=String(n)).toLowerCase()],i===void 0))throw new Ke(`Unknown adapter '${o}'`);if(i&&(re.isFunction(i)||(i=i.get(e))))break;r[o||"#"+a]=i}if(!i){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(Um).join(`
`):" "+Um(a[0]):"as no adapter specified";throw new Ke("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return i}const Om={getAdapter:AM,adapters:bd};function yd(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new Br(null,s)}function zm(s){return yd(s),s.headers=wn.from(s.headers),s.data=vd.call(s,s.transformRequest),["post","put","patch"].indexOf(s.method)!==-1&&s.headers.setContentType("application/x-www-form-urlencoded",!1),Om.getAdapter(s.adapter||Ra.adapter,s)(s).then(function(e){return yd(s),e.data=vd.call(s,s.transformResponse,e),e.headers=wn.from(e.headers),e},function(e){return Sm(e)||(yd(s),e&&e.response&&(e.response.data=vd.call(s,s.transformResponse,e.response),e.response.headers=wn.from(e.response.headers))),Promise.reject(e)})}const Fm="1.13.2",bl={};["object","boolean","number","function","string","symbol"].forEach((s,e)=>{bl[s]=function(t){return typeof t===s||"a"+(e<1?"n ":" ")+s}});const Hm={};bl.transitional=function(s,e,t){function n(i,r){return"[Axios v"+Fm+"] Transitional option '"+i+"'"+r+(t?". "+t:"")}return(i,r,a)=>{if(s===!1)throw new Ke(n(r," has been removed"+(e?" in "+e:"")),Ke.ERR_DEPRECATED);return e&&!Hm[r]&&(Hm[r]=!0,console.warn(n(r," has been deprecated since v"+e+" and will be removed in the near future"))),s?s(i,r,a):!0}},bl.spelling=function(s){return(e,t)=>(console.warn(`${t} is likely a misspelling of ${s}`),!0)};function PM(s,e,t){if(typeof s!="object")throw new Ke("options must be an object",Ke.ERR_BAD_OPTION_VALUE);const n=Object.keys(s);let i=n.length;for(;i-- >0;){const r=n[i],a=e[r];if(a){const o=s[r],l=o===void 0||a(o,r,s);if(l!==!0)throw new Ke("option "+r+" must be "+l,Ke.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new Ke("Unknown option "+r,Ke.ERR_BAD_OPTION)}}const yl={assertOptions:PM,validators:bl},ui=yl.validators;let Is=class{constructor(s){this.defaults=s||{},this.interceptors={request:new ym,response:new ym}}async request(s,e){try{return await this._request(s,e)}catch(t){if(t instanceof Error){let n={};Error.captureStackTrace?Error.captureStackTrace(n):n=new Error;const i=n.stack?n.stack.replace(/^.+\n/,""):"";try{t.stack?i&&!String(t.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(t.stack+=`
`+i):t.stack=i}catch{}}throw t}}_request(s,e){typeof s=="string"?(e=e||{},e.url=s):e=s||{},e=Ls(this.defaults,e);const{transitional:t,paramsSerializer:n,headers:i}=e;t!==void 0&&yl.assertOptions(t,{silentJSONParsing:ui.transitional(ui.boolean),forcedJSONParsing:ui.transitional(ui.boolean),clarifyTimeoutError:ui.transitional(ui.boolean)},!1),n!=null&&(re.isFunction(n)?e.paramsSerializer={serialize:n}:yl.assertOptions(n,{encode:ui.function,serialize:ui.function},!0)),e.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?e.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:e.allowAbsoluteUrls=!0),yl.assertOptions(e,{baseUrl:ui.spelling("baseURL"),withXsrfToken:ui.spelling("withXSRFToken")},!0),e.method=(e.method||this.defaults.method||"get").toLowerCase();let r=i&&re.merge(i.common,i[e.method]);i&&re.forEach(["delete","get","head","post","put","patch","common"],u=>{delete i[u]}),e.headers=wn.concat(r,i);const a=[];let o=!0;this.interceptors.request.forEach(function(u){typeof u.runWhen=="function"&&u.runWhen(e)===!1||(o=o&&u.synchronous,a.unshift(u.fulfilled,u.rejected))});const l=[];this.interceptors.response.forEach(function(u){l.push(u.fulfilled,u.rejected)});let c,h=0,d;if(!o){const u=[zm.bind(this),void 0];for(u.unshift(...a),u.push(...l),d=u.length,c=Promise.resolve(e);h<d;)c=c.then(u[h++],u[h++]);return c}d=a.length;let p=e;for(;h<d;){const u=a[h++],g=a[h++];try{p=u(p)}catch(f){g.call(this,f);break}}try{c=zm.call(this,p)}catch(u){return Promise.reject(u)}for(h=0,d=l.length;h<d;)c=c.then(l[h++],l[h++]);return c}getUri(s){s=Ls(this.defaults,s);const e=Am(s.baseURL,s.url,s.allowAbsoluteUrls);return bm(e,s.params,s.paramsSerializer)}};re.forEach(["delete","get","head","options"],function(s){Is.prototype[s]=function(e,t){return this.request(Ls(t||{},{method:s,url:e,data:(t||{}).data}))}}),re.forEach(["post","put","patch"],function(s){function e(t){return function(n,i,r){return this.request(Ls(r||{},{method:s,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:i}))}}Is.prototype[s]=e(),Is.prototype[s+"Form"]=e(!0)});let RM=class gg{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(i){t=i});const n=this;this.promise.then(i=>{if(!n._listeners)return;let r=n._listeners.length;for(;r-- >0;)n._listeners[r](i);n._listeners=null}),this.promise.then=i=>{let r;const a=new Promise(o=>{n.subscribe(o),r=o}).then(i);return a.cancel=function(){n.unsubscribe(r)},a},e(function(i,r,a){n.reason||(n.reason=new Br(i,r,a),t(n.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=n=>{e.abort(n)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new gg(function(t){e=t}),cancel:e}}};function LM(s){return function(e){return s.apply(null,e)}}function IM(s){return re.isObject(s)&&s.isAxiosError===!0}const _d={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(_d).forEach(([s,e])=>{_d[e]=s});function Vm(s){const e=new Is(s),t=sm(Is.prototype.request,e);return re.extend(t,Is.prototype,e,{allOwnKeys:!0}),re.extend(t,e,null,{allOwnKeys:!0}),t.create=function(n){return Vm(Ls(s,n))},t}const Dt=Vm(Ra);Dt.Axios=Is,Dt.CanceledError=Br,Dt.CancelToken=RM,Dt.isCancel=Sm,Dt.VERSION=Fm,Dt.toFormData=ml,Dt.AxiosError=Ke,Dt.Cancel=Dt.CanceledError,Dt.all=function(s){return Promise.all(s)},Dt.spread=LM,Dt.isAxiosError=IM,Dt.mergeConfig=Ls,Dt.AxiosHeaders=wn,Dt.formToJSON=s=>Mm(re.isHTMLForm(s)?new FormData(s):s),Dt.getAdapter=Om.getAdapter,Dt.HttpStatusCode=_d,Dt.default=Dt;const{Axios:t4,AxiosError:n4,CanceledError:i4,isCancel:s4,CancelToken:r4,VERSION:a4,all:o4,Cancel:l4,isAxiosError:c4,spread:h4,toFormData:d4,AxiosHeaders:u4,HttpStatusCode:p4,formToJSON:f4,getAdapter:m4,mergeConfig:g4}=Dt;function Gm(s,e){var t;if(window.XMLHttpRequest?t=new XMLHttpRequest:window.ActiveXObject?t=new window.ActiveXObject:alert("请升级至最新版本的浏览器"),t!=null){let n=s;t.open("GET",n,!0),t.send(null),t.onreadystatechange=function(){t.readyState==4&&t.status==200&&(t.responseText.includes("</html>",0)&&t.responseText.includes("</body>",0)&&t.responseText.includes("</head>",0)?e(null):e(t.responseText))},t.onloadend=function(){t.readyState==4&&t.status==404&&t.status==502&&e(null)}}}function DM(s,e){Dt({method:"get",responseType:"blob",url:s}).then(t=>{let n=new window.File([t.data],"zipFolder",{type:"zip"});im.loadAsync(n).then(i=>{const r=new Map,a=[];for(let o in i.files){if(i.files[o].dir)continue;const l=i.file(i.files[o].name);if(l){const c=l.async("blob").then(h=>{const d=URL.createObjectURL(h);r.set("/"+i.files[o].name.replace("\\","/"),d)});a.push(c)}}Promise.all(a).then(()=>{e(r)}).catch(o=>{console.error("解压zip文件失败:",o),e(new Map)})}).catch(i=>{console.error("加载zip文件失败:",i),e(new Map)})}).catch(t=>{console.error("下载zip文件失败:",t),e(new Map)})}function Wm(s,e){Dt({method:"get",responseType:"blob",url:s}).then(n=>{let i=new window.File([n.data],"semantics",{type:"zip"});im.loadAsync(i).then(r=>{for(let a in r.files)r.file(r.files[a].name).async("blob").then(o=>{t(o,"utf-8",function(l,c){e(c)})})})});function t(n,i,r){var a=new FileReader,o=new Blob([n]);a.onload=function(l){r(null,l.target.result)},a.onerror=function(l){r(l.error,null)},a.readAsText(o,i)}}const Md=new WeakMap;class NM extends Ji{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,n,i){const r=new Ma(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,i)},n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,Rt,n).catch(n)}decodeDracoFile(e,t,n,i,r=en,a=()=>{}){const o={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(e,o).then(t).catch(a)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Md.has(e)){const l=Md.get(e);if(l.key===n)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 i;const r=this.workerNextTaskID++,a=e.byteLength,o=this._getWorker(r,a).then(l=>(i=l,new Promise((c,h)=>{i._callbacks[r]={resolve:c,reject:h},i.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return o.catch(()=>!0).then(()=>{i&&r&&this._releaseTask(i,r)}),Md.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new pt;e.index&&t.setIndex(new bt(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:i,array:r,itemSize:a,stride:o,vertexColorSpace:l}=e.attributes[n];let c;if(a===o)c=new bt(r,a);else{const h=new wh(r,o);c=new mr(h,a,0)}i==="color"&&(this._assignVertexColorSpace(c,l),c.normalized=!(r instanceof Float32Array)),t.setAttribute(i,c)}return t}_assignVertexColorSpace(e,t){if(t!==Rt)return;const n=new Fe;for(let i=0,r=e.count;i<r;i++)n.fromBufferAttribute(e,i),it.colorSpaceToWorking(n,Rt),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new Ma(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,r)=>{n.load(e,i,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(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const r=BM.toString(),a=["/* draco decoder */",i,"","/* 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 i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(r){const a=r.data;switch(a.type){case"decode":i._callbacks[a.id].resolve(a);break;case"error":i._callbacks[a.id].reject(a);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+a.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,r){return i._taskLoad>r._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_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 BM(){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,p=new d.Decoder;try{const u=t(d,p,new Int8Array(l),c),g=u.attributes.map(f=>f.array.buffer);u.index&&g.push(u.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:u},g)}catch(u){console.error(u),self.postMessage({type:"error",id:o.id,error:u.message})}finally{d.destroy(p)}});break}};function t(a,o,l,c){const h=c.attributeIDs,d=c.attributeTypes;let p,u;const g=o.GetEncodedGeometryType(l);if(g===a.TRIANGULAR_MESH)p=new a.Mesh,u=o.DecodeArrayToMesh(l,l.byteLength,p);else if(g===a.POINT_CLOUD)p=new a.PointCloud,u=o.DecodeArrayToPointCloud(l,l.byteLength,p);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!u.ok()||p.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+u.error_msg());const f={index:null,attributes:[]};for(const x in h){const m=self[d[x]];let b,v;if(c.useUniqueIDs)v=h[x],b=o.GetAttributeByUniqueId(p,v);else{if(v=o.GetAttributeId(p,a[h[x]]),v===-1)continue;b=o.GetAttribute(p,v)}const y=i(a,o,p,x,m,b);x==="color"&&(y.vertexColorSpace=c.vertexColorSpace),f.attributes.push(y)}return g===a.TRIANGULAR_MESH&&(f.index=n(a,o,p)),a.destroy(p),f}function n(a,o,l){const c=l.num_faces()*3,h=c*4,d=a._malloc(h);o.GetTrianglesUInt32Array(l,h,d);const p=new Uint32Array(a.HEAPF32.buffer,d,c).slice();return a._free(d),{array:p,itemSize:1}}function i(a,o,l,c,h,d){const p=l.num_points(),u=d.num_components(),g=r(a,h),f=u*h.BYTES_PER_ELEMENT,x=Math.ceil(f/4)*4,m=x/h.BYTES_PER_ELEMENT,b=p*f,v=p*x,y=a._malloc(b);o.GetAttributeDataArrayForAllPoints(l,d,g,b,y);const _=new h(a.HEAPF32.buffer,y,b/h.BYTES_PER_ELEMENT);let M;if(f===x)M=_.slice();else{M=new h(v/h.BYTES_PER_ELEMENT);let T=0;for(let R=0,w=_.length;R<w;R++){for(let E=0;E<u;E++)M[T+E]=_[R*u+E];T+=m}}return a._free(y),{name:c,count:p,itemSize:u,array:M,stride:m}}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 ts=(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))(ts||{});function kM(s,e,t,n){let i=0,r=0,a=0,o=s.models.find(u=>u.url==t),l=e.circularMeps,c=e.rectMeps.filter(u=>u.type==="风管"),h=e.rectMeps.filter(u=>u.type==="桥架"),d=e.ellipseMeps,p=s.scene;if(new Ht,new pt,l&&l.length){let u=[],g=0;for(let f of l)f.color=f.color.split(",").map(x=>parseInt(x)/255),f.color=new Fe(f.color[0],f.color[1],f.color[2]),f.position={x:f.startPoint.X*.3048+i,y:f.startPoint.Z*.3048+r,z:-f.startPoint.Y*.3048+a},f.rotation={x:0,y:0,z:0},f.indexes=[[s.scene.children.length,g++,0,0]],o.nodesMap.set(Number(f.id),f),u.push(f);_l("Circle",p,u,t)}if(c&&c.length){let u=[],g=0;for(let f of c)f.color=f.color.split(",").map(x=>parseInt(x)/255),f.color=new Fe(f.color[0],f.color[1],f.color[2]),f.position={x:f.startPoint.X*.3048+i,y:f.startPoint.Z*.3048+r,z:-f.startPoint.Y*.3048+a},f.rotation={x:0,y:0,z:0},f.indexes=[[s.scene.children.length,g++,0,0]],o.nodesMap.set(Number(f.id),f),u.push(f);_l("Rect",p,u,t)}if(d&&d.length){let u=[],g=0;for(let f of d)f.color=f.color.split(",").map(x=>parseInt(x)/255),f.color=new Fe(f.color[0],f.color[1],f.color[2]),f.position={x:f.startPoint.X*.3048+i,y:f.startPoint.Z*.3048+r,z:-f.startPoint.Y*.3048+a},f.rotation={x:0,y:0,z:0},f.indexes=[[s.scene.children.length,g++,0,0]],o.nodesMap.set(Number(f.id),f),u.push(f);_l("Ellipse",p,u,t)}if(h&&h.length){let u=[],g=0;for(let f of h)f.color=f.color.split(",").map(x=>parseInt(x)/255),f.color=new Fe(f.color[0],f.color[1],f.color[2]),f.position={x:f.startPoint.X*.3048+i,y:f.startPoint.Z*.3048+r,z:-f.startPoint.Y*.3048+a},f.rotation={x:0,y:0,z:0},f.indexes=[[s.scene.children.length,g++,0,0]],o.nodesMap.set(Number(f.id),f),u.push(f);_l("Bridge",p,u,t)}}function _l(s,e,t,n,i){let r,a,o={width:1,height:1,length:1,diameter:1,color:new Fe,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(s){case"Rect":a=Ml("Rect",o);break;case"Bridge":a=Ml("Bridge",o);break;case"Circle":a=Ml("Circle",o);break;case"Ellipse":a=Ml("Ellipse",o);break}a&&(r=new Ut(a.geometry,a.material,t.length),r.url=n,e.add(r));let l=[],c=[];for(var h=0;h<t.length;h++){let u=t[h],g=new P(u.startPoint.X,0,-u.startPoint.Y),f=new P(u.endPoint.X,0,-u.endPoint.Y),x=new P(u.startPoint.X,u.startPoint.Z,-u.startPoint.Y),m=new P(u.endPoint.X,u.endPoint.Z,-u.endPoint.Y),b=0,v=0,y=0;if(Math.abs(f.clone().sub(g.clone()).z)<.01&&Math.abs(f.clone().sub(g.clone()).x)<.01){if(b=(u.startPoint.Z>u.endPoint.Z?1:-1)*Math.PI*.5,u.base_x!=null){var d=new P(u.base_x.X,0,-u.base_x.Y);v=(d.clone().cross(new P(0,0,1)).y<=0?1:-1)*d.angleTo(new P(0,0,1))+Math.PI*.5}}else v=(f.clone().sub(g.clone()).cross(new P(0,0,1)).y>0?-1:1)*f.clone().sub(g.clone()).angleTo(new P(0,0,1)),b=(u.startPoint.Z>u.endPoint.Z?1:-1)*f.clone().sub(g.clone()).angleTo(m.clone().sub(x.clone()));let _=new Ie;const M=new Rn(b,v,y,"YXZ");let T=_.clone().makeRotationFromEuler(M),R,w;s==="Circle"?(R=u.diameter,w=u.diameter):(R=u.width,w=u.height);let E=_.clone().makeScale(R,w,u.length);_.multiplyMatrices(T,E),_.setPosition(u.position.x,u.position.y,u.position.z),r.setMatrixAt(h,_.clone()),r.setColorAt(h,u.color),r.geometry.computeBoundingBox();let I=r.geometry.boundingBox.min.clone().applyMatrix4(_.clone()),A=r.geometry.boundingBox.max.clone().applyMatrix4(_.clone()),B=new P(Math.min(I.x,A.x),Math.min(I.y,A.y),Math.min(I.z,A.z)),S=new P(Math.max(I.x,A.x),Math.max(I.y,A.y),Math.max(I.z,A.z)),U=B.clone().add(S.clone()).multiplyScalar(.5),H={name:u.name,min:B,max:S,center:U,dbid:h,materialName:a.material.name},G=null,Z=null;s==="Circle"&&(G={x:u.startPoint.X*.3048,y:u.startPoint.Z*.3048,z:-u.startPoint.Y*.3048},Z={x:u.endPoint.X*.3048,y:u.endPoint.Z*.3048,z:-u.endPoint.Y*.3048},H.minC=G,H.maxC=Z),r.ids||(r.ids=[]),r.matrixs||(r.matrixs=[]),r.matrixs.push(_.clone()),c.push(_.clone()),r.ids.push(Number(u.id)),l.push(H)}r.castShadow=!0,r.ElementInfos=l,r.name="rootModel",r.TypeName="InstancedMesh-Pipe",r.PipeType=s,r.MeshId=null,r.realMaterial=r.material.clone(),r.originalMaterial=r.material.clone(),r.matrixsClone=c;let p=[];p={geometry:r.geometry,matrix:r.matrix,position:r.position,rotation:r.rotation},r.meshs=p,r.instanceMatrix&&r.instanceMatrix.array&&(r.cloneInstanceMatrix=Array.from(r.instanceMatrix.array))}function Ml(s,e,t){let n=new Qp;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,s){case"Rect":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Ellipse":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Bridge":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(-e.width/2+.01,e.height/2),n.lineTo(-e.width/2+.01,-e.height/2+.01),n.lineTo(e.width/2-.01,-e.height/2+.01),n.lineTo(e.width/2-.01,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Circle":n.moveTo(0,0),n.absarc(0,0,e.diameter*.5,0,Math.PI*2,!1);break}const i={depth:e.length*.3048,bevelEnabled:!1};return r(n,i,e.color,e.position,e.rotation);function r(a,o,l,c,h){let d=new Hh(a,o),p=new Ki({color:l,side:yt}),u=new at(d,p);return u.position.set(c.x,c.y,c.z),u.rotation._order="YXZ",u.rotation.set(h.x,h.y,h.z),u}}function Xm(s,e=!1){const t=s[0].index!==null,n=new Set(Object.keys(s[0].attributes)),i=new Set(Object.keys(s[0].morphAttributes)),r={},a={},o=s[0].morphTargetsRelative,l=new pt;let c=0;for(let h=0;h<s.length;++h){const d=s[h];let p=0;if(t!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const u in d.attributes){if(!n.has(u))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+u+'" attribute exists among all geometries, or in none of them.'),null;r[u]===void 0&&(r[u]=[]),r[u].push(d.attributes[u]),p++}if(p!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(o!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const u in d.morphAttributes){if(!i.has(u))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;a[u]===void 0&&(a[u]=[]),a[u].push(d.morphAttributes[u])}if(e){let u;if(t)u=d.index.count;else if(d.attributes.position!==void 0)u=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,u,h),c+=u}}if(t){let h=0;const d=[];for(let p=0;p<s.length;++p){const u=s[p].index;for(let g=0;g<u.count;++g)d.push(u.getX(g)+h);h+=s[p].attributes.position.count}l.setIndex(d)}for(const h in r){const d=jm(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 p=0;p<d;++p){const u=[];for(let f=0;f<a[h].length;++f)u.push(a[h][f][p]);const g=jm(u);if(!g)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(g)}}return l}function jm(s){let e,t,n,i=-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(n===void 0&&(n=h.normalized),n!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=h.gpuType),i!==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 bt(a,t,n);let l=0;for(let c=0;c<s.length;++c){const h=s[c];if(h.isInterleavedBufferAttribute){const d=l/t;for(let p=0,u=h.count;p<u;p++)for(let g=0;g<t;g++){const f=h.getComponent(p,g);o.setComponent(p+d,g,f)}}else a.set(h.array,l);l+=h.count*t}return i!==void 0&&(o.gpuType=i),o}function qm(s,e){if(e===jg)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===Kc||e===qu){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 n=t.count-2,i=[];if(e===Kc)for(let a=1;a<=n;a++)i.push(t.getX(0)),i.push(t.getX(a)),i.push(t.getX(a+1));else for(let a=0;a<n;a++)a%2===0?(i.push(t.getX(a)),i.push(t.getX(a+1)),i.push(t.getX(a+2))):(i.push(t.getX(a+2)),i.push(t.getX(a+1)),i.push(t.getX(a)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=s.clone();return r.setIndex(i),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),s}class UM extends Ji{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new VM(t)}),this.register(function(t){return new GM(t)}),this.register(function(t){return new JM(t)}),this.register(function(t){return new QM(t)}),this.register(function(t){return new ew(t)}),this.register(function(t){return new XM(t)}),this.register(function(t){return new jM(t)}),this.register(function(t){return new qM(t)}),this.register(function(t){return new ZM(t)}),this.register(function(t){return new HM(t)}),this.register(function(t){return new YM(t)}),this.register(function(t){return new WM(t)}),this.register(function(t){return new KM(t)}),this.register(function(t){return new $M(t)}),this.register(function(t){return new zM(t)}),this.register(function(t){return new tw(t)}),this.register(function(t){return new nw(t)})}load(e,t,n,i){const r=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const c=Sa.extractUrlBase(e);a=Sa.resolveURL(c,this.path)}else a=Sa.extractUrlBase(e);this.manager.itemStart(e);const o=function(c){i?i(c):console.error(c),r.manager.itemError(e),r.manager.itemEnd(e)},l=new Ma(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)}},n,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,n,i){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))===Zm){try{a[nt.KHR_BINARY_GLTF]=new iw(e)}catch(h){i&&i(h);return}r=JSON.parse(a[nt.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new gw(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],p=r.extensionsRequired||[];switch(d){case nt.KHR_MATERIALS_UNLIT:a[d]=new FM;break;case nt.KHR_DRACO_MESH_COMPRESSION:a[d]=new sw(r,this.dracoLoader);break;case nt.KHR_TEXTURE_TRANSFORM:a[d]=new rw;break;case nt.KHR_MESH_QUANTIZATION:a[d]=new aw;break;default:p.indexOf(d)>=0&&o[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(a),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function OM(){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={}}}}const nt={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",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class zM{constructor(e){this.parser=e,this.name=nt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const r=t[n];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,n="light:"+e;let i=t.cache.get(n);if(i)return i;const r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let o;const l=new Fe(16777215);a.color!==void 0&&l.setRGB(a.color[0],a.color[1],a.color[2],en);const c=a.range!==void 0?a.range:0;switch(a.type){case"directional":o=new Pi(l),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new nv(l),o.distance=c;break;case"spot":o=new ev(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),pi(o,a),a.intensity!==void 0&&(o.intensity=a.intensity),o.name=t.createUniqueName(a.name||"light_"+e),i=Promise.resolve(o),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],r=(i.extensions&&i.extensions[this.name]||{}).light;return r===void 0?null:this._loadLight(r).then(function(a){return n._getNodeRef(t.cache,r,a)})}}class FM{constructor(){this.name=nt.KHR_MATERIALS_UNLIT}getMaterialType(){return Ht}extendParams(e,t,n){const i=[];e.color=new Fe(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],en),e.opacity=a[3]}r.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",r.baseColorTexture,Rt))}return Promise.all(i)}}class HM{constructor(e){this.parser=e,this.name=nt.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return i!==void 0&&(t.emissiveIntensity=i),Promise.resolve()}}class VM{constructor(e){this.parser=e,this.name=nt.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:hi}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];if(a.clearcoatFactor!==void 0&&(t.clearcoat=a.clearcoatFactor),a.clearcoatTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),a.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),a.clearcoatRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),a.clearcoatNormalTexture!==void 0&&(r.push(n.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),a.clearcoatNormalTexture.scale!==void 0)){const o=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new he(o,o)}return Promise.all(r)}}class GM{constructor(e){this.parser=e,this.name=nt.KHR_MATERIALS_DISPERSION}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:hi}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class WM{constructor(e){this.parser=e,this.name=nt.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:hi}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];return a.iridescenceFactor!==void 0&&(t.iridescence=a.iridescenceFactor),a.iridescenceTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceMap",a.iridescenceTexture)),a.iridescenceIor!==void 0&&(t.iridescenceIOR=a.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),a.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),a.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),a.iridescenceThicknessTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(r)}}class XM{constructor(e){this.parser=e,this.name=nt.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:hi}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new Fe(0,0,0),t.sheenRoughness=0,t.sheen=1;const a=i.extensions[this.name];if(a.sheenColorFactor!==void 0){const o=a.sheenColorFactor;t.sheenColor.setRGB(o[0],o[1],o[2],en)}return a.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=a.sheenRoughnessFactor),a.sheenColorTexture!==void 0&&r.push(n.assignTexture(t,"sheenColorMap",a.sheenColorTexture,Rt)),a.sheenRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(r)}}class jM{constructor(e){this.parser=e,this.name=nt.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:hi}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];return a.transmissionFactor!==void 0&&(t.transmission=a.transmissionFactor),a.transmissionTexture!==void 0&&r.push(n.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(r)}}class qM{constructor(e){this.parser=e,this.name=nt.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:hi}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];t.thickness=a.thicknessFactor!==void 0?a.thicknessFactor:0,a.thicknessTexture!==void 0&&r.push(n.assignTexture(t,"thicknessMap",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;const o=a.attenuationColor||[1,1,1];return t.attenuationColor=new Fe().setRGB(o[0],o[1],o[2],en),Promise.all(r)}}class ZM{constructor(e){this.parser=e,this.name=nt.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:hi}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class YM{constructor(e){this.parser=e,this.name=nt.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:hi}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];t.specularIntensity=a.specularFactor!==void 0?a.specularFactor:1,a.specularTexture!==void 0&&r.push(n.assignTexture(t,"specularIntensityMap",a.specularTexture));const o=a.specularColorFactor||[1,1,1];return t.specularColor=new Fe().setRGB(o[0],o[1],o[2],en),a.specularColorTexture!==void 0&&r.push(n.assignTexture(t,"specularColorMap",a.specularColorTexture,Rt)),Promise.all(r)}}class $M{constructor(e){this.parser=e,this.name=nt.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:hi}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];return t.bumpScale=a.bumpFactor!==void 0?a.bumpFactor:1,a.bumpTexture!==void 0&&r.push(n.assignTexture(t,"bumpMap",a.bumpTexture)),Promise.all(r)}}class KM{constructor(e){this.parser=e,this.name=nt.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:hi}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],a=i.extensions[this.name];return a.anisotropyStrength!==void 0&&(t.anisotropy=a.anisotropyStrength),a.anisotropyRotation!==void 0&&(t.anisotropyRotation=a.anisotropyRotation),a.anisotropyTexture!==void 0&&r.push(n.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(r)}}class JM{constructor(e){this.parser=e,this.name=nt.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.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 QM{constructor(e){this.parser=e,this.name=nt.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],o=i.images[a.source];let l=n.textureLoader;if(o.uri){const c=n.options.manager.getHandler(o.uri);c!==null&&(l=c)}return n.loadTextureImage(e,a.source,l)}}class ew{constructor(e){this.parser=e,this.name=nt.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],o=i.images[a.source];let l=n.textureLoader;if(o.uri){const c=n.options.manager.getHandler(o.uri);c!==null&&(l=c)}return n.loadTextureImage(e,a.source,l)}}class tw{constructor(e){this.name=nt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.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=i.byteOffset||0,c=i.byteLength||0,h=i.count,d=i.byteStride,p=new Uint8Array(o,l,c);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(h,d,p,i.mode,i.filter).then(function(u){return u.buffer}):a.ready.then(function(){const u=new ArrayBuffer(h*d);return a.decodeGltfBuffer(new Uint8Array(u),h,d,p,i.mode,i.filter),u})})}else return null}}class nw{constructor(e){this.name=nt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const l of i.primitives)if(l.mode!==Gn.TRIANGLES&&l.mode!==Gn.TRIANGLE_STRIP&&l.mode!==Gn.TRIANGLE_FAN&&l.mode!==void 0)return null;const r=n.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,p=[];for(const u of h){const g=new Ie,f=new P,x=new zn,m=new P(1,1,1),b=new Ut(u.geometry,u.material,d);for(let v=0;v<d;v++)o.TRANSLATION&&f.fromBufferAttribute(o.TRANSLATION,v),o.ROTATION&&x.fromBufferAttribute(o.ROTATION,v),o.SCALE&&m.fromBufferAttribute(o.SCALE,v),b.setMatrixAt(v,g.compose(f,x,m));for(const v in o)if(v==="_COLOR_0"){const y=o[v];b.instanceColor=new Lo(y.array,y.itemSize,y.normalized)}else v!=="TRANSLATION"&&v!=="ROTATION"&&v!=="SCALE"&&u.geometry.setAttribute(v,o[v]);Et.prototype.copy.call(b,u),this.parser.assignFinalMaterial(b),p.push(b)}return c.isGroup?(c.clear(),c.add(...p),c):p[0]}))}}const Zm="glTF",Ia=12,Ym={JSON:1313821514,BIN:5130562};class iw{constructor(e){this.name=nt.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Ia),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Zm)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-Ia,r=new DataView(e,Ia);let a=0;for(;a<i;){const o=r.getUint32(a,!0);a+=4;const l=r.getUint32(a,!0);if(a+=4,l===Ym.JSON){const c=new Uint8Array(e,Ia+a,o);this.content=n.decode(c)}else if(l===Ym.BIN){const c=Ia+a;this.body=e.slice(c,c+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class sw{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=nt.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},l={},c={};for(const h in a){const d=Sd[h]||h.toLowerCase();o[d]=a[h]}for(const h in e.attributes){const d=Sd[h]||h.toLowerCase();if(a[h]!==void 0){const p=n.accessors[e.attributes[h]],u=kr[p.componentType];c[d]=u.name,l[d]=p.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(d,p){i.decodeDracoFile(h,function(u){for(const g in u.attributes){const f=u.attributes[g],x=l[g];x!==void 0&&(f.normalized=x)}d(u)},o,c,en,p)})})}}class rw{constructor(){this.name=nt.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 aw{constructor(){this.name=nt.KHR_MESH_QUANTIZATION}}class $m extends _a{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let a=0;a!==i;a++)t[a]=n[r+a];return t}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=o*2,c=o*3,h=i-t,d=(n-t)/h,p=d*d,u=p*d,g=e*c,f=g-c,x=-2*u+3*p,m=u-p,b=1-x,v=m-p+d;for(let y=0;y!==o;y++){const _=a[f+y+o],M=a[f+y+l]*h,T=a[g+y+o],R=a[g+y]*h;r[y]=b*_+v*M+x*T+m*R}return r}}const ow=new zn;class lw extends $m{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return ow.fromArray(r).normalize().toArray(r),r}}const Gn={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},kr={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Km={9728:Xt,9729:Pt,9984:Uu,9985:Qa,9986:$r,9987:ai},Jm={33071:Un,33648:Ja,10497:Tn},wd={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Sd={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"},ns={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},cw={CUBICSPLINE:void 0,LINEAR:ea,STEP:Qr},Ed={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function hw(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new Ki({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:kn})),s.DefaultMaterial}function Ds(s,e,t){for(const n in t.extensions)s[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function pi(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 dw(s,e,t){let n=!1,i=!1,r=!1;for(let c=0,h=e.length;c<h;c++){const d=e[c];if(d.POSITION!==void 0&&(n=!0),d.NORMAL!==void 0&&(i=!0),d.COLOR_0!==void 0&&(r=!0),n&&i&&r)break}if(!n&&!i&&!r)return Promise.resolve(s);const a=[],o=[],l=[];for(let c=0,h=e.length;c<h;c++){const d=e[c];if(n){const p=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):s.attributes.position;a.push(p)}if(i){const p=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):s.attributes.normal;o.push(p)}if(r){const p=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):s.attributes.color;l.push(p)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then(function(c){const h=c[0],d=c[1],p=c[2];return n&&(s.morphAttributes.position=h),i&&(s.morphAttributes.normal=d),r&&(s.morphAttributes.color=p),s.morphTargetsRelative=!0,s})}function uw(s,e){if(s.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;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 n=0,i=t.length;n<i;n++)s.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function pw(s){let e;const t=s.extensions&&s.extensions[nt.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Cd(t.attributes):e=s.indices+":"+Cd(s.attributes)+":"+s.mode,s.targets!==void 0)for(let n=0,i=s.targets.length;n<i;n++)e+=":"+Cd(s.targets[n]);return e}function Cd(s){let e="";const t=Object.keys(s).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+s[t[n]]+";";return e}function Td(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 fw(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 mw=new Ie;class gw{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new OM,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 n=!1,i=-1,r=!1,a=-1;if(typeof navigator<"u"){const o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;const l=o.match(/Version\/(\d+)/);i=n&&l?parseInt(l[1],10):-1,r=o.indexOf("Firefox")>-1,a=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||r&&a<98?this.textureLoader=new Gh(this.options.manager):this.textureLoader=new sv(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ma(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 n=this,i=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([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(a){const o={scene:a[0][i.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:i.asset,parser:n,userData:{}};return Ds(r,o,i),pi(o,i),Promise.all(n._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||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){const a=t[i].joints;for(let o=0,l=a.length;o<l;o++)e[a[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){const a=e[i];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(n[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,n){if(e.refs[t]<=1)return n;const i=n.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(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const r=e(t[i]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,a){return n.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=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[nt.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(r,a){n.load(Sa.resolveURL(t.uri,i.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(n){const i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const a=wd[i.type],o=kr[i.componentType],l=i.normalized===!0,c=new o(i.count*a);return Promise.resolve(new bt(c,a,l))}const r=[];return i.bufferView!==void 0?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),i.sparse!==void 0&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then(function(a){const o=a[0],l=wd[i.type],c=kr[i.componentType],h=c.BYTES_PER_ELEMENT,d=h*l,p=i.byteOffset||0,u=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,g=i.normalized===!0;let f,x;if(u&&u!==d){const m=Math.floor(p/u),b="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+m+":"+i.count;let v=t.cache.get(b);v||(f=new c(o,m*u,i.count*u/h),v=new wh(f,u/h),t.cache.add(b,v)),x=new mr(v,l,p%u/h,g)}else o===null?f=new c(i.count*l):f=new c(o,p,i.count*l),x=new bt(f,l,g);if(i.sparse!==void 0){const m=wd.SCALAR,b=kr[i.sparse.indices.componentType],v=i.sparse.indices.byteOffset||0,y=i.sparse.values.byteOffset||0,_=new b(a[1],v,i.sparse.count*m),M=new c(a[2],y,i.sparse.count*l);o!==null&&(x=new bt(x.array.slice(),x.itemSize,x.normalized)),x.normalized=!1;for(let T=0,R=_.length;T<R;T++){const w=_[T];if(x.setX(w,M[T*l]),l>=2&&x.setY(w,M[T*l+1]),l>=3&&x.setZ(w,M[T*l+2]),l>=4&&x.setW(w,M[T*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}x.normalized=g}return x})}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i];let a=this.textureLoader;if(r.uri){const o=n.manager.getHandler(r.uri);o!==null&&(a=o)}return this.loadTextureImage(e,i,a)}loadTextureImage(e,t,n){const i=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,n).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=Km[d.magFilter]||Pt,h.minFilter=Km[d.minFilter]||ai,h.wrapS=Jm[d.wrapS]||Tn,h.wrapT=Jm[d.wrapT]||Tn,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==Xt&&h.minFilter!==Pt,i.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const a=i.images[e],o=self.URL||self.webkitURL;let l=a.uri||"",c=!1;if(a.bufferView!==void 0)l=n.getDependency("bufferView",a.bufferView).then(function(d){c=!0;const p=new Blob([d],{type:a.mimeType});return l=o.createObjectURL(p),l});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(l).then(function(d){return new Promise(function(p,u){let g=p;t.isImageBitmapLoader===!0&&(g=function(f){const x=new Ft(f);x.needsUpdate=!0,p(x)}),t.load(Sa.resolveURL(d,r.path),g,void 0,u)})}).then(function(d){return c===!0&&o.revokeObjectURL(l),pi(d,a),d.userData.mimeType=a.mimeType||fw(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,n,i){const r=this;return this.getDependency("texture",n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),r.extensions[nt.KHR_TEXTURE_TRANSFORM]){const o=n.extensions!==void 0?n.extensions[nt.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const l=r.associations.get(a);a=r.extensions[nt.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),r.associations.set(a,l)}}return i!==void 0&&(a.colorSpace=i),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+n.uuid;let l=this.cache.get(o);l||(l=new Vp,Ln.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(o,l)),n=l}else if(e.isLine){const o="LineBasicMaterial:"+n.uuid;let l=this.cache.get(o);l||(l=new Ms,Ln.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(o,l)),n=l}if(i||r||a){let o="ClonedMaterial:"+n.uuid+":";i&&(o+="derivative-tangents:"),r&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let l=this.cache.get(o);l||(l=n.clone(),r&&(l.vertexColors=!0),a&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(o,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return Ki}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let a;const o={},l=r.extensions||{},c=[];if(l[nt.KHR_MATERIALS_UNLIT]){const d=i[nt.KHR_MATERIALS_UNLIT];a=d.getMaterialType(),c.push(d.extendParams(o,r,t))}else{const d=r.pbrMetallicRoughness||{};if(o.color=new Fe(1,1,1),o.opacity=1,Array.isArray(d.baseColorFactor)){const p=d.baseColorFactor;o.color.setRGB(p[0],p[1],p[2],en),o.opacity=p[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(o,"map",d.baseColorTexture,Rt)),o.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,o.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,"metalnessMap",d.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",d.metallicRoughnessTexture))),a=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,o)})))}r.doubleSided===!0&&(o.side=yt);const h=r.alphaMode||Ed.OPAQUE;if(h===Ed.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===Ed.MASK&&(o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&a!==Ht&&(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new he(1,1),r.normalTexture.scale!==void 0)){const d=r.normalTexture.scale;o.normalScale.set(d,d)}if(r.occlusionTexture!==void 0&&a!==Ht&&(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&a!==Ht){const d=r.emissiveFactor;o.emissive=new Fe().setRGB(d[0],d[1],d[2],en)}return r.emissiveTexture!==void 0&&a!==Ht&&c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,Rt)),Promise.all(c).then(function(){const d=new a(o);return r.name&&(d.name=r.name),pi(d,r),t.associations.set(d,{materials:e}),r.extensions&&Ds(i,d,r),d})}createUniqueName(e){const t=dt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[nt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(l){return Qm(l,o,t)})}const a=[];for(let o=0,l=e.length;o<l;o++){const c=e[o],h=pw(c),d=i[h];if(d)a.push(d.promise);else{let p;c.extensions&&c.extensions[nt.KHR_DRACO_MESH_COMPRESSION]?p=r(c):p=Qm(new pt,c,t),i[h]={primitive:c,promise:p},a.push(p)}}return Promise.all(a)}loadMesh(e){const t=this,n=this.json,i=this.extensions,r=n.meshes[e],a=r.primitives,o=[];for(let l=0,c=a.length;l<c;l++){const h=a[l].material===void 0?hw(this.cache):this.getDependency("material",a[l].material);o.push(h)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(l){const c=l.slice(0,l.length-1),h=l[l.length-1],d=[];for(let u=0,g=h.length;u<g;u++){const f=h[u],x=a[u];let m;const b=c[u];if(x.mode===Gn.TRIANGLES||x.mode===Gn.TRIANGLE_STRIP||x.mode===Gn.TRIANGLE_FAN||x.mode===void 0)m=r.isSkinnedMesh===!0?new Zx(f,b):new at(f,b),m.isSkinnedMesh===!0&&m.normalizeSkinWeights(),x.mode===Gn.TRIANGLE_STRIP?m.geometry=qm(m.geometry,qu):x.mode===Gn.TRIANGLE_FAN&&(m.geometry=qm(m.geometry,Kc));else if(x.mode===Gn.LINES)m=new Hp(f,b);else if(x.mode===Gn.LINE_STRIP)m=new $i(f,b);else if(x.mode===Gn.LINE_LOOP)m=new e1(f,b);else if(x.mode===Gn.POINTS)m=new Wp(f,b);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+x.mode);Object.keys(m.geometry.morphAttributes).length>0&&uw(m,r),m.name=t.createUniqueName(r.name||"mesh_"+e),pi(m,r),x.extensions&&Ds(i,m,x),t.assignFinalMaterial(m),d.push(m)}for(let u=0,g=d.length;u<g;u++)t.associations.set(d[u],{meshes:e,primitives:u});if(d.length===1)return r.extensions&&Ds(i,d[0],r),d[0];const p=new ln;r.extensions&&Ds(i,p,r),t.associations.set(p,{meshes:e});for(let u=0,g=d.length;u<g;u++)p.add(d[u]);return p})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new on(zt.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new Ai(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),pi(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const r=i.pop(),a=i,o=[],l=[];for(let c=0,h=a.length;c<h;c++){const d=a[c];if(d){o.push(d);const p=new Ie;r!==null&&p.fromArray(r.array,c*16),l.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Ah(o,l)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,a=[],o=[],l=[],c=[],h=[];for(let d=0,p=i.channels.length;d<p;d++){const u=i.channels[d],g=i.samplers[u.sampler],f=u.target,x=f.node,m=i.parameters!==void 0?i.parameters[g.input]:g.input,b=i.parameters!==void 0?i.parameters[g.output]:g.output;f.node!==void 0&&(a.push(this.getDependency("node",x)),o.push(this.getDependency("accessor",m)),l.push(this.getDependency("accessor",b)),c.push(g),h.push(f))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(c),Promise.all(h)]).then(function(d){const p=d[0],u=d[1],g=d[2],f=d[3],x=d[4],m=[];for(let v=0,y=p.length;v<y;v++){const _=p[v],M=u[v],T=g[v],R=f[v],w=x[v];if(_===void 0)continue;_.updateMatrix&&_.updateMatrix();const E=n._createAnimationTracks(_,M,T,R,w);if(E)for(let I=0;I<E.length;I++)m.push(E[I])}const b=new X1(r,void 0,m);return pi(b,i),b})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(r){const a=n._getNodeRef(n.meshCache,i.mesh,r);return i.weights!==void 0&&a.traverse(function(o){if(o.isMesh)for(let l=0,c=i.weights.length;l<c;l++)o.morphTargetInfluences[l]=i.weights[l]}),a})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),a=[],o=i.children||[];for(let c=0,h=o.length;c<h;c++)a.push(n.getDependency("node",o[c]));const l=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(a),l]).then(function(c){const h=c[0],d=c[1],p=c[2];p!==null&&h.traverse(function(u){u.isSkinnedMesh&&u.bind(p,mw)});for(let u=0,g=d.length;u<g;u++)h.add(d[u]);return h})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],a=r.name?i.createUniqueName(r.name):"",o=[],l=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&o.push(l),r.camera!==void 0&&o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)})),i._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 Dp:c.length>1?h=new ln:c.length===1?h=c[0]:h=new Et,h!==c[0])for(let d=0,p=c.length;d<p;d++)h.add(c[d]);if(r.name&&(h.userData.name=r.name,h.name=a),pi(h,r),r.extensions&&Ds(n,h,r),r.matrix!==void 0){const d=new Ie;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(!i.associations.has(h))i.associations.set(h,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){const d=i.associations.get(h);i.associations.set(h,{...d})}return i.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,r=new ln;n.name&&(r.name=i.createUniqueName(n.name)),pi(r,n),n.extensions&&Ds(t,r,n);const a=n.nodes||[],o=[];for(let l=0,c=a.length;l<c;l++)o.push(i.getDependency("node",a[l]));return Promise.all(o).then(function(l){for(let h=0,d=l.length;h<d;h++)r.add(l[h]);const c=h=>{const d=new Map;for(const[p,u]of i.associations)(p instanceof Ln||p instanceof Ft)&&d.set(p,u);return h.traverse(p=>{const u=i.associations.get(p);u!=null&&d.set(p,u)}),d};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){const a=[],o=e.name?e.name:e.uuid,l=[];ns[r.path]===ns.weights?e.traverse(function(p){p.morphTargetInfluences&&l.push(p.name?p.name:p.uuid)}):l.push(o);let c;switch(ns[r.path]){case ns.weights:c=Sr;break;case ns.rotation:c=Er;break;case ns.translation:case ns.scale:c=Tr;break;default:switch(n.itemSize){case 1:c=Sr;break;case 2:case 3:default:c=Tr;break}break}const h=i.interpolation!==void 0?cw[i.interpolation]:ea,d=this._getArrayFromAccessor(n);for(let p=0,u=l.length;p<u;p++){const g=new c(l[p]+"."+ns[r.path],t.array,d,h);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),a.push(g)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Td(t.constructor),i=new Float32Array(t.length);for(let r=0,a=t.length;r<a;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(t){const n=this instanceof Er?lw:$m;return new n(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function xw(s,e,t){const n=e.attributes,i=new ut;if(n.POSITION!==void 0){const o=t.json.accessors[n.POSITION],l=o.min,c=o.max;if(l!==void 0&&c!==void 0){if(i.set(new P(l[0],l[1],l[2]),new P(c[0],c[1],c[2])),o.normalized){const h=Td(kr[o.componentType]);i.min.multiplyScalar(h),i.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 p=t.json.accessors[d.POSITION],u=p.min,g=p.max;if(u!==void 0&&g!==void 0){if(l.setX(Math.max(Math.abs(u[0]),Math.abs(g[0]))),l.setY(Math.max(Math.abs(u[1]),Math.abs(g[1]))),l.setZ(Math.max(Math.abs(u[2]),Math.abs(g[2]))),p.normalized){const f=Td(kr[p.componentType]);l.multiplyScalar(f)}o.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(o)}s.boundingBox=i;const a=new li;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,s.boundingSphere=a}function Qm(s,e,t){const n=e.attributes,i=[];function r(a,o){return t.getDependency("accessor",a).then(function(l){s.setAttribute(o,l)})}for(const a in n){const o=Sd[a]||a.toLowerCase();o in s.attributes||i.push(r(n[a],o))}if(e.indices!==void 0&&!s.index){const a=t.getDependency("accessor",e.indices).then(function(o){s.setIndex(o)});i.push(a)}return it.workingColorSpace!==en&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${it.workingColorSpace}" not supported.`),pi(s,e),xw(s,e,t),Promise.all(i).then(function(){return e.targets!==void 0?dw(s,e.targets,t):s})}function vw(s,e,t){let n=new ln;n.name=e,s.scene.add(n),Wm(e+"/info",i=>{let r=JSON.parse(i);s.engineStatus.models.push({type:"light",info:r,name:r.baseInfo.name,status:"loading",url:e,elements:new Map}),s.models==null&&(s.models=[]),s.models.push({url:e,nodesMap:new Map,boundingBox:{min:new P(r.baseInfo.min.X*.3048,r.baseInfo.min.Z*.3048,-r.baseInfo.min.Y*.3048),max:new P(r.baseInfo.max.X*.3048,r.baseInfo.max.Z*.3048,-r.baseInfo.max.Y*.3048)}}),s.events.trigger(ts.EngineFree,e)})}function bw(s,e){s.engineStatus.models.filter(t=>e==null||t.url==e).forEach(t=>{t.loadStatus==null&&(t.loadStatus={mep:!1,instance:!1,normal:!1}),t.status==="loading"&&t.type==="light"&&(t.loadStatus.modelMep!=!0&&(t.loadStatus.modelMep=!0,kM(s,t.info.modelMep,t.url)),t.loadStatus.normal!=!0&&yw(s,t))})}function yw(s,e){if(s.camera.position,e.size,e.info==null||e.info.lods==null)return;e.info.lods.forEach(n=>{if(n.status!=!0)if(n.glbs==null)console.log("加载GLB............."),n.glbs={},DM(e.url+n.path,i=>{Gm(i.get("/nodes.json"),r=>{let a=JSON.parse(r);s.models.find(c=>c.url==e.url).nodesMap==null&&(s.models.find(c=>c.url==e.url).nodesMap=new Map);let o=s.models.find(c=>c.url==e.url).nodesMap,l=0;for(let c in a){a[c].forEach(p=>{p.glb=c,o.has(p.id)==!1?o.set(p.id,{infos:[p]}):o.get(p.id).infos.push(p)});let h=new UM;const d=new NM;d.setDecoderPath("/draco/"),d.preload(),h.setDRACOLoader(d),h.load(i.get(c+".glb"),p=>{n.glbs[c]=p.scene.children,n.glbs[c].forEach(u=>{u.geometry.computeVertexNormals()}),l++,l==Object.keys(a).length&&s.engineStatus.isFree&&(s.events.trigger(ts.EngineFree,e.url),s.viewCube.CameraGoHome())})}Gm(i.get("/instances.json"),c=>{let h=JSON.parse(c);s.models.find(d=>d.url==e.url).instanceNodes=h})})});else{let i=t(e,n,n.octreeBox),r=[],a=s.models.find(l=>l.url==e.url);i.forEach(l=>{a.nodesMap.has(l)&&a.nodesMap.get(l).infos.forEach(c=>{let h=n.glbs[c.glb][c.mesh];if(h!=null&&h.geometry!=null&&h.material!=null){let d=new Ie;d.elements=c.matrix;let p=new at(h.geometry.clone().applyMatrix4(d),h.material),u=new ut().setFromObject(p);c.box=u,c.mesh=p,p.name=l,p.glb=c.glb,p.url=e.url,h.geometry.attributes.position!=null&&r.push(p)}})}),_w(e.url,s,r);let o=a.instanceNodes;if(o!=null)for(let l in o)(o[l].isLoaded==null||o[l].isLoaded==!1)&&(o[l].isLoaded=!0,o[l].forEach(c=>{if(n.glbs[l]!=null){let h=n.glbs[l][c.mesh];Mw(e.url,c.mesh,s,h,c.children)}}))}});function t(n,i,r){let a=[];if(r.status!=!0){if(!s.engineStatus.isFree)return a;let o=new P(r.min.X,r.min.Z,-r.min.Y),l=new P(r.max.X,r.max.Z,-r.max.Y);l.distanceTo(o);let c=s.camera.position,h=new P(o.x+l.x/2,o.y+l.y/2,o.z+l.z/2);c.distanceTo(h),r.elements.forEach(d=>{a.push(d)}),r.children.forEach(d=>{a.push(...t(n,i,d))}),r.children.findIndex(d=>d.status!=!0)==-1&&(r.status=!0),r.children.length==0&&(r.status=!0)}return a}}function _w(s,e,t){let n=[];t.forEach(i=>{n.findIndex(a=>a.glb==i.glb)==-1?n.push({glb:i.glb,meshes:[i],currentIndex:i.geometry.index.count,indexes:new Map}):(n.find(a=>a.glb==i.glb).meshes.push(i),n.find(a=>a.glb==i.glb).currentIndex+=i.geometry.index.count);let r=n.find(a=>a.glb==i.glb);r.indexes.set(Number(i.name),[r.currentIndex-i.geometry.index.count,r.currentIndex])}),n.forEach(i=>{let r=e.scene.children.find(a=>a instanceof at&&a.url==s&&a.glb==i.glb);if(r!=null)r.castShadow=!0,r.receiveShadow=!0;else{let a=new pt,o=ww(i.meshes[0].material);a=Xm(i.meshes.map(h=>h.geometry),!1);let l=new at(a,o);l.castShadow=!0,l.receiveShadow=!0,e.scene.add(l),l.index=e.scene.children.length-1,l.url=s,l.glb=i.glb,l.indexes=i.indexes,l.materialClone=o,l.geometrys=i.meshes.map(h=>h.geometry);let c=e.models.find(h=>h.url==s);if(c!=null){let h=0;i.indexes.forEach(d=>{c.nodesMap.get(Number(i.meshes[h].name)).indexes==null&&(c.nodesMap.get(Number(i.meshes[h].name)).indexes=[]),c.nodesMap.get(Number(i.meshes[h].name)).indexes.push([l.index,h++,d[0],d[1]])})}}})}function Mw(s,e,t,n,i){if(n==null)return;let r=new Ut(n.geometry,n.material,i.length);t.scene.add(r);const a=new Float32Array(i.length*3);for(let l=0;l<i.length;l++)a[l*3]=1,a[l*3+1]=1,a[l*3+2]=1;r.instanceColor=new Lo(a,3);let o=[];for(let l=0;l<i.length;l++){let c=i[l],h=new Ie;h.elements=c.matrix,r.setMatrixAt(l,h),r.matrixs||(r.matrixs=[]),r.matrixs.push(h.clone()),o.push(h.clone()),t.models.find(d=>d.url==s).nodesMap.has(c.id)?(t.models.find(d=>d.url==s).nodesMap.get(c.id).indexes==null&&(t.models.find(d=>d.url==s).nodesMap.get(c.id).indexes=[]),t.models.find(d=>d.url==s).nodesMap.get(c.id).indexes.push([t.scene.children.length-1,l,0,0])):t.models.find(d=>d.url==s).nodesMap.set(c.id,{instance:!0,info:c,indexes:[[t.scene.children.length-1,l,0,0]]})}r.index=t.scene.children.length-1,r.materialClone=n.material,r.url=s,r.glb=n.glb,r.ids=i.map(l=>l.id),r.matrixsClone=o}function ww(s){return s.map!=null&&(s.map.colorSpace=Rt,s.map.needsUpdate=!0),s.shadowSide=kn,s.side=s.side,s}class Sw{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const i of e)n(i)==="light"&&vw(this.engine,i);function n(i){const r=i.split(".").pop();return r==="glb"||r==="gltf"?"gltf":"light"}}}class Ew{engine;isFree;highlightModels;hideModels;translucentModels;models;constructor(e){this.engine=e,this.isFree=!0,this.highlightModels=[],this.hideModels=[],this.translucentModels=[],this.models=[]}init(){this.engine.events.on(ts.EngineFree,e=>{this.updateFree(!0),bw(this.engine,e)}),this.engine.events.on(ts.EngineBusy,()=>{this.updateFree(!1)})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}class Cw{listeners=new Map;debugMode=!1;setDebugMode(e){this.debugMode=e}on(e,t){const n=String(e);this.listeners.has(n)||this.listeners.set(n,[]),this.listeners.get(n).push(t),this.debugMode&&console.debug(`[EventModule] 注册事件监听器: ${n}, 当前监听器数量: ${this.listeners.get(n).length}`)}off(e,t){const n=String(e);if(!this.listeners.has(n)){this.debugMode&&console.warn(`[EventModule] 尝试移除不存在的事件监听器: ${n}`);return}const i=this.listeners.get(n),r=i.indexOf(t);r!==-1?(i.splice(r,1),this.debugMode&&console.debug(`[EventModule] 移除事件监听器: ${n}, 剩余监听器数量: ${i.length}`)):this.debugMode&&console.warn(`[EventModule] 尝试移除的回调函数未找到: ${n}`)}trigger(e,t){const n=String(e);if(!this.listeners.has(n)){this.debugMode&&(console.warn(`[EventModule] 触发事件但未找到监听器: ${n}`),console.debug("[EventModule] 当前已注册的事件类型:",Array.from(this.listeners.keys())));return}const i=this.listeners.get(n);this.debugMode&&console.debug(`[EventModule] 触发事件: ${n}, 监听器数量: ${i.length}`,t),i.forEach((r,a)=>{try{r(t)}catch(o){console.error(`[EventModule] 事件监听器执行错误 [${n}] #${a}:`,o)}})}}class Tw{engine;constructor(e){this.engine=e}init(){const e=new Pi(16777215,1);e.position.set(100,200,100),e.castShadow=!0,e.shadow.mapSize.width=2048,e.shadow.mapSize.height=2048,e.shadow.camera.near=.1,e.shadow.camera.far=5e3,e.shadow.bias=-5e-5,e.shadow.normalBias=.02;const t=50;e.shadow.camera.left=-t,e.shadow.camera.right=t,e.shadow.camera.top=t,e.shadow.camera.bottom=-t,e.shadow.radius=2;const n=new Pi(16777215,2);this.engine.scene.add(e),this.engine.scene.add(n),this.engine.scene.dirLight=n;const i=new jo(16777215,1);this.engine.scene.add(i)}}var Yt=(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))(Yt||{});class Aw{engine;behavior;isCtrlDown=!1;highlightedInstances=[];highlightColor=new Fe(43775);constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved,this.behavior.init(this)}active(){this.behavior.active()}disActive(){this.behavior.disActive()}handelKeyCtrlUp(){this.isCtrlDown=!1}handelKeyCtrlDown(){this.isCtrlDown=!0}hoverOldId=null;handleMouseMove(e){if(!this.engine.engineStatus.isFree){this.engine.hoverHighLight.clearHighlight();return}let t=this.getCatchMeshs(e);t!=null?t.length>0&&this.engine.hoverHighLight.hightMesh(t):this.engine.hoverHighLight.clearHighlight()}getCatchMeshs(e){if(e.catch==null)return this.hoverOldId=null,null;if(e.catch.object.isInstance){let t=e.catch.object,n=e.catch.object.id,i=this.engine.models.find(o=>o.url==t.url).nodesMap.get(n),r=new Map;i?.indexes.forEach(o=>{this.engine.scene.children[o[0]]instanceof Ut&&(r.has(o[0])?r.get(o[0])?.push(o[1]):r.set(o[0],[o[1]]))});let a=[];return r.forEach((o,l)=>{let c=this.engine.scene.children[l];o.forEach(h=>{let d=c.geometry.clone();d.applyMatrix4(c.matrixs[h]),a.push(new at(d,c.material))})}),this.hoverOldId==n?[]:(this.hoverOldId=n,this.engine.hoverHighLight.clearHighlight(),a)}else{const t=e.catch;t.object;let n=t.object,i=n.name,r=this.engine.models.find(a=>a.url===n.url).nodesMap.get(i).infos.map(a=>a.mesh);return this.hoverOldId==i?[]:(this.hoverOldId=i,this.engine.hoverHighLight.clearHighlight(),r)}}handleMouseClick(e){if(e.catch!=null){const t=e.catch;let n=t.object;this.isCtrlDown||this.engine.modelToolModule.unhighlightAllModels(),console.log([{url:n.url,ids:[n.name]}]),this.engine.controlModule.orbitControls.origin.set(t.point.x,t.point.y,t.point.z),this.engine.modelToolModule.highlightModel([{url:n.url,ids:[n.name]}]),this.engine.events.trigger(Yt.Click,[{url:n.url,ids:[n.name]}])}else this.engine.modelToolModule.unhighlightAllModels()}handleMouseDoubleClick(e){if(e.catch){const n=e.catch;n.object;let i=n.object,r=this.engine.models.find(a=>a.url===i.url).nodesMap.get(i.name);if(n.object.isInstance){let a=n.matrix,o=[];r.indexes.forEach(c=>{let h=r.indexes[c][0],d=this.engine.scene.children[h].boundingSphere;const p=new ut,u=d.center.clone().applyMatrix4(a),g=d.radius,f=new P;f.setFromMatrixScale(a);const x=Math.max(f.x,f.y,f.z),m=g*x;p.min.set(u.x-m,u.y-m,u.z-m),p.max.set(u.x+m,u.y+m,u.z+m),o.push(p)});let l=t(o);this.engine.viewCube.zoomToModel(l)}else{let a=r.infos.map(l=>l.box),o=t(a);this.engine.viewCube.zoomToModel(o)}}function t(n){let i=new P(1e8,1e9,1e10),r=new P(-1e8,-1e9,-1e10);return n.forEach(a=>{a.min.x<i.x&&(i.x=a.min.x),a.min.y<i.y&&(i.y=a.min.y),a.min.z<i.z&&(i.z=a.min.z),a.max.x>r.x&&(r.x=a.max.x),a.max.y>r.y&&(r.y=a.max.y),a.max.z>r.z&&(r.z=a.max.z)}),new ut(i,r)}}handleMouseClickInstance(e){return e.intersectObjects(this.engine.scene.children.filter(t=>t instanceof Ut),!0)}}class Pw{engine;highlightMaterial;hideMaterial;translucentMaterial;constructor(e){this.engine=e,this.highlightMaterial=new Ht({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:yt}),this.hideMaterial=new Ht({color:0,transparent:!0,opacity:0,side:yt}),this.translucentMaterial=new Ht({color:16777215,transparent:!0,opacity:.05,side:yt}),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 Ut)return;let t=e.materialClone.clone(),n=Xm(e.geometrys,!0);n.groups.forEach(i=>{i.materialIndex=0}),e.geometry=n,e.material=[t,this.highlightMaterial,this.translucentMaterial],e.needsUpdate=!0,e.isSplit=!0}un_split_merge_model(e){}highlightModel(e){e.forEach(t=>{let n=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.engine.scene.children[o[0]]instanceof Ut?n.has(o[0])?n.get(o[0])?.push(o[1]):n.set(o[0],[o[1]]):(console.log(this.engine.scene.children[o[0]].materialClone.color),this.split_merge_model(this.engine.scene.children[o[0]]),this.engine.scene.children[o[0]].geometry.groups[o[1]].materialIndex=1)})}),Rw(n,this.engine);let i=this.engine.engineStatus.highlightModels.find(r=>r.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.highlightModels.push(t)})}unhighlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(i);r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{this.engine.scene.children[a[0]]instanceof Ut?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):this.engine.scene.children[a[0]].geometry.groups[a[1]].materialIndex=0})}),e0(n,this.engine,"highlightModel")})}unhighlightAllModels(e=!0){this.engine.engineStatus.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus.highlightModels=[])}hideModel(e){e.forEach(t=>{let n=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.engine.scene.children[o[0]];l instanceof Ut?n.has(o[0])?n.get(o[0])?.push(o[1]):n.set(o[0],[o[1]]):(this.split_merge_model(this.engine.scene.children[o[0]]),l.geometry.groups[o[1]].materialIndex=-1,l.geometry.groups[o[1]].visible=!1)})}),n.size>0&&Iw(n,this.engine);let i=this.engine.engineStatus.hideModels.find(r=>r.url==t.url);i!=null?i.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 n=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.engine.scene.children[o[0]];l instanceof Ut?n.has(o[0])?n.get(o[0])?.push(o[1]):n.set(o[0],[o[1]]):(l.geometry.groups[o[1]].materialIndex=0,l.geometry.groups[o[1]].visible=!0)})}),n.size>0&&t0(n,this.engine);let i=this.engine.engineStatus.hideModels.find(r=>r.url==t.url);i&&(t.ids.forEach(r=>{const a=i.ids.indexOf(r);a!==-1&&i.ids.splice(a,1)}),i.ids.length===0&&(this.engine.engineStatus.hideModels=this.engine.engineStatus.hideModels.filter(r=>r!==i)))})}isolateModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},r=e.find(a=>a.url==n.url);for(let a of n.nodesMap)r==null?i.ids.push(a[0]):r.ids.includes(a[0])||i.ids.push(a[0]);t.push(i)}),this.unhighlightAllModels(),this.hideModel(t)}translucentOtherModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},r=e.find(a=>a.url==n.url);for(let a of n.nodesMap)r==null?i.ids.push(a[0]):r.ids.includes(a[0])||i.ids.push(a[0]);t.push(i)}),this.translucentModel(t)}setModelColor(e,t){e.material.color.set(t)}setAllModelsColor(e){this.engine.scene.children.forEach(t=>{t.isMesh})}restoreAllModelsColor(){this.engine.scene.children.forEach(e=>{e.isMesh})}translucentModel(e){this.unhighlightAllModels(),e.forEach(t=>{let n=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.engine.scene.children[o[0]];l instanceof Ut?n.has(o[0])?n.get(o[0])?.push(o[1]):n.set(o[0],[o[1]]):(this.split_merge_model(this.engine.scene.children[o[0]]),l.geometry.groups[o[1]].materialIndex=2)})}),Lw(n,this.engine);let i=this.engine.engineStatus.translucentModels.find(r=>r.url==t.url);i!=null?i.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(n=>{let i=this.engine.models.find(r=>r.url==e.url).nodesMap.get(n);i!=null&&i.indexes!=null&&i.indexes.forEach(r=>{const a=this.engine.scene.children[r[0]];a instanceof Ut?t.has(r[0])?t.get(r[0])?.push(r[1]):t.set(r[0],[r[1]]):(this.split_merge_model(this.engine.scene.children[r[0]]),a.geometry.groups[r[1]].materialIndex=0)})}),t.size>0&&t0(t,this.engine),e0(t,this.engine,"translucentModel")}),this.engine.engineStatus.translucentModels=[]}showAllModels(){this.engine.engineStatus.hideModels&&this.engine.engineStatus.hideModels.length>0&&this.showModel(this.engine.engineStatus.hideModels),this.engine.engineStatus.hideModels=[],this.unhighlightAllModels()}batchSelectSameLevelTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevelType(n.levelName,n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameLevelModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevel(n.levelName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithType(n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}}function Rw(s,e){s.forEach((t,n)=>{const i=e.scene.children[n];if(!(i instanceof Ut))return;const r=i.geometry,a=new Ht({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:yt}),o=new Ut(r,a,t.length);o.name="highlightModel",o.key=n;const l=new Map,c=new Ie,h=new Ie;h.makeScale(0,0,0),t.forEach((d,p)=>{i.getMatrixAt(d,c),l.set(d,c.clone()),i.setMatrixAt(d,h),o.setMatrixAt(p,c)}),i.instanceMatrix.needsUpdate=!0,o.instanceMatrix.needsUpdate=!0,e.scene.add(o)})}function e0(s,e,t){s.forEach((n,i)=>{const r=e.scene.children[i];r instanceof Ut&&(n.forEach(a=>{const o=r.matrixsClone[a];o&&r.setMatrixAt(a,o)}),r.instanceMatrix.needsUpdate=!0,e.scene.children.filter(a=>a.key==i&&a.name==t).forEach(a=>{e.scene.remove(a)}))})}function Lw(s,e){s.forEach((t,n)=>{const i=e.scene.children[n];if(!(i instanceof Ut))return;const r=i.geometry,a=new Ht({color:16777215,transparent:!0,opacity:.05,side:yt}),o=new Ut(r,a,t.length);o.name="translucentModel",o.key=n;const l=new Map,c=new Ie,h=new Ie;h.makeScale(0,0,0),t.forEach((d,p)=>{i.getMatrixAt(d,c),l.set(d,c.clone()),i.setMatrixAt(d,h),o.setMatrixAt(p,c)}),i.instanceMatrix.needsUpdate=!0,o.instanceMatrix.needsUpdate=!0,e.scene.add(o)})}function Iw(s,e){e.scene.children.filter(t=>t.name=="highlightModel").forEach(t=>{e.scene.remove(t)}),s.forEach((t,n)=>{const i=e.scene.children[n];if(!(i instanceof Ut))return;const r=new Map,a=new Ie,o=new Ie;o.makeScale(0,0,0),t.forEach((l,c)=>{i.getMatrixAt(l,a),r.set(l,a.clone()),i.setMatrixAt(l,o)}),i.instanceMatrix.needsUpdate=!0})}function t0(s,e){s.forEach((t,n)=>{const i=e.scene.children[n];i instanceof Ut&&(t.forEach(r=>{const a=i.matrixs[r];a&&i.setMatrixAt(r,a)}),i.instanceMatrix.needsUpdate=!0)})}class Dw{engine;currentMode="";isManualMode=!1;gtaoPass=null;ssaoPass=null;saturationPass=null;outputPass=null;fxaaPass=null;constructor(e){this.engine=e}init(){this.cachePassReferences(),this.autoSwitch("advanced")}switchModel(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}autoSwitch(e){this.isManualMode||(this.currentMode=e,this.applyMode(e))}enableAutoMode(){this.isManualMode=!1}get isManual(){return this.isManualMode}setMode(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}getCurrentMode(){return this.currentMode}cachePassReferences(){this.engine.composerModule?.composer&&(this.engine.composerModule.gtaoPass&&(this.gtaoPass=this.engine.composerModule.gtaoPass),this.engine.composerModule.ssaoPass&&(this.ssaoPass=this.engine.composerModule.ssaoPass),this.engine.composerModule.saturationPass&&(this.saturationPass=this.engine.composerModule.saturationPass),this.engine.composerModule.outputPass&&(this.outputPass=this.engine.composerModule.outputPass),this.engine.composerModule.fxaaPass&&(this.fxaaPass=this.engine.composerModule.fxaaPass))}applyMode(e){switch(e){case"simple":this.setShadows(!1),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!1);break;case"balance":this.setShadows(!0),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!1);break;case"advanced":this.setShadows(!0),this.setSSAO(!1),this.setGTAO(!0),this.setSaturation(!0),this.setOutputPass(!0),this.setFXAA(!0);break;default:console.warn(`[EngineModelModule] Unknown mode: ${e}`)}this.engine.updateVersionDisplay?.()}setShadows(e){this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e);const t=this.engine.scene?.children.find(n=>n instanceof Pi);t&&(t.castShadow=e),this.engine.scene?.traverse(n=>{n.material&&(n.castShadow!==void 0&&(n.castShadow=e),n.receiveShadow!==void 0&&(n.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(i=>i instanceof Pi),n={low:1024,medium:2048,high:2048}[e];t?.shadow&&n&&(t.shadow.mapSize.width=n,t.shadow.mapSize.height=n,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 wl{engine;overlayMaterial;overlayMeshes=[];animState="idle";animStartTime=0;static FADE_IN_MS=200;static FADE_OUT_MS=150;constructor(e){this.engine=e,this.init()}init(){this.overlayMaterial=new Ht({color:16777215,transparent:!0,opacity:0,blending:nc,depthWrite:!1}),this.overlayMaterial.clippingPlanes=this.engine.sectionPlane}hightMesh(e,t=16777215,n=.15){this.animState==="fadeOut"&&this.removeOverlayMeshes();const i=(Array.isArray(e)?e:e?[e]:[]).filter(r=>r?.geometry);if(i.length===0){this.clearHighlight();return}this.overlayMaterial.color.set(t),this.overlayMaterial.opacity=0,this.overlayMaterial.userData.targetOpacity=n;for(const r of i){const a=new at(r.geometry,this.overlayMaterial);r.updateWorldMatrix(!0,!1),a.matrix.copy(r.matrixWorld),a.matrixAutoUpdate=!1,this.engine.scene.add(a),this.overlayMeshes.push(a)}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 n=Math.min(e/wl.FADE_IN_MS,1);this.overlayMaterial.opacity=this.easeOutQuad(n)*t,n>=1&&(this.animState="idle")}else if(this.animState==="fadeOut"){const n=Math.min(e/wl.FADE_OUT_MS,1);this.overlayMaterial.opacity=(1-this.easeOutQuad(n))*t,n>=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 Ad={exports:{}},Nw=Ad.exports,n0;function Bw(){return n0||(n0=1,(function(s,e){(function(t,n){s.exports=n()})(Nw,function(){var t=function(){function n(u){return a.appendChild(u.dom),u}function i(u){for(var g=0;g<a.children.length;g++)a.children[g].style.display=g===u?"block":"none";r=u}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(u){u.preventDefault(),i(++r%a.children.length)},!1);var o=(performance||Date).now(),l=o,c=0,h=n(new t.Panel("FPS","#0ff","#002")),d=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var p=n(new t.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:a,addPanel:n,showPanel:i,begin:function(){o=(performance||Date).now()},end:function(){c++;var u=(performance||Date).now();if(d.update(u-o,200),u>l+1e3&&(h.update(1e3*c/(u-l),100),l=u,c=0,p)){var g=performance.memory;p.update(g.usedJSHeapSize/1048576,g.jsHeapSizeLimit/1048576)}return u},update:function(){o=this.end()},domElement:a,setMode:i}};return t.Panel=function(n,i,r){var a=1/0,o=0,l=Math.round,c=l(window.devicePixelRatio||1),h=80*c,d=48*c,p=3*c,u=2*c,g=3*c,f=15*c,x=74*c,m=30*c,b=document.createElement("canvas");b.width=h,b.height=d,b.style.cssText="width:80px;height:48px";var v=b.getContext("2d");return v.font="bold "+9*c+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=r,v.fillRect(0,0,h,d),v.fillStyle=i,v.fillText(n,p,u),v.fillRect(g,f,x,m),v.fillStyle=r,v.globalAlpha=.9,v.fillRect(g,f,x,m),{dom:b,update:function(y,_){a=Math.min(a,y),o=Math.max(o,y),v.fillStyle=r,v.globalAlpha=1,v.fillRect(0,0,h,f),v.fillStyle=i,v.fillText(l(y)+" "+n+" ("+l(a)+"-"+l(o)+")",p,u),v.drawImage(b,g+c,f,x-c,m,g,f,x-c,m),v.fillRect(g+x-c,f,c,m),v.fillStyle=r,v.globalAlpha=.9,v.fillRect(g+x-c,f,c,l((1-y/_)*m))}}},t})})(Ad)),Ad.exports}var kw=Bw();const Uw=em(kw);var Ur=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-Ur.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?Ur.Bounce.In(s*2)*.5:Ur.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}}}}),Da=function(){return performance.now()},Ow=(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=Da()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<n.length;i++){var r=this._tweens[n[i]],a=!t;r&&r.update(e,a)===!1&&!t&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},s})(),Pd={Linear:function(s,e){var t=s.length-1,n=t*e,i=Math.floor(n),r=Pd.Utils.Linear;return e<0?r(s[0],s[1],n):e>1?r(s[t],s[t-1],t-n):r(s[i],s[i+1>t?t:i+1],n-i)},Utils:{Linear:function(s,e,t){return(e-s)*t+s}}},i0=(function(){function s(){}return s.nextId=function(){return s._nextId++},s._nextId=0,s})(),Rd=new Ow,zw=(function(){function s(e,t){t===void 0&&(t=Rd),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=Ur.Linear.None,this._interpolationFunction=Pd.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=i0.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=Da()),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 n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var i={};for(var r in this._valuesEnd)i[r]=this._valuesEnd[r];this._valuesEnd=i}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,n,i,r){for(var a in n){var o=e[a],l=Array.isArray(o),c=l?"array":typeof o,h=!l&&Array.isArray(n[a]);if(!(c==="undefined"||c==="function")){if(h){var d=n[a];if(d.length===0)continue;for(var p=[o],u=0,g=d.length;u<g;u+=1){var f=this._handleRelativeValue(o,d[u]);if(isNaN(f)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}p.push(f)}h&&(n[a]=p)}if((c==="object"||l)&&o&&!h){t[a]=l?[]:{};var x=o;for(var m in x)t[a][m]=x[m];i[a]=l?[]:{};var d=n[a];if(!this._isDynamic){var b={};for(var m in d)b[m]=d[m];n[a]=d=b}this._setupProperties(x,t[a],d,i[a],r)}else(typeof t[a]>"u"||r)&&(t[a]=o),l||(t[a]*=1),h?i[a]=n[a].slice().reverse():i[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=Da()),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=Da()),!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=Rd),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=Ur.Linear.None),this._easingFunction=e,this},s.prototype.interpolation=function(e){return e===void 0&&(e=Pd.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 n=this,i;if(e===void 0&&(e=Da()),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+((i=this._repeatDelayTime)!==null&&i!==void 0?i:this._delayTime),c=this._duration+this._repeat*l,h=function(){if(n._duration===0||o>c)return 1;var x=Math.trunc(o/l),m=o-x*l,b=Math.min(m/n._duration,1);return b===0&&o===n._duration?1:b},d=h(),p=this._easingFunction(d);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,p),this._onUpdateCallback&&this._onUpdateCallback(this._object,d),this._duration===0||o>=this._duration)if(this._repeat>0){var u=Math.min(Math.trunc((o-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=u);for(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*u,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var g=0,f=this._chainedTweens.length;g<f;g++)this._chainedTweens[g].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},s.prototype._updateProperties=function(e,t,n,i){for(var r in n)if(t[r]!==void 0){var a=t[r]||0,o=n[r],l=Array.isArray(e[r]),c=Array.isArray(o),h=!l&&c;h?e[r]=this._interpolationFunction(o,i):typeof o=="object"&&o?this._updateProperties(e[r],a,o,i):(o=this._handleRelativeValue(a,o),typeof o=="number"&&(e[r]=a+(o-a)*i))}},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],n=this._valuesEnd[e];typeof n=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(n):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},s})();i0.nextId;var fi=Rd;fi.getAll.bind(fi),fi.removeAll.bind(fi),fi.add.bind(fi),fi.remove.bind(fi),fi.update.bind(fi);var Na={Easing:Ur,Tween:zw};class Fw extends J1{constructor(e){super(e),this.type=dn}parse(e){const t=function(x,m){switch(x){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(m||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(m||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(m||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(m||""))}},n=function(x,m,b){m=m||1024;let v=x.pos,y=-1,_=0,M="",T=String.fromCharCode.apply(null,new Uint16Array(x.subarray(v,v+128)));for(;0>(y=T.indexOf(`
`))&&_<m&&v<x.byteLength;)M+=T,_+=T.length,v+=128,T+=String.fromCharCode.apply(null,new Uint16Array(x.subarray(v,v+128)));return-1<y?(x.pos+=_+y+1,M+T.slice(0,y)):!1},i=function(x){const m=/^#\?(\S+)/,b=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,v=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,y=/^\s*FORMAT=(\S+)\s*$/,_=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,M={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let T,R;for((x.pos>=x.byteLength||!(T=n(x)))&&t(1,"no header found"),(R=T.match(m))||t(3,"bad initial token"),M.valid|=1,M.programtype=R[1],M.string+=T+`
`;T=n(x),T!==!1;){if(M.string+=T+`
`,T.charAt(0)==="#"){M.comments+=T+`
`;continue}if((R=T.match(b))&&(M.gamma=parseFloat(R[1])),(R=T.match(v))&&(M.exposure=parseFloat(R[1])),(R=T.match(y))&&(M.valid|=2,M.format=R[1]),(R=T.match(_))&&(M.valid|=4,M.height=parseInt(R[1],10),M.width=parseInt(R[2],10)),M.valid&2&&M.valid&4)break}return M.valid&2||t(3,"missing format specifier"),M.valid&4||t(3,"missing image size specifier"),M},r=function(x,m,b){const v=m;if(v<8||v>32767||x[0]!==2||x[1]!==2||x[2]&128)return new Uint8Array(x);v!==(x[2]<<8|x[3])&&t(3,"wrong scanline width");const y=new Uint8Array(4*m*b);y.length||t(4,"unable to allocate buffer space");let _=0,M=0;const T=4*v,R=new Uint8Array(4),w=new Uint8Array(T);let E=b;for(;E>0&&M<x.byteLength;){M+4>x.byteLength&&t(1),R[0]=x[M++],R[1]=x[M++],R[2]=x[M++],R[3]=x[M++],(R[0]!=2||R[1]!=2||(R[2]<<8|R[3])!=v)&&t(3,"bad rgbe scanline format");let I=0,A;for(;I<T&&M<x.byteLength;){A=x[M++];const S=A>128;if(S&&(A-=128),(A===0||I+A>T)&&t(3,"bad scanline data"),S){const U=x[M++];for(let H=0;H<A;H++)w[I++]=U}else w.set(x.subarray(M,M+A),I),I+=A,M+=A}const B=v;for(let S=0;S<B;S++){let U=0;y[_]=w[S+U],U+=v,y[_+1]=w[S+U],U+=v,y[_+2]=w[S+U],U+=v,y[_+3]=w[S+U],_+=4}E--}return y},a=function(x,m,b,v){const y=x[m+3],_=Math.pow(2,y-128)/255;b[v+0]=x[m+0]*_,b[v+1]=x[m+1]*_,b[v+2]=x[m+2]*_,b[v+3]=1},o=function(x,m,b,v){const y=x[m+3],_=Math.pow(2,y-128)/255;b[v+0]=vo.toHalfFloat(Math.min(x[m+0]*_,65504)),b[v+1]=vo.toHalfFloat(Math.min(x[m+1]*_,65504)),b[v+2]=vo.toHalfFloat(Math.min(x[m+2]*_,65504)),b[v+3]=vo.toHalfFloat(1)},l=new Uint8Array(e);l.pos=0;const c=i(l),h=c.width,d=c.height,p=r(l.subarray(l.pos),h,d);let u,g,f;switch(this.type){case hn:f=p.length/4;const x=new Float32Array(f*4);for(let b=0;b<f;b++)a(p,b*4,x,b*4);u=x,g=hn;break;case dn:f=p.length/4;const m=new Uint16Array(f*4);for(let b=0;b<f;b++)o(p,b*4,m,b*4);u=m,g=dn;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:h,height:d,data:u,header:c.string,gamma:c.gamma,exposure:c.exposure,type:g}}setDataType(e){return this.type=e,this}load(e,t,n,i){function r(a,o){switch(a.type){case hn:case dn:a.colorSpace=en,a.minFilter=Pt,a.magFilter=Pt,a.generateMipmaps=!1,a.flipY=!0;break}t&&t(a,o)}return super.load(e,r,n,i)}}function Hw(){return new wp}function Vw(s,e){s.appendChild(e.domElement)}function Gw(s,e,t){var n=new Object;n.visible=!0;let i=null,r,a,o=[];n.init=function(){r||(c(),h(),d())},n.Hide=function(){r.style.display="none",n.visible=!1},n.Show=function(){r.style.display="block",n.visible=!0},n.RenderScene=function(){n.camera.quaternion.copy(e.camera.quaternion);const g=new P(0,0,1).applyQuaternion(e.camera.quaternion);n.camera.position.copy(g.multiplyScalar(100)),n.sceneOrtho.renderer.render(n.sceneOrtho,n.camera)},n.ToggleDirectionView=function(g){var f=new P(0,0,0);g=="top"?f=new P(0,1,1e-5):g=="down"?f=new P(0,-1,1e-5):g=="front"?f=new P(0,0,1):g=="left"?f=new P(-1,0,0):g=="back"?f=new P(0,0,-1):g=="right"?f=new P(1,0,0):g=="top_front"?f=new P(1,1,0):g=="top_left"?f=new P(0,1,-1):g=="top_back"?f=new P(-1,1,0):g=="top_right"?f=new P(0,1,1):g=="down_front"?f=new P(1,-1,0):g=="down_left"?f=new P(0,-1,-1):g=="down_back"?f=new P(-1,-1,0):g=="down_right"?f=new P(0,-1,1):g=="front_right"?f=new P(1,0,1):g=="right_back"?f=new P(-1,0,1):g=="back_left"?f=new P(-1,0,-1):g=="left_front"?f=new P(1,0,-1):g=="top_left_front"?f=new P(1,1,-1):g=="top_front_right"?f=new P(1,1,1):g=="top_right_back"?f=new P(-1,1,1):g=="top_back_left"?f=new P(-1,1,-1):g=="button_left_front"?f=new P(1,-1,-1):g=="button_front_right"?f=new P(1,-1,1):g=="button_right_back"?f=new P(-1,1,1):g=="button_back_left"&&(f=new P(-1,-1,-1));var x=s.octreeBox.getBoundingBox(),m=x.min,b=x.max,v=m.clone().add(b.clone()).multiplyScalar(.5),y=v.clone().add(f.multiplyScalar(1*b.distanceTo(m)));l(e.camera.position,y,s.controls.target.clone(),v)},n.GetCameraPose=function(){var g=e.camera.quaternion,f=e.camera.position,x=s.controls.target,m={quaternion:g,position:f,target:x};return m},n.ReductionCameraPose=function(g,f=1e3,x){var m=new zn(g.quaternion._x,g.quaternion._y,g.quaternion._z,g.quaternion._w),b=new P(g.position.x,g.position.y,g.position.z),v=new P(g.target.x,g.target.y,g.target.z);let y=!1;l(e.camera.position,b,s.controls.target.clone(),v,e.camera.quaternion,m,f,_=>{x&&(y||(x(_),y=!0))}),x&&setTimeout(()=>{y||(x(!0),y=!0)},f+10)},n.CameraGoHome=function(){var g=s.octreeBox.getBoundingBox(),f=g.min.clone().add(g.max.clone()).multiplyScalar(.5);let x=new P(1,1,1);var m=g.max.distanceTo(g.min),b=f.clone().add(x.multiplyScalar(m));if(e.camera.isOrthographicCamera){var v=s.container.clientWidth/s.container.clientHeight,y=m*.6;e.camera.left=-y*v,e.camera.right=y*v,e.camera.top=y,e.camera.bottom=-y,e.camera.zoom=1,e.camera.updateProjectionMatrix()}l(e.camera.position,b,s.controls.target.clone(),f)},n.zoomToBox=function(g){var f=g.min.clone().add(g.max.clone()).multiplyScalar(.5),x=e.camera.position.clone().sub(s.controls.target.clone()).normalize(),m=e.camera.position.distanceTo(s.controls.target),b=f.clone().add(x.multiplyScalar(m)),v=e.camera.zoom;if(e.camera.isOrthographicCamera){var y=new P(1,0,0).applyQuaternion(e.camera.quaternion),_=new P(0,1,0).applyQuaternion(e.camera.quaternion),M=[new P(g.min.x,g.min.y,g.min.z),new P(g.max.x,g.min.y,g.min.z),new P(g.min.x,g.max.y,g.min.z),new P(g.max.x,g.max.y,g.min.z),new P(g.min.x,g.min.y,g.max.z),new P(g.max.x,g.min.y,g.max.z),new P(g.min.x,g.max.y,g.max.z),new P(g.max.x,g.max.y,g.max.z)],T=1/0,R=-1/0,w=1/0,E=-1/0;for(var I of M){var A=I.dot(y),B=I.dot(_);T=Math.min(T,A),R=Math.max(R,A),w=Math.min(w,B),E=Math.max(E,B)}var S=(R-T)/2,U=(E-w)/2,H=(e.camera.right-e.camera.left)/2,G=(e.camera.top-e.camera.bottom)/2;v=Math.min(H/S,G/U)*.75}var Z=e.camera.position.clone(),j=s.controls.target.clone(),ie=e.camera.zoom,X=new Na.Tween({x1:Z.x,y1:Z.y,z1:Z.z,x2:j.x,y2:j.y,z2:j.z,zoom:ie}).to({x1:b.x,y1:b.y,z1:b.z,x2:f.x,y2:f.y,z2:f.z,zoom:v},1e3);X.onUpdate(function(ue){s.controls&&(e.camera.position.set(ue.x1,ue.y1,ue.z1),s.controls.target.set(ue.x2,ue.y2,ue.z2),e.camera.isOrthographicCamera&&(e.camera.zoom=ue.zoom,e.camera.updateProjectionMatrix()),s.controls.auto=!0,s.controls.update(),n.RenderScene())}),X.onComplete(function(){s.controls&&(s.controls.auto=!1,n.RenderScene(),cancelAnimationFrame(i),i=null)}),X.easing(Na.Easing.Cubic.InOut),X.start();function $(){i=requestAnimationFrame($),X.update()}$()};function l(g,f,x,m,b,v,y=1e3,_){var M;b&&v?(M=new Na.Tween({x1:g.x,y1:g.y,z1:g.z,x2:x.x,y2:x.y,z2:x.z,_x:b._x,_y:b._y,_z:b._z,_w:b._w}),M.to({x1:f.x,y1:f.y,z1:f.z,x2:m.x,y2:m.y,z2:m.z,_x:v._x,_y:v._y,_z:v._z,_w:v._w},y)):(M=new Na.Tween({x1:g.x,y1:g.y,z1:g.z,x2:x.x,y2:x.y,z2:x.z}),M.to({x1:f.x,y1:f.y,z1:f.z,x2:m.x,y2:m.y,z2:m.z},y)),M.onUpdate(function(R){s.controls&&(b&&v?(e.camera.quaternion._x=R._x,e.camera.quaternion._y=R._y,e.camera.quaternion._z=R._z,e.camera.quaternion._w=R._w):s.controls.auto=!0,e.camera.position.x=R.x1,e.camera.position.y=R.y1,e.camera.position.z=R.z1,s.controls.target.x=R.x2,s.controls.target.y=R.y2,s.controls.target.z=R.z2,s.controls.update(),n.RenderScene())}),M.onComplete(function(R){s.controls&&(s.controls.auto=!1,n.RenderScene(),_&&_(!0),cancelAnimationFrame(i),i=null)}),M.easing(Na.Easing.Cubic.InOut);function T(R){i=requestAnimationFrame(T),M.update()}M.start(),T()}function c(){r=document.createElement("div"),r.className="ViewCube",t.appendChild(r),a=document.createElement("div"),a.className="viewSettingWrapper",a.innerHTML="...",r.appendChild(a);var g=document.createElement("div");g.className="homeViewWrapper",g.addEventListener("mousedown",function(){console.log("归位"),n.CameraGoHome()}),r.appendChild(g);const f=document.createElement("div");f.className="cameraToggleWrapper",f.title="切换正交/透视视图",f.innerHTML="⊞",f.addEventListener("mousedown",function(y){y.stopPropagation(),console.log("切换视图"),n.ToggleCameraType(),b()}),r.appendChild(f);const x=document.createElement("div");x.className="screenshotWrapper",x.title="截图",x.innerHTML="📷",x.addEventListener("mousedown",function(y){y.stopPropagation(),console.log("截图"),n.TakeScreenshot(),b()}),r.appendChild(x);const m=document.createElement("div");m.className="fullscreenWrapper",m.title="全屏",m.innerHTML="⛶",m.addEventListener("mousedown",function(y){y.stopPropagation(),console.log("全屏"),n.ToggleFullscreen(),b()}),r.appendChild(m),a.addEventListener("mousedown",function(y){y.stopPropagation(),f.classList.contains("show")?(b(),console.log("隐藏功能按钮")):(v(),console.log("显示功能按钮"))});function b(){f.classList.remove("show"),x.classList.remove("show"),m.classList.remove("show")}function v(){f.classList.add("show"),x.classList.add("show"),m.classList.add("show")}}function h(){n.sceneOrtho=Hw();var x=t.clientWidth,m=t.clientWidth,g=x>m?x/m:m/x,f=300;n.camera=new Ai(f*g/-2,f*g/2,f/2,f/-2,.01,1e4);var x=r.clientWidth,m=r.clientHeight,b=new ad({alpha:!0});b.setSize(x,m),b.setClearAlpha(0),n.sceneOrtho.renderer=b;let v=new jo(16777215,.8);n.sceneOrtho.add(v),Vw(r,b)}function d(){const g="/assets/viewcube/";let f=[{label:"右",icon:g+"cn_right.png"},{label:"左",icon:g+"cn_left.png"},{label:"顶",icon:g+"cn_top.png"},{label:"底",icon:g+"cn_bottom.png"},{label:"前",icon:g+"cn_front.png"},{label:"后",icon:g+"cn_back.png"}];var x=[];for(const b of f)x.push(new Ht({color:16777215,map:new Gh().load(b.icon)}));new k1({color:255});var m=new at(new Zi(110,110,110),x);n.sceneOrtho.add(m),p(122),r.addEventListener("mousedown",b=>{var v={};v.x=b.offsetX/r.clientWidth*2-1,v.y=-(b.offsetY/r.clientHeight)*2+1;var y=new Qi;y.setFromCamera(v,n.camera);const _=y.intersectObjects(o,!1);_.length>0&&n.ToggleDirectionView(_[0].object.name)}),r.addEventListener("mousemove",b=>{var v={};v.x=b.offsetX/r.clientWidth*2-1,v.y=-(b.offsetY/r.clientHeight)*2+1;var y=new Qi;y.setFromCamera(v,n.camera);const _=y.intersectObjects(o,!1);for(var M of o)M.material.opacity=.01;_.length>0&&(_[0].object.material.opacity=.2)})}function p(g){for(var f=g*.5-20,x=[{name:"right",a:30,b:75,c:75,point:new P(f,0,0)},{name:"back",a:75,b:75,c:30,point:new P(0,0,-f)},{name:"left",a:30,b:75,c:75,point:new P(-f,0,0)},{name:"front",a:75,b:75,c:30,point:new P(0,0,f)},{name:"top",a:75,b:30,c:75,point:new P(0,f,0)},{name:"button",a:75,b:30,c:75,point:new P(0,-f,0)}],m=[{name:"top_right_back",a:30,b:30,c:30,point:new P(-f,f,f)},{name:"button_front_right",a:30,b:30,c:30,point:new P(-f,-f,f)},{name:"top_front_right",a:30,b:30,c:30,point:new P(f,f,f)},{name:"button_right_back",a:30,b:30,c:30,point:new P(f,-f,f)},{name:"top_back_left",a:30,b:30,c:30,point:new P(-f,f,-f)},{name:"button_back_left",a:30,b:30,c:30,point:new P(-f,-f,-f)},{name:"top_left_front",a:30,b:30,c:30,point:new P(f,f,-f)},{name:"button_left_front",a:30,b:30,c:30,point:new P(f,-f,-f)}],b=[{name:"top_front",a:30,b:30,c:75,point:new P(f,f,0)},{name:"top_right",a:75,b:30,c:30,point:new P(0,f,f)},{name:"top_back",a:30,b:30,c:75,point:new P(-f,f,0)},{name:"top_left",a:75,b:30,c:30,point:new P(0,f,-f)},{name:"button_front",a:30,b:30,c:75,point:new P(f,-f,0)},{name:"button_right",a:75,b:30,c:30,point:new P(0,-f,f)},{name:"button_back",a:30,b:30,c:75,point:new P(-f,-f,0)},{name:"button_left",a:75,b:30,c:30,point:new P(0,-f,-f)},{name:"front_right",a:30,b:75,c:30,point:new P(f,0,f)},{name:"right_back",a:30,b:75,c:30,point:new P(-f,0,f)},{name:"back_left",a:30,b:75,c:30,point:new P(-f,0,-f)},{name:"left_front",a:30,b:75,c:30,point:new P(f,0,-f)}],v=0;v<x.length;v++)o.push(u(x[v]));for(var v=0;v<m.length;v++)o.push(u(m[v]));for(var v=0;v<b.length;v++)o.push(u(b[v]))}function u(g){const f=new Zi(g.a,g.b,g.c),x=new Ht({color:"blue",transparent:!0,opacity:.01}),m=new Ie().makeTranslation(g.point.x,g.point.y,g.point.z);let b=f.applyMatrix4(m),v=new at(b,x);return v.name=g.name,n.sceneOrtho.add(v),v}return n.ToggleCameraType=function(){s.cameraModule.switchCurrentCamera()},n.TakeScreenshot=function(){try{if(!s.renderer){console.error("渲染器未初始化");return}s.renderer.render(e,e.camera);const g=s.renderer.domElement.toDataURL("image/png"),f=document.createElement("a"),x=new Date().toISOString().replaceAll(/[:.]/g,"-");f.download=`screenshot_${x}.png`,f.href=g,f.click(),console.log("截图已保存")}catch(g){console.error("截图失败:",g)}},n.ToggleFullscreen=function(){const g=t||document.documentElement;!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.mozFullScreenElement&&!document.msFullscreenElement?(g.requestFullscreen?g.requestFullscreen():g.webkitRequestFullscreen?g.webkitRequestFullscreen():g.mozRequestFullScreen?g.mozRequestFullScreen():g.msRequestFullscreen&&g.msRequestFullscreen(),console.log("已进入全屏模式")):(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),console.log("已退出全屏模式"))},n}class Ww{engine;cubeTool;constructor(e){this.engine=e}init(){this.cubeTool=Gw(this.engine,this.engine.scene,this.engine.container),this.cubeTool.init()}CameraGoHome(){this.cubeTool.CameraGoHome()}zoomToModel(e){this.cubeTool.zoomToBox(e)}hide(){}}function Xw(s){let e=new Object;return e.getBoundingBox=function(){let t=s.models,n=new P(1e8,1e9,1e10),i=new P(-1e8,-1e9,-1e10);t.forEach(d=>{let p=d.boundingBox.min,u=d.boundingBox.max;p.x<n.x&&(n.x=p.x),p.y<n.y&&(n.y=p.y),p.z<n.z&&(n.z=p.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)});let r=Math.min(n.x,i.x),a=Math.min(n.y,i.y),o=Math.min(n.z,i.z),l=Math.max(n.x,i.x),c=Math.max(n.y,i.y),h=Math.max(n.z,i.z);return{min:new P(r,a,o),max:new P(l,c,h)}},e.rayInterationModel=function(t){let n=[];return s.engineStatus.models.forEach(r=>{r.info.lods.forEach(a=>{let o=a.octreeBox;i(t,o,r)})}),n=n.filter(r=>r instanceof at),t.intersectObjects(n,!1);function i(r,a,o){if(a==null)return;let l=new P(a.min.X*.3048,a.min.Z*.3048,-a.min.Y*.3048),c=new P(a.max.X*.3048,a.max.Z*.3048,-a.max.Y*.3048),h=new P(Math.min(l.x,c.X),Math.min(l.y,c.y),Math.min(l.z,c.z)),d=new P(Math.max(c.x,l.x),Math.max(c.y,l.y),Math.max(c.z,l.z)),p=new ut(h,d),u=r.ray.intersectsBox(p);if(!(u==null||u==!1))if(a.children==null||a.children.length==0){if(a.elements!=null)for(var g of a.elements){let f=s.engineStatus.hideModels.find(b=>b.url==o.url)?.ids;if(f!=null&&f.includes(g))continue;let x=s.engineStatus.translucentModels.find(b=>b.url==o.url)?.ids;if(x!=null&&x.includes(g))continue;let m=s.models.find(b=>b.url==o.url).nodesMap.get(g);m!=null&&!m.instance&&m.infos.map(b=>b.mesh).forEach(b=>{n.push(b)})}}else{if(a.elements!=null)for(var g of a.elements){let x=s.engineStatus.hideModels.find(v=>v.url==o.url)?.ids;if(x!=null&&x.includes(g))continue;let m=s.engineStatus.translucentModels.find(v=>v.url==o.url)?.ids;if(m!=null&&m.includes(g))continue;let b=s.models.find(v=>v.url==o.url).nodesMap.get(g);b!=null&&!b.instance&&b.infos.map(v=>v.mesh).forEach(v=>{n.push(v)})}for(let f of a.children)i(r,f,o)}}},e}class jw{engine;isDrawing=!1;startPoint=new he;endPoint=new he;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 yn(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),n=Math.abs(this.endPoint.x-this.startPoint.x),i=Math.abs(this.endPoint.y-this.startPoint.y);this.selectionBox.style.left=`${e}px`,this.selectionBox.style.top=`${t}px`,this.selectionBox.style.width=`${n}px`,this.selectionBox.style.height=`${i}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 n=Math.min(this.startPoint.x,this.endPoint.x),i=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:n,y:r},{x:i,y:r},{x:i,y:a},{x:n,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 ut;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,n=this.engine.controls;if(!t||!n){console.warn("RangeScale: 相机或控制器未初始化");return}const i=new P;e.getCenter(i);const r=new P;e.getSize(r);const a=Math.max(r.x,r.y,r.z);if(t instanceof on){const o=t.fov*(Math.PI/180),l=a/(2*Math.tan(o/2))*1.2,c=new P;t.getWorldDirection(c);const h=i.clone().sub(t.position);c.dot(h.normalize())<0&&c.negate();const d=i.clone().sub(c.multiplyScalar(l));t.position.copy(d),n.target&&n.target.copy(i),t.lookAt(i),n.update()}else if(t instanceof Ai){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,p=i.clone().sub(h.multiplyScalar(d));t.position.copy(p),n.target&&n.target.copy(i),t.lookAt(i),n.update()}}}class qw{engine;ground=null;constructor(e){this.engine=e}init(){}setStatsVisible(e){this.engine.stats?.dom&&(this.engine.stats.dom.style.display=e?"block":"none")}setAmbientLightIntensity(e){const t=this.engine.scene.children.find(n=>n instanceof jo);t&&(t.intensity=e)}setAmbientLightColor(e){const t=this.engine.scene.children.find(n=>n instanceof jo);t&&t.color.set(e)}setDirectionalLightIntensity(e){const t=this.engine.scene.children.find(n=>n instanceof Pi);t&&(t.intensity=e)}setDirectionalLightColor(e){const t=this.engine.scene.children.find(n=>n instanceof Pi);t&&t.color.set(e)}setShadowQuality(e){const t=this.engine.scene.children.find(n=>n instanceof Pi);if(t?.shadow){const n={low:1024,medium:2048,high:4096,ultra:8192}[e];t.shadow.mapSize.width=n,t.shadow.mapSize.height=n,t.shadow.map?.dispose(),t.shadow.map=null}}setDirectionalLightShadow(e){const t=this.engine.scene.children.find(n=>n instanceof Pi);t&&(t.castShadow=e),this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e)}setGTAOEnabled(e){if(!this.engine.composerModule?.composer){console.warn("Composer not initialized");return}const t=this.engine.composerModule.composer,n=t.passes.find(i=>i instanceof _n);if(e)if(n)n.enabled=!0;else{const{width:i,height:r}=this.engine.deviceModule.getContainerSize(),a=new _n(this.engine.scene,this.engine.camera,i,r);a.output=_n.OUTPUT.Default,a.blendIntensity=.5,a.updateGtaoMaterial&&a.updateGtaoMaterial({radius:1,distanceExponent:1,thickness:1,scale:1,distanceFallOff:1,screenSpaceRadius:!0});const o=t.passes.findIndex(l=>l.constructor.name==="RenderPass");t.passes.splice(o+1,0,a)}else n&&(n.enabled=!1)}setSceneSaturation(e){if(!this.engine.composerModule?.saturationPass){console.warn("Saturation pass not initialized");return}this.engine.composerModule.saturationPass.uniforms.saturation.value=e}setSceneContrast(e){if(!this.engine.composerModule?.saturationPass){console.warn("Saturation pass not initialized");return}this.engine.composerModule.saturationPass.uniforms.contrast.value=e}setGroundEnabled(e,t){if(e)if(this.ground)this.ground.visible=!0;else{const n=t?.size??100,i=t?.color??8421504,r=t?.opacity??.3,a=new Ss(n,n),o=new Ki({color:i,transparent:!0,opacity:r,side:yt});this.ground=new at(a,o),this.ground.rotation.x=-Math.PI/2,this.ground.position.y=0,this.ground.receiveShadow=!0,this.ground.name="ground",this.engine.scene.add(this.ground)}else this.ground&&(this.ground.visible=!1)}setHDRBackground(e){e?(this.engine.scene.background=e,this.engine.scene.environment=e):(this.engine.scene.background=null,this.engine.scene.environment=null)}}function Ii(){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 Di{engine;handelBehaved;setting;constructor(e){this.engine=e,this.handelBehaved=cd(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 n=this.setting.unit,i=n;return t==1?n=="mm"?e=e*1e3:n=="cm"?e=e*100:n=="dm"?e=e*10:n=="m"?e=e*1:n=="km"&&(e=e*.001):t==2&&(n=="mm"?e=e*1e3*1e3:n=="cm"?e=e*100*100:n=="dm"?e=e*10*10:n=="m"?e=e*1*1:n=="km"&&(e=e*.001*.001),i=i+"²"),e.toFixed(this.setting.precision)+" "+i}cancelCurrentSelectedAnnotation(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(n=>{n.highlight==!0&&(n.highlight=!1,n.container.classList.remove("Hight"),n.container.getElementsByTagName("svg")[0].classList.remove("Hight"))})}handelKeyEscDown(){this.cancelCurrentSelectedAnnotation();let e=this.engine.measure.annotationData;for(let t in e)for(let n=e[t].length-1;n>=0;n--){let i=e[t][n];i.isSelect==!0&&(i.container.remove(),e[t].splice(n,1))}this.engine.measure.clearAllPoints()}handelKeyDeleteDown(){let e=this.engine.measure.annotationData;for(let t in e)for(let n=e[t].length-1;n>=0;n--){let i=e[t][n];i.highlight==!0&&(i.container.remove(),e[t].splice(n,1))}}clearHighlight(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(n=>{n.highlight=!1,n.container.classList.remove("Hight"),n.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=>{n(l)}),this.engine.measure.annotationData.slopeAnnotation.forEach(l=>{i(l)});function t(l){if(l.container==null){let m=['<svg class="measureSvg">','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<polyline stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+l.text+"</text>","</svg>"].join("");l.container=document.createElement("div"),l.container.className="angle-annotation",l.container.id=l.id,l.container.style.pointerEvents="none",l.container.innerHTML=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(Yt.MeasureClick,l)})}let c=new yn(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point1),h=new yn(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point2),d=new yn(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point3),p=e.engine.reactBoundingClientRect.left,u=e.engine.reactBoundingClientRect.top;c.x+=p,c.y+=u,h.x+=p,h.y+=u,d.x+=p,d.y+=u;let g=l.container;g.getElementsByTagName("circle")[0].setAttribute("cx",c.x),g.getElementsByTagName("circle")[0].setAttribute("cy",c.y),g.getElementsByTagName("circle")[1].setAttribute("cx",h.x),g.getElementsByTagName("circle")[1].setAttribute("cy",h.y),g.getElementsByTagName("circle")[2].setAttribute("cx",d.x),g.getElementsByTagName("circle")[2].setAttribute("cy",d.y),g.getElementsByTagName("polyline")[0].setAttribute("points",c.x+","+c.y+" "+h.x+","+h.y),g.getElementsByTagName("polyline")[1].setAttribute("points",h.x+","+h.y+" "+d.x+","+d.y);let f=h.x,x=h.y-30;g.getElementsByTagName("rect")[0].setAttribute("x",f-40),g.getElementsByTagName("rect")[0].setAttribute("y",x-12.5),g.getElementsByTagName("text")[0].setAttribute("x",f),g.getElementsByTagName("text")[0].setAttribute("y",x+4),g.getElementsByTagName("text")[0].innerHTML=l.text,g.style.top="0px",g.style.left="0px"}function n(l){if(l.container==null){let b=['<svg class="measureSvg">','<polygon fill="rgba(255, 165, 0, 0.3)" stroke="orange" stroke-width="2" points="" style="opacity: 0.3;"/>','<polyline stroke="orange" stroke-width="2" points="" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(l.text,2)+"</text>","</svg>"].join("");l.container=document.createElement("div"),l.container.className="area-annotation",l.container.id=l.id,l.container.innerHTML=b,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(Yt.MeasureClick,l)})}if(!l.points||l.points.length<3)return;let c=e.engine.reactBoundingClientRect.left,h=e.engine.reactBoundingClientRect.top,d=[],p=0,u=0;for(let b=0;b<l.points.length;b++){let v=new yn(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.points[b]);v.x+=c,v.y+=h,d.push(v),p+=v.x,u+=v.y}p=p/d.length,u=u/d.length;let g=d.map(b=>b.x+","+b.y).join(" "),f=l.container;f.getElementsByTagName("polygon")[0].setAttribute("points",g),f.getElementsByTagName("polyline")[0].setAttribute("points",g);let x=p,m=u;f.getElementsByTagName("rect")[0].setAttribute("x",x-40),f.getElementsByTagName("rect")[0].setAttribute("y",m-12.5),f.getElementsByTagName("text")[0].setAttribute("x",x),f.getElementsByTagName("text")[0].setAttribute("y",m+4),f.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(l.text,2),f.style.top="0px",f.style.left="0px"}function i(l){if(l.container==null){let x=['<svg class="measureSvg">',"<defs>",'<marker id="slope-arrow-'+l.id+'" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto" markerUnits="strokeWidth">','<path d="M0,0 L0,6 L9,3 z" fill="orange" stroke="orange" />',"</marker>","</defs>",'<polyline 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=x,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(Yt.MeasureClick,l)})}let c=new yn(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point1),h=new yn(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point2),d=e.engine.reactBoundingClientRect.left,p=e.engine.reactBoundingClientRect.top;c.x+=d,c.y+=p,h.x+=d,h.y+=p;let u=l.container;u.getElementsByTagName("polyline")[0].setAttribute("points",c.x+","+c.y+" "+h.x+","+h.y);let g=(c.x+h.x)/2,f=(c.y+h.y)/2-30;u.getElementsByTagName("rect")[0].setAttribute("x",g-50),u.getElementsByTagName("rect")[0].setAttribute("y",f-12.5),u.getElementsByTagName("text")[0].setAttribute("x",g),u.getElementsByTagName("text")[0].setAttribute("y",f+4),u.getElementsByTagName("text")[0].innerHTML=l.text,u.style.top="0px",u.style.left="0px"}function r(l){if(l.container==null){let m=['<svg class="measureSvg">','<circle cx="0" cy="0" r="5" fill="#f99d0b" />','<rect x="0" y="-25" width="100" height="25" class="measureBack" />','<text x="40" y="-11" text-anchor="middle" class="measureLabel">X: '+e.getMeasureText(l.textX,1)+"</text>",'<rect x="0" y="-10" width="100" height="25" class="measureBack" />','<text x="40" y="25" text-anchor="middle" class="measureLabel">Y: '+e.getMeasureText(-l.textZ,1)+"</text>",'<rect x="0" y="10" width="100" height="25" class="measureBack" />','<text x="40" y="51" text-anchor="middle" class="measureLabel">Z: '+e.getMeasureText(l.textY,1)+"</text>","</svg>"].join("");l.container=document.createElement("div"),l.container.className="coordinate-annotation",l.container.id=l.id,l.container.style.position="absolute",l.container.style.pointerEvents="none",l.container.innerHTML=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(Yt.MeasureClick,l)})}let c=l.container,h=new yn(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point),d=e.engine.reactBoundingClientRect.left,p=e.engine.reactBoundingClientRect.top;h.x+=d,h.y+=p,c.style.top="0px",c.style.left="0px";let u=c.getElementsByTagName("circle")[0];u&&(u.setAttribute("cx",h.x),u.setAttribute("cy",h.y));let g=c.getElementsByTagName("rect"),f=c.getElementsByTagName("text"),x=-55;g[0]&&(g[0].setAttribute("x",h.x+10),g[0].setAttribute("y",h.y+10+x)),f[0]&&(f[0].setAttribute("x",h.x+10+40),f[0].setAttribute("y",h.y+10+16+x)),g[1]&&(g[1].setAttribute("x",h.x+10),g[1].setAttribute("y",h.y+10+30+x)),f[1]&&(f[1].setAttribute("x",h.x+10+40),f[1].setAttribute("y",h.y+10+46+x)),g[2]&&(g[2].setAttribute("x",h.x+10),g[2].setAttribute("y",h.y+10+60+x)),f[2]&&(f[2].setAttribute("x",h.x+10+40),f[2].setAttribute("y",h.y+10+76+x)),f[0]&&(f[0].innerHTML="X: "+e.getMeasureText(l.textX,1)),f[1]&&(f[1].innerHTML="Y: "+e.getMeasureText(-l.textZ,1)),f[2]&&(f[2].innerHTML="Z: "+e.getMeasureText(l.textY,1))}function a(l){if(l.container==null){let u=['<svg width="100" height="50" class="measureSvg">','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(l.text,1)+"</text>",'<polyline stroke="#f99d0b" stroke-width="2" points="80,32 0,32 16,48 32,32" style="fill: none; opacity: 1;"/>',"</svg>"].join("");l.container=document.createElement("div"),l.container.className="elevation-annotation",l.container.id=l.id,l.container.style.position="absolute",l.container.style.pointerEvents="none",l.container.innerHTML=u,e.engine.measure.annotationContainer.appendChild(l.container),l.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0,e.engine.events.trigger(Yt.MeasureClick,l)})}let c=l.container,h=new yn(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point),d=e.engine.reactBoundingClientRect.left,p=e.engine.reactBoundingClientRect.top;c.style.top=h.y+p-48+"px",c.style.left=h.x+d-16+"px",c.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(l.text,1)}function o(l){if(l.container==null){let g=['<svg class="measureSvg">','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline stroke="orange" stroke-width="2" points="80,32 0,32" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(l.text,1)+"</text>","</svg>"].join("");l.container=document.createElement("div"),l.container.className="normal-annotation",l.container.id=l.id,l.container.innerHTML=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(Yt.MeasureClick,l)})}let c=l.container;if(l.point1==null||l.point2==null){c.style.display="none";return}else c.style.display="block";let h=new yn(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point1),d=new yn(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point2),p=e.engine.reactBoundingClientRect.left,u=e.engine.reactBoundingClientRect.top;h.x+=p,h.y+=u,d.x+=p,d.y+=u,c.getElementsByTagName("polyline")[0].setAttribute("points",h.x+","+h.y+" "+d.x+","+d.y),c.getElementsByTagName("circle")[0].setAttribute("cx",h.x),c.getElementsByTagName("circle")[0].setAttribute("cy",h.y),c.getElementsByTagName("circle")[1].setAttribute("cx",d.x),c.getElementsByTagName("circle")[1].setAttribute("cy",d.y),c.getElementsByTagName("rect")[0].setAttribute("x",h.x*.5+d.x*.5-40),c.getElementsByTagName("rect")[0].setAttribute("y",h.y*.5+d.y*.5-12.5),c.getElementsByTagName("text")[0].setAttribute("x",h.x*.5+d.x*.5+40-40),c.getElementsByTagName("text")[0].setAttribute("y",h.y*.5+d.y*.5+16-12.5),c.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(l.text,1),c.style.top="0px",c.style.left="0px"}}}class Zw{engine;isActive=!1;tools;points=[];behavior;catchDir=0;type="point";constructor(e){this.engine=e,this.tools=new Di(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}setDirection(e){this.catchDir=e}setSelectType(e){this.type=e}getMeshesMinMaxY(e){if(!Array.isArray(e)||e.length===0)return null;let t=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;for(let i=0;i<e.length;i++){const r=e[i];if(!r)continue;typeof r.updateMatrixWorld=="function"&&r.updateMatrixWorld(!0);const a=new ut().setFromObject(r);!Number.isFinite(a.min.y)||!Number.isFinite(a.max.y)||(a.min.y<t&&(t=a.min.y),a.max.y>n&&(n=a.max.y))}return!Number.isFinite(t)||!Number.isFinite(n)?null:{minY:t,maxY:n}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch.point;if(this.type=="element"){let r=this.engine.interactionModule.getCatchMeshs(e);var n=this.getMeshesMinMaxY(r);this.catchDir==0?t.set(t.x,n?.minY,t.z):t.set(t.x,n?.maxY,t.z)}else t=e.catch.point;if(this.points.length==0){this.points.push(t);return}let i=this.engine.measure.annotationData.normalAnnotation.find(r=>r.isSelect==!0);i!=null&&(i.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);t==null&&(t={text:null,id:Ii(),isSelect:!0,type:"clear-height"},this.engine.measure.annotationData.normalAnnotation.push(t));let n=e.catch;if(this.type=="element"){let i=e.catch.point.clone();i.set(i.x,this.points[0].y,i.z);let r=new Qi(i.add(new P(0,.01,0)),new P(0,this.catchDir==0?-1:1,0));n.point=this.points[0];const a=this.engine.octreeBox.rayInterationModel(r);if(a.length===0){t.point2=null;return}t.point1=i,t.point2=a[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Yt.MeasureChanged,t)}else{let i=new Qi(e.catch.point.clone().add(new P(0,.01,0)),new P(0,this.catchDir==0?-1:1,0));const r=this.engine.octreeBox.rayInterationModel(i);if(r.length===0){t.point2=null;return}t.point1=n.point,t.point2=r[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Yt.MeasureChanged,t)}}}class Yw{engine;tools;isActive=!1;points=[];behavior;constructor(e){this.engine=e,this.tools=new Di(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.isActive=!1,this.engine.handelBehaved.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.points.push(t.point);else if(this.points.length==1){let n=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);if(n==null)return;n.point2=t.point,n.isSelect=!1,this.points=[],this.engine.events.trigger(Yt.MeasureChanged,n)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let n=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);n==null&&(n={id:Ii(),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(n)),n.point2=t.point,n.text=n.point1.clone().distanceTo(n.point2.clone())}}}class $w{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new Di(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;if(this.points.length==0){this.points.push(e.catch.point);return}let t=this.engine.measure.annotationData.normalAnnotation.find(n=>n.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:Ii(),isSelect:!0,type:"clear-distance"},this.engine.measure.annotationData.normalAnnotation.push(t));let n=new Qi(e.catch.point.clone().add(e.catch.face.normal.clone().setLength(.01)),e.catch.face.normal);const i=this.engine.octreeBox.rayInterationModel(n);if(i.length==0){t.point2=null;return}let r=e.catch;t.point1=r.point,t.point2=i[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Yt.MeasureChanged,t)}}class Kw{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new Di(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active(),this.isActive=!0;let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.elevationAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:Ii(),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;let t=this.engine.measure.annotationData.elevationAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1,t.point=e.catch.point.clone(),t.text=e.catch.point.y,this.engine.events.trigger(Yt.MeasureChanged,t))}}class Jw{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new Di(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active(),this.isActive=!0;let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseUp(e){this.engine.DeviceType!="PC"&&this.createMeasure()}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:Ii(),point:e.catch.point.clone(),text:Math.round(e.catch.point.y)+" m",isSelect:!0,type:"point"},this.engine.measure.annotationData.coordinateAnnotation.push(t)),t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z,console.log("有在移动")}handleMouseClick(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(n=>n.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,this.engine.events.trigger(Yt.MeasureChanged,t))}createMeasure(){let e=this.engine.measure.annotationData.coordinateAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1,this.engine.events.trigger(Yt.MeasureChanged,e))}}class Qw{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new Di(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateAngle(e,t,n){const i=new P().subVectors(e,t),r=new P().subVectors(n,t),a=i.length(),o=r.length();if(a===0||o===0)return 0;const l=i.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.points.push(t.point);else if(this.points.length==1)this.points.push(t.point);else if(this.points.length==2){let n=this.engine.measure.annotationData.angleAnnotation.find(i=>i.isSelect==!0);if(n==null)return;n.point3=t.point.clone(),n.angle=this.calculateAngle(n.point1,n.point2,n.point3),n.text=n.angle.toFixed(2)+"°",n.isSelect=!1,n.type="angle",this.points=[],this.engine.events.trigger(Yt.MeasureChanged,n)}}handleMouseMove(e){if(e.catch!=null&&this.points.length!=1&&this.points.length==2){let t=this.engine.measure.annotationData.angleAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:Ii(),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 eS{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new Di(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateArea(e){if(e.length<3)return 0;let t=0;const n=e.length;for(let i=0;i<n;i++){const r=(i+1)%n;t+=e[i].x*e[r].z,t-=e[r].x*e[i].z}return t=Math.abs(t)/2,t}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.push(t.point.clone()),this.points.length>=3){let n=this.engine.measure.annotationData.areaAnnotation.find(i=>i.isSelect==!0);n==null?(n={id:Ii(),points:this.points.map(i=>i.clone()),area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(n)):(this.points.push(t.point.clone()),n.points=this.points.map(i=>i.clone())),n.area=this.calculateArea(n.points),n.text=n.area,console.log("面积",n.text)}}handleMouseMove(e){if(e.catch!=null&&this.points.length>=2){let t=this.engine.measure.annotationData.areaAnnotation.find(n=>n.isSelect==!0);if(t==null){if(this.points.length>=2){let n=this.points.map(i=>i.clone());n.push(e.catch.point.clone()),n.length>=3&&(t={id:Ii(),points:n,area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(t))}}else if(t.points.length>0){const n=t.points.length-1;t.points[n]=e.catch.point.clone()}else t.points=this.points.map(n=>n.clone()),t.points.push(e.catch.point.clone());t&&t.points.length>=3&&(t.area=this.calculateArea(t.points),t.text=t.area)}}handelKeyEnterDown(){this.finishMeasure()}finishMeasure(){this.points=this.points.slice(0,this.points.length-1);let e=this.engine.measure.annotationData.areaAnnotation.find(t=>t.isSelect==!0);e!=null&&e.points.length>=3&&(e.points.length>this.points.length&&(e.points=this.points.map(t=>t.clone())),e.area=this.calculateArea(e.points),e.text=e.area,e.isSelect=!1,this.points=[],this.engine.events.trigger(Yt.MeasureChanged,e))}}class tS{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new Di(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateSlope(e,t){const n=t.y-e.y,i=t.x-e.x,r=t.z-e.z,a=Math.sqrt(i*i+r*r);if(a===0)return{percentage:0,angle:0,heightDiff:n,horizontalDist:0,type:"slope"};const o=n/a*100,l=Math.atan(n/a)*(180/Math.PI);return{percentage:o,angle:l,heightDiff:n,horizontalDist:a,type:"slope"}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.points.push(t.point);else if(this.points.length==1){let n=this.engine.measure.annotationData.slopeAnnotation.find(r=>r.isSelect==!0);if(n==null)return;console.log("进来了"),n.point2=t.point.clone();const i=this.calculateSlope(n.point1,n.point2);n.slopePercentage=i.percentage,n.slopeAngle=i.angle,n.heightDiff=i.heightDiff,n.horizontalDist=i.horizontalDist,n.text=i.percentage.toFixed(2)+"% ("+i.angle.toFixed(2)+"°)",n.isSelect=!1,this.points=[],this.engine.events.trigger(Yt.MeasureChanged,n)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let n=this.engine.measure.annotationData.slopeAnnotation.find(r=>r.isSelect==!0);n==null&&(n={id:Ii(),point1:this.points[0].clone(),point2:t.point.clone(),slopePercentage:0,slopeAngle:0,heightDiff:0,horizontalDist:0,text:"0.00% (0.00°)",isSelect:!0,type:"slope"},this.engine.measure.annotationData.slopeAnnotation.push(n)),n.point2=t.point.clone();const i=this.calculateSlope(n.point1,n.point2);n.slopePercentage=i.percentage,n.slopeAngle=i.angle,n.heightDiff=i.heightDiff,n.horizontalDist=i.horizontalDist,n.text=i.percentage.toFixed(2)+"% ("+i.angle.toFixed(2)+"°)"}}}class nS{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 Zw(e),this.distanceMeasure=new Yw(e),this.clearDistanceMeasure=new $w(e),this.elevationMeasure=new Kw(e),this.pointMeasure=new Jw(e),this.angleMeasure=new Qw(e),this.areaMeasure=new eS(e),this.slopeMeasure=new tS(e),this.tools=new Di(e),this.annotationContainer=document.createElement("div"),this.annotationContainer.className="annotation-container",e.container.appendChild(this.annotationContainer)}active(){this.isActive=!0,this.engine.modelEdge.loadModelEdge(),this.tools.active()}disActive(){this.tools.disActive(),this.clearAll(),this.isActive=!1,this.clearHeightMeasure.disActive(),this.distanceMeasure.disActive(),this.clearDistanceMeasure.disActive(),this.elevationMeasure.disActive(),this.pointMeasure.disActive(),this.angleMeasure.disActive(),this.areaMeasure.disActive(),this.slopeMeasure.disActive(),this.engine.interactionModule.init(),this.engine.interactionModule.active()}clearAllPoints(){this.clearHeightMeasure.clearAllPoints(),this.distanceMeasure.clearAllPoints(),this.clearDistanceMeasure.clearAllPoints(),this.elevationMeasure.clearAllPoints(),this.pointMeasure.clearAllPoints(),this.angleMeasure.clearAllPoints(),this.areaMeasure.clearAllPoints(),this.slopeMeasure.clearAllPoints()}clearAll(){e(this.annotationData.normalAnnotation),e(this.annotationData.textAnnotation),e(this.annotationData.coordinateAnnotation),e(this.annotationData.angleAnnotation),e(this.annotationData.distanceAnnotation),e(this.annotationData.areaAnnotation),e(this.annotationData.slopeAnnotation),e(this.annotationData.elevationAnnotation),e(this.annotationData.volumeAnnotation);function e(t){for(let n=0;n<t.length;n++)t[n].container.remove();t=[]}}saveSetting(e){this.tools.saveSetting(e)}getSetting(){return this.tools.getSetting()}update(){this.isActive&&this.tools.drawNormalAnnotation()}}const s0=0,iS=1,sS=2,r0=2,Ld=1.25,a0=1,fn=32,Kt=fn/4,o0=65535,rS=Math.pow(2,-24),Id=Symbol("SKIP_GENERATION");function aS(s){return s.index?s.index.count:s.attributes.position.count}function Ns(s){return aS(s)/3}function oS(s,e=ArrayBuffer){return s>65535?new Uint32Array(new e(4*s)):new Uint16Array(new e(2*s))}function lS(s,e){if(!s.index){const t=s.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=oS(t,n);s.setIndex(new bt(i,1));for(let r=0;r<t;r++)i[r]=r}}function l0(s,e){const t=Ns(s),n=e||s.drawRange,i=n.start/3,r=(n.start+n.count)/3,a=Math.max(0,i),o=Math.min(t,r)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function c0(s,e){if(!s.groups||!s.groups.length)return l0(s,e);const t=[],n=e||s.drawRange,i=n.start/3,r=(n.start+n.count)/3,a=Ns(s),o=[];for(const h of s.groups){const{start:d,count:p}=h,u=d/3,g=isFinite(p)?p:a*3-d,f=(d+g)/3;u<r&&f>i&&(o.push({pos:Math.max(i,u),isStart:!0}),o.push({pos:Math.min(r,f),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 Dd(s,e,t,n,i){let r=1/0,a=1/0,o=1/0,l=-1/0,c=-1/0,h=-1/0,d=1/0,p=1/0,u=1/0,g=-1/0,f=-1/0,x=-1/0;const m=s.offset||0;for(let b=(e-m)*6,v=(e+t-m)*6;b<v;b+=6){const y=s[b+0],_=s[b+1],M=y-_,T=y+_;M<r&&(r=M),T>l&&(l=T),y<d&&(d=y),y>g&&(g=y);const R=s[b+2],w=s[b+3],E=R-w,I=R+w;E<a&&(a=E),I>c&&(c=I),R<p&&(p=R),R>f&&(f=R);const A=s[b+4],B=s[b+5],S=A-B,U=A+B;S<o&&(o=S),U>h&&(h=U),A<u&&(u=A),A>x&&(x=A)}n[0]=r,n[1]=a,n[2]=o,n[3]=l,n[4]=c,n[5]=h,i[0]=d,i[1]=p,i[2]=u,i[3]=g,i[4]=f,i[5]=x}function h0(s,e,t=null,n=null,i=null){const r=s.attributes.position,a=s.index?s.index.array:null,o=r.normalized;if(i===null)i=new Float32Array(t*6),i.offset=e;else if(e<0||t+e>i.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"],p=i.offset;for(let u=e,g=e+t;u<g;u++){const f=(n?n[u]:u)*3,x=(u-p)*6;let m=f+0,b=f+1,v=f+2;a&&(m=a[m],b=a[b],v=a[v]),o||(m=m*h+c,b=b*h+c,v=v*h+c);for(let y=0;y<3;y++){let _,M,T;o?(_=r[d[y]](m),M=r[d[y]](b),T=r[d[y]](v)):(_=l[m+y],M=l[b+y],T=l[v+y]);let R=_;M<R&&(R=M),T<R&&(R=T);let w=_;M>w&&(w=M),T>w&&(w=T);const E=(w-R)/2,I=y*2;i[x+I+0]=R+E,i[x+I+1]=E+(Math.abs(R)+E)*rS}}return i}function Nt(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 d0(s){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=s[n+3]-s[n];i>t&&(t=i,e=n)}return e}function u0(s,e){e.set(s)}function p0(s,e,t){let n,i;for(let r=0;r<3;r++){const a=r+3;n=s[r],i=e[r],t[r]=n<i?n:i,n=s[a],i=e[a],t[a]=n>i?n:i}}function Sl(s,e,t){for(let n=0;n<3;n++){const i=e[s+2*n],r=e[s+2*n+1],a=i-r,o=i+r;a<t[n]&&(t[n]=a),o>t[n+3]&&(t[n+3]=o)}}function Ba(s){const e=s[3]-s[0],t=s[4]-s[1],n=s[5]-s[2];return 2*(e*t+t*n+n*e)}const Ni=32,cS=(s,e)=>s.candidate-e.candidate,is=new Array(Ni).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),El=new Float32Array(6);function hS(s,e,t,n,i,r){let a=-1,o=0;if(r===s0)a=d0(e),a!==-1&&(o=(e[a]+e[a+3])/2);else if(r===iS)a=d0(s),a!==-1&&(o=dS(t,n,i,a));else if(r===sS){const l=Ba(s);let c=Ld*i;const h=t.offset||0,d=(n-h)*6,p=(n+i-h)*6;for(let u=0;u<3;u++){const g=e[u],f=(e[u+3]-g)/Ni;if(i<Ni/4){const x=[...is];x.length=i;let m=0;for(let v=d;v<p;v+=6,m++){const y=x[m];y.candidate=t[v+2*u],y.count=0;const{bounds:_,leftCacheBounds:M,rightCacheBounds:T}=y;for(let R=0;R<3;R++)T[R]=1/0,T[R+3]=-1/0,M[R]=1/0,M[R+3]=-1/0,_[R]=1/0,_[R+3]=-1/0;Sl(v,t,_)}x.sort(cS);let b=i;for(let v=0;v<b;v++){const y=x[v];for(;v+1<b&&x[v+1].candidate===y.candidate;)x.splice(v+1,1),b--}for(let v=d;v<p;v+=6){const y=t[v+2*u];for(let _=0;_<b;_++){const M=x[_];y>=M.candidate?Sl(v,t,M.rightCacheBounds):(Sl(v,t,M.leftCacheBounds),M.count++)}}for(let v=0;v<b;v++){const y=x[v],_=y.count,M=i-y.count,T=y.leftCacheBounds,R=y.rightCacheBounds;let w=0;_!==0&&(w=Ba(T)/l);let E=0;M!==0&&(E=Ba(R)/l);const I=a0+Ld*(w*_+E*M);I<c&&(a=u,c=I,o=y.candidate)}}else{for(let b=0;b<Ni;b++){const v=is[b];v.count=0,v.candidate=g+f+b*f;const y=v.bounds;for(let _=0;_<3;_++)y[_]=1/0,y[_+3]=-1/0}for(let b=d;b<p;b+=6){let v=~~((t[b+2*u]-g)/f);v>=Ni&&(v=Ni-1);const y=is[v];y.count++,Sl(b,t,y.bounds)}const x=is[Ni-1];u0(x.bounds,x.rightCacheBounds);for(let b=Ni-2;b>=0;b--){const v=is[b],y=is[b+1];p0(v.bounds,y.rightCacheBounds,v.rightCacheBounds)}let m=0;for(let b=0;b<Ni-1;b++){const v=is[b],y=v.count,_=v.bounds,M=is[b+1].rightCacheBounds;y!==0&&(m===0?u0(_,El):p0(_,El,El)),m+=y;let T=0,R=0;m!==0&&(T=Ba(El)/l);const w=i-m;w!==0&&(R=Ba(M)/l);const E=a0+Ld*(T*m+R*w);E<c&&(a=u,c=E,o=v.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${r} used.`);return{axis:a,pos:o}}function dS(s,e,t,n){let i=0;const r=s.offset;for(let a=e,o=e+t;a<o;a++)i+=s[(a-r)*6+n*2];return i/t}class Nd{constructor(){this.boundingData=new Float32Array(6)}}function uS(s,e,t,n,i,r){let a=n,o=n+i-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 p=e[a*3+d];e[a*3+d]=e[o*3+d],e[o*3+d]=p}for(let d=0;d<6;d++){const p=a-h,u=o-h,g=t[p*6+d];t[p*6+d]=t[u*6+d],t[u*6+d]=g}a++,o--}else return a}}function pS(s,e,t,n,i,r){let a=n,o=n+i-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 p=0;p<6;p++){const u=a-h,g=o-h,f=t[u*6+p];t[u*6+p]=t[g*6+p],t[g*6+p]=f}a++,o--}else return a}}let f0,Cl,Bd,m0;const fS=Math.pow(2,32);function kd(s){return"count"in s?1:1+kd(s.left)+kd(s.right)}function mS(s,e,t){return f0=new Float32Array(t),Cl=new Uint32Array(t),Bd=new Uint16Array(t),m0=new Uint8Array(t),Ud(s,e)}function Ud(s,e){const t=s/4,n=s/2,i="count"in e,r=e.boundingData;for(let a=0;a<6;a++)f0[t+a]=r[a];if(i)return e.buffer?(m0.set(new Uint8Array(e.buffer),s),s+e.buffer.byteLength):(Cl[t+6]=e.offset,Bd[n+14]=e.count,Bd[n+15]=o0,s+fn);{const{left:a,right:o,splitAxis:l}=e,c=s+fn;let h=Ud(c,a);const d=s/fn,p=h/fn-d;if(p>fS)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return Cl[t+6]=p,Cl[t+7]=l,Ud(h,o)}}function gS(s,e,t){const n=(s.index?s.index.count:s.attributes.position.count)/3>65536,i=t.reduce((c,h)=>c+h.count,0),r=n?4:2,a=e?new SharedArrayBuffer(i*r):new ArrayBuffer(i*r),o=n?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 p=0;p<d;p++)o[l+p]=h+p;l+=d}return o}function xS(s,e,t,n,i){const{maxDepth:r,verbose:a,maxLeafTris:o,strategy:l,onProgress:c,indirect:h}=i,d=s._indirectBuffer,p=s.geometry,u=p.index?p.index.array:null,g=h?pS:uS,f=Ns(p),x=new Float32Array(6);let m=!1;const b=new Nd;return Dd(e,t,n,b.boundingData,x),y(b,t,n,x),b;function v(_){c&&c(_/f)}function y(_,M,T,R=null,w=0){if(!m&&w>=r&&(m=!0,a&&(console.warn(`MeshBVH: Max depth of ${r} reached when generating BVH. Consider increasing maxDepth.`),console.warn(p))),T<=o||w>=r)return v(M+T),_.offset=M,_.count=T,_;const E=hS(_.boundingData,R,e,M,T,l);if(E.axis===-1)return v(M+T),_.offset=M,_.count=T,_;const I=g(d,u,e,M,T,E);if(I===M||I===M+T)v(M+T),_.offset=M,_.count=T;else{_.splitAxis=E.axis;const A=new Nd,B=M,S=I-M;_.left=A,Dd(e,B,S,A.boundingData,x),y(A,B,S,x,w+1);const U=new Nd,H=I,G=T-S;_.right=U,Dd(e,H,G,U.boundingData,x),y(U,H,G,x,w+1)}return _}}function vS(s,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=s.geometry;let i,r;if(e.indirect){const a=c0(n,e.range),o=gS(n,e.useSharedArrayBuffer,a);s._indirectBuffer=o,i=h0(n,0,o.length,o),r=[{offset:0,count:o.length}]}else{lS(n,e);const a=l0(n,e.range)[0];i=h0(n,a.offset,a.count),r=c0(n,e.range)}s._roots=r.map(a=>{const o=xS(s,i,a.offset,a.count,e),l=kd(o),c=new t(fn*l);return mS(0,o,c),c})}class Bi{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let r=0,a=e.length;r<a;r++){const o=e[r][t];n=o<n?o:n,i=o>i?o:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let r=0,a=t.length;r<a;r++){const o=t[r],l=e.dot(o);n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}Bi.prototype.setFromBox=(function(){const s=new P;return function(e,t){const n=t.min,i=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=n.x*o+i.x*(1-o),s.y=n.y*l+i.y*(1-l),s.z=n.z*c+i.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 bS=(function(){const s=new P,e=new P,t=new P;return function(n,i,r){const a=n.start,o=s,l=i.start,c=e;t.subVectors(a,l),s.subVectors(n.end,n.start),e.subVectors(i.end,i.start);const h=t.dot(c),d=c.dot(o),p=c.dot(c),u=t.dot(o),g=o.dot(o)*p-d*d;let f,x;g!==0?f=(h*d-u*p)/g:f=0,x=(h+f*d)/p,r.x=f,r.y=x}})(),Od=(function(){const s=new he,e=new P,t=new P;return function(n,i,r,a){bS(n,i,s);let o=s.x,l=s.y;if(o>=0&&o<=1&&l>=0&&l<=1){n.at(o,r),i.at(l,a);return}else if(o>=0&&o<=1){l<0?i.at(0,a):i.at(1,a),n.closestPointToPoint(a,!0,r);return}else if(l>=0&&l<=1){o<0?n.at(0,r):n.at(1,r),i.closestPointToPoint(r,!0,a);return}else{let c;o<0?c=n.start:c=n.end;let h;l<0?h=i.start:h=i.end;const d=e,p=t;if(n.closestPointToPoint(h,!0,e),i.closestPointToPoint(c,!0,t),d.distanceToSquared(h)<=p.distanceToSquared(c)){r.copy(d),a.copy(h);return}else{r.copy(c),a.copy(p);return}}}})(),yS=(function(){const s=new P,e=new P,t=new It,n=new Vn;return function(i,r){const{radius:a,center:o}=i,{a:l,b:c,c:h}=r;if(n.start=l,n.end=c,n.closestPointToPoint(o,!0,s).distanceTo(o)<=a||(n.start=l,n.end=h,n.closestPointToPoint(o,!0,s).distanceTo(o)<=a)||(n.start=c,n.end=h,n.closestPointToPoint(o,!0,s).distanceTo(o)<=a))return!0;const d=r.getPlane(t);if(Math.abs(d.distanceToPoint(o))<=a){const p=d.projectPoint(o,e);if(r.containsPoint(p))return!0}return!1}})(),_S=["x","y","z"],ki=1e-15,g0=ki*ki;function Wn(s){return Math.abs(s)<ki}class Xn extends vt{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new P),this.satBounds=new Array(4).fill().map(()=>new Bi),this.points=[this.a,this.b,this.c],this.plane=new It,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new Vn,this.needsUpdate=!0}intersectsSphere(e){return yS(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,r=this.satAxes,a=this.satBounds,o=r[0],l=a[0];this.getNormal(o),l.setFromPoints(o,i);const c=r[1],h=a[1];c.subVectors(e,t),h.setFromPoints(c,i);const d=r[2],p=a[2];d.subVectors(t,n),p.setFromPoints(d,i);const u=r[3],g=a[3];u.subVectors(n,e),g.setFromPoints(u,i);const f=c.length(),x=d.length(),m=u.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,f<ki?x<ki||m<ki?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):x<ki?m<ki?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):m<ki&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}Xn.prototype.closestPointToSegment=(function(){const s=new P,e=new P,t=new Vn;return function(n,i=null,r=null){const{start:a,end:o}=n,l=this.points;let c,h=1/0;for(let d=0;d<3;d++){const p=(d+1)%3;t.start.copy(l[d]),t.end.copy(l[p]),Od(t,n,s,e),c=s.distanceToSquared(e),c<h&&(h=c,i&&i.copy(s),r&&r.copy(e))}return this.closestPointToPoint(a,s),c=a.distanceToSquared(s),c<h&&(h=c,i&&i.copy(s),r&&r.copy(a)),this.closestPointToPoint(o,s),c=o.distanceToSquared(s),c<h&&(h=c,i&&i.copy(s),r&&r.copy(o)),Math.sqrt(h)}})(),Xn.prototype.intersectsTriangle=(function(){const s=new Xn,e=new Bi,t=new Bi,n=new P,i=new P,r=new P,a=new P,o=new Vn,l=new Vn,c=new P,h=new he,d=new he;function p(v,y,_,M){const T=n;!v.isDegenerateIntoPoint&&!v.isDegenerateIntoSegment?T.copy(v.plane.normal):T.copy(y.plane.normal);const R=v.satBounds,w=v.satAxes;for(let A=1;A<4;A++){const B=R[A],S=w[A];if(e.setFromPoints(S,y.points),B.isSeparated(e)||(a.copy(T).cross(S),e.setFromPoints(a,v.points),t.setFromPoints(a,y.points),e.isSeparated(t)))return!1}const E=y.satBounds,I=y.satAxes;for(let A=1;A<4;A++){const B=E[A],S=I[A];if(e.setFromPoints(S,v.points),B.isSeparated(e)||(a.crossVectors(T,S),e.setFromPoints(a,v.points),t.setFromPoints(a,y.points),e.isSeparated(t)))return!1}return _&&(M||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),_.start.set(0,0,0),_.end.set(0,0,0)),!0}function u(v,y,_,M,T,R,w,E,I,A,B){let S=w/(w-E);A.x=M+(T-M)*S,B.start.subVectors(y,v).multiplyScalar(S).add(v),S=w/(w-I),A.y=M+(R-M)*S,B.end.subVectors(_,v).multiplyScalar(S).add(v)}function g(v,y,_,M,T,R,w,E,I,A,B){if(T>0)u(v.c,v.a,v.b,M,y,_,I,w,E,A,B);else if(R>0)u(v.b,v.a,v.c,_,y,M,E,w,I,A,B);else if(E*I>0||w!=0)u(v.a,v.b,v.c,y,_,M,w,E,I,A,B);else if(E!=0)u(v.b,v.a,v.c,_,y,M,E,w,I,A,B);else if(I!=0)u(v.c,v.a,v.b,M,y,_,I,w,E,A,B);else return!0;return!1}function f(v,y,_,M){const T=y.degenerateSegment,R=v.plane.distanceToPoint(T.start),w=v.plane.distanceToPoint(T.end);return Wn(R)?Wn(w)?p(v,y,_,M):(_&&(_.start.copy(T.start),_.end.copy(T.start)),v.containsPoint(T.start)):Wn(w)?(_&&(_.start.copy(T.end),_.end.copy(T.end)),v.containsPoint(T.end)):v.plane.intersectLine(T,n)!=null?(_&&(_.start.copy(n),_.end.copy(n)),v.containsPoint(n)):!1}function x(v,y,_){const M=y.a;return Wn(v.plane.distanceToPoint(M))&&v.containsPoint(M)?(_&&(_.start.copy(M),_.end.copy(M)),!0):!1}function m(v,y,_){const M=v.degenerateSegment,T=y.a;return M.closestPointToPoint(T,!0,n),T.distanceToSquared(n)<g0?(_&&(_.start.copy(T),_.end.copy(T)),!0):!1}function b(v,y,_,M){if(v.isDegenerateIntoSegment)if(y.isDegenerateIntoSegment){const T=v.degenerateSegment,R=y.degenerateSegment,w=i,E=r;T.delta(w),R.delta(E);const I=n.subVectors(R.start,T.start),A=w.x*E.y-w.y*E.x;if(Wn(A))return!1;const B=(I.x*E.y-I.y*E.x)/A,S=-(w.x*I.y-w.y*I.x)/A;if(B<0||B>1||S<0||S>1)return!1;const U=T.start.z+w.z*B,H=R.start.z+E.z*S;return Wn(U-H)?(_&&(_.start.copy(T.start).addScaledVector(w,B),_.end.copy(T.start).addScaledVector(w,B)),!0):!1}else return y.isDegenerateIntoPoint?m(v,y,_):f(y,v,_,M);else{if(v.isDegenerateIntoPoint)return y.isDegenerateIntoPoint?y.a.distanceToSquared(v.a)<g0?(_&&(_.start.copy(v.a),_.end.copy(v.a)),!0):!1:y.isDegenerateIntoSegment?m(y,v,_):x(y,v,_);if(y.isDegenerateIntoPoint)return x(v,y,_);if(y.isDegenerateIntoSegment)return f(v,y,_,M)}}return function(v,y=null,_=!1){this.needsUpdate&&this.update(),v.isExtendedTriangle?v.needsUpdate&&v.update():(s.copy(v),s.update(),v=s);const M=b(this,v,y,_);if(M!==void 0)return M;const T=this.plane,R=v.plane;let w=R.distanceToPoint(this.a),E=R.distanceToPoint(this.b),I=R.distanceToPoint(this.c);Wn(w)&&(w=0),Wn(E)&&(E=0),Wn(I)&&(I=0);const A=w*E,B=w*I;if(A>0&&B>0)return!1;let S=T.distanceToPoint(v.a),U=T.distanceToPoint(v.b),H=T.distanceToPoint(v.c);Wn(S)&&(S=0),Wn(U)&&(U=0),Wn(H)&&(H=0);const G=S*U,Z=S*H;if(G>0&&Z>0)return!1;i.copy(T.normal),r.copy(R.normal);const j=i.cross(r);let ie=0,X=Math.abs(j.x);const $=Math.abs(j.y);$>X&&(X=$,ie=1),Math.abs(j.z)>X&&(ie=2);const ue=_S[ie],pe=this.a[ue],fe=this.b[ue],se=this.c[ue],ce=v.a[ue],me=v.b[ue],be=v.c[ue];if(g(this,pe,fe,se,A,B,w,E,I,h,o))return p(this,v,y,_);if(g(v,ce,me,be,G,Z,S,U,H,d,l))return p(this,v,y,_);if(h.y<h.x){const Se=h.y;h.y=h.x,h.x=Se,c.copy(o.start),o.start.copy(o.end),o.end.copy(c)}if(d.y<d.x){const Se=d.y;d.y=d.x,d.x=Se,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)}})(),Xn.prototype.distanceToPoint=(function(){const s=new P;return function(e){return this.closestPointToPoint(e,s),e.distanceTo(s)}})(),Xn.prototype.distanceToTriangle=(function(){const s=new P,e=new P,t=["a","b","c"],n=new Vn,i=new Vn;return function(r,a=null,o=null){const l=a||o?n: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 p=t[h],u=r[p];this.closestPointToPoint(u,s),d=u.distanceToSquared(s),d<c&&(c=d,a&&a.copy(s),o&&o.copy(u));const g=this[p];r.closestPointToPoint(g,s),d=g.distanceToSquared(s),d<c&&(c=d,a&&a.copy(g),o&&o.copy(s))}for(let h=0;h<3;h++){const d=t[h],p=t[(h+1)%3];n.set(this[d],this[p]);for(let u=0;u<3;u++){const g=t[u],f=t[(u+1)%3];i.set(r[g],r[f]),Od(n,i,s,e);const x=s.distanceToSquared(e);x<c&&(c=x,a&&a.copy(s),o&&o.copy(e))}}return Math.sqrt(c)}})();class mn{constructor(e,t,n){this.isOrientedBox=!0,this.min=new P,this.max=new P,this.matrix=new Ie,this.invMatrix=new Ie,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 Bi),this.alignedSatBounds=new Array(3).fill().map(()=>new Bi),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}mn.prototype.update=(function(){return function(){const s=this.matrix,e=this.min,t=this.max,n=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,p=n[d];p.x=l?t.x:e.x,p.y=c?t.y:e.y,p.z=h?t.z:e.z,p.applyMatrix4(s)}const i=this.satBounds,r=this.satAxes,a=n[0];for(let l=0;l<3;l++){const c=r[l],h=i[l],d=1<<l,p=n[d];c.subVectors(a,p),h.setFromPoints(c,n)}const o=this.alignedSatBounds;o[0].setFromPointsField(n,"x"),o[1].setFromPointsField(n,"y"),o[2].setFromPointsField(n,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})(),mn.prototype.intersectsBox=(function(){const s=new Bi;return function(e){this.needsUpdate&&this.update();const t=e.min,n=e.max,i=this.satBounds,r=this.satAxes,a=this.alignedSatBounds;if(s.min=t.x,s.max=n.x,a[0].isSeparated(s)||(s.min=t.y,s.max=n.y,a[1].isSeparated(s))||(s.min=t.z,s.max=n.z,a[2].isSeparated(s)))return!1;for(let o=0;o<3;o++){const l=r[o],c=i[o];if(s.setFromBox(l,e),c.isSeparated(s))return!1}return!0}})(),mn.prototype.intersectsTriangle=(function(){const s=new Xn,e=new Array(3),t=new Bi,n=new Bi,i=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 p=a[d],u=o[d];if(t.setFromPoints(u,e),p.isSeparated(t))return!1}const l=r.satBounds,c=r.satAxes,h=this.points;for(let d=0;d<3;d++){const p=l[d],u=c[d];if(t.setFromPoints(u,h),p.isSeparated(t))return!1}for(let d=0;d<3;d++){const p=o[d];for(let u=0;u<4;u++){const g=c[u];if(i.crossVectors(p,g),t.setFromPoints(i,e),n.setFromPoints(i,h),t.isSeparated(n))return!1}}return!0}})(),mn.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}})(),mn.prototype.distanceToPoint=(function(){const s=new P;return function(e){return this.closestPointToPoint(e,s),e.distanceTo(s)}})(),mn.prototype.distanceToBox=(function(){const s=["x","y","z"],e=new Array(12).fill().map(()=>new Vn),t=new Array(12).fill().map(()=>new Vn),n=new P,i=new P;return function(r,a=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(r))return(o||l)&&(r.getCenter(i),this.closestPointToPoint(i,n),r.closestPointToPoint(n,i),o&&o.copy(n),l&&l.copy(i)),0;const c=a*a,h=r.min,d=r.max,p=this.points;let u=1/0;for(let f=0;f<8;f++){const x=p[f];i.copy(x).clamp(h,d);const m=x.distanceToSquared(i);if(m<u&&(u=m,o&&o.copy(x),l&&l.copy(i),m<c))return Math.sqrt(m)}let g=0;for(let f=0;f<3;f++)for(let x=0;x<=1;x++)for(let m=0;m<=1;m++){const b=(f+1)%3,v=(f+2)%3,y=x<<b|m<<v,_=1<<f|x<<b|m<<v,M=p[y],T=p[_];e[g].set(M,T);const R=s[f],w=s[b],E=s[v],I=t[g],A=I.start,B=I.end;A[R]=h[R],A[w]=x?h[w]:d[w],A[E]=m?h[E]:d[w],B[R]=d[R],B[w]=x?h[w]:d[w],B[E]=m?h[E]:d[w],g++}for(let f=0;f<=1;f++)for(let x=0;x<=1;x++)for(let m=0;m<=1;m++){i.x=f?d.x:h.x,i.y=x?d.y:h.y,i.z=m?d.z:h.z,this.closestPointToPoint(i,n);const b=i.distanceToSquared(n);if(b<u&&(u=b,o&&o.copy(n),l&&l.copy(i),b<c))return Math.sqrt(b)}for(let f=0;f<12;f++){const x=e[f];for(let m=0;m<12;m++){const b=t[m];Od(x,b,n,i);const v=n.distanceToSquared(i);if(v<u&&(u=v,o&&o.copy(n),l&&l.copy(i),v<c))return Math.sqrt(v)}}return Math.sqrt(u)}})();class zd{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 MS extends zd{constructor(){super(()=>new Xn)}}const jn=new MS;function Jt(s,e){return e[s+15]===o0}function Dn(s,e){return e[s+6]}function qn(s,e){return e[s+14]}function tn(s){return s+Kt}function nn(s,e){const t=e[s+6];return s+t*Kt}function Fd(s,e){return e[s+7]}class wS{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const _t=new wS;let ss,Or;const zr=[],Tl=new zd(()=>new ut);function SS(s,e,t,n,i,r){ss=Tl.getPrimitive(),Or=Tl.getPrimitive(),zr.push(ss,Or),_t.setBuffer(s._roots[e]);const a=Hd(0,s.geometry,t,n,i,r);_t.clearBuffer(),Tl.releasePrimitive(ss),Tl.releasePrimitive(Or),zr.pop(),zr.pop();const o=zr.length;return o>0&&(Or=zr[o-1],ss=zr[o-2]),a}function Hd(s,e,t,n,i=null,r=0,a=0){const{float32Array:o,uint16Array:l,uint32Array:c}=_t;let h=s*2;if(Jt(h,l)){const d=Dn(s,c),p=qn(h,l);return Nt(s,o,ss),n(d,p,!1,a,r+s/Kt,ss)}else{let d=function(I){const{uint16Array:A,uint32Array:B}=_t;let S=I*2;for(;!Jt(S,A);)I=tn(I),S=I*2;return Dn(I,B)},p=function(I){const{uint16Array:A,uint32Array:B}=_t;let S=I*2;for(;!Jt(S,A);)I=nn(I,B),S=I*2;return Dn(I,B)+qn(S,A)};const u=tn(s),g=nn(s,c);let f=u,x=g,m,b,v,y;if(i&&(v=ss,y=Or,Nt(f,o,v),Nt(x,o,y),m=i(v),b=i(y),b<m)){f=g,x=u;const I=m;m=b,b=I,v=y}v||(v=ss,Nt(f,o,v));const _=Jt(f*2,l),M=t(v,_,m,a+1,r+f/Kt);let T;if(M===r0){const I=d(f),A=p(f)-I;T=n(I,A,!0,a+1,r+f/Kt,v)}else T=M&&Hd(f,e,t,n,i,r,a+1);if(T)return!0;y=Or,Nt(x,o,y);const R=Jt(x*2,l),w=t(y,R,b,a+1,r+x/Kt);let E;if(w===r0){const I=d(x),A=p(x)-I;E=n(I,A,!0,a+1,r+x/Kt,y)}else E=w&&Hd(x,e,t,n,i,r,a+1);return!!E}}const ka=new P,Vd=new P;function ES(s,e,t={},n=0,i=1/0){const r=n*n,a=i*i;let o=1/0,l=null;if(s.shapecast({boundsTraverseOrder:h=>(ka.copy(e).clamp(h.min,h.max),ka.distanceToSquared(e)),intersectsBounds:(h,d,p)=>p<o&&p<a,intersectsTriangle:(h,d)=>{h.closestPointToPoint(e,ka);const p=e.distanceToSquared(ka);return p<o&&(Vd.copy(ka),o=p,l=d),p<r}}),o===1/0)return null;const c=Math.sqrt(o);return t.point?t.point.copy(Vd):t.point=Vd.clone(),t.distance=c,t.faceIndex=l,t}const Al=parseInt(Yr)>=169,CS=parseInt(Yr)<=161,Bs=new P,ks=new P,Us=new P,Pl=new he,Rl=new he,Ll=new he,x0=new P,v0=new P,b0=new P,Ua=new P;function TS(s,e,t,n,i,r,a,o){let l;if(r===sn?l=s.intersectTriangle(n,t,e,!0,i):l=s.intersectTriangle(e,t,n,r!==yt,i),l===null)return null;const c=s.origin.distanceTo(i);return c<a||c>o?null:{distance:c,point:i.clone()}}function y0(s,e,t,n,i,r,a,o,l,c,h){Bs.fromBufferAttribute(e,r),ks.fromBufferAttribute(e,a),Us.fromBufferAttribute(e,o);const d=TS(s,Bs,ks,Us,Ua,l,c,h);if(d){if(n){Pl.fromBufferAttribute(n,r),Rl.fromBufferAttribute(n,a),Ll.fromBufferAttribute(n,o),d.uv=new he;const u=vt.getInterpolation(Ua,Bs,ks,Us,Pl,Rl,Ll,d.uv);Al||(d.uv=u)}if(i){Pl.fromBufferAttribute(i,r),Rl.fromBufferAttribute(i,a),Ll.fromBufferAttribute(i,o),d.uv1=new he;const u=vt.getInterpolation(Ua,Bs,ks,Us,Pl,Rl,Ll,d.uv1);Al||(d.uv1=u),CS&&(d.uv2=d.uv1)}if(t){x0.fromBufferAttribute(t,r),v0.fromBufferAttribute(t,a),b0.fromBufferAttribute(t,o),d.normal=new P;const u=vt.getInterpolation(Ua,Bs,ks,Us,x0,v0,b0,d.normal);d.normal.dot(s.direction)>0&&d.normal.multiplyScalar(-1),Al||(d.normal=u)}const p={a:r,b:a,c:o,normal:new P,materialIndex:0};if(vt.getNormal(Bs,ks,Us,p.normal),d.face=p,d.faceIndex=r,Al){const u=new P;vt.getBarycoord(Ua,Bs,ks,Us,u),d.barycoord=u}}return d}function _0(s){return s&&s.isMaterial?s.side:s}function Il(s,e,t,n,i,r,a){const o=n*3;let l=o+0,c=o+1,h=o+2;const{index:d,groups:p}=s;s.index&&(l=d.getX(l),c=d.getX(c),h=d.getX(h));const{position:u,normal:g,uv:f,uv1:x}=s.attributes;if(Array.isArray(e)){const m=n*3;for(let b=0,v=p.length;b<v;b++){const{start:y,count:_,materialIndex:M}=p[b];if(m>=y&&m<y+_){const T=_0(e[M]),R=y0(t,u,g,f,x,l,c,h,T,r,a);if(R)if(R.faceIndex=n,R.face.materialIndex=M,i)i.push(R);else return R}}}else{const m=_0(e),b=y0(t,u,g,f,x,l,c,h,m,r,a);if(b)if(b.faceIndex=n,b.face.materialIndex=0,i)i.push(b);else return b}return null}function Wt(s,e,t,n){const i=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)),i.x=n.getX(o),i.y=n.getY(o),i.z=n.getZ(o),r.x=n.getX(l),r.y=n.getY(l),r.z=n.getZ(l),a.x=n.getX(c),a.y=n.getY(c),a.z=n.getZ(c)}function AS(s,e,t,n,i,r,a,o){const{geometry:l,_indirectBuffer:c}=s;for(let h=n,d=n+i;h<d;h++)Il(l,e,t,h,r,a,o)}function PS(s,e,t,n,i,r,a){const{geometry:o,_indirectBuffer:l}=s;let c=1/0,h=null;for(let d=n,p=n+i;d<p;d++){let u;u=Il(o,e,t,d,null,r,a),u&&u.distance<c&&(h=u,c=u.distance)}return h}function RS(s,e,t,n,i,r,a){const{geometry:o}=t,{index:l}=o,c=o.attributes.position;for(let h=s,d=e+s;h<d;h++){let p;if(p=h,Wt(a,p*3,l,c),a.needsUpdate=!0,n(a,p,i,r))return!0}return!1}function LS(s,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=s.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let r,a,o,l,c=0;const h=s._roots;for(let p=0,u=h.length;p<u;p++)r=h[p],a=new Uint32Array(r),o=new Uint16Array(r),l=new Float32Array(r),d(0,c),c+=r.byteLength;function d(p,u,g=!1){const f=p*2;if(Jt(f,o)){const x=a[p+6],m=o[f+14];let b=1/0,v=1/0,y=1/0,_=-1/0,M=-1/0,T=-1/0;for(let R=3*x,w=3*(x+m);R<w;R++){let E=n[R];const I=i.getX(E),A=i.getY(E),B=i.getZ(E);I<b&&(b=I),I>_&&(_=I),A<v&&(v=A),A>M&&(M=A),B<y&&(y=B),B>T&&(T=B)}return l[p+0]!==b||l[p+1]!==v||l[p+2]!==y||l[p+3]!==_||l[p+4]!==M||l[p+5]!==T?(l[p+0]=b,l[p+1]=v,l[p+2]=y,l[p+3]=_,l[p+4]=M,l[p+5]=T,!0):!1}else{const x=tn(p),m=nn(p,a);let b=g,v=!1,y=!1;if(e){if(!b){const E=x/Kt+u/fn,I=m/Kt+u/fn;v=e.has(E),y=e.has(I),b=!v&&!y}}else v=!0,y=!0;const _=b||v,M=b||y;let T=!1;_&&(T=d(x,u,b));let R=!1;M&&(R=d(m,u,b));const w=T||R;if(w)for(let E=0;E<3;E++){const I=x+E,A=m+E,B=l[I],S=l[I+3],U=l[A],H=l[A+3];l[p+E]=B<U?B:U,l[p+E+3]=S>H?S:H}return w}}}function rs(s,e,t,n,i){let r,a,o,l,c,h;const d=1/t.direction.x,p=1/t.direction.y,u=1/t.direction.z,g=t.origin.x,f=t.origin.y,x=t.origin.z;let m=e[s],b=e[s+3],v=e[s+1],y=e[s+3+1],_=e[s+2],M=e[s+3+2];return d>=0?(r=(m-g)*d,a=(b-g)*d):(r=(b-g)*d,a=(m-g)*d),p>=0?(o=(v-f)*p,l=(y-f)*p):(o=(y-f)*p,l=(v-f)*p),r>l||o>a||((o>r||isNaN(r))&&(r=o),(l<a||isNaN(a))&&(a=l),u>=0?(c=(_-x)*u,h=(M-x)*u):(c=(M-x)*u,h=(_-x)*u),r>h||c>a)?!1:((c>r||r!==r)&&(r=c),(h<a||a!==a)&&(a=h),r<=i&&a>=n)}function IS(s,e,t,n,i,r,a,o){const{geometry:l,_indirectBuffer:c}=s;for(let h=n,d=n+i;h<d;h++){let p=c?c[h]:h;Il(l,e,t,p,r,a,o)}}function DS(s,e,t,n,i,r,a){const{geometry:o,_indirectBuffer:l}=s;let c=1/0,h=null;for(let d=n,p=n+i;d<p;d++){let u;u=Il(o,e,t,l?l[d]:d,null,r,a),u&&u.distance<c&&(h=u,c=u.distance)}return h}function NS(s,e,t,n,i,r,a){const{geometry:o}=t,{index:l}=o,c=o.attributes.position;for(let h=s,d=e+s;h<d;h++){let p;if(p=t.resolveTriangleIndex(h),Wt(a,p*3,l,c),a.needsUpdate=!0,n(a,p,i,r))return!0}return!1}function BS(s,e,t,n,i,r,a){_t.setBuffer(s._roots[e]),Gd(0,s,t,n,i,r,a),_t.clearBuffer()}function Gd(s,e,t,n,i,r,a){const{float32Array:o,uint16Array:l,uint32Array:c}=_t,h=s*2;if(Jt(h,l)){const d=Dn(s,c),p=qn(h,l);AS(e,t,n,d,p,i,r,a)}else{const d=tn(s);rs(d,o,n,r,a)&&Gd(d,e,t,n,i,r,a);const p=nn(s,c);rs(p,o,n,r,a)&&Gd(p,e,t,n,i,r,a)}}const kS=["x","y","z"];function US(s,e,t,n,i,r){_t.setBuffer(s._roots[e]);const a=Wd(0,s,t,n,i,r);return _t.clearBuffer(),a}function Wd(s,e,t,n,i,r){const{float32Array:a,uint16Array:o,uint32Array:l}=_t;let c=s*2;if(Jt(c,o)){const h=Dn(s,l),d=qn(c,o);return PS(e,t,n,h,d,i,r)}else{const h=Fd(s,l),d=kS[h],p=n.direction[d]>=0;let u,g;p?(u=tn(s),g=nn(s,l)):(u=nn(s,l),g=tn(s));const f=rs(u,a,n,i,r)?Wd(u,e,t,n,i,r):null;if(f){const m=f.point[d];if(p?m<=a[g+h]:m>=a[g+h+3])return f}const x=rs(g,a,n,i,r)?Wd(g,e,t,n,i,r):null;return f&&x?f.distance<=x.distance?f:x:f||x||null}}const Dl=new ut,Fr=new Xn,Hr=new Xn,Oa=new Ie,M0=new mn,Nl=new mn;function OS(s,e,t,n){_t.setBuffer(s._roots[e]);const i=Xd(0,s,t,n);return _t.clearBuffer(),i}function Xd(s,e,t,n,i=null){const{float32Array:r,uint16Array:a,uint32Array:o}=_t;let l=s*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),M0.set(t.boundingBox.min,t.boundingBox.max,n),i=M0),Jt(l,a)){const c=e.geometry,h=c.index,d=c.attributes.position,p=t.index,u=t.attributes.position,g=Dn(s,o),f=qn(l,a);if(Oa.copy(n).invert(),t.boundsTree)return Nt(s,r,Nl),Nl.matrix.copy(Oa),Nl.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>Nl.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(n),x.b.applyMatrix4(n),x.c.applyMatrix4(n),x.needsUpdate=!0;for(let m=g*3,b=(f+g)*3;m<b;m+=3)if(Wt(Hr,m,h,d),Hr.needsUpdate=!0,x.intersectsTriangle(Hr))return!0;return!1}});{const x=Ns(t);for(let m=g*3,b=(f+g)*3;m<b;m+=3){Wt(Fr,m,h,d),Fr.a.applyMatrix4(Oa),Fr.b.applyMatrix4(Oa),Fr.c.applyMatrix4(Oa),Fr.needsUpdate=!0;for(let v=0,y=x*3;v<y;v+=3)if(Wt(Hr,v,p,u),Hr.needsUpdate=!0,Fr.intersectsTriangle(Hr))return!0}}}else{const c=tn(s),h=nn(s,o);return Nt(c,r,Dl),!!(i.intersectsBox(Dl)&&Xd(c,e,t,n,i)||(Nt(h,r,Dl),i.intersectsBox(Dl)&&Xd(h,e,t,n,i)))}}const Bl=new Ie,jd=new mn,za=new mn,zS=new P,FS=new P,HS=new P,VS=new P;function GS(s,e,t,n={},i={},r=0,a=1/0){e.boundingBox||e.computeBoundingBox(),jd.set(e.boundingBox.min,e.boundingBox.max,t),jd.needsUpdate=!0;const o=s.geometry,l=o.attributes.position,c=o.index,h=e.attributes.position,d=e.index,p=jn.getPrimitive(),u=jn.getPrimitive();let g=zS,f=FS,x=null,m=null;i&&(x=HS,m=VS);let b=1/0,v=null,y=null;return Bl.copy(t).invert(),za.matrix.copy(Bl),s.shapecast({boundsTraverseOrder:_=>jd.distanceToBox(_),intersectsBounds:(_,M,T)=>T<b&&T<a?(M&&(za.min.copy(_.min),za.max.copy(_.max),za.needsUpdate=!0),!0):!1,intersectsRange:(_,M)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:T=>za.distanceToBox(T),intersectsBounds:(T,R,w)=>w<b&&w<a,intersectsRange:(T,R)=>{for(let w=T,E=T+R;w<E;w++){Wt(u,3*w,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let I=_,A=_+M;I<A;I++){Wt(p,3*I,c,l),p.needsUpdate=!0;const B=p.distanceToTriangle(u,g,x);if(B<b&&(f.copy(g),m&&m.copy(x),b=B,v=I,y=w),B<r)return!0}}}});{const T=Ns(e);for(let R=0,w=T;R<w;R++){Wt(u,3*R,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let E=_,I=_+M;E<I;E++){Wt(p,3*E,c,l),p.needsUpdate=!0;const A=p.distanceToTriangle(u,g,x);if(A<b&&(f.copy(g),m&&m.copy(x),b=A,v=E,y=R),A<r)return!0}}}}}),jn.releasePrimitive(p),jn.releasePrimitive(u),b===1/0?null:(n.point?n.point.copy(f):n.point=f.clone(),n.distance=b,n.faceIndex=v,i&&(i.point?i.point.copy(m):i.point=m.clone(),i.point.applyMatrix4(Bl),f.applyMatrix4(Bl),i.distance=f.sub(i.point).length(),i.faceIndex=y),n)}function WS(s,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=s.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let r,a,o,l,c=0;const h=s._roots;for(let p=0,u=h.length;p<u;p++)r=h[p],a=new Uint32Array(r),o=new Uint16Array(r),l=new Float32Array(r),d(0,c),c+=r.byteLength;function d(p,u,g=!1){const f=p*2;if(Jt(f,o)){const x=a[p+6],m=o[f+14];let b=1/0,v=1/0,y=1/0,_=-1/0,M=-1/0,T=-1/0;for(let R=x,w=x+m;R<w;R++){const E=3*s.resolveTriangleIndex(R);for(let I=0;I<3;I++){let A=E+I;A=n?n[A]:A;const B=i.getX(A),S=i.getY(A),U=i.getZ(A);B<b&&(b=B),B>_&&(_=B),S<v&&(v=S),S>M&&(M=S),U<y&&(y=U),U>T&&(T=U)}}return l[p+0]!==b||l[p+1]!==v||l[p+2]!==y||l[p+3]!==_||l[p+4]!==M||l[p+5]!==T?(l[p+0]=b,l[p+1]=v,l[p+2]=y,l[p+3]=_,l[p+4]=M,l[p+5]=T,!0):!1}else{const x=tn(p),m=nn(p,a);let b=g,v=!1,y=!1;if(e){if(!b){const E=x/Kt+u/fn,I=m/Kt+u/fn;v=e.has(E),y=e.has(I),b=!v&&!y}}else v=!0,y=!0;const _=b||v,M=b||y;let T=!1;_&&(T=d(x,u,b));let R=!1;M&&(R=d(m,u,b));const w=T||R;if(w)for(let E=0;E<3;E++){const I=x+E,A=m+E,B=l[I],S=l[I+3],U=l[A],H=l[A+3];l[p+E]=B<U?B:U,l[p+E+3]=S>H?S:H}return w}}}function XS(s,e,t,n,i,r,a){_t.setBuffer(s._roots[e]),qd(0,s,t,n,i,r,a),_t.clearBuffer()}function qd(s,e,t,n,i,r,a){const{float32Array:o,uint16Array:l,uint32Array:c}=_t,h=s*2;if(Jt(h,l)){const d=Dn(s,c),p=qn(h,l);IS(e,t,n,d,p,i,r,a)}else{const d=tn(s);rs(d,o,n,r,a)&&qd(d,e,t,n,i,r,a);const p=nn(s,c);rs(p,o,n,r,a)&&qd(p,e,t,n,i,r,a)}}const jS=["x","y","z"];function qS(s,e,t,n,i,r){_t.setBuffer(s._roots[e]);const a=Zd(0,s,t,n,i,r);return _t.clearBuffer(),a}function Zd(s,e,t,n,i,r){const{float32Array:a,uint16Array:o,uint32Array:l}=_t;let c=s*2;if(Jt(c,o)){const h=Dn(s,l),d=qn(c,o);return DS(e,t,n,h,d,i,r)}else{const h=Fd(s,l),d=jS[h],p=n.direction[d]>=0;let u,g;p?(u=tn(s),g=nn(s,l)):(u=nn(s,l),g=tn(s));const f=rs(u,a,n,i,r)?Zd(u,e,t,n,i,r):null;if(f){const m=f.point[d];if(p?m<=a[g+h]:m>=a[g+h+3])return f}const x=rs(g,a,n,i,r)?Zd(g,e,t,n,i,r):null;return f&&x?f.distance<=x.distance?f:x:f||x||null}}const kl=new ut,Vr=new Xn,Gr=new Xn,Fa=new Ie,w0=new mn,Ul=new mn;function ZS(s,e,t,n){_t.setBuffer(s._roots[e]);const i=Yd(0,s,t,n);return _t.clearBuffer(),i}function Yd(s,e,t,n,i=null){const{float32Array:r,uint16Array:a,uint32Array:o}=_t;let l=s*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),w0.set(t.boundingBox.min,t.boundingBox.max,n),i=w0),Jt(l,a)){const c=e.geometry,h=c.index,d=c.attributes.position,p=t.index,u=t.attributes.position,g=Dn(s,o),f=qn(l,a);if(Fa.copy(n).invert(),t.boundsTree)return Nt(s,r,Ul),Ul.matrix.copy(Fa),Ul.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>Ul.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(n),x.b.applyMatrix4(n),x.c.applyMatrix4(n),x.needsUpdate=!0;for(let m=g,b=f+g;m<b;m++)if(Wt(Gr,3*e.resolveTriangleIndex(m),h,d),Gr.needsUpdate=!0,x.intersectsTriangle(Gr))return!0;return!1}});{const x=Ns(t);for(let m=g,b=f+g;m<b;m++){const v=e.resolveTriangleIndex(m);Wt(Vr,3*v,h,d),Vr.a.applyMatrix4(Fa),Vr.b.applyMatrix4(Fa),Vr.c.applyMatrix4(Fa),Vr.needsUpdate=!0;for(let y=0,_=x*3;y<_;y+=3)if(Wt(Gr,y,p,u),Gr.needsUpdate=!0,Vr.intersectsTriangle(Gr))return!0}}}else{const c=tn(s),h=nn(s,o);return Nt(c,r,kl),!!(i.intersectsBox(kl)&&Yd(c,e,t,n,i)||(Nt(h,r,kl),i.intersectsBox(kl)&&Yd(h,e,t,n,i)))}}const Ol=new Ie,$d=new mn,Ha=new mn,YS=new P,$S=new P,KS=new P,JS=new P;function QS(s,e,t,n={},i={},r=0,a=1/0){e.boundingBox||e.computeBoundingBox(),$d.set(e.boundingBox.min,e.boundingBox.max,t),$d.needsUpdate=!0;const o=s.geometry,l=o.attributes.position,c=o.index,h=e.attributes.position,d=e.index,p=jn.getPrimitive(),u=jn.getPrimitive();let g=YS,f=$S,x=null,m=null;i&&(x=KS,m=JS);let b=1/0,v=null,y=null;return Ol.copy(t).invert(),Ha.matrix.copy(Ol),s.shapecast({boundsTraverseOrder:_=>$d.distanceToBox(_),intersectsBounds:(_,M,T)=>T<b&&T<a?(M&&(Ha.min.copy(_.min),Ha.max.copy(_.max),Ha.needsUpdate=!0),!0):!1,intersectsRange:(_,M)=>{if(e.boundsTree){const T=e.boundsTree;return T.shapecast({boundsTraverseOrder:R=>Ha.distanceToBox(R),intersectsBounds:(R,w,E)=>E<b&&E<a,intersectsRange:(R,w)=>{for(let E=R,I=R+w;E<I;E++){const A=T.resolveTriangleIndex(E);Wt(u,3*A,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let B=_,S=_+M;B<S;B++){const U=s.resolveTriangleIndex(B);Wt(p,3*U,c,l),p.needsUpdate=!0;const H=p.distanceToTriangle(u,g,x);if(H<b&&(f.copy(g),m&&m.copy(x),b=H,v=B,y=E),H<r)return!0}}}})}else{const T=Ns(e);for(let R=0,w=T;R<w;R++){Wt(u,3*R,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let E=_,I=_+M;E<I;E++){const A=s.resolveTriangleIndex(E);Wt(p,3*A,c,l),p.needsUpdate=!0;const B=p.distanceToTriangle(u,g,x);if(B<b&&(f.copy(g),m&&m.copy(x),b=B,v=E,y=R),B<r)return!0}}}}}),jn.releasePrimitive(p),jn.releasePrimitive(u),b===1/0?null:(n.point?n.point.copy(f):n.point=f.clone(),n.distance=b,n.faceIndex=v,i&&(i.point?i.point.copy(m):i.point=m.clone(),i.point.applyMatrix4(Ol),f.applyMatrix4(Ol),i.distance=f.sub(i.point).length(),i.faceIndex=y),n)}function eE(){return typeof SharedArrayBuffer<"u"}const Va=new _t.constructor,zl=new _t.constructor,as=new zd(()=>new ut),Wr=new ut,Xr=new ut,Kd=new ut,Jd=new ut;let Qd=!1;function tE(s,e,t,n){if(Qd)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Qd=!0;const i=s._roots,r=e._roots;let a,o=0,l=0;const c=new Ie().copy(t).invert();for(let h=0,d=i.length;h<d;h++){Va.setBuffer(i[h]),l=0;const p=as.getPrimitive();Nt(0,Va.float32Array,p),p.applyMatrix4(c);for(let u=0,g=r.length;u<g&&(zl.setBuffer(r[u]),a=ii(0,0,t,c,n,o,l,0,0,p),zl.clearBuffer(),l+=r[u].byteLength/fn,!a);u++);if(as.releasePrimitive(p),Va.clearBuffer(),o+=i[h].byteLength/fn,a)break}return Qd=!1,a}function ii(s,e,t,n,i,r=0,a=0,o=0,l=0,c=null,h=!1){let d,p;h?(d=zl,p=Va):(d=Va,p=zl);const u=d.float32Array,g=d.uint32Array,f=d.uint16Array,x=p.float32Array,m=p.uint32Array,b=p.uint16Array,v=s*2,y=e*2,_=Jt(v,f),M=Jt(y,b);let T=!1;if(M&&_)h?T=i(Dn(e,m),qn(e*2,b),Dn(s,g),qn(s*2,f),l,a+e/Kt,o,r+s/Kt):T=i(Dn(s,g),qn(s*2,f),Dn(e,m),qn(e*2,b),o,r+s/Kt,l,a+e/Kt);else if(M){const R=as.getPrimitive();Nt(e,x,R),R.applyMatrix4(t);const w=tn(s),E=nn(s,g);Nt(w,u,Wr),Nt(E,u,Xr);const I=R.intersectsBox(Wr),A=R.intersectsBox(Xr);T=I&&ii(e,w,n,t,i,a,r,l,o+1,R,!h)||A&&ii(e,E,n,t,i,a,r,l,o+1,R,!h),as.releasePrimitive(R)}else{const R=tn(e),w=nn(e,m);Nt(R,x,Kd),Nt(w,x,Jd);const E=c.intersectsBox(Kd),I=c.intersectsBox(Jd);if(E&&I)T=ii(s,R,t,n,i,r,a,o,l+1,c,h)||ii(s,w,t,n,i,r,a,o,l+1,c,h);else if(E)if(_)T=ii(s,R,t,n,i,r,a,o,l+1,c,h);else{const A=as.getPrimitive();A.copy(Kd).applyMatrix4(t);const B=tn(s),S=nn(s,g);Nt(B,u,Wr),Nt(S,u,Xr);const U=A.intersectsBox(Wr),H=A.intersectsBox(Xr);T=U&&ii(R,B,n,t,i,a,r,l,o+1,A,!h)||H&&ii(R,S,n,t,i,a,r,l,o+1,A,!h),as.releasePrimitive(A)}else if(I)if(_)T=ii(s,w,t,n,i,r,a,o,l+1,c,h);else{const A=as.getPrimitive();A.copy(Jd).applyMatrix4(t);const B=tn(s),S=nn(s,g);Nt(B,u,Wr),Nt(S,u,Xr);const U=A.intersectsBox(Wr),H=A.intersectsBox(Xr);T=U&&ii(w,B,n,t,i,a,r,l,o+1,A,!h)||H&&ii(w,S,n,t,i,a,r,l,o+1,A,!h),as.releasePrimitive(A)}}return T}const Fl=new mn,S0=new ut,nE={strategy:s0,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class eu{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,r=e._indirectBuffer,a=n.getIndex(),o={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(o.roots=i.map(l=>l.slice()),o.index=a?a.array.slice():null,o.indirectBuffer=r?r.slice():null):(o.roots=i,o.index=a?a.array:null,o.indirectBuffer=r),o}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,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 eu(t,{...n,[Id]:!0});if(o._roots=r,o._indirectBuffer=a||null,n.setIndex){const c=t.getIndex();if(c===null){const h=new bt(e.index,1,!1);t.setIndex(h)}else c.array!==i&&(c.array.set(i),c.needsUpdate=!0)}return o;function l(c){for(let h=0;h<c.length;h++){const d=c[h],p=new Uint32Array(d),u=new Uint16Array(d);for(let g=0,f=d.byteLength/fn;g<f;g++){const x=Kt*g,m=2*x;Jt(m,u)||(p[x+6]=p[x+6]/Kt-g)}}}}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({...nE,[Id]:!1},t),t.useSharedArrayBuffer&&!eE())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Id]||(vS(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new ut))),this.resolveTriangleIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n}shiftTriangleOffsets(e){const t=this._indirectBuffer;if(t)for(let n=0,i=t.length;n<i;n++)t[n]+=e;else{const n=this._roots;for(let i=0;i<n.length;i++){const r=n[i],a=new Uint32Array(r),o=new Uint16Array(r),l=r.byteLength/fn;for(let c=0;c<l;c++){const h=Kt*c,d=2*h;Jt(d,o)&&(a[h+6]+=e)}}}}refit(e=null){return(this.indirect?WS:LS)(this,e)}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),r=new Uint16Array(n);a(0);function a(o,l=0){const c=o*2,h=Jt(c,r);if(h){const d=i[o+6],p=r[c+14];e(l,h,new Float32Array(n,o*4,6),d,p)}else{const d=tn(o),p=nn(o,i),u=Fd(o,i);e(l,h,new Float32Array(n,o*4,6),u)||(a(d,l+1),a(p,l+1))}}}raycast(e,t=kn,n=0,i=1/0){const r=this._roots,a=[],o=this.indirect?XS:BS;for(let l=0,c=r.length;l<c;l++)o(this,l,t,e,a,n,i);return a}raycastFirst(e,t=kn,n=0,i=1/0){const r=this._roots;let a=null;const o=this.indirect?qS:US;for(let l=0,c=r.length;l<c;l++){const h=o(this,l,t,e,n,i);h!=null&&(a==null||h.distance<a.distance)&&(a=h)}return a}intersectsGeometry(e,t){let n=!1;const i=this._roots,r=this.indirect?ZS:OS;for(let a=0,o=i.length;a<o&&(n=r(this,a,e,t),!n);a++);return n}shapecast(e){const t=jn.getPrimitive(),n=this.indirect?NS:RS;let{boundsTraverseOrder:i,intersectsBounds:r,intersectsRange:a,intersectsTriangle:o}=e;if(a&&o){const d=a;a=(p,u,g,f,x)=>d(p,u,g,f,x)?!0:n(p,u,this,o,g,f,t)}else a||(o?a=(d,p,u,g)=>n(d,p,this,o,u,g,t):a=(d,p,u)=>u);let l=!1,c=0;const h=this._roots;for(let d=0,p=h.length;d<p;d++){const u=h[d];if(l=SS(this,d,r,a,i,c),l)break;c+=u.byteLength/fn}return jn.releasePrimitive(t),l}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:r}=n;const a=jn.getPrimitive(),o=this.geometry.index,l=this.geometry.attributes.position,c=this.indirect?g=>{const f=this.resolveTriangleIndex(g);Wt(a,f*3,o,l)}:g=>{Wt(a,g*3,o,l)},h=jn.getPrimitive(),d=e.geometry.index,p=e.geometry.attributes.position,u=e.indirect?g=>{const f=e.resolveTriangleIndex(g);Wt(h,f*3,d,p)}:g=>{Wt(h,g*3,d,p)};if(r){const g=(f,x,m,b,v,y,_,M)=>{for(let T=m,R=m+b;T<R;T++){u(T),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let w=f,E=f+x;w<E;w++)if(c(w),a.needsUpdate=!0,r(a,h,w,T,v,y,_,M))return!0}return!1};if(i){const f=i;i=function(x,m,b,v,y,_,M,T){return f(x,m,b,v,y,_,M,T)?!0:g(x,m,b,v,y,_,M,T)}}else i=g}return tE(this,e,t,i)}intersectsBox(e,t){return Fl.set(e.min,e.max,t),Fl.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Fl.intersectsBox(n),intersectsTriangle:n=>Fl.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},r=0,a=1/0){return(this.indirect?QS:GS)(this,e,t,n,i,r,a)}closestPointToPoint(e,t={},n=0,i=1/0){return ES(this,e,t,n,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{Nt(0,new Float32Array(t),S0),e.union(S0)}),e}}const E0=1e-6,iE=E0*.5,C0=Math.pow(10,-Math.log10(E0)),sE=iE*C0;function mi(s){return~~(s*C0+sE)}function rE(s){return`${mi(s.x)},${mi(s.y)}`}function T0(s){return`${mi(s.x)},${mi(s.y)},${mi(s.z)}`}function aE(s){return`${mi(s.x)},${mi(s.y)},${mi(s.z)},${mi(s.w)}`}function oE(s,e,t){t.direction.subVectors(e,s).normalize();const n=s.dot(t.direction);return t.origin.copy(s).addScaledVector(t.direction,-n),t}function A0(){return typeof SharedArrayBuffer<"u"}function lE(s){if(s.buffer instanceof SharedArrayBuffer)return s;const e=s.constructor,t=s.buffer,n=new SharedArrayBuffer(t.byteLength),i=new Uint8Array(t);return new Uint8Array(n).set(i,0),new e(n)}function cE(s,e=ArrayBuffer){return s>65535?new Uint32Array(new e(4*s)):new Uint16Array(new e(2*s))}function hE(s,e){if(!s.index){const t=s.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=cE(t,n);s.setIndex(new bt(i,1));for(let r=0;r<t;r++)i[r]=r}}function dE(s){return s.index?s.index.count:s.attributes.position.count}function tu(s){return dE(s)/3}const uE=1e-8,pE=new P;function fE(s){return~~(s/3)}function mE(s){return s%3}function P0(s,e){return s.start-e.start}function R0(s,e){return pE.subVectors(e,s.origin).dot(s.direction)}function gE(s,e,t,n=uE){s.sort(P0),e.sort(P0);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}}}i(s),i(e);function i(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)<n}function a(o){return Math.abs(o.end-o.start)<n}}const L0=1e-5,I0=1e-4;class xE{constructor(){this._rays=[]}addRay(e){this._rays.push(e)}findClosestRay(e){const t=this._rays,n=e.clone();n.direction.multiplyScalar(-1);let i=1/0,r=null;for(let l=0,c=t.length;l<c;l++){const h=t[l];if(a(h,e)&&a(h,n))continue;const d=o(h,e),p=o(h,n),u=Math.min(d,p);u<i&&(i=u,r=h)}return r;function a(l,c){const h=l.origin.distanceTo(c.origin)>L0;return l.direction.angleTo(c.direction)>I0||h}function o(l,c){const h=l.origin.distanceTo(c.origin),d=l.direction.angleTo(c.direction);return h/L0+d/I0}}}const nu=new P,iu=new P,Hl=new Xi;function vE(s,e,t){const n=s.attributes,i=s.index,r=n.position,a=new Map,o=new Map,l=Array.from(e),c=new xE;for(let h=0,d=l.length;h<d;h++){const p=l[h],u=fE(p),g=mE(p);let f=3*u+g,x=3*u+(g+1)%3;i&&(f=i.getX(f),x=i.getX(x)),nu.fromBufferAttribute(r,f),iu.fromBufferAttribute(r,x),oE(nu,iu,Hl);let m,b=c.findClosestRay(Hl);b===null&&(b=Hl.clone(),c.addRay(b)),o.has(b)||o.set(b,{forward:[],reverse:[],ray:b}),m=o.get(b);let v=R0(b,nu),y=R0(b,iu);v>y&&([v,y]=[y,v]),Hl.direction.dot(b.direction)<0?m.reverse.push({start:v,end:y,index:p}):m.forward.push({start:v,end:y,index:p})}return o.forEach(({forward:h,reverse:d},p)=>{gE(h,d,a,t),h.length===0&&d.length===0&&o.delete(p)}),{disjointConnectivityMap:a,fragmentMap:o}}const bE=new he,su=new P,yE=new tt,ru=["","",""];class _E{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 n=this.data[e*3+t];return n===-1?-1:~~(n/3)}getSiblingEdgeIndex(e,t){const n=this.data[e*3+t];return n===-1?-1:n%3}getDisjointSiblingTriangleIndices(e,t){const n=e*3+t,i=this.disjointConnections.get(n);return i?i.map(r=>~~(r/3)):[]}getDisjointSiblingEdgeIndices(e,t){const n=e*3+t,i=this.disjointConnections.get(n);return i?i.map(r=>r%3):[]}isFullyConnected(){return this.unmatchedEdges===0}updateFrom(e){const{useAllAttributes:t,useDrawRange:n,matchDisjointEdges:i,degenerateEpsilon:r}=this,a=t?v:b,o=new Map,{attributes:l}=e,c=t?Object.keys(l):null,h=e.index,d=l.position;let p=tu(e);const u=p;let g=0;n&&(g=e.drawRange.start,e.drawRange.count!==1/0&&(p=~~(e.drawRange.count/3)));let f=this.data;(!f||f.length<3*u)&&(f=new Int32Array(3*u)),f.fill(-1);let x=0,m=new Set;for(let y=g,_=p*3+g;y<_;y+=3){const M=y;for(let T=0;T<3;T++){let R=M+T;h&&(R=h.getX(R)),ru[T]=a(R)}for(let T=0;T<3;T++){const R=(T+1)%3,w=ru[T],E=ru[R],I=`${E}_${w}`;if(o.has(I)){const A=M+T,B=o.get(I);f[A]=B,f[B]=A,o.delete(I),x+=2,m.delete(B)}else{const A=`${w}_${E}`,B=M+T;o.set(A,B),m.add(B)}}}if(i){const{fragmentMap:y,disjointConnectivityMap:_}=vE(e,m,r);m.clear(),y.forEach(({forward:M,reverse:T})=>{M.forEach(({index:R})=>m.add(R)),T.forEach(({index:R})=>m.add(R))}),this.unmatchedDisjointEdges=y,this.disjointConnections=_,x=p*3-m.size}this.matchedEdges=x,this.unmatchedEdges=m.size,this.data=f;function b(y){return su.fromBufferAttribute(d,y),T0(su)}function v(y){let _="";for(let M=0,T=c.length;M<T;M++){const R=l[c[M]];let w;switch(R.itemSize){case 1:w=mi(R.getX(y));break;case 2:w=rE(bE.fromBufferAttribute(R,y));break;case 3:w=T0(su.fromBufferAttribute(R,y));break;case 4:w=aE(yE.fromBufferAttribute(R,y));break}_!==""&&(_+="|"),_+=w}return _}}}class Vl extends at{constructor(...e){super(...e),this.isBrush=!0,this._previousMatrix=new Ie,this._previousMatrix.elements.fill(0)}markUpdated(){this._previousMatrix.copy(this.matrix)}isDirty(){const{matrix:e,_previousMatrix:t}=this,n=e.elements,i=t.elements;for(let r=0;r<16;r++)if(n[r]!==i[r])return!0;return!1}prepareGeometry(){const e=this.geometry,t=e.attributes,n=A0();if(n)for(const i in t){const r=t[i];if(r.isInterleavedBufferAttribute)throw new Error("Brush: InterleavedBufferAttributes are not supported.");r.array=lE(r.array)}if(e.boundsTree||(hE(e,{useSharedArrayBuffer:n}),e.boundsTree=new eu(e,{maxLeafTris:3,indirect:!0,useSharedArrayBuffer:n})),e.halfEdges||(e.halfEdges=new _E(e)),!e.groupIndices){const i=tu(e),r=new Uint16Array(i),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,p=(c+h)/3;d<p;d++)r[d]=o}e.groupIndices=r}}disposeCacheData(){const{geometry:e}=this;e.halfEdges=null,e.boundsTree=null,e.groupIndices=null}}const ME=1e-14,au=new P,D0=new P,N0=new P;function os(s,e=ME){au.subVectors(s.b,s.a),D0.subVectors(s.c,s.a),N0.subVectors(s.b,s.c);const t=au.angleTo(D0),n=au.angleTo(N0),i=Math.PI-t-n;return Math.abs(t)<e||Math.abs(n)<e||Math.abs(i)<e||s.a.distanceToSquared(s.b)<e||s.a.distanceToSquared(s.c)<e||s.b.distanceToSquared(s.c)<e}const ou=1e-10,Ga=1e-10,wE=1e-10,Ui=new Vn,Ot=new Vn,Oi=new P,lu=new P,B0=new P,Gl=new It,cu=new Xn;class SE{constructor(){this._pool=[],this._index=0}getTriangle(){return this._index>=this._pool.length&&this._pool.push(new vt),this._pool[this._index++]}clear(){this._index=0}reset(){this._pool.length=0,this._index=0}}class EE{constructor(){this.trianglePool=new SE,this.triangles=[],this.normal=new P,this.coplanarTriangleUsed=!1}initialize(e){this.reset();const{triangles:t,trianglePool:n,normal:i}=this;if(Array.isArray(e))for(let r=0,a=e.length;r<a;r++){const o=e[r];if(r===0)o.getNormal(i);else if(Math.abs(1-o.getNormal(Oi).dot(i))>ou)throw new Error("Triangle Splitter: Cannot initialize with triangles that have different normals.");const l=n.getTriangle();l.copy(o),t.push(l)}else{e.getNormal(i);const r=n.getTriangle();r.copy(e),t.push(r)}}splitByTriangle(e){const{normal:t,triangles:n}=this;if(e.getNormal(lu).normalize(),Math.abs(1-Math.abs(lu.dot(t)))<wE){this.coplanarTriangleUsed=!0;for(let r=0,a=n.length;r<a;r++){const o=n[r];o.coplanarCount=0}const i=[e.a,e.b,e.c];for(let r=0;r<3;r++){const a=(r+1)%3,o=i[r],l=i[a];Oi.subVectors(l,o).normalize(),B0.crossVectors(lu,Oi),Gl.setFromNormalAndCoplanarPoint(B0,o),this.splitByPlane(Gl,e)}}else e.getPlane(Gl),this.splitByPlane(Gl,e)}splitByPlane(e,t){const{triangles:n,trianglePool:i}=this;cu.copy(t),cu.needsUpdate=!0;for(let r=0,a=n.length;r<a;r++){const o=n[r];if(!cu.intersectsTriangle(o,Ui,!0))continue;const{a:l,b:c,c:h}=o;let d=0,p=-1,u=!1,g=[],f=[];const x=[l,c,h];for(let m=0;m<3;m++){const b=(m+1)%3;Ui.start.copy(x[m]),Ui.end.copy(x[b]);const v=e.distanceToPoint(Ui.start),y=e.distanceToPoint(Ui.end);if(Math.abs(v)<Ga&&Math.abs(y)<Ga){u=!0;break}if(v>0?g.push(m):f.push(m),Math.abs(v)<Ga)continue;let _=!!e.intersectLine(Ui,Oi);!_&&Math.abs(y)<Ga&&(Oi.copy(Ui.end),_=!0),_&&!(Oi.distanceTo(Ui.start)<ou)&&(Oi.distanceTo(Ui.end)<ou&&(p=m),d===0?Ot.start.copy(Oi):Ot.end.copy(Oi),d++)}if(!u&&d===2&&Ot.distance()>Ga)if(p!==-1){p=(p+1)%3;let m=0;m===p&&(m=(m+1)%3);let b=m+1;b===p&&(b=(b+1)%3);const v=i.getTriangle();v.a.copy(x[b]),v.b.copy(Ot.end),v.c.copy(Ot.start),os(v)||n.push(v),o.a.copy(x[m]),o.b.copy(Ot.start),o.c.copy(Ot.end),os(o)&&(n.splice(r,1),r--,a--)}else{const m=g.length>=2?f[0]:g[0];if(m===0){let M=Ot.start;Ot.start=Ot.end,Ot.end=M}const b=(m+1)%3,v=(m+2)%3,y=i.getTriangle(),_=i.getTriangle();x[b].distanceToSquared(Ot.start)<x[v].distanceToSquared(Ot.end)?(y.a.copy(x[b]),y.b.copy(Ot.start),y.c.copy(Ot.end),_.a.copy(x[b]),_.b.copy(x[v]),_.c.copy(Ot.start)):(y.a.copy(x[v]),y.b.copy(Ot.start),y.c.copy(Ot.end),_.a.copy(x[b]),_.b.copy(x[v]),_.c.copy(Ot.end)),o.a.copy(x[m]),o.b.copy(Ot.end),o.c.copy(Ot.start),os(y)||n.push(y),os(_)||n.push(_),os(o)&&(n.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 CE(s){return s=~~s,s+4-s%4}class k0{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,n=A0()?SharedArrayBuffer:ArrayBuffer,i=new t(new n(CE(e*t.BYTES_PER_ELEMENT)));this.array&&i.set(this.array,0),this.array=i}expand(){const{array:e,expansionFactor:t}=this;this.setSize(e.length*t)}push(...e){let{array:t,length:n}=this;n+e.length>t.length&&(this.expand(),t=this.array);for(let i=0,r=e.length;i<r;i++)t[n+i]=e[i];this.length+=e.length}clear(){this.length=0}}class TE{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:n}=this;let i=0;for(let r=0;r<t;r++){const a=n[r];i+=a[e].length}return i}getGroupAttrSet(e=0){const{groupAttributes:t}=this;if(t[e])return this.groupCount=Math.max(this.groupCount,e+1),t[e];const n=t[0];for(this.groupCount=Math.max(this.groupCount,e+1);e>=t.length;){const i={};t.push(i);for(const r in n){const a=n[r],o=new k0(a.type);o.itemSize=a.itemSize,o.normalized=a.normalized,i[r]=o}}return t[e]}getGroupAttrArray(e,t=0){const{groupAttributes:n}=this;if(!n[0][e])throw new Error(`TypedAttributeData: Attribute with "${e}" has not been initialized`);return this.getGroupAttrSet(t)[e]}initializeArray(e,t,n,i){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=n,c.normalized=i}}else for(let o=0,l=r.length;o<l;o++){const c=new k0(t);c.itemSize=n,c.normalized=i,r[o][e]=c}}clear(){this.groupCount=0;const{groupAttributes:e}=this;e.forEach(t=>{for(const n in t)t[n].clear()})}delete(e){this.groupAttributes.forEach(t=>{delete t[e]})}reset(){this.groupAttributes=[],this.groupCount=0}}class U0{constructor(){this.intersectionSet={},this.ids=[]}add(e,t){const{intersectionSet:n,ids:i}=this;n[e]||(n[e]=[],i.push(e)),n[e].push(t)}}const AE=0,PE=1,RE=2,O0=3,LE=4,z0=5,F0=6,Zn=new Xi,H0=new Ie,gn=new vt,zi=new P,V0=new tt,G0=new tt,W0=new tt,hu=new tt,Wl=new tt,Xl=new tt,X0=new Vn,du=new P,uu=1e-8,IE=1e-15,Os=-1,zs=1,jl=-2,ql=2,Wa=0,Fs=1,pu=2,DE=1e-14;let Zl=null;function j0(s){Zl=s}function q0(s,e){s.getMidpoint(Zn.origin),s.getNormal(Zn.direction);const t=e.raycastFirst(Zn,yt);return t&&Zn.direction.dot(t.face.normal)>0?Os:zs}function NE(s,e){function t(){return Math.random()-.5}s.getNormal(du),Zn.direction.copy(du),s.getMidpoint(Zn.origin);const n=3;let i=0,r=1/0;for(let a=0;a<n;a++){Zn.direction.x+=t()*uu,Zn.direction.y+=t()*uu,Zn.direction.z+=t()*uu,Zn.direction.multiplyScalar(-1);const o=e.raycastFirst(Zn,yt);if(o&&Zn.direction.dot(o.face.normal)>0&&i++,o!==null&&(r=Math.min(r,o.distance)),r<=IE)return o.face.normal.dot(du)>0?ql:jl;if(i/n>.5||(a-i+1)/n>.5)break}return i/n>.5?Os:zs}function BE(s,e){const t=new U0,n=new U0;return H0.copy(s.matrixWorld).invert().multiply(e.matrixWorld),s.geometry.boundsTree.bvhcast(e.geometry.boundsTree,H0,{intersectsTriangles(i,r,a,o){if(!os(i)&&!os(r)){let l=i.intersectsTriangle(r,X0,!0);if(!l){const c=i.plane,h=r.plane,d=c.normal,p=h.normal;d.dot(p)===1&&Math.abs(c.constant-h.constant)<DE&&(l=!0)}if(l){let c=s.geometry.boundsTree.resolveTriangleIndex(a),h=e.geometry.boundsTree.resolveTriangleIndex(o);t.add(c,h),n.add(h,c),Zl&&(Zl.addEdge(X0),Zl.addIntersectingTriangles(a,i,o,r))}}return!1}}),{aIntersections:t,bIntersections:n}}function kE(s,e,t,n,i,r,a=!1){const o=t.attributes,l=t.index,c=s*3,h=l.getX(c+0),d=l.getX(c+1),p=l.getX(c+2);for(const u in r){const g=o[u],f=r[u];if(!(u in o))throw new Error(`CSG Operations: Attribute ${u} not available on geometry.`);const x=g.itemSize;u==="position"?(gn.a.fromBufferAttribute(g,h).applyMatrix4(n),gn.b.fromBufferAttribute(g,d).applyMatrix4(n),gn.c.fromBufferAttribute(g,p).applyMatrix4(n),fu(gn.a,gn.b,gn.c,e,3,f,a)):u==="normal"?(gn.a.fromBufferAttribute(g,h).applyNormalMatrix(i),gn.b.fromBufferAttribute(g,d).applyNormalMatrix(i),gn.c.fromBufferAttribute(g,p).applyNormalMatrix(i),a&&(gn.a.multiplyScalar(-1),gn.b.multiplyScalar(-1),gn.c.multiplyScalar(-1)),fu(gn.a,gn.b,gn.c,e,3,f,a,!0)):(V0.fromBufferAttribute(g,h),G0.fromBufferAttribute(g,d),W0.fromBufferAttribute(g,p),fu(V0,G0,W0,e,x,f,a))}}function UE(s,e,t,n,i,r,a,o=!1){mu(s,n,i,r,a,o),mu(o?t:e,n,i,r,a,o),mu(o?e:t,n,i,r,a,o)}function Z0(s,e,t=!1){switch(s){case AE:if(e===zs||e===ql&&!t)return Fs;break;case PE:if(t){if(e===Os)return Wa}else if(e===zs||e===jl)return Fs;break;case RE:if(t){if(e===zs||e===jl)return Fs}else if(e===Os)return Wa;break;case LE:if(e===Os)return Wa;if(e===zs)return Fs;break;case O0:if(e===Os||e===ql&&!t)return Fs;break;case z0:if(!t&&(e===zs||e===jl))return Fs;break;case F0:if(!t&&(e===Os||e===ql))return Fs;break;default:throw new Error(`Unrecognized CSG operation enum "${s}".`)}return pu}function fu(s,e,t,n,i,r,a=!1,o=!1){const l=c=>{r.push(c.x),i>1&&r.push(c.y),i>2&&r.push(c.z),i>3&&r.push(c.w)};hu.set(0,0,0,0).addScaledVector(s,n.a.x).addScaledVector(e,n.a.y).addScaledVector(t,n.a.z),Wl.set(0,0,0,0).addScaledVector(s,n.b.x).addScaledVector(e,n.b.y).addScaledVector(t,n.b.z),Xl.set(0,0,0,0).addScaledVector(s,n.c.x).addScaledVector(e,n.c.y).addScaledVector(t,n.c.z),o&&(hu.normalize(),Wl.normalize(),Xl.normalize()),l(hu),a?(l(Xl),l(Wl)):(l(Wl),l(Xl))}function mu(s,e,t,n,i,r=!1){for(const a in i){const o=e[a],l=i[a];if(!(a in e))throw new Error(`CSG Operations: Attribute ${a} no available on geometry.`);const c=o.itemSize;a==="position"?(zi.fromBufferAttribute(o,s).applyMatrix4(t),l.push(zi.x,zi.y,zi.z)):a==="normal"?(zi.fromBufferAttribute(o,s).applyNormalMatrix(n),r&&zi.multiplyScalar(-1),l.push(zi.x,zi.y,zi.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 OE{constructor(e){this.triangle=new vt().copy(e),this.intersects={}}addTriangle(e,t){this.intersects[e]=new vt().copy(t)}getIntersectArray(){const e=[],{intersects:t}=this;for(const n in t)e.push(t[n]);return e}}class Y0{constructor(){this.data={}}addTriangleIntersection(e,t,n,i){const{data:r}=this;r[e]||(r[e]=new OE(t)),r[e].addTriangle(n,i)}getTrianglesAsArray(e=null){const{data:t}=this,n=[];if(e!==null)e in t&&n.push(t[e].triangle);else for(const i in t)n.push(t[i].triangle);return n}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(n=>parseInt(n)):[]}getIntersectionsAsArray(e=null,t=null){const{data:n}=this,i=new Set,r=[],a=o=>{if(n[o])if(t!==null)n[o].intersects[t]&&r.push(n[o].intersects[t]);else{const l=n[o].intersects;for(const c in l)i.has(c)||(i.add(c),r.push(l[c]))}};if(e!==null)a(e);else for(const o in n)a(o);return r}reset(){this.data={}}}class zE{constructor(){this.enabled=!1,this.triangleIntersectsA=new Y0,this.triangleIntersectsB=new Y0,this.intersectionEdges=[]}addIntersectingTriangles(e,t,n,i){const{triangleIntersectsA:r,triangleIntersectsB:a}=this;r.addTriangleIntersection(e,t,n,i),a.addTriangleIntersection(n,i,e,t)}addEdge(e){this.intersectionEdges.push(e.clone())}reset(){this.triangleIntersectsA.reset(),this.triangleIntersectsB.reset(),this.intersectionEdges=[]}init(){this.enabled&&(this.reset(),j0(this))}complete(){this.enabled&&j0(null)}}const ls=new Ie,Yl=new $e,Hs=new vt,$l=new vt,cs=new vt,Kl=new vt,si=[],Vs=[];function FE(s){for(const e of s)return e}function HE(s,e,t,n,i,r={}){const{useGroups:a=!0}=r,{aIntersections:o,bIntersections:l}=BE(s,e),c=[];let h=null,d;return d=a?0:-1,$0(s,e,o,t,!1,n,i,d),K0(s,e,o,t,!1,i,d),t.findIndex(p=>p!==F0&&p!==z0)!==-1&&(d=a?s.geometry.groups.length||1:-1,$0(e,s,l,t,!0,n,i,d),K0(e,s,l,t,!0,i,d)),si.length=0,Vs.length=0,{groups:c,materials:h}}function $0(s,e,t,n,i,r,a,o=0){const l=s.matrixWorld.determinant()<0;ls.copy(e.matrixWorld).invert().multiply(s.matrixWorld),Yl.getNormalMatrix(s.matrixWorld).multiplyScalar(l?-1:1);const c=s.geometry.groupIndices,h=s.geometry.index,d=s.geometry.attributes.position,p=e.geometry.boundsTree,u=e.geometry.index,g=e.geometry.attributes.position,f=t.ids,x=t.intersectionSet;for(let m=0,b=f.length;m<b;m++){const v=f[m],y=o===-1?0:c[v]+o,_=3*v,M=h.getX(_+0),T=h.getX(_+1),R=h.getX(_+2);Hs.a.fromBufferAttribute(d,M).applyMatrix4(ls),Hs.b.fromBufferAttribute(d,T).applyMatrix4(ls),Hs.c.fromBufferAttribute(d,R).applyMatrix4(ls),r.reset(),r.initialize(Hs);const w=x[v];for(let I=0,A=w.length;I<A;I++){const B=3*w[I],S=u.getX(B+0),U=u.getX(B+1),H=u.getX(B+2);$l.a.fromBufferAttribute(g,S),$l.b.fromBufferAttribute(g,U),$l.c.fromBufferAttribute(g,H),r.splitByTriangle($l)}const E=r.triangles;for(let I=0,A=E.length;I<A;I++){const B=E[I],S=r.coplanarTriangleUsed?NE(B,p):q0(B,p);si.length=0,Vs.length=0;for(let U=0,H=n.length;U<H;U++){const G=Z0(n[U],S,i);G!==pu&&(Vs.push(G),si.push(a[U].getGroupAttrSet(y)))}if(si.length!==0){Hs.getBarycoord(B.a,Kl.a),Hs.getBarycoord(B.b,Kl.b),Hs.getBarycoord(B.c,Kl.c);for(let U=0,H=si.length;U<H;U++){const G=si[U],Z=Vs[U]===Wa;kE(v,Kl,s.geometry,s.matrixWorld,Yl,G,l!==Z)}}}}return f.length}function K0(s,e,t,n,i,r,a=0){const o=s.matrixWorld.determinant()<0;ls.copy(e.matrixWorld).invert().multiply(s.matrixWorld),Yl.getNormalMatrix(s.matrixWorld).multiplyScalar(o?-1:1);const l=e.geometry.boundsTree,c=s.geometry.groupIndices,h=s.geometry.index,d=s.geometry.attributes,p=d.position,u=[],g=s.geometry.halfEdges,f=new Set,x=tu(s.geometry);for(let m=0,b=x;m<b;m++)m in t.intersectionSet||f.add(m);for(;f.size>0;){const m=FE(f);f.delete(m),u.push(m);const b=3*m,v=h.getX(b+0),y=h.getX(b+1),_=h.getX(b+2);cs.a.fromBufferAttribute(p,v).applyMatrix4(ls),cs.b.fromBufferAttribute(p,y).applyMatrix4(ls),cs.c.fromBufferAttribute(p,_).applyMatrix4(ls);const M=q0(cs,l);Vs.length=0,si.length=0;for(let T=0,R=n.length;T<R;T++){const w=Z0(n[T],M,i);w!==pu&&(Vs.push(w),si.push(r[T]))}for(;u.length>0;){const T=u.pop();for(let R=0;R<3;R++){const w=g.getSiblingTriangleIndex(T,R);w!==-1&&f.has(w)&&(u.push(w),f.delete(w))}if(si.length!==0){const R=3*T,w=h.getX(R+0),E=h.getX(R+1),I=h.getX(R+2),A=a===-1?0:c[T]+a;if(cs.a.fromBufferAttribute(p,w),cs.b.fromBufferAttribute(p,E),cs.c.fromBufferAttribute(p,I),!os(cs))for(let B=0,S=si.length;B<S;B++){const U=Vs[B],H=si[B].getGroupAttrSet(A),G=U===Wa;UE(w,E,I,d,s.matrixWorld,Yl,H,G!==o)}}}}}function VE(s){for(let e=0;e<s.length-1;e++){const t=s[e],n=s[e+1];if(t.materialIndex===n.materialIndex){const i=t.start,r=n.start+n.count;n.start=i,n.count=r-i,s.splice(e,1),e--}}}function GE(s,e,t,n){t.clear();const i=s.attributes;for(let r=0,a=n.length;r<a;r++){const o=n[r],l=i[o];t.initializeArray(o,l.array.constructor,l.itemSize,l.normalized)}for(const r in t.attributes)n.includes(r)||t.delete(r);for(const r in e.attributes)n.includes(r)||(e.deleteAttribute(r),e.dispose())}function WE(s,e,t){let n=!1,i=-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),p=e.getNormalized(l);let u=r[l];(!u||u.array.length<c)&&(u=new bt(new h(c),d,p),s.setAttribute(l,u),n=!0);let g=0;for(let f=0,x=Math.min(t.length,e.groupCount);f<x;f++){const m=t[f].index,{array:b,type:v,length:y}=e.groupAttributes[m][l],_=new v(b.buffer,0,y);u.array.set(_,g),g+=_.length}u.needsUpdate=!0,i=c/u.itemSize}if(s.index){const l=s.index.array;if(l.length<i)s.index=null,n=!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],p=e.getCount(h);p!==0&&(s.addGroup(o,p,d),o+=p)}s.setDrawRange(0,i),s.boundsTree=null,n&&s.dispose()}function J0(s,e){let t=e;return Array.isArray(e)||(t=[],s.forEach(n=>{t[n.materialIndex]=e})),t}class XE{constructor(){this.triangleSplitter=new EE,this.attributeData=[],this.attributes=["position","uv","normal"],this.useGroups=!0,this.consolidateGroups=!0,this.debug=new zE}getGroupRanges(e){return!this.useGroups||e.groups.length===0?[{start:0,count:1/0,materialIndex:0}]:e.groups.map(t=>({...t}))}evaluate(e,t,n,i=new Vl){let r=!0;if(Array.isArray(n)||(n=[n]),Array.isArray(i)||(i=[i],r=!1),i.length!==n.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<i.length;)o.push(new TE);i.forEach((m,b)=>{GE(e.geometry,m.geometry,o[b],l)}),d.init(),HE(e,t,n,a,o,{useGroups:c}),d.complete();const p=this.getGroupRanges(e.geometry),u=J0(p,e.material),g=this.getGroupRanges(t.geometry),f=J0(g,t.material);g.forEach(m=>m.materialIndex+=u.length);let x=[...p,...g].map((m,b)=>({...m,index:b}));if(c){const m=[...u,...f];h&&(x=x.map(v=>{const y=m[v.materialIndex];return v.materialIndex=m.indexOf(y),v}).sort((v,y)=>v.materialIndex-y.materialIndex));const b=[];for(let v=0,y=m.length;v<y;v++){let _=!1;for(let M=0,T=x.length;M<T;M++){const R=x[M];R.materialIndex===v&&(_=!0,R.materialIndex=b.length)}_&&b.push(m[v])}i.forEach(v=>{v.material=b})}else x=[{start:0,count:1/0,index:0,materialIndex:0}],i.forEach(m=>{m.material=u[0]});return i.forEach((m,b)=>{const v=m.geometry;WE(v,o[b],x),h&&VE(v.groups)}),r?i:i[0]}evaluateHierarchy(e,t=new Vl){e.updateMatrixWorld(!0);const n=(r,a)=>{const o=r.children;for(let l=0,c=o.length;l<c;l++){const h=o[l];h.isOperationGroup?n(h,a):a(h)}},i=r=>{const a=r.children;let o=!1;for(let c=0,h=a.length;c<h;c++){const d=a[c];o=i(d)||o}const l=r.isDirty();if(l&&r.markUpdated(),o&&!r.isOperationGroup){let c;return n(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 i(e),t.geometry=e._cachedGeometry,t.material=e._cachedMaterials,t}reset(){this.triangleSplitter.reset()}}class jE{engine;planeObjects=[];planes=[];isActive=!1;evaluator;geometryCache=new Map;sectionMeshes=new Map;planeGroup;planeSize=1e3;sourceMeshes=new Map;planeThickness=.01;updateThrottleTime=100;lastUpdateTime=0;pendingUpdate=!1;updateTimer=null;cacheExpireTime=3e4;planeStates=new Map;constructor(e,t={}){this.engine=e,this.evaluator=new XE,this.planeGroup=new ln,this.planeGroup.name="CSG_ClippingPlanes_Optimized",t.updateThrottleTime!==void 0&&(this.updateThrottleTime=t.updateThrottleTime),t.cacheExpireTime!==void 0&&(this.cacheExpireTime=t.cacheExpireTime),t.planeThickness!==void 0&&(this.planeThickness=t.planeThickness),this.evaluator.attributes=["position","normal"],this.evaluator.useGroups=!1}init(){this.calculateSceneSize(),this.engine.scene.add(this.planeGroup),this.planes.forEach((e,t)=>{const n=this.createEmptySectionMesh(e,t);this.planeGroup.add(n),this.sectionMeshes.set(`plane_${t}`,n),this.planeObjects.push(n),this.planeStates.set(t,{constant:e.constant,normal:e.normal.clone()})})}createEmptySectionMesh(e,t){const n=new pt,i=new Ki({color:new Fe(33023),metalness:.1,roughness:.75,side:yt,depthWrite:!0,depthTest:!0,clippingPlanes:this.planes.filter((a,o)=>o!==t)}),r=new at(n,i);return r.name=`CSG_Section_Optimized_${t}`,r.visible=!1,r.renderOrder=t+1,r}active(){this.isActive=!0,this.requestUpdate(),this.planeObjects.forEach(e=>{e.visible=!0})}disActive(){this.isActive=!1,this.planeObjects.forEach(e=>{e.visible=!1}),this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null)}setSourceMeshes(e){this.sourceMeshes.clear(),e.forEach(t=>{const n=t.uuid;this.sourceMeshes.set(n,t)}),this.isActive&&this.requestUpdate()}addSourceMesh(e){const t=e.uuid;this.sourceMeshes.has(t)||(this.sourceMeshes.set(t,e),this.isActive&&this.requestUpdate())}removeSourceMesh(e){const t=e.uuid;this.sourceMeshes.delete(t)&&(this.clearMeshCache(t),this.isActive&&this.requestUpdate())}requestUpdate(){if(!this.isActive)return;const e=Date.now(),t=e-this.lastUpdateTime;t>=this.updateThrottleTime?(this.lastUpdateTime=e,this.pendingUpdate=!1):(this.pendingUpdate=!0,this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.pendingUpdate&&this.isActive&&(this.lastUpdateTime=Date.now(),this.pendingUpdate=!1),this.updateTimer=null},this.updateThrottleTime-t))}updateAllSections(){this.isActive&&(this.planes.forEach((e,t)=>{if(Math.abs(e.constant)<99999)this.hasPlaneChanged(t,e)&&(this.updateSection(e,t),this.updatePlaneState(t,e));else{const n=this.sectionMeshes.get(`plane_${t}`);n&&(n.visible=!1)}}),this.cleanExpiredCache())}hasPlaneChanged(e,t){const n=this.planeStates.get(e);if(!n)return!0;const i=Math.abs(n.constant-t.constant)>1e-4,r=!n.normal.equals(t.normal);return i||r}updatePlaneState(e,t){this.planeStates.set(e,{constant:t.constant,normal:t.normal.clone()})}getPlaneHash(e){const t=e.normal,n=e.constant;return`${t.x.toFixed(4)}_${t.y.toFixed(4)}_${t.z.toFixed(4)}_${n.toFixed(4)}`}getCacheKey(e,t){return`${e}_plane_${t}`}updateSection(e,t){const n=this.sectionMeshes.get(`plane_${t}`);if(!n)return;const i=this.getPlaneHash(e),r=[];if(this.sourceMeshes.forEach((a,o)=>{const l=this.getCacheKey(o,t),c=this.geometryCache.get(l);if(c&&c.planeHash===i)r.push(c.geometry.clone()),c.timestamp=Date.now();else try{const h=this.createPlaneBrush(e),d=new Vl(a.geometry);a.updateMatrixWorld(!0),d.matrix.copy(a.matrixWorld),d.updateMatrixWorld();const p=this.evaluator.evaluate(h,d,O0);p&&p.geometry.attributes.position.count>0?(r.push(p.geometry),this.geometryCache.set(l,{geometry:p.geometry.clone(),planeHash:i,timestamp:Date.now()})):this.geometryCache.delete(l)}catch(h){console.warn(`CSG intersection failed for mesh ${o}:`,h)}}),r.length>0){const a=this.mergeGeometries(r);n.geometry&&n.geometry.dispose(),n.geometry=a,n.visible=!0,n.position.set(0,0,0),n.rotation.set(0,0,0),n.scale.set(1,1,1),n.updateMatrixWorld()}else n.visible=!1;r.forEach(a=>a.dispose())}clearMeshCache(e){const t=[];this.geometryCache.forEach((n,i)=>{i.startsWith(e)&&(n.geometry.dispose(),t.push(i))}),t.forEach(n=>this.geometryCache.delete(n))}cleanExpiredCache(){const e=Date.now(),t=[];this.geometryCache.forEach((n,i)=>{e-n.timestamp>this.cacheExpireTime&&(n.geometry.dispose(),t.push(i))}),t.forEach(n=>this.geometryCache.delete(n))}clearAllCache(){this.geometryCache.forEach(e=>{e.geometry.dispose()}),this.geometryCache.clear()}createPlaneBrush(e){const t=new Zi(this.planeSize,this.planeThickness,this.planeSize);t.translate(0,e.constant,0),t.applyQuaternion(new zn().setFromUnitVectors(new P(0,-1,0),e.normal));const n=new at(t),i=new Vl(t);return i.matrix.copy(n.matrixWorld),i.updateMatrixWorld(),i}mergeGeometries(e){if(e.length===1)return e[0].clone();const t=new pt,n=[],i=[],r=[];let a=0;return e.forEach(o=>{const l=o.attributes.position,c=o.attributes.normal;for(let h=0;h<l.count;h++)n.push(l.getX(h),l.getY(h),l.getZ(h));if(c)for(let h=0;h<c.count;h++)i.push(c.getX(h),c.getY(h),c.getZ(h));if(o.index)for(let h=0;h<o.index.count;h++)r.push(o.index.getX(h)+a);a+=l.count}),t.setAttribute("position",new jt(n,3)),i.length>0?t.setAttribute("normal",new jt(i,3)):t.computeVertexNormals(),r.length>0&&t.setIndex(r),t}calculateSceneSize(){const e=new ut;if(this.engine.scene.traverse(t=>{if(t.isMesh&&t.geometry){const n=new ut().setFromObject(t);e.union(n)}}),e.isEmpty())this.planeSize=1e3;else{const t=e.getSize(new P),n=Math.max(t.x,t.y,t.z);this.planeSize=n*3}}update(){this.isActive&&this.pendingUpdate&&!this.updateTimer&&this.requestUpdate()}dispose(){this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null),this.clearAllCache(),this.planeObjects.forEach(e=>{e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose())}),this.sectionMeshes.clear(),this.planeObjects=[],this.sourceMeshes.clear(),this.planeGroup.parent&&this.planeGroup.parent.remove(this.planeGroup)}setSectionColor(e){this.planeObjects.forEach(t=>{t.material instanceof Ki&&t.material.color.set(e)})}getCacheStats(){return{cacheSize:this.geometryCache.size,sourceMeshCount:this.sourceMeshes.size,sectionMeshCount:this.sectionMeshes.size}}setPlaneThickness(e){if(e<=0){console.warn("Plane thickness must be positive");return}this.planeThickness=e,this.clearAllCache(),this.isActive&&this.requestUpdate()}getPlaneThickness(){return this.planeThickness}showSections(){this.sectionMeshes.forEach(e=>{e.geometry?.attributes.position?.count&&e.geometry.attributes.position.count>0&&(e.visible=!0)})}hideSections(){this.sectionMeshes.forEach(e=>{e.visible=!1})}showSection(){this.planeGroup.visible=!0}hideSection(){this.planeGroup.visible=!1}toggleSectionsVisibility(){let e=!1;return this.sectionMeshes.forEach(t=>{t.visible&&(e=!0)}),e?(this.hideSections(),!1):(this.showSections(),!0)}toggleSectionVisibility(e){const t=this.sectionMeshes.get(`plane_${e}`);return t?(t.visible=!t.visible,t.visible):!1}}class qE{engine;isActive=!1;box;pickPoint;pickNormal;pickMesh;box_;plane;meshs;isDrag=!1;maxBox;csgClipping=null;useCsgClipping=!1;constructor(e,t){this.engine=e,this.meshs=[],t?.useCsgClipping!==void 0&&(this.useCsgClipping=t.useCsgClipping),this.useCsgClipping&&this.initCsgClipping()}initCsgClipping(){this.csgClipping=new jE(this.engine,{updateThrottleTime:150,cacheExpireTime:45e3}),this.csgClipping.planes=this.engine.sectionPlane,this.csgClipping.init()}active(){this.isActive||(this.engine.handelBehaved.init(this),this.engine.handelBehaved.active(),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,this.init())}disActive(){this.init(),this.isActive=!1,this.engine.handelBehaved.disActive(),this.csgClipping&&this.csgClipping.disActive(),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)})}),this.engine.interactionModule.init(),this.engine.interactionModule.active()}disabled(){this.isActive=!1,this.engine.handelBehaved.disActive(),this.engine.interactionModule.init(),this.engine.interactionModule.active(),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.engine.handelBehaved.init(this),this.engine.handelBehaved.active(),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(){let e=this.engine.octreeBox.getBoundingBox();this.maxBox=JSON.parse(JSON.stringify(e)),this.box=e,this.updata_face(e)}getboxXyz(){return{minX:this.box.min.x,minY:this.box.min.y,minZ:this.box.min.z,maxX:this.box.max.x,maxY:this.box.max.y,maxZ:this.box.max.z}}setboxXyz(e){this.box.min.x=e.minX,this.box.min.y=e.minY,this.box.min.z=e.minZ,this.box.max.x=e.maxX,this.box.max.y=e.maxY,this.box.max.z=e.maxZ,this.updata_face(this.box)}setBox(e){this.box=e,this.updata_face(e)}reverseBox(){}handleMouseDown(e){this.isDrag=!0;const t=e.raycaster.intersectObjects(this.meshs,!1);if(t!=null&&t.length>0)if(this.pickPoint=t[0].point,this.pickNormal=t[0].face.normal,this.engine.controls.enabled=!1,this.pickMesh=t[0].object,this.box_={min:this.box.min.clone(),max:this.box.max.clone()},this.pickNormal.y==0){const n=new It;n.setFromNormalAndCoplanarPoint(new P(0,1,0),this.pickPoint),this.plane=n}else{let n=new P(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new It;i.setFromNormalAndCoplanarPoint(n.clone().sub(this.pickPoint.clone()).setLength(1),this.pickPoint),this.plane=i}}handleMouseUp(e){this.isDrag=!1,this.pickPoint=null,this.pickNormal=null,this.pickMesh=null,this.engine.controls.enabled=!0,this.csgClipping&&this.isActive}handleMouseMove(e){this.meshs.forEach(n=>{n.material.opacity=0});const t=e.raycaster.intersectObjects(this.meshs,!1);if(t!=null&&t.length>0&&(t[0].object.material.opacity=.05),this.pickPoint!=null){const n=new P;if(e.raycaster.ray.intersectPlane(this.plane,n)){let i=n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());this.pickMesh.name=="前"||this.pickMesh.name=="左"||this.pickMesh.name=="底"?this.box.min=this.box_.min.clone().add(this.pickNormal.clone().setLength(i)):this.box.max=this.box_.max.clone().add(this.pickNormal.clone().setLength(i)),this.updata_face(this.box),this.calculate_ratio()}}}calculate_ratio(){let e=this.maxBox.max.x-this.maxBox.min.x,t=this.maxBox.max.y-this.maxBox.min.y,n=this.maxBox.max.z-this.maxBox.min.z,i=(this.box.min.x-this.maxBox.min.x)/e*100,r=(this.box.max.x-this.maxBox.min.x)/e*100,a=(this.box.min.y-this.maxBox.min.y)/t*100,o=(this.box.max.y-this.maxBox.min.y)/t*100,l=(this.box.min.z-this.maxBox.min.z)/n*100,c=(this.box.max.z-this.maxBox.min.z)/n*100;i<0&&(i=0),r<0&&(r=0),a<0&&(a=0),o<0&&(o=0),l<0&&(l=0),c<0&&(c=0),i>100&&(i=100),r>100&&(r=100),a>100&&(a=100),o>100&&(o=100),l>100&&(l=100),c>100&&(c=100);let h={x:{min:i,max:r},y:{min:a,max:o},z:{min:l,max:c}};this.engine.events.trigger(Yt.SectionMove,h)}updata_face(e){let t=this,n=[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.max.y,e.min.z),new P(e.min.x,e.max.y,e.min.z)],i=[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)],r=[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)],a=[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)],o=[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.max.y,e.max.z),new P(e.min.x,e.max.y,e.max.z)],l=[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)];c(n,new P(0,0,-1),"前"),c(i,new P(0,0,1),"后"),c(r,new P(1,0,0),"右"),c(a,new P(-1,0,0),"左"),c(o,new P(0,1,0),"顶"),c(l,new P(0,-1,0),"底");function c(h,d,p){const u=new pt,g=new Float32Array([h[0].x,h[0].y,h[0].z,h[1].x,h[1].y,h[1].z,h[2].x,h[2].y,h[2].z,h[3].x,h[3].y,h[3].z]),f=[0,1,2,0,2,3];u.setAttribute("position",new bt(g,3)),u.setIndex(f);let x=t.engine.scene.children.find(M=>M.type=="Group"&&M.name=="ClippingBox");x==null&&(x=new ln,x.name="ClippingBox",t.engine.scene.add(x));let m=t.meshs.find(M=>M.name==p);if(m==null){const M=new Ht({color:65280,transparent:!0,opacity:0,side:yt});M.polygonOffset=!0,M.polygonOffsetFactor=1,M.polygonOffsetUnits=4;const T=new at(u,M);T.normal=d,T.name=p,x.add(T),t.meshs.push(T)}else m.geometry=u;const b=new Float32Array([h[0].x,h[0].y,h[0].z,h[1].x,h[1].y,h[1].z,h[2].x,h[2].y,h[2].z,h[3].x,h[3].y,h[3].z,h[0].x,h[0].y,h[0].z]);let v=new Ms({color:255}),y=new pt;y.setAttribute("position",new bt(b,3));let _=t.meshs.find(M=>M.name==p+"Line");_==null&&(_=new $i(y,v),_.name=p+"Line",x.add(_),t.meshs.push(_)),_.geometry=y,_.material=v,p=="前"||p=="左"||p=="底"?t.engine.sectionPlane.find(M=>M.name==p).setFromNormalAndCoplanarPoint(d.clone().setLength(-1),e.min):t.engine.sectionPlane.find(M=>M.name==p).setFromNormalAndCoplanarPoint(d.clone().setLength(-1),e.max),t.engine.scene.children.filter(M=>M.type=="Mesh"&&M.url).forEach(M=>{M.material&&Array.isArray(M.material)?M.material.forEach(T=>{T.clippingPlanes=t.engine.sectionPlane}):M.material.clippingPlanes=t.engine.sectionPlane})}}}class ZE{engine;isActive=!1;isDrag=!1;meshs=[];box;pickPoint;pickNormal;pickMesh;box_;plane;angleX=0;angleY=0;angleZ=0;direction=1;normal=new P(0,0,1);distance=0;center=null;current_center=null;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(n=>{n.name.includes("face")&&(n.visible=!0)})}),this.engine.handelBehaved.init(this),this.engine.handelBehaved.active();let e=this;e.engine.scene.children.filter(t=>t.type=="Mesh"&&t.url).forEach(t=>{t.material&&Array.isArray(t.material)?t.material.forEach(n=>{n.clippingPlanes=e.engine.sectionPlane}):t.material.clippingPlanes=e.engine.sectionPlane,e.engine.clipping.clippingStencil?.addMesh(e.engine.sectionPlane.find(n=>n.name=="face"),t)}),this.init()}disActive(){this.init(),this.isActive=!1,this.engine.handelBehaved.disActive();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(n=>{n.name.includes("face")&&(n.visible=!1)})})}init(){let e=this.engine.octreeBox.getBoundingBox();this.box=e,this.updata_face(0)}disabled(){this.isActive=!1,this.engine.handelBehaved.disActive(),this.engine.interactionModule.init(),this.engine.interactionModule.active(),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.engine.handelBehaved.init(this),this.engine.handelBehaved.active(),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,n){this.angleX=e,this.angleY=t,this.angleZ=n,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),n),this.normal.normalize(),this.updata_face(0)}setFaceNormal(e,t=0){this.normal=e,this.distance=t,this.updata_face(t)}reverse(){this.direction=this.direction*-1,this.updata_face(this.distance)}getFaceAngle(){return{angleX:this.angleX,angleY:this.angleY,angleZ:this.angleZ,direction:this.direction}}updata_face(e){let t=this,n=t.engine.scene.children.find(R=>R.type=="Group"&&R.name=="ClippingBox");n==null&&(n=new ln,n.name="ClippingBox",t.engine.scene.add(n));let i=new P(1,0,0),r=new P(0,1,0),a=new P(0,0,1),o,l,c=this.normal.clone().normalize(),h=Math.abs(c.dot(i)),d=Math.abs(c.dot(r)),p=Math.abs(c.dot(a));h<=d&&h<=p?o=i:d<=h&&d<=p?o=r:o=a,o=o.clone().sub(c.clone().multiplyScalar(o.dot(c))).normalize(),l=new P().crossVectors(c,o).normalize();let u=null;this.center==null?(u=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=u.clone()):u=this.center.clone();let g=this.box.max.x-this.box.min.x,f=this.box.max.y-this.box.min.y,x=this.box.max.z-this.box.min.z,m=Math.max(Math.abs(o.x)*g,Math.abs(o.y)*f,Math.abs(o.z)*x),b=Math.max(Math.abs(l.x)*g,Math.abs(l.y)*f,Math.abs(l.z)*x),v=u.clone().add(o.clone().multiplyScalar(-m/2)).add(l.clone().multiplyScalar(-b/2)),y=u.clone().add(o.clone().multiplyScalar(m/2)).add(l.clone().multiplyScalar(-b/2)),_=u.clone().add(o.clone().multiplyScalar(m/2)).add(l.clone().multiplyScalar(b/2)),M=u.clone().add(o.clone().multiplyScalar(-m/2)).add(l.clone().multiplyScalar(b/2));v.add(c.clone().multiplyScalar(e)),y.add(c.clone().multiplyScalar(e)),_.add(c.clone().multiplyScalar(e)),M.add(c.clone().multiplyScalar(e)),this.current_center=u.clone().add(c.clone().multiplyScalar(e)),T([v,y,_,M],c,"face");function T(R,w,E){const I=new pt,A=new Float32Array([R[0].x,R[0].y,R[0].z,R[1].x,R[1].y,R[1].z,R[2].x,R[2].y,R[2].z,R[3].x,R[3].y,R[3].z]),B=[0,1,2,0,2,3];I.setAttribute("position",new bt(A,3)),I.setIndex(B);let S=t.meshs.find(j=>j.name==E);if(S==null){const j=new Ht({color:65280,transparent:!0,opacity:.02,side:yt});j.polygonOffset=!0,j.polygonOffsetFactor=1,j.polygonOffsetUnits=4;const ie=new at(I,j);ie.normal=w,ie.name=E,n.add(ie),t.meshs.push(ie)}else S.geometry=I;const U=new Float32Array([R[0].x,R[0].y,R[0].z,R[1].x,R[1].y,R[1].z,R[2].x,R[2].y,R[2].z,R[3].x,R[3].y,R[3].z,R[0].x,R[0].y,R[0].z]);let H=new Ms({color:255}),G=new pt;G.setAttribute("position",new bt(U,3));let Z=t.meshs.find(j=>j.name==E+"Line");Z==null&&(Z=new $i(G,H),Z.name=E+"Line",n.add(Z),t.meshs.push(Z)),Z.geometry=G,Z.material=H,t.engine.sectionPlane.find(j=>j.name==E).setFromNormalAndCoplanarPoint(w.clone().setLength(t.direction),R[0])}}handleMouseDown(e){this.isDrag=!0;const t=e.raycaster.intersectObjects(this.meshs,!1);if(t!=null&&t.length>0)if(this.pickPoint=t[0].point,this.pickNormal=t[0].face.normal,this.engine.controls.enabled=!1,this.pickMesh=t[0].object,this.box_={min:this.box.min.clone(),max:this.box.max.clone()},this.center=this.current_center.clone(),this.pickNormal.y==0){const n=new It;n.setFromNormalAndCoplanarPoint(new P(0,1,0),this.pickPoint),this.plane=n}else{let n=new P(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new It;i.setFromNormalAndCoplanarPoint(n.clone().sub(this.pickPoint.clone()).setLength(1),this.pickPoint),this.plane=i}}handleMouseUp(e){this.isDrag=!1,this.pickPoint=null,this.pickNormal=null,this.pickMesh=null,this.engine.controls.enabled=!0}handleMouseMove(e){this.meshs.forEach(n=>{n.material.opacity=0});const t=e.raycaster.intersectObjects(this.meshs,!1);if(t!=null&&t.length>0&&(t[0].object.material.opacity=.05),this.pickPoint!=null){const n=new P;if(e.raycaster.ray.intersectPlane(this.plane,n)){let i=n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());this.distance=i,this.updata_face(this.distance)}}}}class YE{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){let t=e.catch.normal;this.engine.handelBehaved.disActive(),this.callback_({dir:t,position:e.catch.point})}}class $E{engine;sectionBox;sectionFace;clippingStencil;currentClippingMode="";constructor(e){this.engine=e;let t=new It(new P(0,0,1),1e5);t.name="前";let n=new It(new P(0,0,1),1e5);n.name="左";let i=new It(new P(0,0,1),1e5);i.name="后";let r=new It(new P(0,0,1),1e5);r.name="右";let a=new It(new P(0,0,1),1e5);a.name="顶";let o=new It(new P(0,0,1),1e5);o.name="底";let l=new It(new P(0,0,1),1e5);l.name="face",this.engine.sectionPlane=[t,n,i,r,a,o,l]}init(){this.sectionBox=new qE(this.engine),this.sectionFace=new ZE(this.engine)}scaleBox(){let e=this.engine.octreeBox.getBoundingBox();this.sectionBox.setBox(e)}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 n=i(t);this.sectionBox.setBox(n);function i(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 ut(a,o)}}updateClippingValue(e){let t=this.sectionBox.maxBox,n=t.min.x+(t.max.x-t.min.x)*e.x.min*.01,i=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:n,minY:i,minZ:r,maxX:a,maxY:o,maxZ:l})}active(e){if(this.sectionFace.disActive(),this.sectionBox.disActive(),this.currentClippingMode=e,e=="x")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(Math.PI/2,0,0);else if(e=="y")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(0,Math.PI/2,0);else if(e=="z")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(0,0,Math.PI/2);else if(e=="box")this.sectionBox.init(),this.sectionBox.active();else if(e=="face"){let t=new YE(this.engine);t.init(),t.catch_face(n=>{this.sectionFace.init(),this.sectionFace.active();let i=this.engine.octreeBox.getBoundingBox(),r=n.position.clone().sub(i.min.clone().add(i.max.clone()).setLength(.5)),a=new P(n.dir.x,n.dir.y,n.dir.z),o=r.dot(a);this.sectionFace.setFaceNormal(n.dir,o)})}}disabled(){this.currentClippingMode=="box"?this.sectionBox.disabled():this.sectionFace.disabled()}recover(){this.currentClippingMode=="box"?this.sectionBox.recover():this.sectionFace.recover()}reverse(){this.sectionFace.reverse()}disActive(){this.sectionFace.disActive(),this.sectionBox.disActive(),this.currentClippingMode=""}}class KE{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 JE{engine;constructor(e){this.engine=e}getEngineInfo(){let e=0,t=0,n=0;return!this.engine||!this.engine.scene?{totalVertices:0,totalTriangles:0,meshCount:0}:(this.engine.scene.traverse(i=>{if(i instanceof at){const r=i.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(i=>{n=n+i.info.modelEdge.length}),{totalVertices:Math.floor(e),totalTriangles:Math.floor(t),meshCount:n})}}class QE{engine;constructor(e){this.engine=e}init(){}getModelProperties(e,t,n){let i=this.engine.engineStatus.models.find(a=>a.url===e);i.properties==null&&Wm(e+"/property",a=>{let o=JSON.parse(a);i.properties=o,setTimeout(()=>{r(o,t,n)},100)}),r(i.properties,t,n);function r(a,o,l){let c=[],h=a.models[o.toString()||""],d=h.map(p=>p[0]);d=d.filter((p,u)=>d.indexOf(p)===u),d.forEach(p=>{let u={name:a.categorys[p],children:[]};c.push(u),h.filter(g=>g[0]===p).forEach(g=>{u.children.push({name:a.names[g[1]],value:a.values[g[2]]})})}),l?.({properties:c,materials:c})}}}class eC{engine;constructor(e){this.engine=e}getModelTypes(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(n=>{e.push(n.typeName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelMajors(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(n=>{e.push(n.majorName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelLevels(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(n=>{e.push(n.levelName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelMappers(e){}getModelMapper(e,t){let n=this.engine.engineStatus.models.find(i=>i.url==e);return n?n.info.modelMapper.find(i=>i.id==t):null}getModelsWithLevelType(e,t,n=null){let i=[];return this.engine.engineStatus.models.forEach(r=>{let a={url:r.url,ids:[]};i.push(a),r.info.modelMapper.filter(o=>o.levelName===e&&o.typeName===t).forEach(o=>{a.ids.push(Number(o.id))})}),n&&n(i),i}getModelsWithType(e,t=null){let n=[];return this.engine.engineStatus.models.forEach(i=>{let r={url:i.url,ids:[]};n.push(r),i.info.modelMapper.filter(a=>a.typeName===e).forEach(a=>{r.ids.push(Number(a.id))})}),t&&t(n),n}getModelsWithLevel(e,t){let n=[];return this.engine.engineStatus.models.forEach(i=>{let r={url:i.url,ids:[]};n.push(r),i.info.modelMapper.filter(a=>a.levelName===e).forEach(a=>{r.ids.push(Number(a.id))})}),t&&t(n),n}getModelsWithMajor(e,t){let n=[];return this.engine.engineStatus.models.forEach(i=>{let r={url:i.url,ids:[]};n.push(r),i.info.modelMapper.filter(a=>a.majorName===e).forEach(a=>{r.ids.push(Number(a.id))})}),t&&t(n),n}}class tC{engine;isActive=!1;groupEdge;material;modelEdgeLoaded=!1;indexes=new Map;constructor(e){this.engine=e,this.groupEdge=this.engine.scene.getObjectByName("groupEdge"),this.material=new Ms({color:"#000000",depthTest:!0,transparent:!0,opacity:.3}),this.material.clippingPlanes=this.engine.sectionPlane}active(){this.isActive=!0,this.groupEdge.visible=!0,this.engine.scene.traverse(e=>{e.isMesh&&e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(t=>{t.polygonOffset=!0,t.polygonOffsetFactor=1,t.polygonOffsetUnits=4})}),this.show()}disActive(){this.isActive=!1,this.groupEdge.visible=!1,this.engine.scene.traverse(e=>{e.isMesh&&e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(t=>{t.polygonOffset=!1})})}loadModelEdge(){this.modelEdgeLoaded||(this.engine.engineStatus.models.forEach(e=>{if(!this.groupEdge.children.find(t=>t.url==e.url)){let t=e.info,n=[],i=new Map;t.modelEdge.forEach(r=>{let a=n.length;for(let o=0;o<r.points.length;o++)r.points[o].length==2&&(n.push(r.points[o][0].X),n.push(r.points[o][0].Z),n.push(-r.points[o][0].Y),n.push(r.points[o][1].X),n.push(r.points[o][1].Z),n.push(-r.points[o][1].Y));i.set(Number(r.id),[a,n.length,r.points])}),this.indexes.set(e.url,i)}}),this.modelEdgeLoaded=!0)}show(){this.modelEdgeLoaded||this.loadModelEdge(),this.indexes.forEach((e,t)=>{let n=[];e.forEach((a,o)=>{a[2].forEach((l,c)=>{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))})});let i=new pt;i.setAttribute("position",new jt(n,3));let r=new Hp(i,this.material);r.url=t,this.groupEdge.add(r)})}getModelEdge(e,t){let n=this.indexes.get(e);if(n){let i=n.get(t);if(i)return i.slice()}return null}hideModelEdge(e,t){let n=this.indexes.get(e);if(n){let i=n.get(t);if(i){let[r,a,o]=i,l=this.groupEdge.children.find(c=>c.url==e);if(l){let c=l.geometry.attributes.position.array;for(let h=r;h<a;h++)c[h]=NaN;l.geometry.attributes.position.needsUpdate=!0}}}}showModelEdge(e,t){let n=this.indexes.get(e);if(n){let i=n.get(t);if(i){let[r,a,o]=i,l=this.groupEdge.children.find(c=>c.url==e);if(l){let c=l.geometry.attributes.position.array,h=0;for(let d=r;d<a;d+=3){const p=Math.floor(h/6),u=h%6>=3;if(o[p]&&o[p].length===2){const g=u?o[p][1]:o[p][0];c[d]=g.X,c[d+1]=g.Z,c[d+2]=-g.Y}h+=3}l.geometry.attributes.position.needsUpdate=!0}}}}}class nC{config;constructor(e){this.config={temperature:.7,maxTokens:2e4,timeout:3e5,...e}}async chat(e){const t=new AbortController,n=setTimeout(()=>t.abort(),this.config.timeout);try{const i=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(n),!i.ok){const r=await i.json().catch(()=>({}));throw new Error(`API请求失败 (${i.status}): ${r.error?.message||r.message||i.statusText}`)}return(await i.json()).choices?.[0]?.message?.content||""}catch(i){throw clearTimeout(n),i.name==="AbortError"?new Error("请求超时,请重试"):i.message.includes("Failed to fetch")?new Error(`网络请求失败,请检查:
1. 网络连接
2. API地址是否正确
3. 是否有CORS限制`):i}}async chatStream(e,t){const n=new AbortController,i=setTimeout(()=>n.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:n.signal});if(clearTimeout(i),!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 p of d){const u=p.trim();if(!u||!u.startsWith("data: "))continue;const g=u.slice(6);if(g!=="[DONE]")try{const f=JSON.parse(g).choices?.[0]?.delta?.content;f&&t(f,!1)}catch(f){console.warn("解析流式数据失败:",f)}}}}catch(r){throw clearTimeout(i),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 iC{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,n){this._callback_message=e,this._callback_question=t,this._callback_content=n,this.conversationHistory=[];let i={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=i,this.llmApi=new nC(i.llmConfig);try{const r=await Promise.resolve().then(()=>dT);this.prompts.main=r.default;const a=await Promise.resolve().then(()=>uT);this.prompts.step=a.default;const o=await Promise.resolve().then(()=>pT);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 i={role:"system",content:`${this.prompts.main}`},r={role:"system",content:`## BIM引擎API文档
${this.prompts.apiDoc}`};this.conversationHistory.push(i),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 n=await this.parseAnalysisResponse(t);n&&n.questions&&n.questions.length>0&&this._callback_question(n.questions)}async parseAnalysisResponse(e){try{if(e.includes("##question##")){const t=e.match(/##question##\s*([\s\S]*?)(?=##|$)/);if(t){let n=t[1].trim();n=n.replace(/^```json\n?/,"").replace(/^```\n?/,"").replace(/\n?```$/,"");const i=n.match(/(\[[\s\S]*\])/);i&&(n=i[1]);const r=JSON.parse(n);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 n=t[1].trim();n=n.replace(/^```json\n?/,"").replace(/^```\n?/,"").replace(/\n?```$/,"");const i=n.match(/(\[[\s\S]*\])/);return i&&(n=i[1]),this.steps=JSON.parse(n),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),n=await this.executeStep(e,t);this.stepResults.set(e.id,n),this.config?.debug&&console.log(`[AI Manager] 步骤 ${e.id} 执行完成:`,n)}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 n=this.config?.stepExecution?.maxRetries??1,i=[];let r=null,a=!1;for(let o=0;o<=n;o++)try{const l=i.length>0?i[i.length-1]:"",c=await(o===0?this.generateCode(e,t):a?this.regenerateCodeAfterFailure(e,t,l,r,o):this.generateCode(e,t));i.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>=n)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修复后重试剩余重试次数${n-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 n=[/```javascript\s*([\s\S]*?)```/i,/```js\s*([\s\S]*?)```/i,/```\s*([\s\S]*?)```/];for(const a of n){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 i=/[请|说明|注意|需要|应该|可以|如果|但是|因为|所以|例如|比如]/i.test(e),r=/(function|const|let|var|return|async|await|=>|engine\.|previousStepOutput)/.test(e);if(!i&&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 n={role:"system",content:`${this.prompts.step}`},i={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=[n,i,r],o=await this.llmApi.chat(a);return this.extractCodeFromResponse(o)}catch(n){throw console.error("[AI Manager] 代码生成失败:",n),n}}async regenerateCodeAfterFailure(e,t,n,i,r){try{const a={role:"system",content:`${this.prompts.step}`},o={role:"system",content:`
## BIM引擎API文档
${this.prompts.apiDoc}`},l={message:i?.message||(i instanceof Object?JSON.stringify(i):String(i)),name:i?.name,stack:i?.stack},c={role:"user",content:`上一次生成的代码在执行时失败了,请你修复后重新输出完整可执行的 JavaScript 代码(仍然要严格按 ##code## 格式输出)。
当前步骤信息:
${JSON.stringify(e,null,2)}
前序步骤输出数据:
${t?JSON.stringify(t,null,2):"null"}
上一次生成的代码:
${n?`
\`\`\`javascript
${n}
\`\`\`
`:`
(无)
`}
执行错误信息(第 ${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 n=this.engine;let i=e;i=i.replace(/\b(const|let|var)\s+previousStepOutput\s*=\s*[^;]*;/g,""),i=i.replace(/\b(const|let|var)\s+previousStepOutput\s*;/g,"");const r=new Function("engine","previousStepOutput",`
'use strict';
${i}
`)(n,t);return r&&typeof r.then=="function"?await r:r}catch(n){return console.error("[AI Manager] 代码执行失败:",n),"error"+n.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 sC{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,n={}){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,...n},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,n=Math.min(e/t,1),i=this.points[this.playFromIndex],r=this.points[this.playToIndex],a=this.interpolatePose(i,r,n);this.engine.cameraModule.restoreCameraPose(a),n>=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,n){const i=this.easeInOutCubic(n),r={type:t.type,position:{x:zt.lerp(e.position.x,t.position.x,i),y:zt.lerp(e.position.y,t.position.y,i),z:zt.lerp(e.position.z,t.position.z,i)},rotation:{x:zt.lerp(e.rotation.x,t.rotation.x,i),y:zt.lerp(e.rotation.y,t.rotation.y,i),z:zt.lerp(e.rotation.z,t.rotation.z,i)},quaternion:{x:zt.lerp(e.quaternion.x,t.quaternion.x,i),y:zt.lerp(e.quaternion.y,t.quaternion.y,i),z:zt.lerp(e.quaternion.z,t.quaternion.z,i),w:zt.lerp(e.quaternion.w,t.quaternion.w,i)}};return e.target&&t.target?r.target={x:zt.lerp(e.target.x,t.target.x,i),y:zt.lerp(e.target.y,t.target.y,i),z:zt.lerp(e.target.z,t.target.z,i)}:t.target&&(r.target={...t.target}),e.zoom!==void 0&&t.zoom!==void 0&&(r.zoom=zt.lerp(e.zoom,t.zoom,i)),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 rC{engine;miniMapCamera=null;miniMapRenderer=null;miniMapContainer=null;overlayCanvas=null;overlayCtx=null;isVisible=!1;mapSize=200;currentHalfSize=500;minHalfSize=5;maxHalfSize=1e4;halfSizeInitialized=!1;camY=1e3;centerX=0;centerZ=0;dragMode=null;lastMouseX=0;lastMouseY=0;constructor(e){this.engine=e,this.init()}getstate(){return this.isVisible}init(){this.miniMapContainer=document.createElement("div"),this.miniMapContainer.style.position="absolute",this.miniMapContainer.style.bottom="20px",this.miniMapContainer.style.left="20px",this.miniMapContainer.style.width=`${this.mapSize}px`,this.miniMapContainer.style.height=`${this.mapSize}px`,this.miniMapContainer.style.border="2px solid rgba(255, 255, 255, 0.4)",this.miniMapContainer.style.borderRadius="4px",this.miniMapContainer.style.overflow="hidden",this.miniMapContainer.style.display="none",this.miniMapContainer.style.zIndex="200",this.miniMapContainer.style.pointerEvents="auto",this.miniMapContainer.style.cursor="crosshair",this.engine.container.appendChild(this.miniMapContainer),this.miniMapRenderer=new ad({alpha:!0,antialias:!1}),this.miniMapRenderer.setSize(this.mapSize,this.mapSize),this.miniMapRenderer.setPixelRatio(window.devicePixelRatio),this.miniMapRenderer.setClearColor(1710638,.85),this.miniMapContainer.appendChild(this.miniMapRenderer.domElement);const e=window.devicePixelRatio||1;this.overlayCanvas=document.createElement("canvas"),this.overlayCanvas.width=this.mapSize*e,this.overlayCanvas.height=this.mapSize*e,this.overlayCanvas.style.position="absolute",this.overlayCanvas.style.top="0",this.overlayCanvas.style.left="0",this.overlayCanvas.style.width=`${this.mapSize}px`,this.overlayCanvas.style.height=`${this.mapSize}px`,this.overlayCanvas.style.pointerEvents="none",this.miniMapContainer.appendChild(this.overlayCanvas),this.overlayCtx=this.overlayCanvas.getContext("2d"),this.overlayCtx&&this.overlayCtx.scale(e,e),this.miniMapCamera=new Ai(-this.currentHalfSize,this.currentHalfSize,this.currentHalfSize,-this.currentHalfSize,.1,1e5),this.miniMapCamera.up.set(0,0,-1),this.setupEvents()}worldToPixel(e,t){const n=this.currentHalfSize;return{x:((e-this.centerX)/n*.5+.5)*this.mapSize,y:((t-this.centerZ)/n*.5+.5)*this.mapSize}}pixelToWorld(e,t){const n=this.currentHalfSize;return{x:(e/this.mapSize-.5)*2*n+this.centerX,z:(t/this.mapSize-.5)*2*n+this.centerZ}}setupEvents(){const e=this.miniMapContainer;e.addEventListener("wheel",this.onWheel,{passive:!1}),e.addEventListener("mousedown",this.onMouseDown),e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("mouseup",this.onMouseUp),e.addEventListener("mouseleave",this.onMouseUp),e.addEventListener("contextmenu",t=>t.preventDefault()),["pointerdown","pointermove","pointerup","click","dblclick"].forEach(t=>e.addEventListener(t,n=>n.stopPropagation()))}onWheel=e=>{e.preventDefault(),e.stopPropagation();const t=e.deltaY>0?1.25:.8;this.currentHalfSize=Math.max(this.minHalfSize,Math.min(this.maxHalfSize,this.currentHalfSize*t))};onMouseDown=e=>{e.stopPropagation();const t=this.miniMapContainer.getBoundingClientRect(),n=e.clientX-t.left,i=e.clientY-t.top,r=this.engine.camera;if(!r)return;const{x:a,y:o}=this.worldToPixel(r.position.x,r.position.z);Math.hypot(n-a,i-o)<25?(this.dragMode="rotate",this.miniMapContainer.style.cursor="alias"):(this.dragMode=null,this.handleTeleport(n,i)),this.lastMouseX=n,this.lastMouseY=i};onMouseMove=e=>{if(e.stopPropagation(),this.dragMode!=="rotate")return;const t=this.miniMapContainer.getBoundingClientRect(),n=e.clientX-t.left,i=e.clientY-t.top;this.handleRotate(n,i),this.lastMouseX=n,this.lastMouseY=i};onMouseUp=e=>{e.stopPropagation(),this.dragMode=null,this.miniMapContainer&&(this.miniMapContainer.style.cursor="crosshair")};handleTeleport(e,t){const n=this.engine.camera,i=this.engine.controls;if(!n||!i)return;const{x:r,z:a}=this.pixelToWorld(e,t),o=r-n.position.x,l=a-n.position.z;n.position.x+=o,n.position.z+=l,i.target.x+=o,i.target.z+=l,i.update()}handleRotate(e,t){const n=this.engine.camera,i=this.engine.controls;if(!n||!i)return;const r=this.mapSize/2,a=this.mapSize/2,o=Math.atan2(this.lastMouseY-a,this.lastMouseX-r);let l=Math.atan2(t-a,e-r)-o;l>Math.PI&&(l-=2*Math.PI),l<-Math.PI&&(l+=2*Math.PI);const c=new P().copy(i.target).sub(n.position),h=new Kh().setFromVector3(c);h.theta-=l,c.setFromSpherical(h),i.target.copy(n.position).add(c),i.update()}drawOverlay(){const e=this.overlayCtx,t=this.engine.camera;if(!e||!t)return;e.clearRect(0,0,this.mapSize,this.mapSize);const n=this.mapSize/2,i=this.mapSize/2,r=new P;t.getWorldDirection(r);const a=Math.atan2(r.x,-r.z),o=36,l=Math.PI/10;e.save(),e.translate(n,i),e.rotate(a);const c=e.createRadialGradient(0,0,2,0,0,o);c.addColorStop(0,"rgba(0, 230, 130, 0.9)"),c.addColorStop(1,"rgba(0, 230, 130, 0)");const h=-Math.sin(l)*o,d=-Math.cos(l)*o,p=Math.sin(l)*o,u=-Math.cos(l)*o;e.beginPath(),e.moveTo(0,0),e.lineTo(h,d),e.lineTo(p,u),e.closePath(),e.fillStyle=c,e.fill(),e.fillStyle="rgba(255, 255, 255, 0.95)",e.strokeStyle="rgba(0, 200, 110, 0.9)",e.lineWidth=1.5,e.beginPath(),e.arc(0,0,4,0,Math.PI*2),e.fill(),e.stroke(),e.restore()}show(){this.isVisible=!0,this.miniMapContainer&&(this.miniMapContainer.style.display="block")}hide(){this.isVisible=!1,this.miniMapContainer&&(this.miniMapContainer.style.display="none")}toggle(){this.isVisible?this.hide():this.show()}update(){if(!this.isVisible||!this.miniMapCamera||!this.miniMapRenderer)return;const e=this.engine.camera;if(!(!e||!this.engine.scene)){if(this.engine.octreeBox){const t=this.engine.octreeBox.getBoundingBox();if(t?.min&&t?.max){const n=t.max.x-t.min.x,i=t.max.z-t.min.z,r=t.max.y-t.min.y;this.camY=t.max.y+Math.max(n,i,r),!this.halfSizeInitialized&&n+i>0&&(this.currentHalfSize=Math.max(n,i)*2,this.halfSizeInitialized=!0)}}this.centerX=e.position.x,this.centerZ=e.position.z,this.miniMapCamera.left=-this.currentHalfSize,this.miniMapCamera.right=this.currentHalfSize,this.miniMapCamera.top=this.currentHalfSize,this.miniMapCamera.bottom=-this.currentHalfSize,this.miniMapCamera.updateProjectionMatrix(),this.miniMapCamera.position.set(this.centerX,this.camY,this.centerZ),this.miniMapCamera.lookAt(this.centerX,this.camY-1,this.centerZ),this.miniMapRenderer.render(this.engine.scene,this.miniMapCamera),this.drawOverlay()}}dispose(){this.miniMapContainer&&(this.miniMapContainer.removeEventListener("wheel",this.onWheel),this.miniMapContainer.removeEventListener("mousedown",this.onMouseDown),this.miniMapContainer.removeEventListener("mousemove",this.onMouseMove),this.miniMapContainer.removeEventListener("mouseup",this.onMouseUp),this.miniMapContainer.removeEventListener("mouseleave",this.onMouseUp)),this.miniMapRenderer&&(this.miniMapRenderer.dispose(),this.miniMapRenderer=null),this.miniMapContainer&&(this.miniMapContainer.remove(),this.miniMapContainer=null),this.miniMapCamera=null,this.overlayCtx=null,this.overlayCanvas=null}}const aC=[{Id:"100001",Name:"1",Points:[{X:-2,Y:-5,Z:0},{X:-2,Y:5,Z:0}]},{Id:"100002",Name:"2",Points:[{X:2,Y:-5,Z:0},{X:2,Y:5,Z:0}]},{Id:"100003",Name:"A",Points:[{X:-5,Y:-2,Z:0},{X:5,Y:-2,Z:0}]},{Id:"100004",Name:"B",Points:[{X:-5,Y:2,Z:0},{X:5,Y:2,Z:0}]}];class oC{engine;rootGroup=null;isVisible=!1;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(){this.setData(aC)}show(){this.isVisible=!0,this.rootGroup&&(this.rootGroup.visible=!0)}hide(){this.isVisible=!1,this.rootGroup&&(this.rootGroup.visible=!1)}toggle(){this.isVisible?this.hide():this.show()}update(){if(!this.isVisible||!this.rootGroup)return;const e=this.engine.camera,t=this.engine.renderer;if(!e||!t)return;let n=.5;if(e instanceof Ai){const i=e,r=(i.top-i.bottom)/i.zoom,a=t.domElement.clientHeight||1;n=30*r/a}this.rootGroup.traverse(i=>{i instanceof Eh&&i.scale.set(n,n,1)})}dispose(){this._clearAxes(),this.rootGroup&&(this.engine.scene&&this.engine.scene.remove(this.rootGroup),this.rootGroup=null)}_initRoot(){this.rootGroup=new ln,this.rootGroup.name="GridRoot",this.rootGroup.visible=!1,this.engine.scene&&this.engine.scene.add(this.rootGroup)}_clearAxes(){this.axes.forEach(e=>{e.group&&(this.rootGroup?.remove(e.group),e.group.traverse(t=>{const n=t;if("geometry"in n&&n.geometry&&n.geometry.dispose(),"material"in n&&n.material){const i=n.material;"map"in i&&i.map&&i.map.dispose(),i.dispose()}}),e.group=null)}),this.axes=[]}_buildAxis(e){if(!this.rootGroup)return;const t=this.coordinateMapper(e.data.Points[0]),n=this.coordinateMapper(e.data.Points[1]),i=e.data.Name,r=new ln;r.name=`GridAxis_${e.data.Id}`;const a=new pt().setFromPoints([t,n]),o=new Ms({color:1609983,depthTest:!1}),l=new $i(a,o);l.renderOrder=998,r.add(l),r.add(this._makeCircleSprite(i,t)),r.add(this._makeCircleSprite(i,n)),this.rootGroup.add(r),e.group=r}_makeCircleSprite(e,t){const n=document.createElement("canvas");n.width=128,n.height=128;const i=n.getContext("2d"),r=128/2,a=128/2,o=128/2-4;i.beginPath(),i.arc(r,a,o,0,Math.PI*2),i.fillStyle="white",i.fill(),i.strokeStyle="#1890ff",i.lineWidth=6,i.stroke(),i.fillStyle="#1890ff",i.font=`bold ${Math.round(128*.38)}px Arial`,i.textAlign="center",i.textBaseline="middle",i.fillText(e,r,a);const l=new t1(n),c=new Sp({map:l,depthTest:!1,transparent:!0}),h=new Eh(c);return h.position.copy(t),h.scale.set(.5,.5,1),h.renderOrder=999,h}}const lC=[{Id:"339",Name:"站台",Elevation:-.32808398950131235},{Id:"2787",Name:"站厅",Elevation:16.896325459317584},{Id:"236633",Name:"顶板",Elevation:36.745406824146976}];class cC{engine;isVisible=!1;levels=[];svgContainer=null;svgOverlay=null;worldToScreen=null;halfSize=500;COLOR="#1890ff";PLANE_OPACITY=.08;constructor(e){this.engine=e,this._initSvg()}_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)}setData(e){this._clearAll(),this.levels=e.map(t=>({data:t,group:null,svgGroup:null})),this.levels.forEach(t=>this._buildThreeObject(t))}setMockData(){this.setData(lC)}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(){this.isVisible?this.hide():this.show()}update(){!this.isVisible||!this.svgOverlay||!this.levels.length||!this.engine.camera||!this.engine.renderer||(this._initWorldToScreen(),this.levels.forEach(e=>this._updateSvgLabels(e)))}dispose(){this._clearAll(),this.svgContainer&&(this.svgContainer.remove(),this.svgContainer=null),this.svgOverlay=null,this.worldToScreen=null}_initWorldToScreen(){this.engine.camera&&this.engine.renderer&&this.engine.scene&&(this.worldToScreen=new yn(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(n=>n.dispose()):t.material.dispose())}),e.group=null),e.svgGroup&&this.svgOverlay&&(e.svgGroup.remove(),e.svgGroup=null)}),this.levels=[]}_buildThreeObject(e){if(!this.engine.scene)return;const t=e.data.Elevation,n=this.halfSize,i=new ln,r=new Ss(n*2,n*2);r.rotateX(-Math.PI/2);const a=new Ht({color:this.COLOR,transparent:!0,opacity:this.PLANE_OPACITY,side:yt,depthWrite:!1}),o=new at(r,a);o.position.y=t,i.add(o);const l=[new P(-n,t,-n),new P(n,t,-n),new P(n,t,n),new P(-n,t,n),new P(-n,t,-n)],c=new pt().setFromPoints(l),h=new Ms({color:this.COLOR,transparent:!0,opacity:.7});if(i.add(new $i(c,h)),i.visible=this.isVisible,this.engine.scene.add(i),e.group=i,this.svgOverlay){const d=document.createElementNS("http://www.w3.org/2000/svg","g");d.dataset.levelId=e.data.Id;for(let p=0;p<4;p++)d.appendChild(this._makeLabel(e.data.Name,e.data.Elevation));this.svgOverlay.appendChild(d),e.svgGroup=d}}_updateSvgLabels(e){if(!e.svgGroup||!this.worldToScreen)return;const t=this.halfSize,n=e.data.Elevation,i=[new P(-t,n,-t),new P(t,n,-t),new P(t,n,t),new P(-t,n,t)],r=Array.from(e.svgGroup.children);i.forEach((a,o)=>{const l=this.worldToScreen.worldToScreen(a);r[o].setAttribute("x",String(l.x)),r[o].setAttribute("y",String(l.y))})}_makeLabel(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","text");return n.textContent=`${e} ▲${t.toFixed(3)}m`,n.setAttribute("text-anchor","middle"),n.setAttribute("dominant-baseline","central"),n.setAttribute("fill",this.COLOR),n.setAttribute("font-size","12"),n.setAttribute("font-family","Arial, sans-serif"),n.setAttribute("font-weight","bold"),n.setAttribute("stroke","white"),n.setAttribute("stroke-width","2"),n.setAttribute("paint-order","stroke"),n.style.pointerEvents="none",n}}class hC{engine;constructor(e){}update(){}}class dC{engine;currentHdrId="0";isVisible=!0;currentIntensity=.2;currentTexture=null;skybox=null;textureCache=new Map;hdrList=[{id:"0",name:"无"},{id:"1",name:"纯净-多云",url:"assets/hdr/纯净-多云.hdr"},{id:"2",name:"纯净-落日",url:"assets/hdr/纯净-落日.hdr"},{id:"3",name:"纯净-少云",url:"assets/hdr/纯净-少云.hdr"},{id:"4",name:"纯净-无云",url:"assets/hdr/纯净-无云.hdr"},{id:"5",name:"纯净-夜晚",url:"assets/hdr/纯净-夜晚.hdr"},{id:"6",name:"纯净-阴天",url:"assets/hdr/纯净-阴天.hdr"},{id:"7",name:"纯净-中云",url:"assets/hdr/纯净-中云.hdr"}];constructor(e){this.engine=e}getHdrList(){return this.hdrList}async setHdr(e){const t=this.hdrList.find(n=>n.id===e);if(!t){console.warn(`[Hdr] HDR id "${e}" not found`);return}if(e==="0"||!t.url){this._clearHdr(),this.currentHdrId="0";return}if(this.textureCache.has(e)){this._applyTexture(this.textureCache.get(e)),this.currentHdrId=e;return}try{const n=await this._loadHdr(t.url);this.textureCache.set(e,n),this._applyTexture(n),this.currentHdrId=e}catch(n){console.error(`[Hdr] Failed to load HDR "${t.url}":`,n)}}setVisible(e){this.isVisible=e,e&&this.currentTexture&&!this.skybox?this._createSkybox(this.currentTexture):this.skybox&&(this.skybox.visible=e)}getCurrentHdrId(){return this.currentHdrId}getVisible(){return this.isVisible}setIntensity(e){this.currentIntensity=e,this.engine.scene&&(this.engine.scene.environmentIntensity=e),this.skybox&&this.skybox.material.color.setScalar(e)}getIntensity(){return this.currentIntensity}addHdrItem(e){const t=this.hdrList.find(n=>n.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,n)=>{new Fw().load(e,i=>{i.mapping=$a,t(i)},void 0,i=>n(i))})}_applyTexture(e){if(this.currentTexture=e,!this.engine.scene)return;const t=new id(this.engine.renderer),n=t.fromEquirectangular(e).texture;t.dispose(),this.engine.scene.environment=n,this.engine.scene.environmentIntensity=this.currentIntensity,this.engine.scene.background=null,this._removeSkybox(),this.isVisible&&this._createSkybox(e),this.engine.setting.setAmbientLightIntensity(0)}_createSkybox(e){const t=new Vh(500,64,32),n=new Ht({map:e,side:sn,depthWrite:!1,fog:!1});this.skybox=new at(t,n),this.skybox.name="hdr_skybox",this.skybox.renderOrder=-1,this.skybox.frustumCulled=!1,n.color.setScalar(this.currentIntensity),this.engine.scene.add(this.skybox)}_removeSkybox(){this.skybox&&(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.engine.scene.background=null,this.engine.scene.environment=null,this.engine.setting.setAmbientLightIntensity(1))}}class uC{engine;currentId="0";groundGroup;groundMesh=null;waterMaterial=null;clock;groundY=0;groundList=[{id:"0",name:"无"},{id:"1",name:"草地",color:4881486,roughness:.9,metalness:0,map:"/textures/ground/grass.jpg"},{id:"2",name:"混凝土",color:9474192,roughness:.85,metalness:.1,map:"/textures/ground/concrete.jpg"},{id:"3",name:"地砖",color:13152400,roughness:.55,metalness:.1,map:"/textures/ground/tiles.jpg"},{id:"4",name:"湖面",water:!0,waterColor:28062,waveHeight:.04,waveSpeed:.8},{id:"5",name:"海面",water:!0,waterColor:15708,waveHeight:.12,waveSpeed:1.4}];constructor(e){this.engine=e,this.groundGroup=new ln,this.groundGroup.name="groundGroup",this.clock=new mf}init(){this.engine.scene.add(this.groundGroup)}setGround(e,t){if(this._dispose(),this.currentId=e,e==="0")return;const n=this.groundList.find(c=>c.id===e);if(!n)return;const i=t?.size??300,r=n.water?80:1,a=new Ss(i,i,r,r);a.rotateX(-Math.PI/2);let o;if(n.water)o=this._createWaterMaterial(n,t),this.waterMaterial=o;else{const c=new Ki({color:n.color,roughness:n.roughness,metalness:n.metalness}),h=t?.textureUrl??n.map;h&&new Gh().load(h,d=>{d.wrapS=d.wrapT=Tn,d.repeat.set(8,8),c.map=d,c.needsUpdate=!0},void 0,()=>{}),o=c}const l=new at(a,o);l.name="groundMesh",l.receiveShadow=!0,l.castShadow=!1,l.position.y=-.01,this.groundMesh=l,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}_createWaterMaterial(e,t){const n=new Fe(e.waterColor),i=n.clone().multiplyScalar(.35),r=t?.sunDirection?t.sunDirection.clone().normalize():new P(.5,.8,.5).normalize();return new Lt({uniforms:{uTime:{value:0},uWaterColor:{value:n},uDeepColor:{value:i},uSunColor:{value:new Fe(16777215)},uSunDir:{value:r},uWaveHeight:{value:e.waveHeight??.05},uWaveSpeed:{value:e.waveSpeed??1},uOpacity:{value:t?.opacity??.82}},vertexShader:pC,fragmentShader:fC,transparent:!0,side:yt})}update(){if(!this.waterMaterial)return;this.waterMaterial.uniforms.uTime.value=this.clock.getElapsedTime();const e=this.engine.scene?.dirLight;if(e){const t=e.position.clone().normalize();this.waterMaterial.uniforms.uSunDir.value.copy(t)}}getGroundList(){return this.groundList.map(({id:e,name:t})=>({id:e,name:t}))}getCurrentId(){return this.currentId}show(){this.groundGroup.visible=!0}hide(){this.groundGroup.visible=!1}dispose(){this._dispose(),this.engine.scene.remove(this.groundGroup)}_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.waterMaterial=null}}const pC=`
uniform float uTime;
uniform float uWaveHeight;
uniform float uWaveSpeed;
varying vec2 vUv;
varying vec3 vWorldPos;
varying vec3 vNormal;
void main() {
vUv = uv;
vec3 pos = position;
float t = uTime * uWaveSpeed;
// 多层叠加正弦波,模拟真实水面涟漪
float w1 = sin(pos.x * 0.80 + t * 1.20) * uWaveHeight;
float w2 = sin(pos.z * 0.60 + t * 0.90) * uWaveHeight * 1.10;
float w3 = sin((pos.x + pos.z) * 0.50 + t * 1.50) * uWaveHeight * 0.60;
float w4 = sin(pos.x * 1.40 - pos.z * 0.90 + t * 0.70) * uWaveHeight * 0.40;
pos.y += w1 + w2 + w3 + w4;
// 由波形偏导数近似计算法线
float dx = ( cos(pos.x * 0.80 + t * 1.20) * 0.80
+ cos((pos.x + pos.z) * 0.50 + t * 1.50) * 0.50
+ cos(pos.x * 1.40 - pos.z * 0.90 + t * 0.70) * 1.40 ) * uWaveHeight;
float dz = ( cos(pos.z * 0.60 + t * 0.90) * 0.60
+ cos((pos.x + pos.z) * 0.50 + t * 1.50) * 0.50
- cos(pos.x * 1.40 - pos.z * 0.90 + t * 0.70) * 0.90 ) * uWaveHeight;
vNormal = normalize(normalMatrix * vec3(-dx, 1.0, -dz));
vec4 worldPos = modelMatrix * vec4(pos, 1.0);
vWorldPos = worldPos.xyz;
gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);
}
`,fC=`
uniform float uTime;
uniform vec3 uWaterColor;
uniform vec3 uDeepColor;
uniform vec3 uSunColor;
uniform vec3 uSunDir;
uniform float uOpacity;
varying vec2 vUv;
varying vec3 vWorldPos;
varying vec3 vNormal;
void main() {
vec3 N = normalize(vNormal);
vec3 V = normalize(cameraPosition - vWorldPos);
vec3 L = normalize(uSunDir);
// 高频细节法线扰动(模拟毛细波)
float rx = sin(vUv.x * 55.0 + uTime * 3.2) * 0.012
+ sin(vUv.x * 30.0 - uTime * 1.8) * 0.008;
float ry = sin(vUv.y * 50.0 + uTime * 2.8) * 0.012
+ sin(vUv.y * 25.0 - uTime * 2.2) * 0.008;
N = normalize(N + vec3(rx, 0.0, ry));
// FresnelSchlick 近似):掠射角反射更强
float NdotV = clamp(dot(N, V), 0.0, 1.0);
float fresnel = 0.02 + 0.98 * pow(1.0 - NdotV, 5.0);
// 漫反射
float diff = max(dot(N, L), 0.0);
// 高光Blinn-Phong
vec3 H = normalize(L + V);
float spec = pow(max(dot(N, H), 0.0), 160.0);
// 深浅水色混合
float depthFac = clamp((N.y - 0.90) * 10.0, 0.0, 1.0);
vec3 baseCol = mix(uDeepColor, uWaterColor, depthFac);
vec3 color = baseCol * (0.30 + diff * 0.60)
+ uSunColor * spec * 1.0
+ vec3(0.72, 0.88, 1.0) * fresnel * 0.28; // 天空反射色
gl_FragColor = vec4(color, uOpacity);
}
`;class mC{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=3;_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;viewCube;rangeScale;setting;measure;clipping;modelTree;engineInfo;modelProperties;modelMapperBatch;modelEdge;ai;pathRoaming;hoverHighLight;minMap;grid;level;text;hdr;ground;models=[];reactBoundingClientRect={left:0,top:0};version="2.0.6";versionEl=null;container;constructor(e){if(this.options=e,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);this.engineModelModule=new Dw(this),this.engineModelModule.init(),this.ai=new iC(this),this.deviceModule=new C3(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new E3(this),this.sceneModule=new S3(this),this.scene=this.sceneModule.scene,this.renderModule=new T3(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.controlModule=new V3(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.composerModule=new t_(this),this.composerModule.init(),this.events=new Cw,this.engineStatus=new Ew(this),this.engineStatus.init(),this.loaderModule=new Sw(this),this.lightModule=new Tw(this),this.lightModule.init(),this.viewCube=new Ww(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=Xw(this),this.rangeScale=new jw(this),this.rangeScale.init(),this.clipping=new $E(this),this.clipping.init(),this.setting=new qw(this),this.setting.init(),this.engineModelModule.init(),this.handelBehaved=cd(this),this.modelMapperBatch=new eC(this),this.measure=new nS(this),this.modelToolModule=new Pw(this),this.modelProperties=new QE(this),this.interactionModule=new Aw(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new wl(this),this.modelEdge=new tC(this),this.modelTree=new KE(this),this.engineInfo=new JE(this),this.pathRoaming=new sC(this),this.pathRoaming.init(),this.minMap=new rC(this),this.grid=new oC(this),this.level=new cC(this),this.text=new hC(this),this.hdr=new dC(this),this.ground=new uC(this),this.ground.init(),this.worldToScreen=new yn(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new Uw,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 n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.style.position="absolute",n.style.zIndex="1000",n.style.left="0px",n.style.top="0px",n.style.pointerEvents="none",this.container.appendChild(n),this.catchSvg=n,this.onWindowResize=()=>{this.handleWindowResize()},window.addEventListener("resize",this.onWindowResize);let i=this;this.controls.addEventListener("start",()=>{i.events.trigger(ts.EngineBusy)}),this.controls.addEventListener("end",()=>{i.events.trigger(ts.EngineFree)}),this.controls.addEventListener("change",()=>{}),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.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)):o>this._fpsUpgradeThreshold?(this._highFpsCount++,this._lowFpsCount=0):(this._lowFpsCount=0,this._highFpsCount=0)}if(this.scene){let a=this.scene?.dirLight;a&&this.camera&&this.updateLightPosition(this.camera,a)}},this.animate()}updateVersionDisplay(){if(!this.versionEl)return;const e={simple:"simple",balance:"balance",advanced:"advanced"},t=this.engineModelModule?.getCurrentMode()??"",n=e[t]??t;this.versionEl.innerHTML=`v${this.version} | ${n}`}updateLightPosition(e,t){const n=new P;e.getWorldDirection(n);const i=100,r=new P().copy(n).multiplyScalar(-i),a=new P(0,1,0),o=new P().crossVectors(n,a).normalize();r.addScaledVector(a,i*.5),r.addScaledVector(o,i*.3),t.position.copy(e.position).add(r);const l=new P().copy(e.position).add(n.multiplyScalar(20));t.target.position.copy(l),t.target.updateMatrixWorld()}_adaptiveRenderingDowngrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n>0){const i=e[n-1];console.log(`[AdaptiveRendering] FPS低于${this._fpsThreshold},自动降级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}_adaptiveRenderingUpgrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n<e.length-1){const i=e[n+1];console.log(`[AdaptiveRendering] FPS高于${this._fpsUpgradeThreshold},自动升级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}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 i=this.deviceModule.getContainerSize();e=e??i.width,t=t??i.height}if(!e||!t)return;this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t);const n=e/t;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=n,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const i=this.cameraModule.orthographicCamera,r=50,a=this.container.clientWidth/this.container.clientHeight;i.left=r*a/-2,i.right=r*a/2,i.top=r/2,i.bottom=r/-2,i.updateProjectionMatrix()}if(this.catchSvg){const i=this.container.clientWidth,r=this.container.clientHeight;this.catchSvg.setAttribute("viewBox",`0 0 ${i} ${r}`)}this.events&&this.events.trigger(ts.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.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 at&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(t=>this.disposeMaterial(t)):this.disposeMaterial(e.material))),e instanceof $i&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof Wp&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof Ut&&(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 Eh&&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 n=e[t];n&&n instanceof Ft&&n.dispose()}),e.dispose())}}function gC(s){return new mC(s)}class hs{engine=null;registry;container;containerId;options;_isInitialized=!1;_isDestroyed=!1;unsubscribeTheme=null;currentMeasureType=null;isMeasureActive=!1;currentSectionMode=null;selectedComponent=null;constructor(e,t){this.registry=t,this.container=e.container,this.container.id?this.containerId=this.container.id:(this.containerId=`engine-container-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,this.container.id=this.containerId),this.options={backgroundColor:"linear-gradient(to bottom, rgb(214, 224, 235), rgb(246, 250, 255))",version:e.version??"v2",showStats:e.showStats??!1,showViewCube:e.showViewCube??!0}}init(){if(this._isInitialized){console.warn("[Engine] Engine already initialized.");return}if(this._isDestroyed){console.error("[Engine] Cannot initialize destroyed engine.");return}try{typeof this.options.backgroundColor=="string"&&(this.container.style.background=this.options.backgroundColor);const e={containerId:this.containerId,backgroundColor:this.options.backgroundColor,version:this.options.version,showStats:this.options.showStats,showViewCube:this.options.showViewCube};if(console.log("引擎配置信息:",e),this.engine=gC(e),!this.engine)throw new Error("Failed to create engine instance");this._isInitialized=!0,this.unsubscribeTheme=ot.subscribe(t=>{this.setTheme(t)}),this.setTheme(ot.getTheme()),this.engine.events.on("click",t=>{const n=this.registry;t&&Array.isArray(t)&&t.length>0&&t[0].url?(this.selectedComponent={url:t[0].url,id:t[0].ids?.[0]},console.log("[Engine] 构件选中:",this.selectedComponent),n.emit("component:selected",this.selectedComponent)):(this.selectedComponent=null,console.log("[Engine] 取消选中"),n.emit("component:deselected",{}))})}catch(e){throw console.error("[Engine] Failed to initialize engine:",e),this._isInitialized=!1,e}}setTheme(e){}setLocales(){}isInitialized(){return this._isInitialized}loadModel(e,t){if(!this._isInitialized||!this.engine){console.error("[Engine] Engine not initialized. Please call init() first.");return}if(!e||e.length===0){console.error("[Engine] Model URLs are required.");return}this.engine.loaderModule.loadModels(e,t)}CameraGoHome(){this.engine.viewCube.CameraGoHome()}onRawEvent(e,t){this.engine?.events?.on(e,t)}offRawEvent(e,t){this.engine?.events?.off(e,t)}pauseRendering(){if(!this._isInitialized||!this.engine){console.warn("[Engine] Engine not initialized.");return}this.engine.pauseRendering()}resumeRendering(){if(!this._isInitialized||!this.engine){console.warn("[Engine] Engine not initialized.");return}this.engine.resumeRendering()}dispose(){if(!this._isInitialized||!this.engine){console.warn("[Engine] Engine not initialized.");return}this.engine.dispose()}resize(){!this._isInitialized||this.engine}activateMeasure(e){if(!this._isInitialized||!this.engine?.measure){console.error("[Engine] Cannot activate measure: engine not initialized.");return}if(this.currentMeasureType===e){console.log(`[Engine] Measure ${e} already active, skipping.`);return}this.isMeasureActive||(console.log("[Engine] Activating measure module"),this.engine.measure.active(),this.isMeasureActive=!0),console.log(`[Engine] Activating measure: ${e}`);const t=this.engine.measure;switch(e){case"clearHeight":t.clearHeightMeasure.active();break;case"clearDistance":t.clearDistanceMeasure.active();break;case"distance":t.distanceMeasure.active();break;case"elevation":t.elevationMeasure.active();break;case"point":t.pointMeasure.active();break;case"angle":t.angleMeasure.active();break;case"area":t.areaMeasure.active();break;case"slope":t.slopeMeasure.active();break;default:console.error(`[Engine] Unknown measure type: ${e}`);return}this.currentMeasureType=e}getCurrentMeasureType(){return this.currentMeasureType}deactivateMeasure(){!this._isInitialized||!this.engine?.measure||(console.log("[Engine] Deactivating measure"),this.engine.measure.disActive(),this.engine.measure.clearAll(),this.isMeasureActive=!1,this.currentMeasureType=null)}clearAllMeasures(){!this._isInitialized||!this.engine?.measure||(console.log("[Engine] Clearing all measures"),this.engine.measure.clearAll())}saveMeasureSetting(e){!this._isInitialized||!this.engine?.measure||this.engine.measure.saveSetting?.(e)}setClearHeightDirection(e){!this._isInitialized||!this.engine?.measure||(console.log(`[Engine] Setting clearHeight direction: ${e}`),this.engine.measure.clearHeightMeasure.setDirection(e))}setClearHeightSelectType(e){!this._isInitialized||!this.engine?.measure||(console.log(`[Engine] Setting clearHeight selectType: ${e}`),this.engine.measure.clearHeightMeasure.setSelectType(e))}activeSection(e){if(!this._isInitialized||!this.engine?.clipping){console.error("[Engine] Cannot activate section: engine not initialized.");return}if(this.currentSectionMode===e){console.log(`[Engine] Section ${e} already active, skipping.`);return}console.log(`[Engine] Activating section: ${e}`),this.engine.clipping.active(e),this.currentSectionMode=e}getCurrentSectionMode(){return this.currentSectionMode}setSectionBoxRange(e){if(!this._isInitialized||!this.engine?.clipping){console.error("[Engine] Cannot set section box range: engine not initialized.");return}this.engine.clipping.updateClippingValue(e)}deactivateSection(){!this._isInitialized||!this.engine?.clipping||(console.log("[Engine] Deactivating all sections"),this.engine.clipping.disActive(),this.currentSectionMode=null)}hideSection(){if(!this._isInitialized||!this.engine?.clipping){console.error("[Engine] Cannot hide section: engine not initialized.");return}console.log("[Engine] Hiding section"),this.engine.clipping.disabled()}recoverSection(){if(!this._isInitialized||!this.engine?.clipping){console.error("[Engine] Cannot recover section: engine not initialized.");return}console.log("[Engine] Recovering section"),this.engine.clipping.recover()}fitSectionBoxToModel(){if(!this._isInitialized||!this.engine){console.error("[Engine] Cannot fit section box: engine not initialized.");return}const e=this.engine.engineStatus?.highlightModels;e&&(console.log("[Engine] Fitting section box to model"),this.engine.clipping?.clippingModel(e))}scaleSectionBox(){if(!this._isInitialized||!this.engine?.clipping){console.error("[Engine] Cannot scale section box: engine not initialized.");return}this.engine.clipping.scaleBox()}reverseSection(){if(!this._isInitialized||!this.engine?.clipping){console.error("[Engine] Cannot reverse section: engine not initialized.");return}this.engine.clipping.reverse()}switchCamera(){if(!this._isInitialized||!this.engine?.cameraModule){console.warn("[Engine] Cannot switch camera: engine not initialized.");return}this.engine.cameraModule.switchCurrentCamera()}getCameraType(){return!this._isInitialized||!this.engine?.cameraModule?"perspective":this.engine.cameraModule.getCameraType()===1?"orthographic":"perspective"}getRenderMode(){return!this._isInitialized||!this.engine?.engineModelModule?"balance":this.engine.engineModelModule.getCurrentMode()}setRenderMode(e){if(!this._isInitialized||!this.engine?.engineModelModule){console.warn("[Engine] Cannot set render mode: engine not initialized.");return}try{this.engine.engineModelModule.setMode(e)}catch(t){console.warn("[Engine] Failed to set render mode:",t)}}activeModelEdge(){if(!this._isInitialized||!this.engine?.modelEdge){console.warn("[Engine] Cannot active model edge: engine not initialized.");return}this.engine.modelEdge.active()}disActiveModelEdge(){!this._isInitialized||!this.engine?.modelEdge||this.engine.modelEdge.disActive()}getModelEdgeActive(){return!this._isInitialized||!this.engine?.modelEdge?!1:this.engine.modelEdge.getActive?.()??!1}setAmbientLightIntensity(e){if(!this._isInitialized||!this.engine?.setting){console.warn("[Engine] Cannot set ambient light intensity: engine not initialized.");return}this.engine.setting.setAmbientLightIntensity(e)}getAmbientLightIntensity(){return!this._isInitialized||!this.engine?.setting?50:this.engine.setting.getAmbientLightIntensity?.()??50}setSceneContrast(e){if(!this._isInitialized||!this.engine?.setting){console.warn("[Engine] Cannot set scene contrast: engine not initialized.");return}this.engine.setting.setSceneContrast(e)}getSceneContrast(){return!this._isInitialized||!this.engine?.setting?50:this.engine.setting.getSceneContrast?.()??50}setSceneSaturation(e){if(!this._isInitialized||!this.engine?.setting){console.warn("[Engine] Cannot set scene saturation: engine not initialized.");return}this.engine.setting.setSceneSaturation(e)}getSceneSaturation(){return!this._isInitialized||!this.engine?.setting?50:this.engine.setting.getSceneSaturation?.()??50}getHDRBackgroundList(){return!this._isInitialized||!this.engine?.setting?[]:this.engine.setting.getHDRBackground?.()??[]}setHDRBackgroundId(e){if(!this._isInitialized||!this.engine?.setting){console.warn("[Engine] Cannot set HDR background: engine not initialized.");return}this.engine.setting.setHDRBackgroundId(e)}getHDRBackgroundId(){return!this._isInitialized||!this.engine?.setting?"":this.engine.setting.getHDRBackgroundId?.()??""}setHDRBackgroundVisibility(e){if(!this._isInitialized||!this.engine?.setting){console.warn("[Engine] Cannot set HDR background visibility: engine not initialized.");return}this.engine.setting.setHDRBackgroundVisibility(e)}getHDRBackgroundVisibility(){return!this._isInitialized||!this.engine?.setting?!0:this.engine.setting.getHDRBackgroundVisibility?.()??!0}getGroundList(){return!this._isInitialized||!this.engine?.setting?[]:this.engine.setting.getGroundList?.()??[]}setGroundId(e){if(!this._isInitialized||!this.engine?.setting){console.warn("[Engine] Cannot set ground: engine not initialized.");return}this.engine.setting.setGroundId(e)}getGroundId(){return!this._isInitialized||!this.engine?.setting?"":this.engine.setting.getGroundId?.()??""}setGroundElevation(e){if(!this._isInitialized||!this.engine?.setting){console.warn("[Engine] Cannot set ground elevation: engine not initialized.");return}this.engine.setting.setGroundElevation(e)}getGroundElevation(){return!this._isInitialized||!this.engine?.setting?0:this.engine.setting.getGroundElevation?.()??0}isWalkModeActive=!1;activateFirstPersonMode(){if(!this._isInitialized||!this.engine){console.error("[Engine] Cannot activate first person mode: engine not initialized.");return}if(!this.engine.controlModule){console.error("[Engine] Control module not available.");return}if(this.isWalkModeActive){console.log("[Engine] First person mode already active, skipping.");return}console.log("[Engine] Activating first person mode"),this.engine.controlModule.switchFirstPersonMode(),this.loadWalkSettings(),this.isWalkModeActive=!0}deactivateFirstPersonMode(){!this._isInitialized||!this.engine?.controlModule||this.isWalkModeActive&&(console.log("[Engine] Deactivating first person mode"),this.engine.controlModule.switchDefaultMode(),this.isWalkModeActive=!1)}static WALK_SPEED_KEY="bim-walk-speed";static WALK_GRAVITY_KEY="bim-walk-gravity";static WALK_COLLISION_KEY="bim-walk-collision";setWalkSpeed(e){if(!this._isInitialized||!this.engine?.controlModule){console.error("[Engine] Cannot set walk speed: engine not initialized.");return}localStorage.setItem(hs.WALK_SPEED_KEY,String(e)),this.engine.controlModule.setMoveSpeed(e)}setWalkGravity(e){if(!this._isInitialized||!this.engine?.controlModule){console.error("[Engine] Cannot set walk gravity: engine not initialized.");return}localStorage.setItem(hs.WALK_GRAVITY_KEY,String(e)),this.engine.controlModule.setApplyGravity(e)}setWalkCollision(e){if(!this._isInitialized||!this.engine?.controlModule){console.error("[Engine] Cannot set walk collision: engine not initialized.");return}localStorage.setItem(hs.WALK_COLLISION_KEY,String(e)),this.engine.controlModule.setApplyCollision(e)}loadWalkSettings(){if(!this.engine?.controlModule)return;const e=localStorage.getItem(hs.WALK_SPEED_KEY),t=localStorage.getItem(hs.WALK_GRAVITY_KEY),n=localStorage.getItem(hs.WALK_COLLISION_KEY);this.engine.controlModule.setMoveSpeed(e?Number(e):1),this.engine.controlModule.setApplyGravity(t==="true"),this.engine.controlModule.setApplyCollision(n==="true")}toggleMiniMap(){if(!this._isInitialized||!this.engine){console.error("[Engine] Cannot toggle mini map: engine not initialized.");return}this.engine.minMap?.toggle()}getMiniMapState(){return!this._isInitialized||!this.engine?!1:this.engine.minMap?.getstate()??!1}isFirstPersonModeActive(){return this.isWalkModeActive}getSelectedComponent(){return this.selectedComponent}getComponentProperties(e,t,n){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,n)}getTypeTreeData(){return!this._isInitialized||!this.engine?.modelTree?[]:this.engine.modelTree.getTypeTreeData()}getLevelTreeData(){return!this._isInitialized||!this.engine?.modelTree?[]:this.engine.modelTree.getLevelTreeData()}getMajorTreeData(){return!this._isInitialized||!this.engine?.modelTree?[]:this.engine.modelTree.getMajorTreeData()}activateZoomBox(){if(!this._isInitialized||!this.engine){console.warn("[Engine] Engine not initialized.");return}this.engine.rangeScale?.active()}getEngineInfo(){return!this._isInitialized||!this.engine?(console.warn("[Engine] Engine not initialized."),null):this.engine.engineInfo.getEngineInfo()}pathRoamingAddPoint(){if(!this._isInitialized||!this.engine?.pathRoaming){console.warn("[Engine] pathRoaming not available");return}this.engine.pathRoaming.addPoint(0)}pathRoamingRemovePoint(e){if(!this._isInitialized||!this.engine?.pathRoaming){console.warn("[Engine] pathRoaming not available");return}this.engine.pathRoaming.removePoint(e)}pathRoamingClearPoints(){if(!this._isInitialized||!this.engine?.pathRoaming){console.warn("[Engine] pathRoaming not available");return}this.engine.pathRoaming.clearPoints()}pathRoamingGetPoints(){return!this._isInitialized||!this.engine?.pathRoaming?(console.warn("[Engine] pathRoaming not available"),[]):this.engine.pathRoaming.getPoints()??[]}pathRoamingJumpToPoint(e){if(!this._isInitialized||!this.engine?.pathRoaming){console.warn("[Engine] pathRoaming not available");return}this.engine.pathRoaming.jumpToPoint(e)}pathRoamingPlay(e){if(!this._isInitialized||!this.engine?.pathRoaming){console.warn("[Engine] pathRoaming not available");return}this.engine.pathRoaming.play(e)}pathRoamingStop(){if(!this._isInitialized||!this.engine?.pathRoaming){console.warn("[Engine] pathRoaming not available");return}this.engine.pathRoaming.stop()}getHighlightModels(){return!this._isInitialized||!this.engine?null:this.engine.engineStatus?.highlightModels??null}highlightModel(e){if(!this._isInitialized||!this.engine?.modelToolModule){console.warn("[Engine] Cannot highlight model: engine not initialized.");return}const t=this.sanitizeModelParams(e);if(t.length)try{this.engine.modelToolModule.highlightModel(t)}catch(n){console.warn("[Engine] highlightModel failed:",n)}}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(n){console.warn("[Engine] viewScaleToModel failed:",n)}}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(n){console.warn("[Engine] hideModels failed:",n)}}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(n){console.warn("[Engine] showModel failed:",n)}}sanitizeModelParams(e){if(!Array.isArray(e))return[];const t=a=>a.replace(/\/+$/,""),n=Array.isArray(this.engine?.models)?this.engine.models:[],i=new Map;for(const a of n)a?.url&&i.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=i.get(t(a.url));if(!o||!(o.nodesMap instanceof Map))continue;const l=new Set;for(const h of a.ids){if(!Number.isFinite(h))continue;const d=Number(h);if(!Number.isInteger(d))continue;const p=o.nodesMap.get(d);!p||!Array.isArray(p.indexes)||p.indexes.length===0||l.add(d)}const c=Array.from(l);c.length&&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)}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 xC{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 n=e.clientX-this.mouseDownX,i=e.clientY-this.mouseDownY;n*n+i*i>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 n=this.element.getBoundingClientRect(),i=window.innerWidth,r=window.innerHeight;let a=e,o=t;e+n.width>i&&(a=e-n.width),t+n.height>r&&(o=t-n.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 gu{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=Qt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ot.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 n=new Map,i="default";e.forEach(a=>{const o=a.group||i;n.has(o)||n.set(o,[]),n.get(o).push(a)});let r=[];if(t){r=t.filter(a=>n.has(a));for(const a of n.keys())r.includes(a)||r.push(a)}else r=Array.from(n.keys());r.forEach((a,o)=>{if(o>0){const c=document.createElement("li");c.className="bim-menu-divider",this.element.appendChild(c)}const l=n.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"),n=!e.disabled;t.className=`bim-menu-item ${n?"":"disabled"}`;const i=document.createElement("div");i.className="bim-menu-item-icon",e.icon&&(i.innerHTML=e.icon),t.appendChild(i);const r=document.createElement("div");r.className="bim-menu-item-label",r.textContent=xe(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 n&&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 n=e.children;if(!n||n.length===0)return;this.closeSubMenu();const i=document.createElement("div");i.style.position="fixed",i.style.zIndex="10001";const r=t.getBoundingClientRect();i.style.top=`${r.top}px`,i.style.left=`${r.right}px`,i.addEventListener("mousedown",l=>l.stopPropagation());const a=new gu({items:n});a.init(),i.appendChild(a.element),document.body.appendChild(i),this.activeSubMenu={menu:a,container:i};const o=i.getBoundingClientRect();o.right>window.innerWidth&&(i.style.left=`${r.left-o.width}px`)}closeSubMenu(){this.activeSubMenu&&(this.activeSubMenu.menu.destroy(),this.activeSubMenu.container.remove(),this.activeSubMenu=null)}}class Q0 extends xi{container;rightKeyPanel;contextHandlers=[];constructor(e,t){super(t),this.container=e,this.rightKeyPanel=new xC({zIndex:9e3,container:this.container,onContext:this.handleContextMenu}),this.rightKeyPanel.init()}destroy(){this.rightKeyPanel.destroy(),super.destroy()}registerHandler(e){this.contextHandlers.push(e)}showMenu(e,t,n,i){if(!n||n.length===0)return;const r=new gu({items:n,groupOrder:i});r.init(),this.rightKeyPanel.mount(r),this.rightKeyPanel.show(e,t)}hide(){this.rightKeyPanel.hide()}handleContextMenu=e=>{let t=null;for(const n of this.contextHandlers){const i=n(e);i&&i.length>0&&(t||(t=[]),t=t.concat(i))}t&&t.length>0?this.showMenu(e.clientX,e.clientY,t):this.hide()}}class vC extends xi{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 hs({container:this.container,...e},this.registry),this.engineInstance.init(),this.rightKey=new Q0(this.container,this.registry),this.rightKey.registerHandler(t=>{const n=this.engineInstance?.getSelectedComponent(),i=[];return n&&(i.push({id:"componentDetail",label:"menu.componentDetail",group:"component",order:1,divider:!0,onClick:()=>{this.registry.componentDetail?.show(),this.rightKey?.hide()}}),i.push({id:"hideSelected",label:"menu.hideSelected",group:"component",order:2,onClick:()=>{const r=this.engineInstance?.getHighlightModels();r&&this.engineInstance?.hideModels(r),this.rightKey?.hide()}}),i.push({id:"transparentSelected",label:"menu.transparentSelected",group:"component",order:3,onClick:()=>{const r=this.engineInstance?.getHighlightModels();r&&this.engineInstance?.translucentModels(r),this.rightKey?.hide()}}),i.push({id:"cancelTranslucent",label:"menu.cancelTranslucent",group:"component",order:4,onClick:()=>{this.engineInstance?.unTranslucentModel(),this.rightKey?.hide()}}),i.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()}}]}),i.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()}}]}),i.push({id:"fitSectionBox",label:"menu.fitSectionBox",group:"component",order:7,onClick:()=>{this.engineInstance?.fitSectionBoxToModel(),this.rightKey?.hide()}})),i.push({id:"showAll",label:"menu.showAll",group:"component",order:8,onClick:()=>{this.engineInstance?.showAllModels(),this.emit("menu:show-all",{}),this.rightKey?.hide()}}),i}),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()}destroy(){this.engineInstance&&(this.engineInstance.destroy(),this.engineInstance=null),this.rightKey&&(this.rightKey.destroy(),this.rightKey=null),super.destroy()}}var Mt=(s=>(s[s.Unchecked=0]="Unchecked",s[s.Checked=1]="Checked",s[s.Indeterminate=2]="Indeterminate",s))(Mt||{});class bC{config;element;children=[];parent=null;checkState=Mt.Unchecked;contentEl;switcherEl;checkboxEl=null;titleEl;actionsEl;childrenContainer;onExpandChange;onCheckChange;onNodeClick;renderActions;constructor(e,t,n){this.config=e,this.onExpandChange=n.onExpand,this.onCheckChange=n.onCheck,this.onNodeClick=n.onClick,this.renderActions=t.renderActions,this.checkState=e.checked?Mt.Checked:Mt.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 n=this.config.children&&this.config.children.length>0;if(n?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.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 i=e.indent||24;return this.childrenContainer.style.paddingLeft=`${i}px`,this.config.expanded&&n&&this.childrenContainer.classList.add("is-visible"),t.appendChild(this.childrenContainer),t}setSelected(e){if(e){if(this.contentEl.classList.add("is-selected"),this.renderActions){const t=this.renderActions(this.config);this.actionsEl.innerHTML="",typeof t=="string"?this.actionsEl.innerHTML=t:t instanceof HTMLElement&&this.actionsEl.appendChild(t)}}else this.contentEl.classList.remove("is-selected"),this.actionsEl.innerHTML=""}updateLabel(){this.titleEl&&(this.titleEl.textContent=this.config.label)}toggleExpand(e){if(!this.config.children||this.config.children.length===0)return;const t=e!==void 0?e:!this.config.expanded;this.config.expanded=t,t?(this.switcherEl.classList.add("is-expanded"),this.childrenContainer.classList.add("is-visible")):(this.switcherEl.classList.remove("is-expanded"),this.childrenContainer.classList.remove("is-visible")),e===void 0&&this.onExpandChange(this)}toggleCheck(){const e=this.checkState!==Mt.Checked;this.setChecked(e?Mt.Checked:Mt.Unchecked,!0)}setChecked(e,t=!1,n=!1){!n&&this.checkState===e||(this.checkState=e,this.config.checked=e===Mt.Checked,this.updateCheckboxUI(),t&&this.onCheckChange(this))}updateCheckboxUI(){this.checkboxEl&&(this.checkboxEl.classList.remove("is-checked","is-indeterminate"),this.checkState===Mt.Checked?this.checkboxEl.classList.add("is-checked"):this.checkState===Mt.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 yC{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 n=document.createElement("span");n.className="bim-tree-search-icon",n.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(n),this.searchInput=document.createElement("input"),this.searchInput.className="bim-tree-search-input",this.searchInput.type="text",this.searchInput.placeholder=xe(this.options.searchPlaceholder||"搜索..."),this.searchInput.addEventListener("input",i=>{const r=i.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=i=>{this.searchResults&&!this.searchResults.contains(i.target)&&!this.searchInput?.contains(i.target)&&this.searchResults.classList.remove("is-visible")},document.addEventListener("click",this.clickOutsideHandler)}init(){this.render(),this.unsubscribeLocale=Qt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ot.subscribe(e=>this.setTheme(e)),this.setTheme(ot.getTheme())}handleSearch(e){if(!this.searchResults)return;if(!e.trim()){this.searchResults.classList.remove("is-visible"),this.searchResults.innerHTML="";return}const t=[],n=e.toLowerCase();this.nodeMap.forEach(i=>{const r=i.config.label;r.toLowerCase().includes(n)&&t.push({node:i,label:r,path:this.getNodePath(i)})}),this.renderSearchResults(t)}getNodePath(e){const t=[];let n=e.parent;for(;n;)t.unshift(n.config.label),n=n.parent;return t.join(" > ")}renderSearchResults(e){if(this.searchResults){if(this.searchResults.innerHTML="",e.length===0){const t=document.createElement("div");t.className="bim-tree-search-item",t.style.cursor="default",t.style.color="#999",t.textContent="No results",this.searchResults.appendChild(t)}else e.forEach(t=>{const n=document.createElement("div");n.className="bim-tree-search-item";const i=document.createElement("span");i.className="bim-tree-search-item-title",i.textContent=t.label;const r=document.createElement("span");r.className="bim-tree-search-item-path",r.textContent=t.path,n.appendChild(i),t.path&&n.appendChild(r),n.addEventListener("click",()=>{this.revealNode(t.node)}),this.searchResults.appendChild(n)});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 n=t.getBoundingClientRect(),i=e.element.getBoundingClientRect();return i.top>=n.top&&i.bottom<=n.bottom}scrollNodeIntoContentCenter(e){const t=this.contentElement;if(!t||!e?.element?.isConnected)return;const n=t.getBoundingClientRect(),i=e.element.getBoundingClientRect();if(i.top>=n.top&&i.bottom<=n.bottom)return;const r=i.top-n.top+t.scrollTop,a=Math.max(0,r-(t.clientHeight-i.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=xe(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 n=new bC(e,this.options,{onExpand:i=>{this.onNodeExpand&&this.onNodeExpand(i)},onCheck:i=>this.handleNodeCheck(i),onClick:i=>this.handleNodeSelect(i)});this.nodeMap.set(e.id,n),t?t.appendChild(n):(this.rootNodes.push(n),this.contentElement.appendChild(n.element)),e.children&&e.children.length>0&&e.children.forEach(i=>{this.createNodeRecursively(i,n)})}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===Mt.Checked;if(this.onNodeCheck&&this.onNodeCheck(e),this.options.checkStrictly===!1)return;const n=(r,a)=>{r.children.forEach(o=>{o.config.disabled||(o.setChecked(a,!1),n(o,a))})};t?n(e,Mt.Checked):n(e,Mt.Unchecked);let i=e.parent;for(;i;){if(i.config.disabled){i=i.parent;continue}const r=i.children,a=r.every(l=>l.checkState===Mt.Checked),o=r.every(l=>l.checkState===Mt.Unchecked);a?i.setChecked(Mt.Checked,!1):o?i.setChecked(Mt.Unchecked,!1):i.setChecked(Mt.Indeterminate,!1),i=i.parent}}getNode(e){return this.nodeMap.get(e)}checkNode(e,t){const n=this.nodeMap.get(e);n&&n.setChecked(t?Mt.Checked:Mt.Unchecked,!0)}expandAll(e){this.nodeMap.forEach(t=>t.toggleExpand(e))}checkAllNodes(e){const t=e?Mt.Checked:Mt.Unchecked;this.nodeMap.forEach(n=>n.setChecked(t,!1,!0))}getCheckedNodes(e=!1){const t=[];return this.nodeMap.forEach(n=>{(n.checkState===Mt.Checked||e&&n.checkState===Mt.Indeterminate)&&t.push(n.config)}),t}}class eg{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(ot.getTheme()),this.unsubscribeLocale=Qt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ot.subscribe(e=>this.setTheme(e))}renderNav(){this.navElement.innerHTML="",this.navClickHandler=e=>{const t=e.target.closest(".bim-tab__item");if(!t)return;const n=t.dataset.id;!n||this.tabMap.get(n)?.disabled||this.activateTab(n)},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 i=document.createElement("span");i.className="bim-tab__icon",i.innerHTML=e.icon,t.appendChild(i)}const n=document.createElement("span");n.className="bim-tab__title",n.textContent=this.resolveTitle(e.title),t.appendChild(n),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(i=>{const r=i.dataset.id===e;i.classList.toggle("is-active",r),i.setAttribute("aria-selected",`${r}`)}),this.panelMap.forEach((i,r)=>{const a=r===e;a||this.savePanelTreeScrollTop(r,i),i.classList.toggle("is-active",a),i.style.display=a?"":"none",a&&this.restorePanelTreeScrollTop(r,i)}),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 n=t.dataset.id;if(!n)return;const i=this.tabMap.get(n);if(!i)return;const r=t.querySelector(".bim-tab__title");r&&(r.textContent=this.resolveTitle(i.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 n=t.querySelector(".bim-tree-content");n&&this.panelTreeScrollTopMap.set(e,n.scrollTop)}restorePanelTreeScrollTop(e,t){const n=this.panelTreeScrollTopMap.get(e);if(n===void 0)return;const i=t.querySelector(".bim-tree-content");i&&requestAnimationFrame(()=>{i.scrollTop=n})}resolveTitle(e){try{return xe(e)||e}catch{return e}}}const tg={测量:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M0,28.207H3.429v3.526H44.571V28.207H48v7.052H0ZM0,3.526v14.1a3.478,3.478,0,0,0,3.429,3.526H6.857V17.629h3.429v3.526h3.429V17.629h3.429v3.526h3.429V10.578H24V21.155h3.429V17.629h3.429v3.526h3.429V17.629h3.429v3.526h3.429V10.578h3.429V21.155A3.478,3.478,0,0,0,48,17.629V3.526A3.478,3.478,0,0,0,44.571,0H3.429A3.478,3.478,0,0,0,0,3.526Z" transform="translate(0 5.456)"/></svg>',地图:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M32.984,563.2H26.329a66.982,66.982,0,0,1-5.471,7.121l-1.455,1.61-1.455-1.61a66.978,66.978,0,0,1-5.471-7.121H5.821L0,580.662H38.8Z" transform="translate(4.598 -537.259)"/><path fill="currentColor" d="M275.4,9.7a9.7,9.7,0,1,0-19.4,0c0,6.636,9.7,17.462,9.7,17.462S275.4,16.337,275.4,9.7Zm-13.582,0a3.88,3.88,0,1,1,3.88,3.88,3.88,3.88,0,0,1-3.88-3.88Z" transform="translate(-241.701 4.598)"/></svg>',框选放大:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M336.351,336.158l-5.5.037-.037-5.5-3.665.025.037,5.5-5.491.037.025,3.665,5.491-.037.041,5.491,3.661-.025-.037-5.491,5.5-.041Z" transform="translate(-305.467 -314.477)"/><path fill="currentColor" d="M41.88,40.861l-.227-.223-7.167-7.068a14.787,14.787,0,1,0-2.832,2.4l7.4,7.3.227.223.021-.021a1.821,1.821,0,0,0,1.065.33,1.849,1.849,0,0,0,1.837-1.862,1.868,1.868,0,0,0-.343-1.061l.017-.021ZM23.648,34.668A11.1,11.1,0,1,1,34.675,23.487,11.106,11.106,0,0,1,23.648,34.668ZM3,41.492H6.241v3.241H3ZM3,15.564H6.241v3.241H3ZM3,2.6H6.241V5.841H3Zm12.964,0h3.241V5.841H15.964Zm-6.482,0h3.241V5.841H9.482Zm12.964,0h3.241V5.841H22.446Zm6.482,0h3.241V5.841H28.928Zm6.482,0h3.241V5.841H35.41Zm6.482,0h3.241V5.841H41.892Zm0,6.482h3.241v3.241H41.892Zm0,6.482h3.241v3.241H41.892Zm0,6.482h3.241v3.241H41.892ZM9.482,41.492h3.241v3.241H9.482Zm6.482,0h3.241v3.241H15.964Zm6.482,0h3.241v3.241H22.446ZM3,9.082H6.241v3.241H3ZM3,22.046H6.241v3.241H3Zm38.892,6.482h3.241v3.241H41.892ZM3,28.528H6.241v3.241H3ZM3,35.01H6.241v3.241H3Z" transform="translate(-0.067 0.333)"/></svg>',漫游:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M327.239,38.548a6.01,6.01,0,1,0-6.358-6A6.144,6.144,0,0,0,327.239,38.548Zm8.006,5.76a3.082,3.082,0,0,0-3.061-2.64h-1.648c-.471,0-.706.24-1.177.48l-2.119,1.68-2.119-1.92a1.781,1.781,0,0,0-1.177-.48h-1.648a2.914,2.914,0,0,0-3.061,2.64l-1.413,10.8c0,.48,0,.96.471,1.2a1.781,1.781,0,0,0,1.177.48h1.648l1.413,15.36a3.082,3.082,0,0,0,3.061,2.64h3.532a2.914,2.914,0,0,0,3.061-2.64l1.413-15.36h1.648a1.781,1.781,0,0,0,1.177-.48,2.2,2.2,0,0,0,.235-1.2Z" transform="translate(-303.239 -26.548)"/></svg>',目录树:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M116.8,153.474h12a1.2,1.2,0,0,0,1.2-1.185v-7.111a1.2,1.2,0,0,0-1.2-1.184h-12a1.2,1.2,0,0,0-1.2,1.184v1.629H93.553v-7.554H100a1.2,1.2,0,0,0,1.2-1.185v-7.112a1.2,1.2,0,0,0-1.2-1.185H83.2a1.2,1.2,0,0,0-1.2,1.185v7.112a1.2,1.2,0,0,0,1.2,1.185h6.45v28a2.383,2.383,0,0,0,2.4,2.37H115.6v1.63a1.2,1.2,0,0,0,1.2,1.185h12a1.2,1.2,0,0,0,1.2-1.185v-7.112a1.2,1.2,0,0,0-1.2-1.185h-12a1.2,1.2,0,0,0-1.2,1.185v1.63H93.553V150.657H115.6v1.629a1.2,1.2,0,0,0,1.2,1.185Z" transform="translate(-82 -126.874)"/></svg>',剖切:'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><g transform="translate(-176.967 -101.068)"><path d="M306.33,364.55h14.737v19.115H306.33Z" transform="translate(-118.068 -248.554)"/><path d="M487.114,140.356a1.6,1.6,0,0,1-1.744-1.393V99.573a1.787,1.787,0,0,1,3.487,0v39.389A1.6,1.6,0,0,1,487.114,140.356Z" transform="translate(-285.677 6.11)"/><path d="M508.34,274.031H487.114a1.743,1.743,0,1,1,0-3.487h17.739V242.767H487.114a1.744,1.744,0,1,1,0-3.487H508.34Z" transform="translate(-285.677 -131.282)"/><path d="M201.437,274.031h-3.278a1.743,1.743,0,1,1,0-3.487h3.278a1.743,1.743,0,1,1,0,3.487Zm-8.858,0H187a1.743,1.743,0,1,1,0-3.487h5.579a1.743,1.743,0,1,1,0,3.487Zm-10.626-.532a1.743,1.743,0,0,1-1.743-1.744v-5.579a1.743,1.743,0,1,1,3.487,0v5.579A1.743,1.743,0,0,1,181.953,273.5Zm0-11.159a1.743,1.743,0,0,1-1.743-1.743v-5.579a1.743,1.743,0,1,1,3.487,0V260.6A1.743,1.743,0,0,1,181.953,262.34Zm0-11.158a1.744,1.744,0,0,1-1.743-1.744v-5.579a1.743,1.743,0,1,1,3.487,0v5.579A1.744,1.744,0,0,1,181.953,251.181Zm19.484-8.414h-5.579a1.744,1.744,0,1,1,0-3.487h5.579a1.744,1.744,0,0,1,0,3.487Zm-11.159,0H184.7a1.744,1.744,0,1,1,0-3.487h5.579a1.744,1.744,0,1,1,0,3.487Z" transform="translate(0 -131.282)"/></g></svg>',剖切盒:'<svg width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><g transform="translate(-56.83 2.793)"><path d="M194.963,19.168a1.69,1.69,0,0,1-.607-.119l-19.027-8.292a1.253,1.253,0,0,1,0-2.35L191.289.112a1.592,1.592,0,0,1,1.24,0l18.663,8.294a1.267,1.267,0,0,1,.791,1.175,1.308,1.308,0,0,1-.791,1.175l-15.6,8.278a1.519,1.519,0,0,1-.633.143Zm-15.7-9.586,15.7,6.832,12.331-6.832L191.9,2.749Z" transform="translate(-109.947 0)"/><path d="M195.008,417.821a1.691,1.691,0,0,1-.607-.119l-19.025-8.294a1.253,1.253,0,0,1,0-2.35l15.958-8.294a1.592,1.592,0,0,1,1.24,0l18.657,8.294a1.267,1.267,0,0,1,.791,1.175,1.308,1.308,0,0,1-.791,1.175l-15.6,8.278c-.211.095-3.483.143-3.694.143Zm-15.6-9.588,15.6,6.832,12.329-6.832L191.948,401.4Z" transform="translate(-109.992 -382.638)"/><path d="M200.046,603.93a1.976,1.976,0,0,1-.634-.119l-18.774-8.3a1.257,1.257,0,0,1-.655-1.754,1.512,1.512,0,0,1,1.931-.595l18.131,8.013,14.971-8.007a1.51,1.51,0,0,1,1.928.6,1.256,1.256,0,0,1-.661,1.75l-15.6,8.282a1.489,1.489,0,0,1-.634.119Z" transform="translate(-115.041 -568.787)"/><path d="M101.029,216.82a1.467,1.467,0,0,1-1-.377,1.237,1.237,0,0,1-.41-.917V198.817a1.413,1.413,0,0,1,2.816,0V215.5a1.241,1.241,0,0,1-.4.931A1.472,1.472,0,0,1,101.029,216.82Zm-34.377.143a1.467,1.467,0,0,1-1-.377,1.237,1.237,0,0,1-.41-.917V198.817a1.413,1.413,0,0,1,2.816,0v16.852a1.237,1.237,0,0,1-.41.917A1.467,1.467,0,0,1,66.652,216.964Zm-5.215,2.8a1.467,1.467,0,0,1-1-.377,1.237,1.237,0,0,1-.41-.917V201.621a1.413,1.413,0,0,1,2.816,0v16.852a1.237,1.237,0,0,1-.41.917A1.467,1.467,0,0,1,61.436,219.768Z" transform="translate(-0.4 -189.683)"/><path d="M60.922,37.617A1.32,1.32,0,0,1,60,37.258a1.2,1.2,0,0,1-.378-.876V20.295a1.3,1.3,0,0,1,2.588,0V36.382a1.276,1.276,0,0,1-1.294,1.235Zm-1.175,8.411a1.341,1.341,0,0,1,1.75-.578l15.126,7.071a1.224,1.224,0,0,1,.6,1.671,1.337,1.337,0,0,1-1.75.572L60.347,47.708a1.228,1.228,0,0,1-.606-1.671Z" transform="translate(0 -18.25)"/><path d="M71.756,44.947a1.337,1.337,0,0,1,1.75-.582l15.126,7.118a1.235,1.235,0,0,1,.6,1.682,1.333,1.333,0,0,1-1.75.576L72.356,46.629a1.239,1.239,0,0,1-.606-1.682ZM59.915,12.652a1.337,1.337,0,0,1,1.75-.582L76.79,19.194a1.235,1.235,0,0,1,.6,1.682,1.333,1.333,0,0,1-1.75.576L60.515,14.334A1.247,1.247,0,0,1,59.915,12.652Z" transform="translate(-0.168 -11.442)"/><path d="M334.418,146.671a1.341,1.341,0,0,1,1.75-.578l15.126,7.073a1.224,1.224,0,0,1,.6,1.671,1.337,1.337,0,0,1-1.75.573l-15.126-7.09a1.25,1.25,0,0,1-.663-.7,1.177,1.177,0,0,1,.058-.945Zm16.3,35.276a1.32,1.32,0,0,1-.917-.36,1.2,1.2,0,0,1-.377-.875v-16.1a1.3,1.3,0,0,1,2.588,0V180.7a1.2,1.2,0,0,1-.38.878,1.321,1.321,0,0,1-.922.357Z" transform="translate(-260.918 -139.687)"/><path d="M576.438,360.4a1.288,1.288,0,0,1-1.294-1.294V342.253a1.294,1.294,0,1,1,2.588,0v16.852A1.3,1.3,0,0,1,576.438,360.4ZM572.8,344.248,573,361.1l-2.613.024-.2-16.857Z" transform="translate(-486.154 -327.316)"/><path d="M508.543,26.833l.192,16.852-2.613.024-.192-16.852Z" transform="translate(-425.253 -25.689)"/></g></svg>',全屏:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M6.241,3.671H12.85a1.734,1.734,0,0,0,1.836-1.836A1.734,1.734,0,0,0,12.85,0H1.469C1.1,0,.734.367.367.734A1.349,1.349,0,0,0,0,1.836V12.85a1.734,1.734,0,0,0,1.836,1.836A1.734,1.734,0,0,0,3.671,12.85V6.241l9.913,9.913a1.817,1.817,0,1,0,2.57-2.57ZM13.584,27.9,6.975,34.51l-3.3,3.3V31.206a1.734,1.734,0,0,0-1.836-1.836A1.734,1.734,0,0,0,0,31.206V42.22a1.734,1.734,0,0,0,1.836,1.836H12.85a1.836,1.836,0,0,0,0-3.671H6.241l3.3-3.3,6.608-6.608a1.817,1.817,0,1,0-2.57-2.57ZM42.22,29.371a1.734,1.734,0,0,0-1.836,1.836v6.608l-3.3-3.3L30.472,27.9a1.817,1.817,0,1,0-2.57,2.57L34.51,37.08l3.3,3.3H31.206a1.836,1.836,0,1,0,0,3.671H42.22a1.734,1.734,0,0,0,1.836-1.836V31.206a1.734,1.734,0,0,0-1.836-1.836ZM42.22,0H31.206a1.734,1.734,0,0,0-1.836,1.836,1.734,1.734,0,0,0,1.836,1.836h6.608l-3.3,3.3L27.9,13.584a1.817,1.817,0,1,0,2.57,2.57L37.08,9.545l3.3-3.3V12.85a1.836,1.836,0,0,0,3.671,0V1.836A1.734,1.734,0,0,0,42.22,0Z" transform="translate(1.972 1.972)"/></svg>',设置:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M112.388,106.443l-2.668-.373a1.687,1.687,0,0,1-1.306-1.031,16.337,16.337,0,0,0-2-3.475,1.681,1.681,0,0,1-.243-1.646l1.012-2.5a1.652,1.652,0,0,0-.709-2.057l-5.769-3.335a1.654,1.654,0,0,0-2.136.415L96.919,94.56a1.693,1.693,0,0,1-1.562.62,15.32,15.32,0,0,0-3.992,0,1.693,1.693,0,0,1-1.562-.62l-1.651-2.113a1.654,1.654,0,0,0-2.136-.415l-5.769,3.33a1.659,1.659,0,0,0-.709,2.057l1.012,2.5a1.679,1.679,0,0,1-.243,1.646,16.141,16.141,0,0,0-2,3.475A1.669,1.669,0,0,1,77,106.066l-2.668.373a1.663,1.663,0,0,0-1.432,1.646v6.665a1.662,1.662,0,0,0,1.427,1.642l2.668.373a1.687,1.687,0,0,1,1.306,1.031,16.338,16.338,0,0,0,2,3.475,1.681,1.681,0,0,1,.243,1.646l-1.012,2.5a1.652,1.652,0,0,0,.709,2.057l5.769,3.33a1.654,1.654,0,0,0,2.136-.415L89.8,128.27a1.693,1.693,0,0,1,1.562-.62,15.321,15.321,0,0,0,3.992,0,1.693,1.693,0,0,1,1.562.62l1.651,2.113a1.654,1.654,0,0,0,2.136.415l5.769-3.33a1.659,1.659,0,0,0,.709-2.057l-1.012-2.5a1.681,1.681,0,0,1,.243-1.646,16.141,16.141,0,0,0,2-3.475,1.669,1.669,0,0,1,1.306-1.031l2.668-.373a1.658,1.658,0,0,0,1.427-1.642v-6.665A1.639,1.639,0,0,0,112.388,106.443ZM93.36,117.893a6.478,6.478,0,1,1,6.478-6.478A6.479,6.479,0,0,1,93.36,117.893Z" transform="translate(-69.355 -87.415)"/></svg>',拾曲面剖切:'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><g transform="translate(-59.63 -21.333)"><path d="M302.465,495.393l2.363-4.363a.842.842,0,0,1,1.091-.273.914.914,0,0,1,.454,1l-1.636,3,11.453-3.454c.091,0,.091,0,.182-.091a.785.785,0,1,1,.273,1.545l-11.453,3.454,3,1.545h.091a.645.645,0,0,1,.182,1,.842.842,0,0,1-1.091.273l-4.545-2.363c-.091,0-.182-.091-.273-.182A.742.742,0,0,1,302.465,495.393Z" transform="translate(205.84 -520.136) rotate(43)"/><path d="M88.23,54.014v2.86l-21.123,8.17V34l21.123-8.17V47.069h2.9l-.207-25.736L64,31.75V69.333L91.129,58.916v-4.9Z"/><path d="M199,255.9l-15.532,6.268v-21.23L199,234.667Z" transform="translate(-113.668 -202.979)"/></g></svg>',轴向剖切:'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><g transform="translate(-59.63 -21.333)"><path d="M.194,3.727,2.558,8.089a.842.842,0,0,0,1.091.273.914.914,0,0,0,.454-1l-1.636-3L13.919,7.817c.091,0,.091,0,.182.091a.785.785,0,1,0,.273-1.545L2.921,2.909l3-1.545h.091a.645.645,0,0,0,.182-1A.842.842,0,0,0,5.1.091L.558,2.454c-.091,0-.182.091-.273.182A.742.742,0,0,0,.194,3.727Z" transform="translate(102.244 57.563) rotate(-178)"/><path d="M88.23,54.014v2.86l-21.123,8.17V34l21.123-8.17V47.069h2.9l-.207-25.736L64,31.75V69.333L91.129,58.916v-4.9Z"/><path d="M199,255.9l-15.532,6.268v-21.23L199,234.667Z" transform="translate(-113.668 -202.979)"/></g></svg>',主视角:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M122.32,181.835v-13.16h-9.87V163.74h19.74v18.095Zm-19.74,0V163.74h9.87v18.095ZM96,163.74,117.385,144l21.385,19.74Z" transform="translate(-93.385 -138.917)"/></svg>',文档:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M64,128h1.714v41.143H64Zm46.286,0H112v41.143h-1.714Zm-44.571,0h44.571v3.429H65.714Zm0,6.857h44.571v3.429H65.714Zm0-3.429h3.429v3.429H65.714Zm8.571,0h3.429v3.429H74.286Zm8.571,0h27.429v3.429H82.857Zm-17.143,36h44.571v1.714H65.714Zm5.143-24H76v1.714H70.857Zm10.286,0h24v1.714h-24Zm-10.286,6.857H76V152H70.857Zm10.286,0h24V152h-24Zm-10.286,6.857H76v1.714H70.857Zm10.286,0h24v1.714h-24Z" transform="translate(-64 -124.571)"/></svg>',第一人称漫游:'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><path d="M178.325,132.27a6.411,6.411,0,0,0,0-9.429,7.359,7.359,0,0,0-9.984,0,6.411,6.411,0,0,0,0,9.429,7.359,7.359,0,0,0,9.984,0Zm-2-7.543a3.845,3.845,0,0,1,0,5.657,4.414,4.414,0,0,1-5.99,0,3.847,3.847,0,0,1,0-5.657,4.414,4.414,0,0,1,5.99,0Zm6.618,31.639q4.975,1.006,4.975,3.189t-4.975,3.189a57.4,57.4,0,0,1-19.226,0q-4.973-1.006-4.973-3.189t4.975-3.189q.777-.156,1.613-.284v-2.521a4.488,4.488,0,0,1-1.412.217,4.761,4.761,0,0,1-.587-.036l-.038,0a29.007,29.007,0,0,0-7.657,2.332q-3.482,1.712-3.482,3.484a2.944,2.944,0,0,0,1.3,2.116,14.359,14.359,0,0,0,4.4,2.293,46.614,46.614,0,0,0,15.477,2.258,46.614,46.614,0,0,0,15.477-2.258,14.362,14.362,0,0,0,4.4-2.293,2.943,2.943,0,0,0,1.3-2.116q0-1.772-3.482-3.484a29.007,29.007,0,0,0-7.657-2.332,4.908,4.908,0,0,1-.625.039,4.488,4.488,0,0,1-1.412-.217v2.521q.836.128,1.613.284Zm-14.788-6.588v5.979q2.391-.2,5.176-.2t5.176.2v-12.2h2.824v6.222a1.25,1.25,0,0,0,.414.942v0l.081.071q.744.1,1.457.22a1.41,1.41,0,0,0,.457-.293,1.25,1.25,0,0,0,.414-.942v-8a3.75,3.75,0,0,0-1.24-2.828,4.2,4.2,0,0,0-2.995-1.172H166.745a4.2,4.2,0,0,0-2.995,1.172,3.75,3.75,0,0,0-1.24,2.828v8a1.268,1.268,0,0,0,.414.942,1.415,1.415,0,0,0,.456.293q.715-.119,1.459-.222.041-.034.081-.071a1.25,1.25,0,0,0,.414-.942v-6.222h2.824Zm-8.471-6.222v-1.778a6.253,6.253,0,0,1,2.067-4.715,7.013,7.013,0,0,1,4.992-1.952h13.176a7.013,7.013,0,0,1,4.992,1.952,6.253,6.253,0,0,1,2.067,4.715v8a3.722,3.722,0,0,1-.484,1.881l0,.005a28.526,28.526,0,0,1,5.841,2.041q5,2.462,5,5.851,0,4.238-7.531,6.9a49.5,49.5,0,0,1-16.469,2.428,49.5,49.5,0,0,1-16.469-2.428q-7.531-2.667-7.531-6.9,0-3.388,5-5.849a28.381,28.381,0,0,1,5.841-2.044,3.707,3.707,0,0,1-.488-1.884Zm24.8,16a13.145,13.145,0,0,0-2.129-.581,54.5,54.5,0,0,0-18.044,0,13.079,13.079,0,0,0-2.127.581,13.078,13.078,0,0,0,2.127.581,54.5,54.5,0,0,0,18.044,0,13.078,13.078,0,0,0,2.127-.581Z" transform="translate(-149.333 -120.889)"/></svg>',反向:'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><g transform="translate(0.364 4.658)"><path d="M0,287.1m0-.817v-2.042a.722.722,0,0,1,.817-.817H44.509a.722.722,0,0,1,.817.817v2.042a.722.722,0,0,1-.817.817H.817A.722.722,0,0,1,0,286.28Z" transform="translate(-0.001 -272.164)"/><path d="M829.7,13.238l-1.443,1.444a.817.817,0,0,1-1.155,0L815.263,2.844a.817.817,0,0,1,0-1.156L816.706.244a.817.817,0,0,1,1.155,0L829.7,12.083a.817.817,0,0,1,0,1.155Z" transform="translate(-782.667)"/><path d="M94.367,648m0,.817v2.042a.722.722,0,0,1-.817.817H49.858a.722.722,0,0,1-.817-.817v-2.042a.722.722,0,0,1,.817-.817H93.55A.722.722,0,0,1,94.367,648.816Z" transform="translate(-47.095 -622.268)"/><path d="M.239,649.97l1.443-1.444a.817.817,0,0,1,1.155,0l11.838,11.838a.817.817,0,0,1,0,1.156l-1.443,1.443a.817.817,0,0,1-1.155,0L.239,651.124a.817.817,0,0,1,0-1.155Z" transform="translate(0 -622.544)"/></g></svg>',路径漫游:'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><g transform="translate(0 -4.9)"><path d="M43.755,35.8a23.352,23.352,0,0,1-8.074-3.095c-1.131-.912-2.263-1.819-2.263-3.458,0-.364-.164-.548-.486-.548-1.776-.364-2.263,0-1.935,2.183a5,5,0,0,0,1.776,3.095,14.337,14.337,0,0,0,4.521,2.551c2.1.912,4.521,1.276,6.461,2.551,1.935,1.091,2.1,2.551.809,4.37A12.572,12.572,0,0,1,37.3,48.187a30.594,30.594,0,0,1-17.115-1.455c-2.585-.912-4.2-.364-5.488,2,0,.184-.164.184-.323.548,2.1.728,3.876,1.455,5.811,2,5.811,1.639,11.786,2.367,17.76.548A14.453,14.453,0,0,0,46.663,45.1c2.422-4.2,1.613-8.381-2.908-9.293Zm-19.7-7.97a11.943,11.943,0,0,0-7.382-10.952A12.17,12.17,0,0,0,3.457,19.546a10.951,10.951,0,0,0-2.3,12.879c2.459,5.329,6.456,9.77,10.453,14.06.463.444.617.444,1.075,0,3.689-4.143,7.382-8.287,10-13.172A11.6,11.6,0,0,0,24.059,27.833Zm-4.151,3.255c-1.692,3.851-4.614,6.955-7.382,10.215-.463.444-.617.3-.921,0A44.891,44.891,0,0,1,4.228,31.088a7.684,7.684,0,0,1-.767-3.109A8.664,8.664,0,0,1,18.22,21.909a8.155,8.155,0,0,1,1.688,9.18ZM33.007,4.9c-5.685,0-9.785,6.416-7.274,11.76,1.454,3.34,4.1,5.745,6.746,8.15a.492.492,0,0,0,.795,0c2.908-2.537,5.554-5.211,7.008-8.821A8.117,8.117,0,0,0,33.007,4.9Zm4.366,10.422A16.825,16.825,0,0,1,33.4,20c-.4.269-.659.269-.926,0a16.342,16.342,0,0,1-3.969-4.545,5.033,5.033,0,1,1,8.864-.132Z"/><path d="M183.031,141.935a2.136,2.136,0,0,0,2.053-2.18,2.084,2.084,0,0,0-2.18-2.18,2.171,2.171,0,0,0-2.053,2.307A2.058,2.058,0,0,0,183.031,141.935Zm-20.094,7.854a4.7,4.7,0,0,0-4.6,4.881,4.913,4.913,0,0,0,4.74,4.881,4.882,4.882,0,0,0-.14-9.762Zm0,6.417a1.77,1.77,0,0,1-1.532-1.532A1.79,1.79,0,0,1,162.937,153a1.611,1.611,0,0,1,1.672,1.672A1.578,1.578,0,0,1,162.937,156.206Z" transform="translate(-150.629 -126.653)"/></g></svg>',适应到模型:'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><g transform="translate(-84.667 -84.667)"><path d="M87.667,97V87.667H97V85.333H86.733a1.4,1.4,0,0,0-1.4,1.4V97Zm0,23.333H85.333V130.6a1.4,1.4,0,0,0,1.4,1.4H97v-2.333H87.667v-9.333Zm32.667,9.333V132H130.6a1.4,1.4,0,0,0,1.4-1.4V120.333h-2.333v9.333h-9.333ZM129.667,97H132V86.733a1.4,1.4,0,0,0-1.4-1.4H120.333v2.333h9.333Z"/><path d="M270.857,243.5l11.3-6.652V223.387l-11.3,6.361V243.5Zm-1.8,0v-13.75l-11.3-6.361v13.456l11.3,6.652Zm-10.278-21.621,11.177,6.284,11.177-6.284L269.958,215.3l-11.177,6.573Zm11.622-8.426,13.1,7.709a.919.919,0,0,1,.448.793v15.419a.926.926,0,0,1-.448.793l-13.1,7.709a.887.887,0,0,1-.9,0l-13.1-7.709a.905.905,0,0,1-.448-.793V221.954a.919.919,0,0,1,.448-.793l13.1-7.709A.887.887,0,0,1,270.4,213.452Z" transform="translate(-161.292 -120.997)"/></g></svg>',隐藏:'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><path d="M61.274,76.178l0-.007-.007,0a32.458,32.458,0,0,0-7.014-9.981L51.53,68.91a28.382,28.382,0,0,1,6.124,8.635c-4.472,9.25-10.809,13.636-19.472,13.636A20.615,20.615,0,0,1,30.6,89.838l-2.937,2.933a23.916,23.916,0,0,0,10.514,2.277q15.472,0,23.088-16.116a3.229,3.229,0,0,0,0-2.755ZM57.839,58.351l-2.274-2.277a.429.429,0,0,0-.608,0l-6.265,6.262a23.775,23.775,0,0,0-10.51-2.281q-15.472,0-23.088,16.116v.007a3.236,3.236,0,0,0,0,2.765,32.617,32.617,0,0,0,7.014,9.985L16.7,94.32a.429.429,0,0,0,0,.608l2.274,2.277a.429.429,0,0,0,.608,0L57.839,58.949a.426.426,0,0,0,0-.6ZM32.113,78.915a6.011,6.011,0,0,1,7.22-7.22l-7.223,7.22Zm9.9-9.9A9.452,9.452,0,0,0,29.43,81.6l-4.6,4.6a28.424,28.424,0,0,1-6.124-8.635c4.475-9.25,10.816-13.636,19.472-13.636a20.615,20.615,0,0,1,7.577,1.343Zm-4.046,14.55a5.752,5.752,0,0,1-1.01-.086l-2.744,2.741A9.446,9.446,0,0,0,46.638,73.794L43.9,76.538a6.018,6.018,0,0,1-5.932,7.024Z" transform="translate(-14.182 -52.64)"/></svg>',重置:'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="currentColor"><path d="M32.936,32.658a15.914,15.914,0,0,1-9.6,3.064c-.451-.006-.9-.042-1.342-.077-.182-.018-.357-.047-.539-.077-.352-.047-.7-.089-1.037-.164-.211-.036-.422-.1-.621-.148-.334-.077-.668-.154-.99-.254-.153-.059-.3-.11-.457-.177-.381-.124-.755-.26-1.113-.414-.082-.036-.162-.071-.24-.1-.422-.2-.844-.408-1.248-.627-.017-.012-.035-.018-.054-.03a16.485,16.485,0,0,1-3.732-2.9c-.017-.018-.035-.042-.054-.059-.34-.355-.668-.721-.979-1.118-.065-.083-.123-.16-.194-.254A17.286,17.286,0,0,1,7.149,18.751h3.98L6.318,9.076,0,18.874H3.942a20.809,20.809,0,0,0,3.5,11.57.871.871,0,0,0,.075.14c.225.34.486.648.724.961.1.113.177.232.274.362.354.443.746.869,1.133,1.285.043.043.075.076.108.113a19.778,19.778,0,0,0,4.436,3.446c.043.027.08.043.128.076.467.259.949.5,1.432.719.124.055.242.113.359.164.419.184.847.335,1.277.493.2.076.4.14.611.21.378.113.762.21,1.153.3.257.065.509.129.772.184a2.252,2.252,0,0,0,.316.076c.37.07.735.1,1.1.151.134.027.27.049.4.065.66.065,1.314.11,1.974.11,4.006,0,8.852-1.3,11.85-4.177a1.908,1.908,0,0,0,.333-2.484,2.228,2.228,0,0,0-2.952.023ZM44.053,20.424a20.728,20.728,0,0,0-3.47-11.537c-.032-.055-.054-.113-.08-.164-.284-.405-.574-.778-.869-1.161a1.289,1.289,0,0,1-.1-.14A19.86,19.86,0,0,0,32.168,1.7c-.086-.032-.155-.076-.242-.11-.456-.195-.922-.362-1.394-.53C30.37,1,30.2.937,30.033.883,29.62.754,29.212.651,28.792.548c-.231-.055-.467-.113-.7-.164-.113-.022-.22-.055-.338-.081-.311-.055-.617-.081-.933-.124C26.6.151,26.392.119,26.18.1,25.655.042,25.135.021,24.616.016c-.1,0-.188-.016-.284-.016-.016,0-.032.005-.049.005A19.124,19.124,0,0,0,13.02,3.695a1.682,1.682,0,0,0-.466,2.515,1.777,1.777,0,0,0,2.309.3A15.251,15.251,0,0,1,24.374,3.45c.486.006.971.03,1.441.077.147.012.287.036.432.059a11.3,11.3,0,0,1,1.16.189c.162.03.334.077.493.11.381.089.744.178,1.107.3a2.577,2.577,0,0,1,.34.124c.422.142.832.29,1.23.467.047.012.082.047.123.059a16.492,16.492,0,0,1,6.182,4.8.367.367,0,0,0,.024.036A17.308,17.308,0,0,1,40.629,20.43H36.645l5.048,9.787L48,20.424Zm0,0" transform="translate(0 4.349)"/></svg>',标高:'<svg width="32" height="32" viewBox="0 0 32 32"><path fill="currentColor" d="M84.131,193.119a1.056,1.056,0,0,1,1.116.982v7.857a1.056,1.056,0,0,1-1.116.982H54.367a1.056,1.056,0,0,1-1.116-.982V194.1a1.056,1.056,0,0,1,1.116-.982Zm-1.116,1.964H55.483v5.893H83.015Zm1.116-13.749a1.064,1.064,0,0,1,1.114.935,1.032,1.032,0,0,1-1.007,1.025l-.107,0H71.2l-7.858,6.914a1.227,1.227,0,0,1-1.578,0l-8.185-7.2-.018-.016-.032-.031.049.047a1.107,1.107,0,0,1-.092-.092l-.011-.014a.869.869,0,0,1-.182-.857l0-.008L53.31,182l.012-.029.02-.045.019-.035a1.1,1.1,0,0,1,.891-.552h.007q.053,0,.107,0ZM68.043,183.3H57.06l5.492,4.831Z" transform="translate(-53.247 -176.136)"/></svg>',距离:'<svg width="32" height="32" viewBox="0 0 32 32"><path fill="currentColor" d="M29.692,3.03,27.55.919a.529.529,0,0,1-.014-.756A.549.549,0,0,1,28.3.15l.014.013,3.067,3.023a.529.529,0,0,1,0,.756L28.317,6.966a.549.549,0,0,1-.767.013.529.529,0,0,1-.014-.756l.014-.013L29.692,4.1H2.31L4.452,6.21a.528.528,0,0,1,.013.756.547.547,0,0,1-.766.013l-.014-.013L.616,3.942a.531.531,0,0,1,0-.756L3.685.163a.548.548,0,0,1,.767.014.528.528,0,0,1,0,.742L2.31,3.03ZM24.136,15.055H23.051V18H21.966v-2.94H20.882V18H19.8v-2.94H18.712V18H17.627v-2.94H16.543v5.078H15.458V15.055H14.373V18H13.288v-2.94H12.2V18H11.119v-2.94H10.034V18H8.949v-2.94H7.865V18H6.78v-2.94H5.7v5.078H4.61V15.055H1.9a.27.27,0,0,0-.272.268v6.413A.269.269,0,0,0,1.9,22H30.1a.268.268,0,0,0,.271-.267V15.323a.269.269,0,0,0-.271-.268H27.39v5.078H26.305V15.055H25.221V18H24.136Zm5.966-1.6A1.884,1.884,0,0,1,32,15.323v6.413a1.885,1.885,0,0,1-1.9,1.871H1.9A1.885,1.885,0,0,1,0,21.736V15.323a1.885,1.885,0,0,1,1.9-1.871Z" transform="translate(0 4.197)"/></svg>',最小距离:'<svg width="32" height="32" viewBox="0 0 32 32"><path fill="currentColor" d="M-5.839,24.8H-34.16A1.875,1.875,0,0,1-36,22.933V16.52a1.887,1.887,0,0,1,1.9-1.871H-5.9A1.887,1.887,0,0,1-4,16.52v6.412A1.875,1.875,0,0,1-5.839,24.8ZM-34.1,16.252a.27.27,0,0,0-.272.268v6.412a.27.27,0,0,0,.272.267H-5.9a.269.269,0,0,0,.271-.267V16.52a.27.27,0,0,0-.271-.268H-8.61V21.33H-9.695V16.252h-1.085v2.939h-1.085V16.252h-1.085v2.939h-1.085V16.252h-1.084v2.939H-16.2V16.252h-1.085v2.939h-1.085V16.252h-1.084V21.33h-1.084V16.252h-1.085v2.939h-1.085V16.252H-23.8v2.939h-1.085V16.252h-1.085v2.939h-1.085V16.252h-1.084v2.939H-29.22V16.252H-30.3V21.33H-31.39V16.252Z" transform="translate(36 2)"/><path fill="currentColor" d="M23.716,7.947V4.875c0-.8-.232-1.085-.765-1.085a1.573,1.573,0,0,0-1.133.585V7.947H20.4V2.75h1.163l.1.687H21.7a2.547,2.547,0,0,1,1.763-.817c1.172,0,1.676.78,1.676,2.089V7.947Zm-7.26,0V2.62h1.58V7.947Zm-3.8,0V4.875c0-.8-.243-1.085-.76-1.085a1.606,1.606,0,0,0-1.049.585V7.947H9.421V4.875c0-.8-.243-1.085-.758-1.085a1.608,1.608,0,0,0-1.05.585V7.947H6.194V2.75H7.36l.1.7H7.5A2.326,2.326,0,0,1,9.169,2.62a1.486,1.486,0,0,1,1.5.91A2.445,2.445,0,0,1,12.4,2.62c1.156,0,1.691.78,1.691,2.089V7.947Zm3.8-6.849a.79.79,0,0,1,1.58,0,.79.79,0,0,1-1.58,0Z" transform="translate(0.333 3.053)"/></svg>',激光边距:'<svg width="32" height="32" viewBox="0 0 32 32"><path fill="currentColor" d="M0,1.293v31.96H32V1.293ZM30.97,32.182H1.03V2.323H30.97Z"/><path fill="currentColor" d="M160.026,291.9l1.6,1.6,7.305-7.305-7.305-7.305-1.6,1.6,4.794,4.566h-6.392v2.283h6.392Zm-5.251,0-4.566-4.566h6.164v-2.283H150.21l4.566-4.566-1.37-1.6L146.1,286.19l7.305,7.305Z" transform="translate(-141.535 -268.917)"/></svg>',角度:'<svg width="32" height="32" viewBox="0 0 32 32"><path fill="currentColor" d="M39.587,50.766h13.7a1,1,0,0,1,0,2H23.171a1,1,0,0,1,0-2h1.418l6.582-7.006v-.006a.517.517,0,0,1,.14-.357.456.456,0,0,1,.337-.144l12.1-12.876a.451.451,0,0,1,.665,0,.524.524,0,0,1,0,.708L32.883,43.355a8.3,8.3,0,0,1,6.7,7.411Zm-.949,0a7.254,7.254,0,0,0-6.611-6.5l-6.108,6.5Z" transform="translate(-22.229 -26.489)"/></svg>',坡度:'<svg width="32" height="32" viewBox="0 0 32 32"><path fill="currentColor" d="M202.1,188.337l2.629-2.191-8.447-3.106,1.533,8.871,2.629-2.194,9.341,11.209,1.656-1.379Zm-13.726-.435a1.075,1.075,0,0,0-1.07-.341,1.057,1.057,0,0,0-.5.277l-5.11,4.08a1.08,1.08,0,0,0-.406.84l-.007,17.386a1.079,1.079,0,0,0,1.077,1.077L205.7,211.2a1.078,1.078,0,0,0,.822-1.774Zm-4.934,21.164.007-15.788,3.968-3.171,15.974,18.941Z" transform="translate(-180.36 -181.131)"/></svg>',体积:'<svg width="32" height="32" viewBox="0 0 32 32"><path fill="currentColor" d="M94.74,86.658V71.189a.371.371,0,0,1,.2-.329l13.869-7.22a.371.371,0,0,1,.344,0l13.053,6.891h0l.819.431a.371.371,0,0,1,.2.328v15.3a.371.371,0,0,1-.2.328l-13.872,7.255a.371.371,0,0,1-.342,0L94.94,86.987a.371.371,0,0,1-.2-.329Zm2.119-.837,11.2,5.8a.024.024,0,0,0,.035-.022V79.483a.371.371,0,0,0-.2-.328l-11.2-5.909a.024.024,0,0,0-.035.021V85.492A.371.371,0,0,0,96.859,85.821Zm13.151-6.459v12a.12.12,0,0,0,.176.106L114,89.474l3.334-1.745,3.771-1.978a.371.371,0,0,0,.2-.328V73.5a.193.193,0,0,0-.284-.171l-10.812,5.708A.371.371,0,0,0,110.01,79.362ZM97.925,71.725l10.839,5.72a.371.371,0,0,0,.346,0L119.8,71.808a.214.214,0,0,0,0-.378l-10.649-5.621a.371.371,0,0,0-.344,0L97.925,71.47A.144.144,0,0,0,97.925,71.725Z" transform="translate(-92.982 -62.907)"/></svg>',空间体积:'<svg width="32" height="32" viewBox="0 0 32 32"><path fill="currentColor" d="M125.977,128.829l13.076-7.363v-13.6l-13.076,6.8Zm-3.126-15.655a.565.565,0,0,1-.258-.064L109.3,106.323a.567.567,0,0,1-.011-1L122.578,98a.567.567,0,0,1,.55,0l13.288,7.325a.567.567,0,0,1-.011,1l-13.292,6.79A.63.63,0,0,1,122.851,113.174ZM110.773,105.8l12.078,6.172,12.078-6.172-12.078-6.657Z" transform="translate(-1.922)"/><path fill="currentColor" d="M120.649,322.52a.58.58,0,0,1-.262-.064l-13.08-6.8a.573.573,0,0,1-.307-.5V301a.566.566,0,0,1,.273-.486.573.573,0,0,1,.558-.019l13.076,6.8a.573.573,0,0,1,.307.5v14.161a.57.57,0,0,1-.565.569Zm-12.511-7.708,11.942,6.206V308.136l-11.942-6.206Zm15.917,9.408a.585.585,0,0,1-.288-.076.567.567,0,0,1-.281-.489V309.49a.562.562,0,0,1,.307-.5l13.076-6.8a.573.573,0,0,1,.558.019.562.562,0,0,1,.273.486v13.6a.568.568,0,0,1-.288.493l-13.076,7.359A.557.557,0,0,1,124.055,324.22Zm.569-14.385V322.68l11.942-6.722V303.629Z" transform="translate(0 -194.822)"/></svg>',close:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12z"/></svg>',check:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M9 16.17L4.83 12l-1.42 1.41L9 19L21 7l-1.41-1.41z"/></svg>',warning:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M1 21h22L12 2L1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"/></svg>',error:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10s10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"/></svg>',success:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10s10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5l1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>',plus:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>',minus:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M19 13H5v-2h14v2z"/></svg>',arrowUp:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6l-6 6z"/></svg>',arrowUpBold:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8l-8 8z"/></svg>',arrowDown:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6l-6-6z"/></svg>',arrowLeft:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M15.41 7.41L14 6l-6 6l6 6l1.41-1.41L10.83 12z"/></svg>',arrowRight:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M10 6L8.59 7.41L13.17 12l-4.58 4.59L10 18l6-6z"/></svg>',search:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5A6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5S14 7.01 14 9.5S11.99 14 9.5 14z"/></svg>',refresh:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M17.65 6.35A7.958 7.958 0 0 0 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08A5.99 5.99 0 0 1 12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"/></svg>',delete:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg>',edit:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a.996.996 0 0 0 0-1.41l-2.34-2.34a.996.996 0 0 0-1.41 0l-1.83 1.83l3.75 3.75l1.83-1.83z"/></svg>',save:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M17 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2V7l-4-4zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3s3 1.34 3 3s-1.34 3-3 3zm3-10H5V5h10v4z"/></svg>',expand:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M16.59 8.59L12 13.17L7.41 8.59L6 10l6 6l6-6z"/></svg>',collapse:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12 8l-6 6l1.41 1.41L12 10.83l4.59 4.58L18 14z"/></svg>',bot:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2M7.5 13A2.5 2.5 0 0 0 5 15.5A2.5 2.5 0 0 0 7.5 18a2.5 2.5 0 0 0 2.5-2.5A2.5 2.5 0 0 0 7.5 13m9 0a2.5 2.5 0 0 0-2.5 2.5a2.5 2.5 0 0 0 2.5 2.5a2.5 2.5 0 0 0 2.5-2.5a2.5 2.5 0 0 0-2.5-2.5Z"/></svg>',history:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M13 3a9 9 0 0 0-9 9H1l3.89 3.89l.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7s-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42A8.954 8.954 0 0 0 13 21a9 9 0 0 0 0-18zm-1 5v5l4.28 2.54l.72-1.21l-3.5-2.08V8H12z"/></svg>',settings:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12 15.5A3.5 3.5 0 0 1 8.5 12A3.5 3.5 0 0 1 12 8.5a3.5 3.5 0 0 1 3.5 3.5a3.5 3.5 0 0 1-3.5 3.5m7.43-2.53c.04-.32.07-.64.07-.97c0-.33-.03-.66-.07-1l2.11-1.63c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.31-.61-.22l-2.49 1c-.52-.39-1.06-.73-1.69-.98l-.37-2.65A.506.506 0 0 0 14 2h-4c-.25 0-.46.18-.5.42l-.37 2.65c-.63.25-1.17.59-1.69.98l-2.49-1c-.22-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64L4.57 11c-.04.34-.07.67-.07 1c0 .33.03.65.07.97l-2.11 1.66c-.19.15-.25.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1.01c.52.4 1.06.74 1.69.99l.37 2.65c.04.24.25.42.5.42h4c.25 0 .46-.18.5-.42l.37-2.65c.63-.26 1.17-.59 1.69-.99l2.49 1.01c.22.08.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.66Z"/></svg>',loader:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12 4V2A10 10 0 0 0 2 12h2a8 8 0 0 1 8-8Z"><animateTransform attributeName="transform" dur="0.75s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12"/></path></svg>',send:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M2 21l21-9L2 3v7l15 2l-15 2v7z"/></svg>',透视相机:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M24 4L4 14v20l20 10l20-10V14L24 4zm0 4.5l14 7v14l-14 7l-14-7v-14l14-7zM24 18a6 6 0 100 12a6 6 0 000-12z"/></svg>',正交相机:'<svg width="48" height="48" viewBox="0 0 48 48"><path fill="currentColor" d="M6 6h36v36H6V6zm4 4v28h28V10H10zm4 4h20v20H14V14z"/></svg>',default:'<svg width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10s10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8s8 3.59 8 8s-3.59 8-8 8zm-1-13h2v6h-2zm0 8h2v2h-2z"/></svg>'};function rt(s){const e=tg[s];return e||(console.warn(`[IconManager] Icon "${s}" not found, using default icon`),tg.default)}function ng(s,e){let t=e>>>0;for(let n=0;n<s.length;n++){const i=s.charCodeAt(n);t^=i&255,t=Math.imul(t,16777619),t^=i>>>8&255,t=Math.imul(t,16777619)}return t>>>0}async function _C(s){const e=JSON.stringify(s),t=ng(e,2166136261),n=ng(e,522970236);return`${t.toString(16).padStart(8,"0")}${n.toString(16).padStart(8,"0")}`}function ig(s){const e=new Map,t=i=>{const r=i.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 i.children||[])t(o)};t(s);const n=[];for(const[i,r]of e)r.size>0&&n.push({url:i,ids:Array.from(r)});return n}let MC=0;async function wC(s){if(!s||s.length===0)return[];const e=async(t,n)=>{const i=t.children&&t.children.length>0;let r;return t.ids?.length?r=await _C(t.ids):t.id?r=t.id:r=`node_${++MC}`,{id:r,label:t.name||"未命名",expanded:!1,checked:!0,children:i?await Promise.all(t.children.map(a=>e(a,n))):void 0,data:{...t,_modelUrl:n}}};return Promise.all(s.map(async t=>{const n=t.children&&t.children.length>0,i=t.url;return{id:i,label:t.name||"模型",expanded:!0,checked:!0,children:n?await Promise.all(t.children.map(r=>e(r,i))):void 0,data:{_modelUrl:i}}}))}class SC extends xi{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 tc({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:rt("目录树"),onClick:()=>{this.openConstructTreeDialog()}}),this.toolbar.render()}async openConstructTreeDialog(){this.setVisible(!1);const e=this.engineComponent?.getLevelTreeData()??[],t=this.engineComponent?.getTypeTreeData()??[],n=this.engineComponent?.getMajorTreeData()??[];console.log("[ConstructTree] 原始数据 (Level):",e),console.log("[ConstructTree] 原始数据 (Type):",t),console.log("[ConstructTree] 原始数据 (Major):",n);const i=async(f,x)=>{const m=await wC(f);console.log(`[ConstructTree] 转换后数据 (${x}):`,m);const b=new yC({data:m,checkable:!0,indent:0,enableSearch:!0,checkStrictly:!0,defaultExpandAll:!0,onNodeCheck:v=>{const y=ig(v);y.length&&(v.checkState===Mt.Checked?this.engineComponent?.showModel(y):this.engineComponent?.hideModels(y))},onNodeSelect:v=>{const y=ig(v);y.length&&(this.engineComponent?.unhighlightAllModels(),this.engineComponent?.highlightModel(y),this.engineComponent?.viewScaleToModel(y))},onNodeDeselect:()=>{this.engineComponent?.unhighlightAllModels()},onNodeExpand:()=>{this.dialog?.fitWidth()}});return b.init(),b},r=await i(e,"Level"),a=await i(t,"Type"),o=await i(n,"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 p=()=>{this.engineComponent?.showAllModels(),r.checkAllNodes(!0),a.checkAllNodes(!0),o.checkAllNodes(!0)},u=new eg({container:d,tabs:[{id:"component",title:"tab.component",content:l},{id:"type",title:"tab.type",content:c},{id:"major",title:"tab.major",content:h}],activeId:"component",onChange:()=>{this.dialog?.fitWidth()}});u.init(),p();const g=this.registry.on("menu:show-all",()=>{p()});this.dialog=this.registry.dialog.create({title:"constructTree.title",minWidth:320,height:600,content:d,position:{x:20,y:20},resizable:!1,onClose:()=>{g(),u.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 Gs extends xi{dialog=null;isVisible=!1;constructor(e){super(e)}get dialogWidth(){return 300}get dialogHeight(){return"auto"}get dialogOptions(){return{draggable:!0,resizable:!1}}onDialogClose(){}onDialogCreated(){}onBeforeDestroy(){}getDialogPosition(){const e=this.registry.container;if(!e)return{x:100,y:100};const t=e.clientWidth,n=e.clientHeight,i=this.dialogWidth,r=typeof this.dialogHeight=="number"?this.dialogHeight:300;return{x:t-i-20,y:(n-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(),n=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:n.draggable,resizable:n.resizable,onClose:()=>{this.onDialogClose(),this.destroyDialog()}}),this.dialog.init(),this.isVisible=!0,this.onDialogCreated()}hide(){this.destroyDialog()}toggle(){this.isVisible?this.hide():this.show()}isOpen(){return this.isVisible}destroyDialog(){this.onBeforeDestroy(),this.dialog&&(this.dialog.destroy(),this.dialog=null),this.isVisible=!1}destroy(){this.destroyDialog(),super.destroy()}}const ds={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>'},Xa={distance:{key:"distance",callBackType:"distance",icon:ds.distance,order:0},clearHeight:{key:"clearHeight",callBackType:"clear-height",icon:ds.clearHeight,order:1},clearDistance:{key:"clearDistance",callBackType:"clear-distance",icon:ds.clearDistance,order:2},elevation:{key:"elevation",callBackType:"elevation",icon:ds.elevation,order:3},point:{key:"point",callBackType:"point",icon:ds.point,order:4},angle:{key:"angle",callBackType:"angle",icon:ds.angle,order:5},area:{key:"area",callBackType:"area",icon:ds.area,order:6},slope:{key:"slope",callBackType:"slope",icon:ds.slope,order:7}},sg=Object.values(Xa).sort((s,e)=>s.order-e.order).map(s=>s.key);function rg(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";case"point":default:return"point"}}function EC(s){return Object.values(Xa).find(e=>e.callBackType===s)?.key}class ja{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()??{...ja.DEFAULT_CONFIG},this.element=this.createDom()}init(){this.unsubscribeLocale=Qt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ot.subscribe(e=>{this.setTheme(e)}),this.setLocales(),this.setTheme(ot.getTheme()),this.applyExpandedState(),this.applyActiveModeState(),this.applyClearHeightOptionsState(),this.applyViewState(),this.renderResult(),this.options.onModeChange&&this.options.onModeChange(this.activeMode)}setTheme(e){const t=this.element.style;t.setProperty("--bim-bg-inset",e.bgInset??"#152232"),t.setProperty("--bim-bg-elevated",e.bgElevated??"#1f2d3e"),t.setProperty("--bim-border-default",e.borderDefault??"#334155"),t.setProperty("--bim-border-strong",e.borderStrong??"#475569"),t.setProperty("--bim-divider",e.divider??"#334155"),t.setProperty("--bim-primary",e.primary??"#3b82f6"),t.setProperty("--bim-primary-hover",e.primaryHover??"#60a5fa"),t.setProperty("--bim-primary-subtle",e.primarySubtle??"rgba(59, 130, 246, 0.15)"),t.setProperty("--bim-danger",e.danger??"#ef4444"),t.setProperty("--bim-text-primary",e.textPrimary??"#ffffff"),t.setProperty("--bim-text-secondary",e.textSecondary??"#94a3b8"),t.setProperty("--bim-text-tertiary",e.textTertiary??"#64748b"),t.setProperty("--bim-text-inverse",e.textInverse??"#152232"),t.setProperty("--bim-icon-default",e.iconDefault??"#ffffff"),t.setProperty("--bim-component-bg-hover",e.componentBgHover??"rgba(248, 250, 252, 0.06)")}setLocales(){for(const[t,n]of this.toolButtons.entries())n.title=xe(this.getModeI18nKey(t)),n.setAttribute("aria-label",n.title);this.toggleBtn.title=this.isExpanded?xe("measure.actions.collapse"):xe("measure.actions.expand"),this.toggleBtn.setAttribute("aria-label",this.toggleBtn.title),this.toggleTextEl&&(this.toggleTextEl.textContent=this.toggleBtn.title),this.clearBtn.textContent=xe("measure.actions.clearAll"),this.settingsBtn.title=xe("measure.actions.settings"),this.settingsBtn.setAttribute("aria-label",this.settingsBtn.title),this.mainValueLabelEl.textContent=xe(this.getModeValueLabelI18nKey(this.activeMode)),this.element.querySelectorAll("[data-i18n-key]").forEach(t=>{const n=t.dataset.i18nKey;n&&(t.textContent=xe(n))}),this.saveSettingsBtn.textContent=xe("measure.settings.save"),this.cancelSettingsBtn.textContent=xe("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=xe(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 n={unit:e.unit??this.config.unit,precision:e.precision??this.config.precision};this.config=n,t&&this.saveConfigToCache(n),this.renderResult(),this.view==="settings"&&this.syncSettingsFormFromConfig(n)}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 n=document.createElement("div");n.className="bim-measure-tool-grid";const i=`
<svg viewBox="0 0 24 24" aria-hidden="true">
<circle cx="12" cy="12" r="9"></circle>
</svg>
`;for(let g=0;g<sg.length;g++){const f=sg[g],x=Xa[f],m=document.createElement("button");m.type="button",m.className="bim-measure-tool-btn",m.dataset.mode=f;const b=document.createElement("span");b.className="bim-measure-tool-icon",b.innerHTML=x.icon||i,m.appendChild(b),m.addEventListener("click",()=>{this.setActiveMode(f)}),this.toolButtons.set(f,m),n.appendChild(m)}t.appendChild(n);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 p=(g,f,x)=>{const m=document.createElement("div");m.className="bim-measure-row";const b=document.createElement("span");b.className="label",b.dataset.i18nKey=g;const v=document.createElement("span");return v.className=`value ${f}`,x(v),m.appendChild(b),m.appendChild(v),m};d.appendChild(p("measure.labels.x","bim-measure-xyz-x",g=>this.xyzXEl=g)),d.appendChild(p("measure.labels.y","bim-measure-xyz-y",g=>this.xyzYEl=g)),d.appendChild(p("measure.labels.z","bim-measure-xyz-z",g=>this.xyzZEl=g)),o.appendChild(d),this.mainViewEl.appendChild(o);const u=document.createElement("div");return u.className="bim-measure-footer",this.clearBtn=document.createElement("button"),this.clearBtn.type="button",this.clearBtn.className="bim-measure-clear-btn",this.clearBtn.addEventListener("click",()=>{this.clearAll()}),this.settingsBtn=document.createElement("button"),this.settingsBtn.type="button",this.settingsBtn.className="bim-measure-settings-btn",this.settingsBtn.innerHTML=`
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M19.14 12.94c.04-.31.06-.63.06-.94s-.02-.63-.06-.94l2.03-1.58a.5.5 0 0 0 .12-.64l-1.92-3.32a.5.5 0 0 0-.6-.22l-2.39.96a7.27 7.27 0 0 0-1.63-.94l-.36-2.54A.5.5 0 0 0 13.9 1h-3.8a.5.5 0 0 0-.49.42l-.36 2.54c-.58.23-1.12.54-1.63.94l-2.39-.96a.5.5 0 0 0-.6.22L2.71 7.48a.5.5 0 0 0 .12.64l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94L2.83 14.52a.5.5 0 0 0-.12.64l1.92 3.32c.13.22.39.3.6.22l2.39-.96c.5.4 1.05.71 1.63.94l.36 2.54c.04.24.25.42.49.42h3.8c.24 0 .45-.18.49-.42l.36-2.54c.58-.23 1.12-.54 1.63-.94l2.39.96c.22.09.47 0 .6-.22l1.92-3.32a.5.5 0 0 0-.12-.64l-2.03-1.58zM12 15.5A3.5 3.5 0 1 1 12 8a3.5 3.5 0 0 1 0 7.5z"></path>
</svg>
`,this.settingsBtn.addEventListener("click",()=>{this.openSettings()}),u.appendChild(this.clearBtn),u.appendChild(this.settingsBtn),this.mainViewEl.appendChild(u),this.settingsViewEl=this.createSettingsDom(),e.appendChild(this.mainViewEl),e.appendChild(this.settingsViewEl),e}createSettingsDom(){const e=document.createElement("div");e.className="bim-measure-settings";const t=document.createElement("div");t.className="bim-measure-settings-title",t.dataset.i18nKey="measure.settings.title",e.appendChild(t);const n=document.createElement("div");n.className="bim-measure-settings-row";const i=document.createElement("div");i.className="label",i.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")),n.appendChild(i),n.appendChild(this.unitSelectEl),e.appendChild(n);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 n=document.createElement("span");n.className="bim-measure-radio-label",n.dataset.i18nKey="measure.clearHeight.direction";const i=document.createElement("div");i.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),i.appendChild(r),i.appendChild(a),t.appendChild(n),t.appendChild(i),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 n=document.createElement("button");return n.type="button",n.className="bim-measure-radio-item",n.dataset.i18nKey=e,n.textContent=xe(e),n.addEventListener("click",t),n}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),n={unit:e,precision:this.isValidPrecision(t)?t:this.config.precision};this.config=n,this.saveConfigToCache(n),this.draftConfig=null,this.view="main",this.applyViewState(),this.renderResult(),this.options.onConfigSave?.(n),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(ja.CONFIG_CACHE_KEY);if(!e)return null;const t=JSON.parse(e);if(!t||typeof t!="object")return null;const n=t.unit,i=t.precision;return!this.isValidUnit(n)||!this.isValidPrecision(i)?null:{unit:n,precision:i}}catch{return null}}saveConfigToCache(e){try{localStorage.setItem(ja.CONFIG_CACHE_KEY,JSON.stringify(e))}catch{}}isValidUnit(e){return e==="m"||e==="cm"||e==="mm"||e==="km"}isValidPrecision(e){return e===0||e===1||e===2||e===3}applyExpandedState(){let e=0;for(const t of this.toolButtons.values())e>=4?t.style.display=this.isExpanded?"":"none":t.style.display="",e++;this.isExpanded?this.toggleBtn.classList.add("is-expanded"):this.toggleBtn.classList.remove("is-expanded")}applyActiveModeState(){for(const[e,t]of this.toolButtons.entries())e===this.activeMode?t.classList.add("is-active"):t.classList.remove("is-active")}renderResult(){if(this.activeMode==="point"){this.mainValueRowEl.style.display="none",this.xyzBoxEl.style.display="";const n=this.result?.xyz;if(!n){this.xyzXEl.textContent="--",this.xyzYEl.textContent="--",this.xyzZEl.textContent="--";return}this.xyzXEl.textContent=this.convertValue("length",n.x)+" "+this.getUnitText("length"),this.xyzYEl.textContent=this.convertValue("length",n.y)+" "+this.getUnitText("length"),this.xyzZEl.textContent=this.convertValue("length",n.z)+" "+this.getUnitText("length");return}this.mainValueRowEl.style.display="",this.mainValueLabelEl.textContent=xe(this.getModeValueLabelI18nKey(this.activeMode));const t=this.result?this.result[Xa[this.activeMode].callBackType]:void 0;if(this.activeMode==="slope"||this.activeMode==="angle")this.mainNumberEl.textContent=t??"--",this.mainUnitEl.textContent="";else{const n=rg(this.activeMode);this.mainNumberEl.textContent=this.convertValue(n,t),this.mainUnitEl.textContent=this.getUnitText(n)}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 n=this.config.unit,i=this.config.precision;let r;switch(e){case"length":switch(n){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(n){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;case"angle":case"percent":case"point":default:r=t}return r.toFixed(i)}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 CC extends Gs{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 ja({defaultMode:"distance",defaultExpanded:!1,onModeChange:t=>{console.log("[MeasureDialogManager] 当前测量方式已切换:",t),this.engineComponent?.activateMeasure(t)},onClearAll:()=>{console.log("[MeasureDialogManager] 删除全部"),this.engineComponent?.clearAllMeasures()},onSettings:()=>{console.log("[MeasureDialogManager] 打开设置")},onExpandedChange:()=>{this.dialog?.fitHeight(!1)},onConfigSave:t=>{console.log("[MeasureDialogManager] 保存设置:",t),this.engineComponent?.saveMeasureSetting({unit:t.unit,precision:t.precision})},onClearHeightDirectionChange:t=>{console.log("[MeasureDialogManager] 净高朝向切换:",t),this.engineComponent?.setClearHeightDirection(t)},onClearHeightSelectTypeChange:t=>{console.log("[MeasureDialogManager] 净高选择对象切换:",t),this.engineComponent?.setClearHeightSelectType(t)}}),this.panel.init(),this.config=this.panel.getConfig(),this.config&&(console.log("[MeasureDialogManager] 同步缓存设置到引擎:",this.config),this.engineComponent?.saveMeasureSetting({unit:this.config.unit,precision:this.config.precision}));const e=document.createElement("div");return e.style.padding="12px",e.appendChild(this.panel.element),e}onDialogCreated(){this.dialog?.fitHeight(!1),this.engineComponent?.setClearHeightDirection(0),this.engineComponent?.setClearHeightSelectType("point");const e=this.engineComponent;if(e){const t=n=>{console.log("[MeasureDialogManager] 测量值回调:",n),n&&this.panel&&this.handleMeasureChanged(n)};e.onRawEvent("measure-changed",t),e.onRawEvent("measure-click",t),this.unsubscribeMeasureChanged=()=>{e.offRawEvent("measure-changed",t),e.offRawEvent("measure-click",t)}}}handleMeasureChanged(e){if(!this.panel)return;const t=EC(e.type);if(!t){console.warn("[MeasureDialogManager] 未知测量类型:",e.type);return}this.panel.getActiveMode()!==t&&this.panel.switchMode(t,!1);const i=this.convertToMeasureResult(e,t);this.panel.setResult(i)}convertToMeasureResult(e,t){const n=Xa[t],i={};return rg(t)==="point"?e.textX!==void 0&&e.textY!==void 0&&e.textZ!==void 0&&(i.xyz={x:e.textX,y:e.textY,z:e.textZ}):i[n.callBackType]=e.text,i}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 n=this.config,i={unit:e.unit??n?.unit??"mm",precision:e.precision??n?.precision??2};this.config=i}clearAll(){this.panel&&this.panel.clearAll()}openSettings(){this.panel&&this.panel.openSettings()}}class TC{element;options;isHidden=!1;hideBtn;reverseBtn;resetBtn;hideLabelEl;reverseLabelEl;resetLabelEl;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.isHidden=e.defaultHidden??!1,this.element=this.createDom()}setHiddenState(e){this.isHidden=e,this.updateButtonStates()}getHiddenState(){return this.isHidden}updateButtonStates(){this.hideBtn?.classList.toggle("active",this.isHidden)}init(){this.unsubscribeLocale=Qt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ot.subscribe(e=>{this.setTheme(e)}),this.setLocales(),this.setTheme(ot.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=xe("sectionPlane.actions.hide"),this.reverseLabelEl.textContent=xe("sectionPlane.actions.reverse"),this.resetLabelEl.textContent=xe("sectionPlane.actions.reset"),this.hideBtn.title=xe("sectionPlane.actions.hide"),this.reverseBtn.title=xe("sectionPlane.actions.reverse"),this.resetBtn.title=xe("sectionPlane.actions.reset")}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove()}createDom(){const e=document.createElement("div");return e.className="section-plane-panel",this.hideBtn=this.createButton("hide",rt("隐藏"),()=>{this.isHidden=!this.isHidden,this.updateButtonStates(),this.options.onHideToggle?.(this.isHidden)}),this.reverseBtn=this.createButton("reverse",rt("反向"),()=>{this.options.onReverse&&this.options.onReverse()}),this.resetBtn=this.createButton("reset",rt("重置"),()=>{this.options.onReset&&this.options.onReset()}),e.appendChild(this.hideBtn),e.appendChild(this.reverseBtn),e.appendChild(this.resetBtn),e}createButton(e,t,n){const i=document.createElement("button");i.type="button",i.className="section-plane-btn";const r=document.createElement("div");r.className="section-plane-btn-icon",r.innerHTML=t,i.appendChild(r);const a=document.createElement("div");return a.className="section-plane-btn-label",i.appendChild(a),e==="hide"?this.hideLabelEl=a:e==="reverse"?this.reverseLabelEl=a:this.resetLabelEl=a,i.addEventListener("click",n),i}}class AC extends Gs{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,n=50,i=e.clientWidth,r=e.clientHeight;return{x:i-this.dialogWidth-t,y:r-this.dialogHeight-n}}createContent(){return this.panel=new TC({defaultHidden:!1,onHideToggle:e=>{console.log("[SectionPlaneDialogManager] 隐藏切换:",e),e?this.engineComponent?.hideSection():this.engineComponent?.recoverSection()},onReverse:()=>{console.log("[SectionPlaneDialogManager] 反向 (not supported in new API)")},onReset:()=>{console.log("[SectionPlaneDialogManager] 重置 (not supported in new API)")}}),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 PC{element;options;isHidden=!1;activeAxis="x";hideBtn;reverseBtn;hideLabelEl;reverseLabelEl;axisXBtn;axisYBtn;axisZBtn;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.isHidden=e.defaultHidden??!1,this.activeAxis=e.defaultAxis??"x",this.element=this.createDom()}init(){this.unsubscribeLocale=Qt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ot.subscribe(e=>{this.setTheme(e)}),this.setLocales(),this.setTheme(ot.getTheme()),this.updateHideButtonState(),this.updateAxisButtonsState()}setTheme(e){const t=this.element.style;t.setProperty("--bim-bg-inset",e.bgInset??"#152232"),t.setProperty("--bim-border-default",e.borderDefault??"#334155"),t.setProperty("--bim-border-strong",e.borderStrong??"#475569"),t.setProperty("--bim-divider",e.divider??"#334155"),t.setProperty("--bim-primary",e.primary??"#3b82f6"),t.setProperty("--bim-primary-subtle",e.primarySubtle??"rgba(59, 130, 246, 0.15)"),t.setProperty("--bim-icon-default",e.iconDefault??"#ffffff"),t.setProperty("--bim-text-primary",e.textPrimary??"#ffffff"),t.setProperty("--bim-component-bg-hover",e.componentBgHover??"rgba(248, 250, 252, 0.06)")}setLocales(){this.hideLabelEl.textContent=xe("sectionAxis.actions.hide"),this.reverseLabelEl.textContent=xe("sectionAxis.actions.reverse"),this.hideBtn.title=xe("sectionAxis.actions.hide"),this.reverseBtn.title=xe("sectionAxis.actions.reverse"),this.axisXBtn.title=xe("sectionAxis.actions.axisX"),this.axisYBtn.title=xe("sectionAxis.actions.axisY"),this.axisZBtn.title=xe("sectionAxis.actions.axisZ")}setHiddenState(e){this.isHidden=e,this.updateHideButtonState()}getHiddenState(){return this.isHidden}setActiveAxis(e){this.activeAxis=e,this.updateAxisButtonsState()}getActiveAxis(){return this.activeAxis}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove()}createDom(){const e=document.createElement("div");e.className="section-axis-panel";const t=document.createElement("div");t.className="section-axis-row-1",this.hideBtn=this.createButton("hide",rt("隐藏"),()=>this.handleHideToggle()),this.reverseBtn=this.createButton("reverse",rt("反向"),()=>this.handleReverse()),t.appendChild(this.hideBtn),t.appendChild(this.reverseBtn);const n=document.createElement("div");return n.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")),n.appendChild(this.axisXBtn),n.appendChild(this.axisYBtn),n.appendChild(this.axisZBtn),e.appendChild(t),e.appendChild(n),e}createButton(e,t,n){const i=document.createElement("button");i.type="button",i.className="section-axis-btn";const r=document.createElement("div");r.className="section-axis-btn-icon",r.innerHTML=t,i.appendChild(r);const a=document.createElement("div");return a.className="section-axis-btn-label",i.appendChild(a),e==="hide"?this.hideLabelEl=a:e==="reverse"&&(this.reverseLabelEl=a),i.addEventListener("click",n),i}createAxisButton(e,t,n){const i=document.createElement("button");i.type="button",i.className="section-axis-btn section-axis-btn-text";const r=document.createElement("div");return r.className="section-axis-btn-label",r.textContent=t,i.appendChild(r),i.addEventListener("click",n),i}handleHideToggle(){this.isHidden=!this.isHidden,this.updateHideButtonState(),this.options.onHideToggle&&this.options.onHideToggle(this.isHidden)}handleReverse(){this.options.onReverse&&this.options.onReverse()}handleAxisChange(e){this.activeAxis!==e&&(this.activeAxis=e,this.updateAxisButtonsState(),this.options.onAxisChange&&this.options.onAxisChange(e))}updateHideButtonState(){this.isHidden?this.hideBtn.classList.add("active"):this.hideBtn.classList.remove("active")}updateAxisButtonsState(){this.axisXBtn.classList.toggle("active",this.activeAxis==="x"),this.axisYBtn.classList.toggle("active",this.activeAxis==="y"),this.axisZBtn.classList.toggle("active",this.activeAxis==="z")}}class RC extends Gs{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,n=e.clientHeight;return{x:t-this.dialogWidth-20,y:n-50-200}}createContent(){return this.panel=new PC({defaultAxis:"x",defaultHidden:!1,onHideToggle:e=>{console.log("[SectionAxisDialogManager] 隐藏切换:",e),e?this.engineComponent?.hideSection():this.engineComponent?.recoverSection()},onReverse:()=>{console.log("[SectionAxisDialogManager] 反向剖切(暂不支持)")},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 ag={x:{min:0,max:100},y:{min:0,max:100},z:{min:0,max:100}};class LC{element;options;isHidden=!1;isReversed=!1;range;hideBtn;reverseBtn;fitBtn;resetBtn;hideLabelEl;reverseLabelEl;fitLabelEl;resetLabelEl;xLabelEl;yLabelEl;zLabelEl;unsubscribeLocale=null;unsubscribeTheme=null;xSlider;ySlider;zSlider;xMinHandle;xMaxHandle;yMinHandle;yMaxHandle;zMinHandle;zMaxHandle;dragState={isDragging:!1,axis:null,handleType:null,pointerId:null};constructor(e={}){this.options=e,this.isHidden=e.defaultHidden??!1,this.isReversed=e.defaultReversed??!1,this.range=JSON.parse(JSON.stringify(e.defaultRange??ag))}init(){this.element=this.createPanel(),this.unsubscribeLocale=Qt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ot.subscribe(e=>this.setTheme(e)),this.setLocales(),this.setTheme(ot.getTheme()),this.updateButtonStates(),this.updateAllSlidersUI(),this.setupDragListeners()}setHiddenState(e){this.isHidden=e,this.updateButtonStates()}getHiddenState(){return this.isHidden}setReversedState(e){this.isReversed=e,this.updateButtonStates()}getReversedState(){return this.isReversed}setRange(e){e.x&&(this.range.x={...this.range.x,...e.x}),e.y&&(this.range.y={...this.range.y,...e.y}),e.z&&(this.range.z={...this.range.z,...e.z}),this.updateAllSlidersUI()}getRange(){return JSON.parse(JSON.stringify(this.range))}reset(){this.isHidden=this.options.defaultHidden??!1,this.isReversed=this.options.defaultReversed??!1,this.range=JSON.parse(JSON.stringify(this.options.defaultRange??ag)),this.updateButtonStates(),this.updateAllSlidersUI(),this.options.onReset?.(),this.options.onRangeChange?.(this.range)}createPanel(){const e=document.createElement("div");e.className="section-box-panel";const t=document.createElement("div");t.className="section-box-row-buttons",this.hideBtn=this.createButton("hide",xe("sectionBox.actions.hide"),()=>{this.isHidden=!this.isHidden,this.updateButtonStates(),this.options.onHideToggle?.(this.isHidden)},"hide"),this.reverseBtn=this.createButton("reverse",xe("sectionBox.actions.reverse"),()=>{this.isReversed=!this.isReversed,this.updateButtonStates(),this.options.onReverseToggle?.(this.isReversed)},"reverse"),this.fitBtn=this.createButton("fit",xe("sectionBox.actions.fitToModel"),()=>{this.options.onFitToModel?.()},"fit"),this.resetBtn=this.createButton("reset",xe("sectionBox.actions.reset"),()=>this.reset(),"reset"),[this.hideBtn,this.reverseBtn,this.fitBtn,this.resetBtn].forEach(i=>t.appendChild(i));const n=document.createElement("div");return n.className="section-box-sliders",n.addEventListener("pointerdown",i=>i.stopPropagation()),this.xSlider=this.createSlider("x",xe("sectionBox.axes.x")),this.ySlider=this.createSlider("y",xe("sectionBox.axes.y")),this.zSlider=this.createSlider("z",xe("sectionBox.axes.z")),[this.xSlider,this.ySlider,this.zSlider].forEach(i=>n.appendChild(i)),e.appendChild(t),e.appendChild(n),e}createButton(e,t,n,i){const r=document.createElement("button");r.className="section-box-btn",r.title=t;const a={hide:"隐藏",reverse:"反向",fit:"适应到模型",reset:"重置"},o=document.createElement("div");o.className="section-box-btn-icon",o.innerHTML=rt(a[e]||e);const l=document.createElement("div");return l.className="section-box-btn-label",l.textContent=t,i==="hide"?this.hideLabelEl=l:i==="reverse"?this.reverseLabelEl=l:i==="fit"?this.fitLabelEl=l:i==="reset"&&(this.resetLabelEl=l),r.appendChild(o),r.appendChild(l),r.addEventListener("click",n),r}createSlider(e,t){const n=document.createElement("div");n.className="section-box-slider";const i=document.createElement("div");i.className="section-box-slider-label",i.textContent=t,e==="x"?this.xLabelEl=i:e==="y"?this.yLabelEl=i:this.zLabelEl=i;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),n.append(i,r),e==="x"?(this.xMinHandle=o,this.xMaxHandle=l):e==="y"?(this.yMinHandle=o,this.yMaxHandle=l):(this.zMinHandle=o,this.zMaxHandle=l),n}setupDragListeners(){[this.xMinHandle,this.xMaxHandle,this.yMinHandle,this.yMaxHandle,this.zMinHandle,this.zMaxHandle].forEach(t=>{t.addEventListener("pointerdown",i=>{i.preventDefault(),i.stopPropagation(),t.setPointerCapture(i.pointerId),this.dragState={isDragging:!0,axis:t.getAttribute("data-axis"),handleType:t.getAttribute("data-handle"),pointerId:i.pointerId},t.classList.add("dragging"),t.closest(".section-box-slider").style.zIndex="100"}),t.addEventListener("pointermove",i=>{this.dragState.isDragging&&this.dragState.pointerId===i.pointerId&&this.onDragging(i)});const n=i=>{this.dragState.isDragging&&this.dragState.pointerId===i.pointerId&&(t.hasPointerCapture(i.pointerId)&&t.releasePointerCapture(i.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",n),t.addEventListener("pointercancel",n),t.addEventListener("lostpointercapture",n)})}onDragging(e){const{axis:t,handleType:n}=this.dragState;if(!t||!n)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];n==="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],n=e==="x"?this.xMinHandle:e==="y"?this.yMinHandle:this.zMinHandle,i=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");n.style.left=`${t.min}%`,i.style.left=`${t.max}%`,a.style.left=`${t.min}%`,a.style.width=`${t.max-t.min}%`,n.setAttribute("data-value",Math.round(t.min).toString()),i.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),this.reverseBtn&&this.reverseBtn.classList.toggle("active",this.isReversed)}setLocales(){this.hideLabelEl&&(this.hideLabelEl.textContent=xe("sectionBox.actions.hide"),this.reverseLabelEl.textContent=xe("sectionBox.actions.reverse"),this.fitLabelEl.textContent=xe("sectionBox.actions.fitToModel"),this.resetLabelEl.textContent=xe("sectionBox.actions.reset"),this.xLabelEl.textContent=xe("sectionBox.axes.x"),this.yLabelEl.textContent=xe("sectionBox.axes.y"),this.zLabelEl.textContent=xe("sectionBox.axes.z"),this.hideBtn.title=xe("sectionBox.actions.hide"),this.reverseBtn.title=xe("sectionBox.actions.reverse"),this.fitBtn.title=xe("sectionBox.actions.fitToModel"),this.resetBtn.title=xe("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 IC extends Gs{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,n=e.clientHeight;return{x:t-this.dialogWidth-20,y:n-50-300}}createContent(){return this.panel=new LC({defaultHidden:!1,defaultReversed:!1,onHideToggle:e=>{console.log("[SectionBoxDialogManager] 隐藏切换:",e),e?this.engineComponent?.hideSection():this.engineComponent?.recoverSection()},onReverseToggle:e=>{console.log("[SectionBoxDialogManager] 反向切换:",e),this.engineComponent?.reverseSection()},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=n=>{n&&this.panel&&this.panel.setRange(n)};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 DC{element;options;state={mode:"none",isPlanViewActive:!1,speed:1,gravity:!1,collision:!1,characterModel:"construction-worker",walkMode:"walk"};planViewBtn;pathModeBtn;settingsContainer;speedControl;speedDecreaseBtn;speedIncreaseBtn;speedDisplay;gravityCheckbox;gravityLabel;collisionCheckbox;collisionLabel;characterModelSelect;characterModelLabel;walkModeSelect;walkModeLabel;exitBtn;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.state.speed=e.defaultSpeed??1,this.state.gravity=e.defaultGravity??!1,this.state.collision=e.defaultCollision??!1,this.state.characterModel=e.defaultCharacterModel??"construction-worker",this.state.walkMode=e.defaultWalkMode??"walk"}init(){this.element=this.createPanel(),this.updateSettingsView(),this.unsubscribeLocale=Qt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ot.subscribe(e=>this.setTheme(e)),this.setLocales(),this.setTheme(ot.getTheme())}setPlanViewActive(e){this.state.isPlanViewActive=e,this.updateButtonStates()}setPathModeActive(e){if(!e&&this.state.mode!=="path")return;const t=e?"path":"none";this.setMode(t)}getState(){return{...this.state}}createPanel(){const e=document.createElement("div");e.className="walk-control-panel";const t=this.createLeftButtons(),n=document.createElement("div");n.className="walk-divider",this.settingsContainer=this.createSettingsContainer();const i=document.createElement("div");i.className="walk-divider";const r=this.createExitButton();return e.appendChild(t),e.appendChild(n),e.appendChild(this.settingsContainer),e.appendChild(i),e.appendChild(r),e}createLeftButtons(){const e=document.createElement("div");return e.className="walk-control-left",this.planViewBtn=this.createIconButton("plan-view",()=>{this.state.isPlanViewActive=!this.state.isPlanViewActive,this.updateButtonStates(),this.options.onPlanViewToggle?.(this.state.isPlanViewActive)}),this.pathModeBtn=this.createIconButton("path",()=>{const t=this.state.mode==="path"?"none":"path";this.setMode(t),this.options.onPathModeToggle?.(t==="path")}),e.appendChild(this.planViewBtn),e.appendChild(this.pathModeBtn),e}createSettingsContainer(){const e=document.createElement("div");e.className="walk-control-settings",this.speedControl=this.createSpeedControl();const t=document.createElement("label");t.className="walk-checkbox-wrapper walk-checkbox-gravity",this.gravityCheckbox=document.createElement("input"),this.gravityCheckbox.type="checkbox",this.gravityCheckbox.className="walk-checkbox",this.gravityCheckbox.checked=this.state.gravity,this.gravityCheckbox.addEventListener("change",()=>{this.state.gravity=this.gravityCheckbox.checked,this.options.onGravityToggle?.(this.state.gravity)}),this.gravityLabel=document.createElement("span"),this.gravityLabel.className="walk-checkbox-label",t.appendChild(this.gravityCheckbox),t.appendChild(this.gravityLabel);const n=document.createElement("label");n.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",n.appendChild(this.collisionCheckbox),n.appendChild(this.collisionLabel);const i=document.createElement("div");i.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)}),i.appendChild(this.characterModelLabel),i.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(i),e.appendChild(r),e.appendChild(t),e.appendChild(n),e}createSpeedControl(){const e=document.createElement("div");e.className="walk-speed-control";const t=document.createElement("label");t.className="walk-speed-label",t.textContent=xe("walkControl.speed");const n=document.createElement("div");return n.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))}),n.appendChild(this.speedDecreaseBtn),n.appendChild(this.speedDisplay),n.appendChild(this.speedIncreaseBtn),e.appendChild(t),e.appendChild(n),e}createIconButton(e,t){const n=document.createElement("button");return n.className=`walk-icon-btn walk-icon-btn-${e}`,n.innerHTML=this.getIconSVG(e),n.addEventListener("click",t),n}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,n=this.collisionCheckbox.parentElement,i=this.characterModelSelect.parentElement,r=this.walkModeSelect.parentElement;this.state.mode==="walk"?(e.style.display="none",t.style.display="flex",n.style.display="flex",i.style.display="flex",r.style.display="flex"):(e.style.display="flex",t.style.display="flex",n.style.display="flex",i.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":rt("地图"),path:rt("路径漫游"),walk:rt("第一人称漫游")}[e]||""}setLocales(){const e=this.speedControl.querySelector(".walk-speed-label");e&&(e.textContent=xe("walkControl.speed")),this.gravityLabel.textContent=xe("walkControl.gravity"),this.collisionLabel.textContent=xe("walkControl.collision"),this.characterModelLabel.textContent=xe("walkControl.characterModel.label"),this.characterModelSelect.innerHTML="";const t=document.createElement("option");t.value="construction-worker",t.textContent=xe("walkControl.characterModel.constructionWorker"),t.selected=this.state.characterModel==="construction-worker",this.characterModelSelect.appendChild(t);const n=document.createElement("option");n.value="office-male",n.textContent=xe("walkControl.characterModel.officeMale"),n.selected=this.state.characterModel==="office-male",this.characterModelSelect.appendChild(n),this.walkModeLabel.textContent=xe("walkControl.walkMode.label"),this.walkModeSelect.innerHTML="";const i=document.createElement("option");i.value="walk",i.textContent=xe("walkControl.walkMode.walk"),i.selected=this.state.walkMode==="walk",this.walkModeSelect.appendChild(i);const r=document.createElement("option");r.value="run",r.textContent=xe("walkControl.walkMode.run"),r.selected=this.state.walkMode==="run",this.walkModeSelect.appendChild(r),this.exitBtn.textContent=xe("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 NC{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=Qt.subscribe(()=>this.render()),this.unsubscribeTheme=ot.subscribe(e=>this.setTheme(e)),this.loadPointsFromEngine(),this.render(),this.setTheme(ot.getTheme())}loadPointsFromEngine(){const e=this.registry.engine3d?.getEngineComponent()?.pathRoamingGetPoints()??[];this.points=e.map((t,n)=>({index:n}))}render(){this.element.innerHTML="";const e=this.createSettingsSection();this.element.appendChild(e);const t=this.createPointsSection();this.element.appendChild(t);const n=this.createPlayButton();this.element.appendChild(n)}createSettingsSection(){const e=document.createElement("div");e.className="walk-path-settings";const t=document.createElement("div");t.className="walk-path-form-group";const n=document.createElement("label");n.textContent=xe("walkControl.path.duration");const i=document.createElement("div");i.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=xe("walkControl.path.durationUnit"),i.appendChild(r),i.appendChild(a),t.appendChild(n),t.appendChild(i);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=xe("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 n=document.createElement("button");n.className="walk-path-btn walk-path-btn-small",n.textContent=`+ ${xe("walkControl.path.addPoint")}`,n.onclick=()=>this.addPoint();const i=document.createElement("button");i.className="walk-path-btn walk-path-btn-small walk-path-btn-danger",i.textContent=xe("walkControl.path.deleteAll"),i.onclick=()=>this.deleteAllPoints(),t.appendChild(n),t.appendChild(i),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=xe("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 n=document.createElement("span");n.className="walk-path-point-name",n.textContent=`${xe("walkControl.path.point")}${e}`;const i=document.createElement("div");i.className="walk-path-point-actions";const r=document.createElement("button");r.className="walk-path-btn-icon",r.innerHTML="▶",r.title=xe("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)},i.appendChild(r),i.appendChild(a),t.appendChild(n),t.appendChild(i),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=`▶ ${xe("walkControl.path.play")}`,t.disabled=this.points.length===0||this.isPlaying,t.onclick=()=>this.playPath();const n=document.createElement("button");return n.className="walk-path-btn walk-path-btn-stop",n.textContent=`■ ${xe("walkControl.path.stop")}`,n.disabled=!this.isPlaying,n.onclick=()=>this.stopPath(),e.appendChild(t),e.appendChild(n),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,n)=>t.index=n),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.textSecondary??"#94a3b8"),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 BC extends Gs{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 NC(this.registry),this.panel.init(),this.panel.element}onDialogClose(){this.registry.walkControl&&this.registry.walkControl.panel&&this.registry.walkControl.panel.setPathModeActive(!1)}onBeforeDestroy(){this.panel&&(this.panel.destroy(),this.panel=null)}}class kC extends xi{panel=null;pathManager=null;constructor(e){super(e)}init(){this.pathManager=new BC(this.registry),this.pathManager.init()}show(){if(!this.registry.toolbar){console.warn("Toolbar not initialized");return}this.registry.toolbar.hide(),console.log("[WalkControl] 打开漫游面板,激活第一人称模式"),this.engineComponent?.activateFirstPersonMode(),this.panel=new DC({onPlanViewToggle:t=>{console.log("[WalkControl] 小地图:",t),this.engineComponent?.toggleMiniMap(),this.registry.toolbar?.setBtnActive("map",t),this.emit("walk:plan-view-toggle",{isActive:t})},onPathModeToggle:t=>{console.log("[WalkControl] 路径漫游:",t),t?this.pathManager?.show():this.pathManager?.hide(),this.emit("walk:path-mode-toggle",{isActive:t})},onWalkModeToggle:t=>{console.log("[WalkControl] 第三人称漫游按钮点击:",t),t&&(this.pathManager?.hide(),alert("第三人称功能开发中")),this.emit("walk:walk-mode-toggle",{isActive:t})},onSpeedChange:t=>{console.log("[WalkControl] 速度变化:",t);const n=t*.1;this.engineComponent?.setWalkSpeed(n),this.emit("walk:speed-change",{speed:t})},onGravityToggle:t=>{console.log("[WalkControl] 重力:",t),this.engineComponent?.setWalkGravity(t),this.emit("walk:gravity-toggle",{enabled:t})},onCollisionToggle:t=>{console.log("[WalkControl] 碰撞:",t),this.engineComponent?.setWalkCollision(t),this.emit("walk:collision-toggle",{enabled:t})},onCharacterModelChange:t=>{console.log("[WalkControl] 角色模型:",t)},onWalkModeChange:t=>{console.log("[WalkControl] 行走模式:",t)},onExit:()=>{this.hide()}}),this.panel.init();const e=this.engineComponent?.getMiniMapState()??!1;this.panel.setPlanViewActive(e),this.registry.container?(this.panel.element.style.position="absolute",this.panel.element.style.bottom="20px",this.panel.element.style.left="50%",this.panel.element.style.transform="translateX(-50%)",this.panel.element.style.zIndex="1000",this.registry.container.appendChild(this.panel.element)):console.warn("[WalkControlManager] Container not found")}hide(){this.pathManager?.hide(),this.engineComponent?.getMiniMapState()&&this.engineComponent.toggleMiniMap(),console.log("[WalkControl] 关闭漫游面板,退出第一人称模式"),this.engineComponent?.deactivateFirstPersonMode(),this.panel&&(this.panel.destroy(),this.panel=null),this.registry.toolbar?.setBtnActive("map",!1),this.registry.toolbar&&this.registry.toolbar.show()}destroy(){this.hide(),this.pathManager?.destroy(),this.pathManager=null,super.destroy()}}class UC extends Gs{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,n=e.clientHeight;return{x:(t-this.dialogWidth)/2,y:(n-150)/2}}createContent(){const e=this.engineComponent?.getEngineInfo()??null,t=document.createElement("div");t.className="engine-info-content",t.style.cssText="padding: 16px;";const n=(i,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=i;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(n(xe("info.meshCount"),e?.meshCount??"-")),t.appendChild(n(xe("info.totalTriangles"),e?.totalTriangles??"-")),t.appendChild(n(xe("info.totalVertices"),e?.totalVertices??"-")),t}}const xu="font-size: 13px; color: var(--bim-text-secondary, #475569); margin-bottom: 8px;",OC="height: 1px; background: var(--bim-divider, #e2e8f0); margin: 14px 0;",vu="display: flex; align-items: center; justify-content: space-between; gap: 12px;",zC="font-size: 12px; color: var(--bim-text-secondary, #475569); min-width: 32px; text-align: right;",jr="var(--bim-border-default, #e2e8f0)",og="var(--bim-bg-inset, #f1f5f9)",Jl="var(--bim-primary, #3b82f6)",bu="var(--bim-text-primary, #0f172a)",FC="var(--bim-text-inverse, #ffffff)",HC="var(--bim-component-bg-hover, rgba(0,0,0,0.04))";class VC extends Gs{get dialogId(){return"setting-dialog"}get dialogTitle(){return"setting.dialogTitle"}get dialogWidth(){return 320}edgeLineEnabled=!1;contrastValue=50;saturationValue=50;lightIntensityValue=50;environmentList=[];environmentId="";backgroundVisible=!0;groundList=[];groundId="";groundElevation=0;savedPosition=null;constructor(e){super(e)}init(){}getDialogPosition(){if(this.savedPosition){const i=this.savedPosition;return this.savedPosition=null,i}const e=this.registry.container;if(!e)return{x:100,y:100};const t=e.clientWidth,n=e.clientHeight;return{x:(t-this.dialogWidth)/2,y:Math.max(20,(n-520)/2)}}loadEngineState(){const e=this.engineComponent;e&&(this.edgeLineEnabled=e.getModelEdgeActive(),this.lightIntensityValue=e.getAmbientLightIntensity(),this.contrastValue=e.getSceneContrast(),this.saturationValue=e.getSceneSaturation(),this.environmentList=e.getHDRBackgroundList(),this.environmentId=e.getHDRBackgroundId(),this.backgroundVisible=e.getHDRBackgroundVisibility(),this.groundList=e.getGroundList(),this.groundId=e.getGroundId(),this.groundElevation=e.getGroundElevation())}createContent(){this.loadEngineState(),this.ensureSliderStyle();const e=document.createElement("div");return e.style.cssText="padding: 16px; max-height: 480px; overflow-y: auto;",e.appendChild(this.createRenderModeSection()),e.appendChild(this.createDivider()),e.appendChild(this.createEdgeLineSection()),e.appendChild(this.createDivider()),e.appendChild(this.createSliderSection(xe("setting.lightIntensity"),this.lightIntensityValue,0,100,t=>{this.lightIntensityValue=t,this.engineComponent?.setAmbientLightIntensity(t)})),e.appendChild(this.createSliderSection(xe("setting.contrast"),this.contrastValue,0,100,t=>{this.contrastValue=t,this.engineComponent?.setSceneContrast(t)})),e.appendChild(this.createSliderSection(xe("setting.saturation"),this.saturationValue,0,100,t=>{this.saturationValue=t,this.engineComponent?.setSceneSaturation(t)})),e.appendChild(this.createDivider()),e.appendChild(this.createEnvironmentSection()),e.appendChild(this.createDivider()),e.appendChild(this.createGroundSection()),e}createDivider(){const e=document.createElement("div");return e.style.cssText=OC,e}createRenderModeSection(){const e=this.engineComponent?.getRenderMode()??"balance",t=document.createElement("div"),n=document.createElement("div");n.style.cssText=xu,n.textContent=xe("setting.renderMode"),t.appendChild(n);const i=document.createElement("div");i.style.cssText=`
display: flex; gap: 0; border-radius: 6px; overflow: hidden;
border: 1px solid ${jr};
`;const r=[{key:"simple",labelKey:"setting.modes.simple"},{key:"balance",labelKey:"setting.modes.balance"},{key:"advanced",labelKey:"setting.modes.advanced"}];for(let a=0;a<r.length;a++){const o=r[a],l=o.key===e,c=document.createElement("div");c.style.cssText=`
flex: 1; text-align: center; padding: 7px 0; cursor: pointer;
font-size: 13px; font-weight: 500; transition: all 0.15s;
background: ${l?Jl:"transparent"};
color: ${l?FC:bu};
${a<r.length-1?`border-right: 1px solid ${jr};`:""}
`,c.textContent=xe(o.labelKey),c.addEventListener("mouseenter",()=>{l||(c.style.background=HC)}),c.addEventListener("mouseleave",()=>{l||(c.style.background="transparent")}),c.addEventListener("click",()=>{this.engineComponent?.setRenderMode(o.key);const h=document.getElementById(this.dialogId);h&&(this.savedPosition={x:h.offsetLeft,y:h.offsetTop}),this.hide(),this.show()}),i.appendChild(c)}return t.appendChild(i),t}createEdgeLineSection(){return this.createToggleRow(xe("setting.edgeLine"),this.edgeLineEnabled,e=>{this.edgeLineEnabled=e,e?this.engineComponent?.activeModelEdge():this.engineComponent?.disActiveModelEdge()})}createSliderSection(e,t,n,i,r){const a=document.createElement("div");a.style.cssText="margin-bottom: 4px;";const o=document.createElement("div");o.style.cssText=vu+" 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=zC,c.textContent=String(t),o.appendChild(c),a.appendChild(o);const h=document.createElement("input");return h.type="range",h.min=String(n),h.max=String(i),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}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)}createEnvironmentSection(){const e=document.createElement("div"),t=document.createElement("div");t.style.cssText=xu,t.textContent=xe("setting.environment"),e.appendChild(t);const n=this.createSelect(this.environmentList.map(r=>({value:r.id,label:r.name})),this.environmentId,r=>{this.environmentId=r,this.engineComponent?.setHDRBackgroundId(r)});e.appendChild(n);const i=this.createToggleRow(xe("setting.backgroundVisible"),this.backgroundVisible,r=>{this.backgroundVisible=r,this.engineComponent?.setHDRBackgroundVisibility(r)});return i.style.marginTop="10px",e.appendChild(i),e}createGroundSection(){const e=document.createElement("div"),t=document.createElement("div");t.style.cssText=xu,t.textContent=xe("setting.ground"),e.appendChild(t);const n=this.createSelect(this.groundList.map(c=>({value:c.id,label:c.name})),this.groundId,c=>{this.groundId=c,this.engineComponent?.setGroundId(c)});e.appendChild(n);const i=document.createElement("div");i.style.cssText=vu+" margin-top: 10px;";const r=document.createElement("span");r.style.cssText="font-size: 13px; color: var(--bim-text-secondary, #475569);",r.textContent=xe("setting.groundElevation"),i.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.groundElevation),o.style.cssText=`
width: 72px; padding: 4px 8px; border-radius: 4px;
border: 1px solid ${jr};
background: ${og};
color: ${bu};
font-size: 13px; outline: none; text-align: right;
`,o.addEventListener("input",()=>{const c=Number(o.value);isNaN(c)||(this.groundElevation=c,this.engineComponent?.setGroundElevation(c))}),o.addEventListener("focus",()=>{o.style.borderColor=Jl}),o.addEventListener("blur",()=>{o.style.borderColor=jr});const l=document.createElement("span");return l.style.cssText="font-size: 13px; color: var(--bim-text-secondary, #475569);",l.textContent=xe("setting.groundElevationUnit"),a.appendChild(o),a.appendChild(l),i.appendChild(a),e.appendChild(i),e}createSelect(e,t,n){const i=document.createElement("select");i.style.cssText=`
width: 100%; padding: 7px 10px; border-radius: 6px;
border: 1px solid ${jr};
background: ${og};
color: ${bu};
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,a.style.cssText=`
background: var(--bim-bg-elevated, #ffffff);
color: var(--bim-text-primary, #0f172a);
`,r.value===t&&(a.selected=!0),i.appendChild(a)}return i.addEventListener("change",()=>{n(i.value)}),i.addEventListener("focus",()=>{i.style.borderColor=Jl}),i.addEventListener("blur",()=>{i.style.borderColor=jr}),i}createToggleRow(e,t,n){const i=document.createElement("div");i.style.cssText=vu;const r=document.createElement("span");r.style.cssText="font-size: 13px; color: var(--bim-text-secondary, #475569);",r.textContent=e,i.appendChild(r);const a="var(--bim-border-strong, #cbd5e1)",o=Jl;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",n(l)}),i.appendChild(c),i}}class GC{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=xe(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=xe(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 lg{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(n=>this.activeIds.add(n)),this.init()}init(){this.options.items.forEach(e=>{const t=new GC(e,this);this.items.set(e.id,t),this.element.appendChild(t.element),this.activeIds.has(e.id)&&t.setActive(!0)}),this.unsubscribeLocale=Qt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ot.subscribe(e=>{this.setTheme(e)}),this.setTheme(ot.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 WC extends xi{dialogId="component-detail-dialog";dialog=null;currentSelection=null;unsubscribeSelected=null;unsubscribeDeselected=null;tabInstance=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=xe("panel.componentDetail.noSelection")||"请先选中构件",this.dialog.setContent(e)}renderTabbedContent(){if(!this.dialog)return;this.tabInstance&&(this.tabInstance.destroy(),this.tabInstance=null);const e=document.createElement("div");e.style.cssText="height:100%;display:flex;flex-direction:column;";const t=this.createPropertiesPanel(),n=this.createMaterialsPanel();this.tabInstance=new eg({container:e,activeId:"properties",tabs:[{id:"properties",title:"panel.property.tab.props",content:t},{id:"materials",title:"panel.property.tab.material",content:n}]}),this.tabInstance.init(),this.dialog.setContent(e)}createPropertiesPanel(){const e=document.createElement("div");e.style.cssText="height:100%;overflow-y:auto;";const t=this.propertiesData?.properties||[];if(t.length===0)return e.innerHTML='<div style="padding:20px;text-align:center;color:var(--bim-text-secondary,#999);">无属性数据</div>',e;const n=t.map((r,a)=>({id:`category-${a}`,title:r.name||`分类 ${a+1}`,content:this.createCategoryContent(r.children||[])}));new lg({container:e,accordion:!1,ghost:!0,activeIds:n.length>0?[n[0].id]:[],items:n});const i=document.createElement("style");return i.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(i),e}createMaterialsPanel(){const e=document.createElement("div");e.style.cssText="height:100%;overflow-y:auto;";const t=this.propertiesData?.materials||[];if(t.length===0)return e.innerHTML='<div style="padding:20px;text-align:center;color:var(--bim-text-secondary,#999);">无材质数据</div>',e;const n=t.map((r,a)=>({id:`material-${a}`,title:r.name||`材质 ${a+1}`,content:this.createCategoryContent(r.children||r.properties||[])}));new lg({container:e,accordion:!1,ghost:!0,activeIds:n.length>0?[n[0].id]:[],items:n});const i=document.createElement("style");return i.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(i),e}createCategoryContent(e){const t=document.createElement("div");return e.forEach((n,i)=>{const r=document.createElement("div");r.style.cssText=`
display: flex;
border-bottom: 1px solid var(--bim-border-default, rgba(255,255,255,0.15));
`,i===e.length-1&&(r.style.borderBottom="none");const a=document.createElement("div");a.style.cssText=`
width: 120px;
flex-shrink: 0;
color: var(--bim-text-secondary, #999);
font-size: 13px;
padding: 8px 12px;
border-right: 1px solid var(--bim-border-default, rgba(255,255,255,0.15));
`,a.textContent=n.name||"-";const o=document.createElement("div");o.style.cssText=`
flex: 1;
color: var(--bim-text-primary, #fff);
font-size: 13px;
padding: 8px 12px;
word-break: break-all;
`,o.textContent=String(n.value??"-"),r.appendChild(a),r.appendChild(o),t.appendChild(r)}),t}isOpen(){return this.dialog!==null}hide(){this.tabInstance&&(this.tabInstance.destroy(),this.tabInstance=null),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 XC{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=ot.subscribe(e=>{this.setTheme(e)}),this.unsubscribeLocale=Qt.subscribe(()=>{this.setLocales()}),this.setTheme(ot.getTheme()),this.setLocales()}setTheme(e){const t=e.name==="dark"||e.name?.includes("dark");this.element.classList.toggle("light",!t);const n=this.element.style;n.setProperty("--bim-ai-accent",e.primary),n.setProperty("--bim-ai-text",e.textPrimary),n.setProperty("--bim-ai-muted",e.textTertiary),n.setProperty("--bim-ai-border",e.borderDefault),n.setProperty("--bim-ai-shadow",e.shadowLg)}setLocales(){const e=this.element.querySelector(".bim-ai-chat-title");e&&this.options.title&&(e.textContent=xe(this.options.title));const t=this.element.querySelector(".bim-ai-textarea");t&&this.options.placeholder&&(t.placeholder=xe(this.options.placeholder));const n=this.element.querySelector(".bim-ai-helper-left");n&&(n.textContent=xe("aiChat.helper.newline"));const i=this.element.querySelector(".bim-ai-helper-right");i&&(i.textContent=xe("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,n=Math.max(50,e-t-50);this.element.style.left=`${n}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 n=this.messages.findIndex(i=>i.id===e);n!==-1&&(this.messages[n]={...this.messages[n],...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 n=`step-${Date.now()}`;return this.addMessage({id:n,type:"step",status:e,content:t,timestamp:Date.now()}),n}addThinkingMessage(){const e=`thinking-${Date.now()}`;return this.addMessage({id:e,type:"thinking",timestamp:Date.now()}),e}addQuestionMessage(e,t,n){const i=`question-${Date.now()}`;return this.addMessage({id:i,type:"question",title:e,question:t,options:n,answered:!1,timestamp:Date.now()}),i}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="${xe("aiChat.action.new")}">
${rt("plus")}
</button>
<button class="bim-ai-chat-action-btn" data-action="history" title="${xe("aiChat.action.history")}">
${rt("history")}
</button>
<button class="bim-ai-chat-action-btn" data-action="settings" title="${xe("aiChat.action.settings")}">
${rt("settings")}
</button>
<button class="bim-ai-chat-action-btn" data-action="close" title="${xe("aiChat.action.close")}">
${rt("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">
${rt("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 i=a=>a.stopPropagation();["click","dblclick","mousedown","mouseup","mousemove","wheel","touchstart","touchend","touchmove"].forEach(a=>{e.addEventListener(a,i,{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,n=0,i=0,r=0,a=0,o=0,l=0,c=0;const h=u=>{u.target.closest(".bim-ai-chat-action-btn")||(u.preventDefault(),u.stopPropagation(),t=u.clientX,n=u.clientY,i=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",p,{capture:!0}))},d=u=>{u.preventDefault(),u.stopPropagation(),!this.rafId&&(this.rafId=requestAnimationFrame(()=>{const g=u.clientX-t,f=u.clientY-n;let x=i+g,m=r+f;const b=a-l,v=o-c;x=Math.max(0,Math.min(x,b)),m=Math.max(0,Math.min(m,v)),this.element.style.left=`${x}px`,this.element.style.top=`${m}px`,this.rafId=null}))},p=()=>{this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null),document.removeEventListener("mousemove",d,{capture:!0}),document.removeEventListener("mouseup",p,{capture:!0})};e.addEventListener("mousedown",h)}updateQuickPrompts(e){const n=(e||this.element).querySelector(".bim-ai-quick-prompts");!n||!this.options.quickPrompts||(n.innerHTML=this.options.quickPrompts.map(i=>`
<button class="bim-ai-quick-prompt" data-prompt-id="${i.id}">
${xe(i.label)}
</button>
`).join(""),n.querySelectorAll(".bim-ai-quick-prompt").forEach(i=>{i.addEventListener("click",r=>{const a=r.currentTarget.dataset.promptId,o=this.options.quickPrompts?.find(l=>l.id===a);o&&this.textarea&&(this.textarea.value=xe(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">${rt({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">${rt("loader")}</span>
<span class="bim-ai-thinking-text">${xe("aiChat.thinking")}</span>
</div>
`}renderActiveQuestion(e){const t=e.options.map(n=>`
<div class="bim-ai-option ${e.selectedOptionId===n.id?"selected":""}"
data-question-id="${e.id}" data-option-id="${n.id}" data-is-other="${n.isOther||!1}">
<div class="bim-ai-option-radio">
<div class="bim-ai-option-radio-dot"></div>
</div>
<span class="bim-ai-option-text">${n.isOther?xe("aiChat.other"):this.escapeHtml(n.label)}</span>
</div>
${n.isOther&&e.selectedOptionId===n.id?`
<input type="text" class="bim-ai-option-input"
data-question-id="${e.id}"
placeholder="${xe("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">${rt("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>${xe("aiChat.submit")}</span>
${rt("send")}
</button>
</div>
</div>
`}renderAnsweredQuestion(e){const t=e.options.find(i=>i.id===e.selectedOptionId),n=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(n||"")}</span>
</div>
</div>
`}bindQuestionEvents(){this.messagesContainer?.querySelectorAll(".bim-ai-option").forEach(e=>{e.addEventListener("click",t=>{const n=t.currentTarget,i=n.dataset.questionId,r=n.dataset.optionId;if(i&&r){const a=this.messages.find(o=>o.id===i);a&&!a.answered&&(a.selectedOptionId=r,this.renderMessages())}})}),this.messagesContainer?.querySelectorAll(".bim-ai-option-input").forEach(e=>{e.addEventListener("input",t=>{const n=t.target,i=n.dataset.questionId;if(i){const r=this.messages.find(a=>a.id===i);r&&(r.customAnswer=n.value)}})}),this.messagesContainer?.querySelectorAll(".bim-ai-question-submit").forEach(e=>{e.addEventListener("click",t=>{const i=t.currentTarget.dataset.questionId;if(i){const r=this.messages.find(a=>a.id===i);r&&r.selectedOptionId&&(r.answered=!0,this.renderMessages(),this.options.onQuestionSubmit?.(i,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 jC{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 XC({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,n,i)=>{console.log("[AiChatManager] 用户回答问题:",{questionId:t,optionId:n,customAnswer:i}),this.registry.emit("aiChat:question-answered",{questionId:t,optionId:n,customAnswer:i})},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,n){return this.aiChat?.addQuestionMessage(e,t,n)??""}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 qC{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 n=this.events.get(e);if(!n)return;const i=n.indexOf(t);i!==-1&&n.splice(i,1)}emit(e,t){const n=this.events.get(e);n&&n.forEach(i=>{try{i(t)}catch(r){console.error(`[EventEmitter] Error in listener for event "${e}":`,r)}})}clear(){this.events.clear()}}class ZC{eventEmitter=new qC;container=null;wrapper=null;toolbar=null;dialog=null;engine3d=null;buttonGroup=null;rightKey=null;constructTree=null;measure=null;walkControl=null;sectionPlane=null;sectionAxis=null;sectionBox=null;walkPath=null;walkPlanView=null;engineInfo=null;componentDetail=null;aiChat=null;setting=null;constructor(){}reset(){this.eventEmitter.clear(),this.container=null,this.wrapper=null,this.toolbar=null,this.dialog=null,this.engine3d=null,this.buttonGroup=null,this.rightKey=null,this.constructTree=null,this.measure=null,this.walkControl=null,this.sectionPlane=null,this.sectionAxis=null,this.sectionBox=null,this.walkPath=null,this.walkPlanView=null,this.engineInfo=null,this.componentDetail=null,this.aiChat=null,this.setting=null}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 YC{container;wrapper=null;registry;toolbar=null;constructTreeBtn=null;buttonGroup=null;dialog=null;engine=null;rightKey=null;measure=null;sectionPlane=null;sectionAxis=null;sectionBox=null;walkControl=null;engineInfo=null;componentDetail=null;aiChat=null;setting=null;constructor(e,t){const n=typeof e=="string"?document.getElementById(e):e;if(!n)throw new Error("Container not found");this.container=n,this.registry=new ZC,t?.locale&&Qt.setLocale(t.locale),t?.theme&&(t.theme==="custom"?console.warn("Custom theme should be set via setCustomTheme()."):ot.setTheme(t.theme)),this.init()}emit(e,t){this.registry.emit(e,t)}on(e,t){return this.registry.on(e,t)}setLocale(e){Qt.setLocale(e)}getLocale(){return Qt.getLocale()}setTheme(e){ot.setTheme(e)}setCustomTheme(e){ot.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="v1.3.3",this.wrapper.appendChild(e),this.registry.container=this.container,this.registry.wrapper=this.wrapper,this.engine=new vC(this.wrapper,this.registry),this.dialog=new Eg(this.wrapper,this.registry),this.toolbar=new Mg(this.wrapper,this.registry),this.buttonGroup=new wg(this.wrapper,this.registry),this.rightKey=new Q0(this.wrapper,this.registry),this.constructTreeBtn=new SC(this.wrapper,this.registry),this.measure=new CC(this.registry),this.sectionPlane=new AC(this.registry),this.sectionAxis=new RC(this.registry),this.sectionBox=new IC(this.registry),this.walkControl=new kC(this.registry),this.walkControl.init(),this.engineInfo=new UC(this.registry),this.engineInfo.init(),this.registry.engine3d=this.engine,this.registry.dialog=this.dialog,this.registry.toolbar=this.toolbar,this.registry.buttonGroup=this.buttonGroup,this.registry.rightKey=this.rightKey,this.registry.constructTree=this.constructTreeBtn,this.registry.measure=this.measure,this.registry.sectionPlane=this.sectionPlane,this.registry.sectionAxis=this.sectionAxis,this.registry.sectionBox=this.sectionBox,this.registry.walkControl=this.walkControl,this.registry.engineInfo=this.engineInfo,this.componentDetail=new WC(this.registry),this.registry.componentDetail=this.componentDetail,this.componentDetail.init(),this.aiChat=new jC(this.registry),this.registry.aiChat=this.aiChat,this.aiChat.init(),this.setting=new VC(this.registry),this.registry.setting=this.setting,this.setting.init(),this.updateTheme(ot.getTheme()),ot.subscribe(t=>{this.updateTheme(t)})}updateTheme(e){this.wrapper&&(this.wrapper.style.color=e.textPrimary)}destroy(){this.toolbar?.destroy(),this.buttonGroup?.destroy(),this.engine?.destroy(),this.dialog?.destroy(),this.rightKey?.destroy(),this.measure?.destroy(),this.sectionPlane?.destroy(),this.sectionAxis?.destroy(),this.sectionBox?.destroy(),this.walkControl?.destroy(),this.aiChat?.destroy(),this.setting?.destroy(),this.container.innerHTML="",this.registry.reset()}}const $C=Object.freeze(Object.defineProperty({__proto__:null,createHomeButton:s=>({id:"home",groupId:"group-1",type:"button",label:"toolbar.home",icon:rt("主视角"),keepActive:!1,onClick:e=>{console.log("首页按钮被点击:",e.id),s.engine3d?.getEngineComponent()?.CameraGoHome()}})},Symbol.toStringTag,{value:"Module"})),KC=Object.freeze(Object.defineProperty({__proto__:null,createZoomBoxButton:s=>({id:"zoom-box",groupId:"group-1",keepActive:!1,type:"button",label:"toolbar.zoomBox",icon:rt("框选放大"),onClick:()=>{s.engine3d?.getEngineComponent()?.activateZoomBox()}})},Symbol.toStringTag,{value:"Module"})),JC=Object.freeze(Object.defineProperty({__proto__:null,createWalkMenuButton:s=>({id:"walk",groupId:"group-1",type:"button",label:"toolbar.walk",align:"vertical",icon:rt("漫游"),onClick:()=>{console.log("漫游按钮被点击"),s.walkControl?.show()}})},Symbol.toStringTag,{value:"Module"})),QC=Object.freeze(Object.defineProperty({__proto__:null,createMapButton:s=>({id:"map",groupId:"group-1",type:"button",label:"toolbar.map",align:"vertical",keepActive:!0,icon:rt("地图"),onClick:()=>{s.engine3d?.getEngineComponent()?.toggleMiniMap();const e=s.engine3d?.getEngineComponent()?.getMiniMapState()??!1;s.walkControl?.panel?.setPlanViewActive(e)}})},Symbol.toStringTag,{value:"Module"})),eT=Object.freeze(Object.defineProperty({__proto__:null,createPropertyButton:s=>({id:"property",groupId:"group-1",type:"button",label:"toolbar.property",align:"vertical",icon:rt("文档"),onClick:()=>{console.log("构件详情按钮被点击"),s.componentDetail?.show()}})},Symbol.toStringTag,{value:"Module"})),tT=Object.freeze(Object.defineProperty({__proto__:null,createSettingButton:s=>({id:"setting",groupId:"group-2",type:"button",label:"toolbar.setting",icon:rt("设置"),keepActive:!1,onClick:e=>{s?.setting?.toggle()}})},Symbol.toStringTag,{value:"Module"})),nT=Object.freeze(Object.defineProperty({__proto__:null,createInfoButton:s=>({id:"info",groupId:"group-2",type:"button",label:"toolbar.info",icon:rt("信息"),keepActive:!1,onClick:()=>{s.engineInfo?.show()}})},Symbol.toStringTag,{value:"Module"})),iT=Object.freeze(Object.defineProperty({__proto__:null,createFullscreenButton:s=>({id:"fullscreen",groupId:"group-2",type:"button",label:"toolbar.fullscreen",align:"vertical",icon:rt("全屏"),onClick:async()=>{console.log("全屏按钮被点击"),window.self!==window.top&&console.warn('检测到在 Iframe 中运行,请确保父级 iframe 标签拥有 allow="fullscreen" 属性');try{const t=document,i=!!(t.fullscreenElement||t.webkitFullscreenElement||t.mozFullScreenElement||t.msFullscreenElement);console.log("当前是否全屏:",i);const a=document.querySelector(".bim-engine-container")||document.body,o=a;if(i){console.log("准备退出全屏...");const l=t.exitFullscreen||t.webkitExitFullscreen||t.mozCancelFullScreen||t.msExitFullscreen;l&&(await l.call(t),console.log("退出全屏请求已发送"))}else{console.log("准备进入全屏..."),(a.style.backgroundColor===""||a.style.backgroundColor==="transparent")&&(a.style.backgroundColor="#ffffff");const l=o.requestFullscreen||o.webkitRequestFullscreen||o.mozRequestFullScreen||o.msRequestFullscreen;l?(await l.call(o,{navigationUI:"hide"}),console.log("全屏请求已发送")):(console.warn("当前浏览器不支持全屏 API"),alert("当前浏览器不支持全屏功能"))}}catch(t){console.error("全屏操作失败:",t),t&&t.message&&t.message.includes("denied")&&console.error('全屏请求被拒绝。如果是 Iframe请检查 allow="fullscreen"。如果是自动触发,请确保由用户点击触发。')}}})},Symbol.toStringTag,{value:"Module"})),sT=Object.freeze(Object.defineProperty({__proto__:null,createMeasureButton:s=>({id:"measure",groupId:"group-1",type:"button",label:"toolbar.measure",icon:rt("测量"),keepActive:!0,onClick:e=>{e.isActive?s.measure?.show():s.measure?.destroy()}})},Symbol.toStringTag,{value:"Module"})),rT=Object.freeze(Object.defineProperty({__proto__:null,createSectionMenuButton:s=>({id:"section",groupId:"group-1",type:"menu",label:"toolbar.section",align:"vertical",icon:rt("剖切"),keepActive:!0,onClick:e=>{console.log("剖切按钮被点击:",e.id)}})},Symbol.toStringTag,{value:"Module"})),aT=Object.freeze(Object.defineProperty({__proto__:null,createSectionPlaneButton:s=>({id:"section-plane",groupId:"group-1",parentId:"section",type:"button",keepActive:!0,exclusive:!0,align:"vertical",label:"toolbar.sectionPlane",icon:rt("拾曲面剖切"),onClick:e=>{console.log("拾取面剖切被点击:",e.id,"激活状态:",e.isActive),e.isActive?s.sectionPlane?.show():s.sectionPlane?.hide()}})},Symbol.toStringTag,{value:"Module"})),oT=Object.freeze(Object.defineProperty({__proto__:null,createSectionAxisButton:s=>({id:"section-axis",groupId:"group-1",parentId:"section",type:"button",keepActive:!0,exclusive:!0,align:"vertical",label:"toolbar.sectionAxis",icon:rt("轴向剖切"),onClick:e=>{e.isActive?s.sectionAxis?.show():s.sectionAxis?.destroy()}})},Symbol.toStringTag,{value:"Module"})),lT=Object.freeze(Object.defineProperty({__proto__:null,createSectionBoxButton:s=>({id:"section-box",groupId:"group-1",parentId:"section",type:"button",keepActive:!0,exclusive:!0,align:"vertical",label:"toolbar.sectionBox",icon:rt("剖切盒"),onClick:e=>{console.log("剖切盒被点击:",e.id,"激活状态:",e.isActive),e.isActive?s.sectionBox?.show():s.sectionBox?.hide()}})},Symbol.toStringTag,{value:"Module"})),cT=Object.freeze(Object.defineProperty({__proto__:null,createAiChatButton:s=>(s.on("aiChat:opened",()=>{s.toolbar?.setBtnActive("aiChat",!0)}),s.on("aiChat:closed",()=>{s.toolbar?.setBtnActive("aiChat",!1)}),{id:"aiChat",groupId:"group-2",type:"button",label:"aiChat.title",align:"vertical",keepActive:!0,icon:rt("bot"),onClick:()=>{s.aiChat?.toggle()}})},Symbol.toStringTag,{value:"Module"})),hT=Object.freeze(Object.defineProperty({__proto__:null,createCameraSwitchButton:s=>({id:"camera-switch",groupId:"group-1",type:"button",label:"toolbar.cameraSwitch",icon:rt("透视相机"),keepActive:!1,onClick:()=>{const e=s.engine3d?.getEngineComponent();if(!e)return;e.switchCamera();const t=e.getCameraType(),n=rt(t==="orthographic"?"正交相机":"透视相机");s.toolbar?.updateButtonIcon("camera-switch",n)}})},Symbol.toStringTag,{value:"Module"})),dT=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"})),uT=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"})),pT=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"}));js.BimEngine=YC,Object.defineProperty(js,Symbol.toStringTag,{value:"Module"})}));
//# sourceMappingURL=iflow-engine.umd.js.map